private void Window_Opened(object sender, EventArgs e) { if (Environment.OSVersion.Version.Major > 5 && PreferencesFile.LoadSetting("ControlCenter", "AeroWarning", true)) { bool aeroEnabled; NativeMethods.DwmIsCompositionEnabled(out aeroEnabled); if (!aeroEnabled) { AeroWarning warningDialog = new AeroWarning(); warningDialog.Owner = this; warningDialog.ShowDialog(); if (warningDialog.DisplayAgainCheckbox.IsChecked == true) { PreferencesFile.SaveSetting("ControlCenter", "AeroWarning", false); } } } App app = Application.Current as App; if (app != null && app.StartupProfile != null && File.Exists(app.StartupProfile)) { LoadProfileList(app.StartupProfile); LoadProfile(app.StartupProfile); StartProfile(); } VersionChecker.Check versionCheck = ConfigManager.VersionChecker.CheckAvailableVersion(false); if (!ConfigManager.VersionChecker.ShouldOfferNewVersion(versionCheck)) { return; } // can't use the interactive dialog, because this would require writing settings StatusMessage = StatusValue.UpgradeAvailable; StatusReportItem item = new StatusReportItem { Status = $"new version {versionCheck.AvailableVersion} is available", Flags = StatusReportItem.StatusFlags.ConfigurationUpToDate }; if (versionCheck.DownloadUrl != null) { item.Link = new Uri(versionCheck.DownloadUrl); item.Recommendation = $"Use Profile Editor to check for new version or download directly from {versionCheck.DownloadUrl}"; } else { item.Link = StatusReportItem.ProfileEditor; item.Recommendation = "check for new version and download it"; } StatusViewer.AddItem(item); }
private void ReportError(string status, string recommendation, Uri link) { StatusReportItem statusReportItem = new StatusReportItem() { Severity = StatusReportItem.SeverityCode.Error, Status = status, Recommendation = recommendation, Link = link }; StatusViewer.AddItem(statusReportItem); statusReportItem.Log(ConfigManager.LogManager); }
private void ReportStatus(string status, Uri link = null) { if (status.Length < 1) { return; } StatusReportItem statusReportItem = new StatusReportItem() { Status = status, Link = link }; StatusViewer.AddItem(statusReportItem); statusReportItem.Log(ConfigManager.LogManager); }
private bool PerformReadyCheck() { bool success = true; foreach (StatusReportItem status in ActiveProfile.PerformReadyCheck()) { if (status.Severity == StatusReportItem.SeverityCode.Error) { success = false; } StatusViewer.AddItem(status); status.Log(ConfigManager.LogManager); } StatusCanvas.StatusLines?.ScrollToBottom(); if (!success) { StatusMessage = StatusValue.FailedPreflight; // preflight only: we automatically pop up the status view StatusCheckBox.IsChecked = true; } return(success); }
public MainWindow() { PreferencesFile = new SettingsManager(Path.Combine(ConfigManager.DocumentPath, "ControlCenterPreferences.xml")) { Writable = true }; Preferences = new Preferences(PreferencesFile); InitializeComponent(); // this is gross, but correct: this time is before any read access to settings, meaning before we load them SettingsLoadTime = DateTime.Now; // starting ConfigManager.LogManager.LogDebug("Control Center initializing"); StatusMessage = StatusValue.RunningVersion; if (Preferences.SplashScreen) { // Display a dynamic splash panel with release and credits DisplaySplash(4000); } else { // add the list of authors and contributors to the console instead, without adding to log StatusViewer.AddItem(new StatusReportItem { Status = $"Authors: {string.Join(", ", About.Authors)}", Flags = StatusReportItem.StatusFlags.ConfigurationUpToDate }); StatusViewer.AddItem(new StatusReportItem { Status = $"Contributors: {string.Join(", ", About.Contributors)}", Flags = StatusReportItem.StatusFlags.ConfigurationUpToDate }); } LoadProfileList(PreferencesFile.LoadSetting("ControlCenter", "LastProfile", "")); if (_profileIndex == -1 && _profiles.Count > 0) { _profileIndex = 0; } if (_profileIndex > -1 && _profileIndex < _profiles.Count) { SelectedProfileName = System.IO.Path.GetFileNameWithoutExtension(_profiles[_profileIndex]); } else { SelectedProfileName = "- No Profiles Available -"; } // fix up UI state that isn't implemented as bindings TouchscreenCheckBox.IsChecked = (Preferences.SuppressMouseAfterTouchDuration > 0); try { RegistryKey pathKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run"); using (pathKey) { if (pathKey.GetValue("Helios") != null) { Preferences.AutoStart = true; } pathKey.Close(); } } catch (Exception e) { AutoStartCheckBox.IsChecked = false; AutoStartCheckBox.IsEnabled = false; AutoStartCheckBox.ToolTip = "Unable to read/write registry to enable auto start. Control Center may require administrator rights for this feature."; ConfigManager.LogManager.LogError("Error checking for auto start.", e); } }