Skip to content

Commit ead7da2

Browse files
authored
change version window ui (#181)
1 parent 25f0ab8 commit ead7da2

File tree

4 files changed

+3
-61
lines changed

4 files changed

+3
-61
lines changed

MainCore/Helper/GithubHelper.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,5 @@ public static async Task<Version> CheckGitHubLatestVersion()
3030
}
3131
return null;
3232
}
33-
34-
public static async Task<Version> CheckGitHublatestBuild()
35-
{
36-
try
37-
{
38-
var releases = await _client.Repository.Release.GetAll(_username, _repo);
39-
if (releases.Count > 0) return new Version(releases[0].TagName);
40-
}
41-
catch
42-
{
43-
}
44-
return null;
45-
}
4633
}
4734
}

WPFUI/ViewModels/VersionViewModel.cs

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@ public VersionViewModel()
1818

1919
DiscordCommand = ReactiveCommand.Create(DiscordTask);
2020
LatestVersionCommand = ReactiveCommand.Create(LatestVersionTask, this.WhenAnyValue(x => x.IsNewVersion));
21-
LatestBuildCommand = ReactiveCommand.Create(LatestBuildTask, this.WhenAnyValue(x => x.IsNewBuild));
2221
CloseCommand = ReactiveCommand.Create(CloseTask);
2322
}
2423

2524
public async Task Load()
2625
{
27-
var result = await Task.WhenAll(GithubHelper.CheckGitHubLatestVersion(), GithubHelper.CheckGitHublatestBuild());
26+
var result = await GithubHelper.CheckGitHubLatestVersion();
2827

29-
LatestVersion = result[0].ToString();
30-
LatestBuild = result[1].ToString();
28+
LatestVersion = result.ToString();
3129
}
3230

3331
private void DiscordTask()
@@ -49,16 +47,6 @@ private void LatestVersionTask()
4947
CloseTask();
5048
}
5149

52-
private void LatestBuildTask()
53-
{
54-
Process.Start(new ProcessStartInfo
55-
{
56-
FileName = GithubHelper.GetLink(_latestBuild),
57-
UseShellExecute = true
58-
});
59-
CloseTask();
60-
}
61-
6250
private void CloseTask()
6351
{
6452
CloseWindow?.Invoke();
@@ -68,7 +56,7 @@ private void CloseTask()
6856

6957
public string CurrentVersion
7058
{
71-
get => $"Current: {_currentVersion}";
59+
get => $"Current version: {_currentVersion}";
7260
set => this.RaiseAndSetIfChanged(ref _currentVersion, value);
7361
}
7462

@@ -85,18 +73,6 @@ public string LatestVersion
8573
}
8674
}
8775

88-
private string _latestBuild;
89-
90-
public string LatestBuild
91-
{
92-
get => $"Latest build: {_latestBuild}";
93-
set
94-
{
95-
this.RaiseAndSetIfChanged(ref _latestBuild, value);
96-
this.RaisePropertyChanged(nameof(IsNewBuild));
97-
}
98-
}
99-
10076
public bool IsNewVersion
10177
{
10278
get
@@ -107,16 +83,6 @@ public bool IsNewVersion
10783
}
10884
}
10985

110-
public bool IsNewBuild
111-
{
112-
get
113-
{
114-
var current = new Version($"{_currentVersion}.0");
115-
var last = new Version($"{_latestVersion}.0");
116-
return current.CompareTo(last) < 0;
117-
}
118-
}
119-
12086
public string Message
12187
{
12288
get => message[IsNewVersion ? 1 : 0];
@@ -131,7 +97,6 @@ public string Message
13197

13298
public ReactiveCommand<Unit, Unit> DiscordCommand { get; }
13399
public ReactiveCommand<Unit, Unit> LatestVersionCommand { get; }
134-
public ReactiveCommand<Unit, Unit> LatestBuildCommand { get; }
135100
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
136101

137102
public event Action CloseWindow;

WPFUI/Views/VersionWindow.xaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<Grid.ColumnDefinitions>
1414
<ColumnDefinition Width="1*" />
1515
<ColumnDefinition Width="1*" />
16-
<ColumnDefinition Width="1*" />
1716
</Grid.ColumnDefinitions>
1817
<Grid.RowDefinitions>
1918
<RowDefinition Height="2*" />
@@ -31,15 +30,8 @@
3130
<Border x:Name="LastVersionBorder" BorderBrush="Black" BorderThickness="1" Grid.Column="1" Margin="20,10,20,0" Grid.Row="2">
3231
<TextBlock x:Name="LastVersionLabel" HorizontalAlignment="Center" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Center" />
3332
</Border>
34-
<Border x:Name="LastBuildBorder" BorderBrush="Black" BorderThickness="1" Grid.Column="2" Margin="20,10,20,0" Grid.Row="2">
35-
<TextBlock x:Name="LastBuildLabel" HorizontalAlignment="Center" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Center" />
36-
</Border>
37-
<Border x:Name="NoteBorder" BorderBrush="Black" BorderThickness="1" Grid.ColumnSpan="3" Margin="20,5,20,5" Grid.Row="3">
38-
<TextBlock x:Name="NoteLabel" HorizontalAlignment="Center" TextWrapping="Wrap" Text="Latest version is stable (we hope) while latest build is unstable and maybe for tester only" VerticalAlignment="Center" />
39-
</Border>
4033
<Button x:Name="DiscordButton" Content="Discord" HorizontalAlignment="Stretch" Margin="20,0,20,0" Grid.Row="1" VerticalAlignment="Stretch" />
4134
<Button x:Name="LastVersionButton" Grid.Column="1" Content="Download latest version" HorizontalAlignment="Stretch" Margin="20,0,20,0" Grid.Row="1" VerticalAlignment="Stretch" />
42-
<Button x:Name="LastBuildButton" Grid.Column="2" Content="Download latest build" HorizontalAlignment="Stretch" Margin="20,0,20,0" Grid.Row="1" VerticalAlignment="Stretch" />
4335
<Button x:Name="CloseButton" Content="Close" Grid.ColumnSpan="3" HorizontalAlignment="Stretch" Margin="20,0,20,10" Grid.Row="4" VerticalAlignment="Stretch" />
4436
</Grid>
4537
</reactiveui:ReactiveWindow>

WPFUI/Views/VersionWindow.xaml.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ public VersionWindow()
1919
{
2020
this.BindCommand(ViewModel, vm => vm.DiscordCommand, v => v.DiscordButton).DisposeWith(d);
2121
this.BindCommand(ViewModel, vm => vm.LatestVersionCommand, v => v.LastVersionButton).DisposeWith(d);
22-
this.BindCommand(ViewModel, vm => vm.LatestBuildCommand, v => v.LastBuildButton).DisposeWith(d);
2322
this.BindCommand(ViewModel, vm => vm.CloseCommand, v => v.CloseButton).DisposeWith(d);
2423

2524
this.OneWayBind(ViewModel, vm => vm.Message, v => v.StatusLabel.Text).DisposeWith(d);
2625
this.OneWayBind(ViewModel, vm => vm.CurrentVersion, v => v.CurrentLabel.Text).DisposeWith(d);
2726
this.OneWayBind(ViewModel, vm => vm.LatestVersion, v => v.LastVersionLabel.Text).DisposeWith(d);
28-
this.OneWayBind(ViewModel, vm => vm.LatestBuild, v => v.LastBuildLabel.Text).DisposeWith(d);
2927
});
3028
}
3129
}

0 commit comments

Comments
 (0)