1717// DEALINGS IN THE SOFTWARE.
1818
1919using System ;
20+ using System . Collections . Generic ;
2021using System . Composition ;
2122using System . IO ;
2223using System . Text . RegularExpressions ;
2324using System . Windows ;
2425using System . Windows . Controls ;
26+ using System . Windows . Controls . Primitives ;
2527using System . Windows . Data ;
2628using System . Windows . Input ;
27- using System . Windows . Navigation ;
2829
2930using ICSharpCode . AvalonEdit . Rendering ;
3031using ICSharpCode . Decompiler ;
3132using ICSharpCode . ILSpy . Properties ;
3233using ICSharpCode . ILSpy . TextView ;
3334using ICSharpCode . ILSpy . Themes ;
3435using ICSharpCode . ILSpy . Updates ;
35- using ICSharpCode . ILSpyX . Settings ;
36+ using ICSharpCode . ILSpy . ViewModels ;
3637
3738namespace ICSharpCode . ILSpy
3839{
3940 [ ExportMainMenuCommand ( ParentMenuID = nameof ( Resources . _Help ) , Header = nameof ( Resources . _About ) , MenuOrder = 99999 ) ]
4041 [ Shared ]
41- sealed class AboutPage : SimpleCommand
42+ public sealed class AboutPage : SimpleCommand
4243 {
44+ readonly SettingsService settingsService ;
45+ readonly IEnumerable < IAboutPageAddition > aboutPageAdditions ;
46+
47+ public AboutPage ( SettingsService settingsService , IEnumerable < IAboutPageAddition > aboutPageAdditions )
48+ {
49+ this . settingsService = settingsService ;
50+ this . aboutPageAdditions = aboutPageAdditions ;
51+ MessageBus < ShowAboutPageEventArgs > . Subscribers += ( _ , e ) => ShowAboutPage ( e . TabPage ) ;
52+ }
53+
4354 public override void Execute ( object parameter )
4455 {
45- MainWindow . Instance . AssemblyTreeModel . NavigateTo (
46- new RequestNavigateEventArgs ( new Uri ( "resource://aboutpage" ) , null ) ,
47- inNewTabPage : true
48- ) ;
56+ MessageBus . Send ( this , new NavigateToEventArgs ( new ( new ( "resource://aboutpage" ) , null ) , inNewTabPage : true ) ) ;
57+ }
58+
59+ private void ShowAboutPage ( TabPageModel tabPage )
60+ {
61+ tabPage . ShowTextView ( Display ) ;
4962 }
5063
51- public static void Display ( DecompilerTextView textView )
64+ private void Display ( DecompilerTextView textView )
5265 {
5366 AvalonEditTextOutput output = new AvalonEditTextOutput ( ) {
5467 Title = Resources . About ,
@@ -61,23 +74,26 @@ public static void Display(DecompilerTextView textView)
6174
6275 output . AddUIElement (
6376 delegate {
64- StackPanel stackPanel = new StackPanel ( ) ;
65- stackPanel . HorizontalAlignment = HorizontalAlignment . Center ;
66- stackPanel . Orientation = Orientation . Horizontal ;
67- if ( NotifyOfUpdatesStrategy . LatestAvailableVersion == null )
77+ StackPanel stackPanel = new ( ) {
78+ HorizontalAlignment = HorizontalAlignment . Center ,
79+ Orientation = Orientation . Horizontal
80+ } ;
81+ if ( UpdateService . LatestAvailableVersion == null )
6882 {
6983 AddUpdateCheckButton ( stackPanel , textView ) ;
7084 }
7185 else
7286 {
7387 // we already retrieved the latest version sometime earlier
74- ShowAvailableVersion ( NotifyOfUpdatesStrategy . LatestAvailableVersion , stackPanel ) ;
88+ ShowAvailableVersion ( UpdateService . LatestAvailableVersion , stackPanel ) ;
7589 }
76- CheckBox checkBox = new CheckBox ( ) ;
77- checkBox . Margin = new Thickness ( 4 ) ;
78- checkBox . Content = Resources . AutomaticallyCheckUpdatesEveryWeek ;
79- UpdateSettings settings = new UpdateSettings ( SettingsService . Instance . SpySettings ) ;
80- checkBox . SetBinding ( CheckBox . IsCheckedProperty , new Binding ( "AutomaticUpdateCheckEnabled" ) { Source = settings } ) ;
90+ CheckBox checkBox = new ( ) {
91+ Margin = new Thickness ( 4 ) ,
92+ Content = Resources . AutomaticallyCheckUpdatesEveryWeek
93+ } ;
94+
95+ var settings = settingsService . GetSettings < UpdateSettings > ( ) ;
96+ checkBox . SetBinding ( ToggleButton . IsCheckedProperty , new Binding ( "AutomaticUpdateCheckEnabled" ) { Source = settings } ) ;
8197 return new StackPanel {
8298 Margin = new Thickness ( 0 , 4 , 0 , 0 ) ,
8399 Cursor = Cursors . Arrow ,
@@ -86,16 +102,15 @@ public static void Display(DecompilerTextView textView)
86102 } ) ;
87103 output . WriteLine ( ) ;
88104
89- foreach ( var plugin in App . ExportProvider . GetExportedValues < IAboutPageAddition > ( ) )
105+ foreach ( var plugin in aboutPageAdditions )
90106 plugin . Write ( output ) ;
91107 output . WriteLine ( ) ;
92108 output . Address = new Uri ( "resource://AboutPage" ) ;
93109 using ( Stream s = typeof ( AboutPage ) . Assembly . GetManifestResourceStream ( typeof ( AboutPage ) , Resources . ILSpyAboutPageTxt ) )
94110 {
95111 using ( StreamReader r = new StreamReader ( s ) )
96112 {
97- string line ;
98- while ( ( line = r . ReadLine ( ) ) != null )
113+ while ( r . ReadLine ( ) is { } line )
99114 {
100115 output . WriteLine ( line ) ;
101116 }
@@ -156,7 +171,7 @@ static void AddUpdateCheckButton(StackPanel stackPanel, DecompilerTextView textV
156171
157172 try
158173 {
159- AvailableVersionInfo vInfo = await NotifyOfUpdatesStrategy . GetLatestVersionAsync ( ) ;
174+ AvailableVersionInfo vInfo = await UpdateService . GetLatestVersionAsync ( ) ;
160175 stackPanel . Children . Clear ( ) ;
161176 ShowAvailableVersion ( vInfo , stackPanel ) ;
162177 }
@@ -199,7 +214,7 @@ static void ShowAvailableVersion(AvailableVersionInfo availableVersion, StackPan
199214 button . Content = Resources . Download ;
200215 button . Cursor = Cursors . Arrow ;
201216 button . Click += delegate {
202- MainWindow . OpenLink ( availableVersion . DownloadUrl ) ;
217+ GlobalUtils . OpenLink ( availableVersion . DownloadUrl ) ;
203218 } ;
204219 stackPanel . Children . Add ( button ) ;
205220 }
0 commit comments