Ejemplo n.º 1
0
        private void Window_Deactivated(object sender, EventArgs e)
        {
            MainWindow window = (MainWindow)sender;

            if (window.ShouldStealFocus)
            {
                window.Topmost = true;
                Focuser.Start();
            }
            else
            {
                window.Topmost = false;
            }
        }
Ejemplo n.º 2
0
        private void MainGrid_OnKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter && Keyboard.IsKeyDown(Key.Escape))
            {
                Process.Start(Application.ResourceAssembly.Location);
                Application.Current.Shutdown();
            }
            else if (e.Key == Key.E && (Keyboard.IsKeyDown(Key.RightCtrl) || Keyboard.IsKeyDown(Key.LeftCtrl)))
            {
                ShouldStealFocus = !ShouldStealFocus;
                if (ShouldStealFocus)
                {
                    FocusNotifierTextBlock.Visibility = Visibility.Collapsed;
                }
                else
                {
                    FocusNotifierTextBlock.Visibility = Visibility.Visible;
                }
            }
            else if (e.Key == Key.Enter)
            {
                var game = MainListbox.SelectedItem as Game;

                //File.GetAttributes("Start.ps1");
                //string strCmdText = Path.Combine(Directory.GetCurrentDirectory(), "Start.ps1");
                var process = new Process();
                process.StartInfo.CreateNoWindow         = true;
                process.StartInfo.UseShellExecute        = false;
                process.StartInfo.LoadUserProfile        = true;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.FileName         = "powershell";
                process.StartInfo.WorkingDirectory = Properties.Settings.Default.GameRootDirectory + "/" + game.Name;

                process.StartInfo.Arguments = @"-ExecutionPolicy Unrestricted ./" + game.PathToRunScript;
                StopHelperProcesses();

                process.Start();
                ShouldStealFocus = false;
                this.WindowState = WindowState.Minimized;
                process.WaitForExit();
                ShouldStealFocus = true;
                this.WindowState = WindowState.Maximized;
                Focuser.Start();
            }
            else if (e.Key == Key.S && (Keyboard.IsKeyDown(Key.RightCtrl) || Keyboard.IsKeyDown(Key.LeftCtrl)))
            {
                if (SettingsEditor.Visibility == Visibility.Visible)
                {
                    SettingsEditor.Visibility = Visibility.Collapsed;
                }
                else
                {
                    SettingsEditor.Visibility = Visibility.Visible;
                }
            }
            else if (e.Key == Key.X && (Keyboard.IsKeyDown(Key.RightCtrl) || Keyboard.IsKeyDown(Key.LeftCtrl)))
            {
                Application.Current.Shutdown();
            }
            //else if(e.Key == Key.E && !(Keyboard.IsKeyDown(Key.RightCtrl) || Keyboard.IsKeyDown(Key.LeftCtrl)))
            //{
            //    UpdateGame(((Game)MainListbox.SelectedItem).Name);
            //}
        }