12
12
using System ;
13
13
using System . Collections . Generic ;
14
14
using System . Collections . ObjectModel ;
15
+ using System . Diagnostics ;
15
16
using System . IO ;
16
17
using System . Linq ;
17
18
using System . Reactive ;
@@ -55,6 +56,7 @@ public class MainWindowViewModel : ViewModelBase
55
56
public ReactiveCommand < Unit , Task > UseDefaultPalette { get ; }
56
57
public ReactiveCommand < Unit , Task > UseCustomPalette { get ; }
57
58
public ReactiveCommand < Unit , Unit > EditSettingsCommand { get ; }
59
+ public ReactiveCommand < Unit , Process ? > OpenDownloadLink { get ; }
58
60
59
61
public const string GithubApplicationName = "ObjectEditor" ;
60
62
public const string GithubIssuePage = "https://github.com/OpenLoco/ObjectEditor/issues" ;
@@ -69,6 +71,9 @@ public class MainWindowViewModel : ViewModelBase
69
71
[ Reactive ]
70
72
public string LatestVersionText { get ; set ; } = "Development build" ;
71
73
74
+ [ Reactive ]
75
+ public bool IsUpdateAvailable { get ; set ; }
76
+
72
77
const string DefaultPaletteImageString = "avares://ObjectEditor/Assets/palette.png" ;
73
78
Image < Rgba32 > DefaultPaletteImage { get ; init ; }
74
79
@@ -118,6 +123,8 @@ public MainWindowViewModel()
118
123
Model . Settings . Save ( ObjectEditorModel . SettingsFile , Model . Logger ) ;
119
124
} ) ;
120
125
126
+ OpenDownloadLink = ReactiveCommand . Create ( ( ) => Process . Start ( new ProcessStartInfo ( GithubLatestReleaseDownloadPage ) { UseShellExecute = true } ) ) ;
127
+
121
128
#region Version
122
129
123
130
_ = this . WhenAnyValue ( o => o . ApplicationVersion )
@@ -137,18 +144,19 @@ public MainWindowViewModel()
137
144
if ( latestVersion > ApplicationVersion )
138
145
{
139
146
LatestVersionText = $ "newer version exists: { latestVersion } ";
147
+ IsUpdateAvailable = true ;
140
148
}
141
149
else
142
150
{
143
151
LatestVersionText = "latest version" ;
152
+ IsUpdateAvailable = false ;
144
153
}
145
154
}
146
155
catch ( Exception ex )
147
156
{
148
157
Model . Logger . Error ( ex ) ;
149
158
}
150
159
#endif
151
-
152
160
#endregion
153
161
}
154
162
0 commit comments