private void Profile_ProfileHintReceived(object sender, ProfileHint e) { string oldValue = _lastProfileHint; _lastProfileHint = e.Tag; if (oldValue != _lastProfileHint) { UpdateStatusMessage(); // send only a simple status message to status viewer instead of whole status via ReportStatusToStatusViewer ReportStatus($"Simulator is '{_lastProfileHint}'"); } if (!Preferences.ProfileAutoStart) { return; } ConfigManager.LogManager.LogDebug($"received profile hint with tag '{e.Tag}'"); string mostRecent = PreferencesFile.LoadSetting("RecentByTag", e.Tag, null); if (mostRecent == null) { ConfigManager.LogManager.LogInfo($"received profile hint with tag '{e.Tag}' but no matching profile has been loaded; cannot auto load"); return; } if ((ActiveProfile != null) && (ActiveProfile.Path == mostRecent)) { ConfigManager.LogManager.LogDebug($"most recent profile for profile hint with tag '{e.Tag}' is already active"); // ask simulator to use the one we are running, if possible ActiveProfile.RequestProfileSupport(); return; } // execute auto load ConfigManager.LogManager.LogDebug($"trying to start most recent matching profile '{mostRecent}'"); ControlCenterCommands.RunProfile.Execute(mostRecent, Application.Current.MainWindow); }
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); }
protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); try { // Load window placement details for previous application session from application settings // Note - if window was closed on a monitor that is now disconnected from the computer, // SetWindowPlacement will place the window onto a visible monitor. if (PreferencesFile.IsSettingAvailable("ControlCenter", "WindowLocation")) { WINDOWPLACEMENT wp = new WINDOWPLACEMENT(); wp.normalPosition = PreferencesFile.LoadSetting("ControlCenter", "WindowLocation", new RECT(0, 0, (int)Width, (int)Height)); wp.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT)); wp.flags = 0; wp.showCmd = (wp.showCmd == NativeMethods.SW_SHOWMINIMIZED ? NativeMethods.SW_SHOWNORMAL : wp.showCmd); IntPtr hwnd = new WindowInteropHelper(this).Handle; NativeMethods.SetWindowPlacement(hwnd, ref wp); } if (!Enum.TryParse(Preferences.HotKeyModifiers, out ModifierKeys mods)) { HotKeyDescription = "None"; return; } if (!Enum.TryParse(Preferences.HotKey, out Keys hotKey)) { HotKeyDescription = "None"; return; } if (hotKey != Keys.None) { _hotkey = new HotKey(mods, hotKey, this); _hotkey.HotKeyPressed += new Action <HotKey>(HotKeyPressed); HotKeyDescription = KeyboardEmulator.ModifierKeysToString(_hotkey.KeyModifier) + _hotkey.Key.ToString(); } else { HotKeyDescription = "None"; } } catch (System.Exception ex) { ConfigManager.LogManager.LogError("exception thrown during hotkey initialization", ex); RemoveHotkey(); } }