public static void Display(DecompilerTextView textView) { AvalonEditTextOutput avalonEditTextOutput = new AvalonEditTextOutput(); avalonEditTextOutput.WriteLine("ILSpy 版本 2.1.0.1603"); avalonEditTextOutput.AddUIElement(delegate { StackPanel stackPanel = new StackPanel(); stackPanel.HorizontalAlignment = HorizontalAlignment.Center; stackPanel.Orientation = Orientation.Horizontal; if (AboutPage.latestAvailableVersion == null) { AboutPage.AddUpdateCheckButton(stackPanel, textView); } else { AboutPage.ShowAvailableVersion(AboutPage.latestAvailableVersion, stackPanel); } CheckBox checkBox = new CheckBox(); checkBox.Margin = new Thickness(4.0); checkBox.Content = "每周自动检查更新"; AboutPage.UpdateSettings source = new AboutPage.UpdateSettings(ILSpySettings.Load()); checkBox.SetBinding(ToggleButton.IsCheckedProperty, new Binding("AutomaticUpdateCheckEnabled") { Source = source }); return new StackPanel { Margin = new Thickness(0.0, 4.0, 0.0, 0.0), Cursor = Cursors.Arrow, Children = { stackPanel, checkBox } }; }); avalonEditTextOutput.WriteLine(); foreach (IAboutPageAddition current in App.CompositionContainer.GetExportedValues<IAboutPageAddition>()) { current.Write(avalonEditTextOutput); } avalonEditTextOutput.WriteLine(); using (Stream manifestResourceStream = typeof(AboutPage).Assembly.GetManifestResourceStream(typeof(AboutPage), "README.txt")) { using (StreamReader streamReader = new StreamReader(manifestResourceStream)) { string text; while ((text = streamReader.ReadLine()) != null) { avalonEditTextOutput.WriteLine(text); } } } avalonEditTextOutput.AddVisualLineElementGenerator(new AboutPage.MyLinkElementGenerator("SharpDevelop", "http://www.icsharpcode.net/opensource/sd/")); avalonEditTextOutput.AddVisualLineElementGenerator(new AboutPage.MyLinkElementGenerator("MIT License", "resource:license.txt")); avalonEditTextOutput.AddVisualLineElementGenerator(new AboutPage.MyLinkElementGenerator("LGPL", "resource:LGPL.txt")); avalonEditTextOutput.AddVisualLineElementGenerator(new AboutPage.MyLinkElementGenerator("iFish(木鱼)", "http://www.fishlee.net/about/")); textView.ShowText(avalonEditTextOutput); textView.manager.Bookmarks.Clear(); }
public static Task<string> CheckForUpdatesIfEnabledAsync(ILSpySettings spySettings) { TaskCompletionSource<string> tcs = new TaskCompletionSource<string>(); AboutPage.UpdateSettings s = new AboutPage.UpdateSettings(spySettings); if (s.AutomaticUpdateCheckEnabled) { if (!s.LastSuccessfulUpdateCheck.HasValue || s.LastSuccessfulUpdateCheck < DateTime.UtcNow.AddDays(-7.0) || s.LastSuccessfulUpdateCheck > DateTime.UtcNow) { AboutPage.GetLatestVersionAsync().ContinueWith(delegate(Task<AboutPage.AvailableVersionInfo> task) { try { s.LastSuccessfulUpdateCheck = new DateTime?(DateTime.UtcNow); AboutPage.AvailableVersionInfo result = task.Result; if (result.Version > AboutPage.currentVersion) { tcs.SetResult(result.DownloadUrl); } else { tcs.SetResult(null); } } catch (AggregateException) { tcs.SetResult(null); } }); } else { tcs.SetResult(null); } } else { tcs.SetResult(null); } return tcs.Task; }