private void AutoConnect(string address, int port) { Logger.Info("Received AutoConnect " + address); if (StartStop.Content.ToString().ToLower() == "connect") { var autoConnect = Settings.SettingsStore.Instance.UserSettings[(int)SettingType.AutoConnectPrompt]; var connection = $"{address}:{port}"; if (autoConnect == "ON") { WindowHelper.BringProcessToFront(Process.GetCurrentProcess()); var result = MessageBox.Show(this, $"Would you like to try to Auto-Connect to DCS-SRS @ {address}:{port}? ", "Auto Connect", MessageBoxButton.YesNo, MessageBoxImage.Question); if ((result == MessageBoxResult.Yes) && (StartStop.Content.ToString().ToLower() == "connect")) { ServerIp.Text = connection; Connect(); } } else { ServerIp.Text = connection; Connect(); } } }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void MenuItemCallback(object sender, EventArgs e) { string message = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.GetType().FullName); string title = "Command4"; // Show a message box to prove we were here //VsShellUtilities.ShowMessageBox( // this.ServiceProvider, // message, // title, // OLEMSGICON.OLEMSGICON_INFO, // OLEMSGBUTTON.OLEMSGBUTTON_OK, // OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); //Process process = Process.Start("Spotify.exe"); //int id = process.Id; //Process tempProc = Process.GetProcessById(id); //this.Visible = false; //tempProc.WaitForExit(); //this.Visible = true; //myOleCommand.Text = "Test."; Process[] retrevedProc = Process.GetProcessesByName("Spotify"); Process spotMain = null; foreach (Process item in retrevedProc) { if (item.MainWindowTitle != "") { spotMain = item; break; } } if (spotMain != null) { WindowHelper.BringProcessToFront(spotMain); } else { Console.WriteLine("Spotify not running."); if (!SpotifyAPI.Local.SpotifyLocalAPI.IsSpotifyRunning()) { SpotifyAPI.Local.SpotifyLocalAPI.RunSpotify(); System.Threading.Thread.Sleep(300); Command1Package.SpotifyConnect(); SpotClientRegisterTrackChange(); Command1Package.UpdateCommandsHiddenState(); } else { Console.WriteLine("Something went wrong..\n " + "Spotify seems to be running but cant focus."); } } }
private void ShowCommence(string databaseName) { if (string.IsNullOrEmpty(databaseName)) { return; } Process p = ProcessHelper.GetProcessFromTitle(COMMENCE_PROCESS, databaseName); if (p != null) { WindowHelper.BringProcessToFront(p); } }
public void ShowWindow(ExternalCommandData commandData) { Process[] processlist = Process.GetProcesses(); foreach (var p in processlist) { if (p.MainWindowTitle.Equals(mpsDXTeybJAfSnv.QuickSelect)) { WindowHelper.BringProcessToFront(p); return; } } var window = new QuickFilterWindow(this); window.Show(); }
private void AutoConnect(String address, int port) { Logger.Info("Received AutoConnect " + address); if (StartStop.Content.ToString().ToLower() == "connect") { WindowHelper.BringProcessToFront(Process.GetCurrentProcess()); MessageBoxResult result = MessageBox.Show(this, $"Would you like to try to Auto-Connect to DCS-SRS @ {address}:{port}? ", "Auto Connect", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes && StartStop.Content.ToString().ToLower() == "connect") { ServerIp.Text = address + ":" + port; startStop_Click(null, null); } } }