Skip to content

Commit

Permalink
修改启动时更新检查为异步以便减少卡顿
Browse files Browse the repository at this point in the history
允许拖动设置和更新窗口
添加窗口标题和图标
  • Loading branch information
MyBlueHorizon committed Sep 19, 2021
1 parent fe66b28 commit 20b4f24
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/ClassTable/LegacyNetwork.vb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Public Class LegacyNetwork
myResponseStream.Close()
Return retString
Catch Ex As Exception
Return ("Error")
Return "Error"
End Try
End Function

Expand All @@ -30,9 +30,9 @@ Public Class LegacyNetwork
Dim JsonString
Try
JsonString = GetHttpResponse("https://api.github.com/repos/mybluehorizon/classtable/releases/latest", 10000)
Return (JsonString)
Return JsonString
Catch Ex As Exception
Return ("Error")
Return "Error"
End Try
End Function

Expand All @@ -56,7 +56,7 @@ Public Class LegacyNetwork
Dim sIndex As String = DownloadUrl("assets")(0)("browser_download_url")
Return sIndex
Catch Ex As Exception
Return ("Error")
Return "Error"
End Try
End Function
End Class
2 changes: 1 addition & 1 deletion src/ClassTable/LegacySettingWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
mc:Ignorable="d"
WindowStartupLocation="CenterScreen" Background="#7A006060"
ResizeMode="NoResize"
Height="180" Width="320" WindowStyle="None" AllowsTransparency="True" Topmost="True" >
Height="180" Width="320" WindowStyle="None" AllowsTransparency="True" Topmost="True" Title="ClassTable - 程序设置" Icon="Resource/Icons/AppIcon.ico" >
<Grid>
<Button x:Name="Button_Back" Content="返 回" HorizontalAlignment="Left" Width="96" FontFamily="STZhongsong" FontSize="28" Height="48" VerticalAlignment="Top" Background="#3DFFFFFF" BorderBrush="{x:Null}" Foreground="{Binding Foreground, ElementName=TextBlock_Weekday}" FontWeight="Bold" Margin="10,122,0,0"/>
<Button x:Name="Button_Save" Content="存储 / 应用" HorizontalAlignment="Left" Width="192" FontFamily="STZhongsong" FontSize="28" Height="48" VerticalAlignment="Top" Background="#3DFFFFFF" BorderBrush="{x:Null}" Foreground="{Binding Foreground, ElementName=TextBlock_Weekday}" FontWeight="Bold" Margin="118,122,0,0"/>
Expand Down
3 changes: 3 additions & 0 deletions src/ClassTable/LegacySettingWindow.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,7 @@ Public Class LegacySettingWindow
Hide()
e.Cancel = True
End Sub
Private Sub LegacySettingWindow_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs) Handles Me.MouseLeftButtonDown
DragMove()
End Sub
End Class
6 changes: 3 additions & 3 deletions src/ClassTable/LegacySidebarWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
ResizeMode="NoResize"
WindowStyle="None"
Height="720"
Width="96"
ShowInTaskbar="False"
Width="96"
Background="#7A006060"
WindowStartupLocation="CenterScreen" Topmost="True">
WindowStartupLocation="CenterScreen"
Topmost="True" Title="ClassTable - 侧边栏" Icon="Resource/Icons/AppIcon.ico" ShowInTaskbar="False">
<Grid>
<TextBlock x:Name="MorRead" HorizontalAlignment="Left" TextWrapping="Wrap" Text="语 文" VerticalAlignment="Top" Height="48" Width="96" FontWeight="Bold" FontFamily="STZhongsong" FontSize="38" Margin="0,49,0,0" TextAlignment="Center" Foreground="{Binding Foreground, ElementName=MorWeekday}"/>
<TextBlock x:Name="MorA" HorizontalAlignment="Left" TextWrapping="Wrap" Text="数 学" VerticalAlignment="Top" Height="48" Width="96" FontWeight="Bold" FontFamily="STZhongsong" FontSize="38" Margin="0,102,0,0" TextAlignment="Center" Foreground="{Binding Foreground, ElementName=MorWeekday}"/>
Expand Down
18 changes: 12 additions & 6 deletions src/ClassTable/LegacySidebarWindow.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ Public Class LegacySidebarWindow
'载入课表
RaiseEvent LoadTable(Me, New EventArgs)
RaiseEvent ReadConfigInformation(Me, New EventArgs)
LegacyUpdateWindow.ReleaseInformation = Network.GetReleaseInformation
LegacyUpdateWindow.LatestVersion = New Version(Network.GetLatestVersion(LegacyUpdateWindow.ReleaseInformation))
If LegacyUpdateWindow.LatestVersion > LegacyUpdateWindow.LocalVersion Then
RaiseEvent ShowUpdateWindow(Me, New EventArgs)
End If
End Sub
GC.Collect()
CheckUpdate()
End Sub
Private Async Function CheckUpdate() As Task
Await Task.Run(action:=Sub()
LegacyUpdateWindow.ReleaseInformation = Network.GetReleaseInformation()
LegacyUpdateWindow.LatestVersion = New Version(Network.GetLatestVersion(LegacyUpdateWindow.ReleaseInformation))
If LegacyUpdateWindow.LatestVersion > LegacyUpdateWindow.LocalVersion Then
RaiseEvent ShowUpdateWindow(Me, New EventArgs)
End If
End Sub)
End Function
Private Sub MainWindow_LoadTable(sender As Object, e As EventArgs) Handles Me.LoadTable
'设置日期
If My.Settings.Mdate = "No" Then
Expand Down
4 changes: 2 additions & 2 deletions src/ClassTable/LegacyUpdateWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
mc:Ignorable="d"
WindowStartupLocation="CenterScreen" Background="#7A006060"
ResizeMode="NoResize"
Title="软件更新" Height="180" Width="320" AllowsTransparency="True"
WindowStyle="None" Topmost="True">
Title="ClassTable - 程序更新" Height="180" Width="320" AllowsTransparency="True"
WindowStyle="None" Topmost="True" Icon="Resource/Icons/AppIcon.ico">
<Grid>
<Label Content="最新版本:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,39,0,0" FontSize="18" FontFamily="STZhongsong" Foreground="{Binding Foreground, ElementName=TextBlock_Name}"/>
<Label x:Name="Label_LatestVersion" Content="尚未检查更新/获取版本失败" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="110,43,0,0" FontSize="14" FontFamily="STZhongsong" Foreground="{Binding Foreground, ElementName=TextBlock_Name}"/>
Expand Down
3 changes: 3 additions & 0 deletions src/ClassTable/LegacyUpdateWindow.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ Public Class LegacyUpdateWindow
Private Sub Button_Back_Click(sender As Object, e As RoutedEventArgs) Handles Button_Back.Click
Hide()
End Sub
Private Sub LegacyUpdatWindow_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs) Handles Me.MouseLeftButtonDown
DragMove()
End Sub
End Class
2 changes: 1 addition & 1 deletion src/ClassTable/Libraries/NetworkLibrary.vb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Imports System.Net.Http
Public Class NetworkLibrary
ReadOnly Client As New HttpClient
'ReadOnly Client As New HttpClient
Public Shared Function InitializeNetworkConfiguration()

End Function
Expand Down

0 comments on commit 20b4f24

Please sign in to comment.