Skip to content

Commit 1bbf533

Browse files
committed
检查更新开启关闭功能
1 parent 1d387a7 commit 1bbf533

8 files changed

Lines changed: 58 additions & 12 deletions

File tree

llcom/App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
<setting name="maxLength" serializeAs="String">
6868
<value>10240</value>
6969
</setting>
70+
<setting name="autoUpdate" serializeAs="String">
71+
<value>True</value>
72+
</setting>
7073
</llcom.Properties.Settings>
7174
</userSettings>
7275
</configuration>

llcom/MainWindow.xaml.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,15 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
130130
this.Title += $" - {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()}";
131131

132132
//检查更新
133-
try
133+
if (Tools.Global.setting.autoUpdate)
134134
{
135-
Random r = new Random();//加上随机参数,确保获取的是最新数据
136-
AutoUpdaterDotNET.AutoUpdater.Start("https://llcom.papapoi.com/autoUpdate.xml?" + r);
135+
try
136+
{
137+
Random r = new Random();//加上随机参数,确保获取的是最新数据
138+
AutoUpdaterDotNET.AutoUpdater.Start("https://llcom.papapoi.com/autoUpdate.xml?" + r);
139+
}
140+
catch { }
137141
}
138-
catch { }
139142
}
140143

141144
private void Uart_UartDataSent(object sender, EventArgs e)

llcom/Model/Settings.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class Settings
2626
private bool _topmost = Properties.Settings.Default.topmost;
2727
private string _quickData = Properties.Settings.Default.quickData;
2828
private bool _bitDelay = Properties.Settings.Default.bitDelay;
29+
private bool _autoUpdate = Properties.Settings.Default.autoUpdate;
2930
private uint _maxLength = Properties.Settings.Default.maxLength;
3031
public static List<string> toSendDatas = new List<string>();
3132

@@ -55,9 +56,6 @@ public uint maxLength
5556
_maxLength = value;
5657
Properties.Settings.Default.maxLength = value;
5758
Properties.Settings.Default.Save();
58-
59-
//更新快捷发送区参数
60-
UpdateQuickSend();
6159
}
6260
}
6361

@@ -78,6 +76,20 @@ public string quickData
7876
}
7977
}
8078

79+
public bool autoUpdate
80+
{
81+
get
82+
{
83+
return _autoUpdate;
84+
}
85+
set
86+
{
87+
_autoUpdate = value;
88+
Properties.Settings.Default.autoUpdate = value;
89+
Properties.Settings.Default.Save();
90+
}
91+
}
92+
8193
public bool bitDelay
8294
{
8395
get
@@ -89,9 +101,6 @@ public bool bitDelay
89101
_bitDelay = value;
90102
Properties.Settings.Default.bitDelay = value;
91103
Properties.Settings.Default.Save();
92-
93-
//更新快捷发送区参数
94-
UpdateQuickSend();
95104
}
96105
}
97106

llcom/Pages/AboutPage.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
用户可自行使用Lua,完成几乎所有可以想象到的自动化操作,大大提高了串口工具的可用性。
3333
</TextBlock>
3434

35+
36+
<CheckBox Content="开启软件后,自动检查是否需要更新" IsChecked="{Binding autoUpdate}" Margin="0,20,0,0" HorizontalAlignment="Center"/>
37+
<Button Name="CheckUpdateButton" Content="立即检查更新" Width="auto" HorizontalAlignment="Center" Click="CheckUpdateButton_Click"/>
38+
3539
<TextBlock Text="作者:晨旭"
3640
FontSize="15"
3741
Margin="10,20,0,0"/>

llcom/Pages/AboutPage.xaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public AboutPage()
2727

2828
private void Page_Loaded(object sender, RoutedEventArgs e)
2929
{
30+
this.DataContext = Tools.Global.setting;
3031
aboutScrollViewer.ScrollToTop();
3132
versionTextBlock.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
3233
}
@@ -45,5 +46,16 @@ private void OpenSourceButton_Click(object sender, RoutedEventArgs e)
4546
{
4647
System.Diagnostics.Process.Start("https://github.com/chenxuuu/llcom");
4748
}
49+
50+
private void CheckUpdateButton_Click(object sender, RoutedEventArgs e)
51+
{
52+
try
53+
{
54+
Random r = new Random();//加上随机参数,确保获取的是最新数据
55+
AutoUpdaterDotNET.AutoUpdater.Start("https://llcom.papapoi.com/autoUpdate.xml?" + r);
56+
}
57+
catch { }
58+
CheckUpdateButton.Content = "已进行过更新检查";
59+
}
4860
}
4961
}

llcom/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
5252
//通过使用 "*",如下所示:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.0.2.0")]
55-
[assembly: AssemblyFileVersion("1.0.2.0")]
54+
[assembly: AssemblyVersion("1.0.2.1")]
55+
[assembly: AssemblyFileVersion("1.0.2.1")]
5656
[assembly: NeutralResourcesLanguage("zh-CN")]
5757

llcom/Properties/Settings.Designer.cs

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

llcom/Properties/Settings.settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,8 @@
5050
<Setting Name="maxLength" Type="System.UInt32" Scope="User">
5151
<Value Profile="(Default)">10240</Value>
5252
</Setting>
53+
<Setting Name="autoUpdate" Type="System.Boolean" Scope="User">
54+
<Value Profile="(Default)">True</Value>
55+
</Setting>
5356
</Settings>
5457
</SettingsFile>

0 commit comments

Comments
 (0)