Пример #1
0
        private void ExecuteShortcut(Shortcut shortcut)
        {
            if (shortcut.SwitchTasksIfAlreadyRunning)
            {
                foreach (DesktopWindows.Window window in _windows.Windows)
                {
                    string windowExe, windowArgs;
                    ParseCommandLine(window.CmdLine, out windowExe, out windowArgs);
                    if ((windowExe.Equals(shortcut.Executable, StringComparison.CurrentCultureIgnoreCase)) &&
                        (windowArgs.Equals(shortcut.Arguments, StringComparison.CurrentCultureIgnoreCase)))
                    {
                        MS.Win32.SetForegroundWindow(window.Hwnd);

                        MS.Win32.WINDOWPLACEMENT placement = new MS.Win32.WINDOWPLACEMENT();
                        MS.Win32.GetWindowPlacement(window.Hwnd, ref placement);
                        if ((placement.showCmd == MS.Win32.SW.MINIMIZE) ||
                            (placement.showCmd == MS.Win32.SW.SHOWMINIMIZED))
                        {
                            MS.Win32.ShowWindow(window.Hwnd, MS.Win32.SW.RESTORE);
                        }

                        if (Settings.Current.Minimize)
                        {
                            SendToTray();
                        }
                        else
                        {
                            Close();
                        }

                        return;
                    }
                }
            }

            string originalWorkingDirectory = null;

            if ((shortcut.WorkingFolder.Length > 0) && (System.IO.Directory.Exists(shortcut.WorkingFolder)))
            {
                originalWorkingDirectory     = Environment.CurrentDirectory;
                Environment.CurrentDirectory = shortcut.WorkingFolder;
            }

            Process process = System.Diagnostics.Process.Start(shortcut.Executable, shortcut.Arguments);

            if (originalWorkingDirectory != null)
            {
                Environment.CurrentDirectory = originalWorkingDirectory;
            }

            if (Settings.Current.Minimize)
            {
                SendToTray();
            }
            else
            {
                Close();
            }
        }
Пример #2
0
        void buttonListControlRunning_ItemActivate(object sender, ButtonListControl.ButtonListControlItem item)
        {
            DesktopWindows.Window window = item.Tag as DesktopWindows.Window;
            MS.Win32.SetForegroundWindow(window.Hwnd);

            MS.Win32.WINDOWPLACEMENT placement = new MS.Win32.WINDOWPLACEMENT();
            MS.Win32.GetWindowPlacement(window.Hwnd, ref placement);
            if ((placement.showCmd == MS.Win32.SW.MINIMIZE) ||
                (placement.showCmd == MS.Win32.SW.SHOWMINIMIZED))
            {
                MS.Win32.ShowWindow(window.Hwnd, MS.Win32.SW.RESTORE);
            }

            if (Settings.Current.Minimize)
            {
                SendToTray();
            }
            else
            {
                Close();
            }
        }