Beispiel #1
0
        /// <summary>
        /// Updates Game, console, category and splits.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="cat"></param>
        public void UpdateGUI(Game g, Category cat)
        {
            MainWindow.instance.Startbtn.IsEnabled = true;
            MainWindow.instance.Resetbtn.IsEnabled = true;
            MainWindow.instance.Splitbtn.IsEnabled = true;
            MainWindow.instance.Stopbtn.IsEnabled  = true;
            GameTitle.Text     = g.GetName();
            ConsoleTitle.Text  = g.GetConsole();
            CategoryTitle.Text = cat.Name;
            if (SPLT.LoadedGame != null)
            {
                SOBTimeText.Text    = SPLT.TimeSpanToString(SPLT.LoadedGame.CategoryList[0].SOBTime, false);
                PBTimeText.Text     = SPLT.TimeSpanToString(SPLT.LoadedGame.CategoryList[0].PersonalBest, false);
                TargetTimeText.Text = SPLT.TimeSpanToString(SPLT.LoadedGame.CategoryList[0].TargetTime, false);
            }
            Splititemlist.Items.Clear();
            foreach (Split s in cat.SplitList)
            {
                Splititemlist.Items.Add(s.GetTitle());
            }
            switch (Preferences.DefaultComparisonSplits)
            {
            case 1:
                RunManager.WriteTargetTime(SPLT.LoadedGame.CategoryList[0].PBSplits);
                break;

            case 2:
                RunManager.WriteTargetTime(SPLT.LoadedGame.CategoryList[0].TargetSplits);
                break;

            case 3:
                RunManager.WriteTargetTime(SPLT.LoadedGame.CategoryList[0].SOBSplits);
                break;
            }
        }
Beispiel #2
0
        private void SelectSplitBtn_Click(object sender, RoutedEventArgs e)
        {
            // Create OpenFileDialog
            Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog();
            dialog.InitialDirectory = Directory.GetCurrentDirectory() + "\\Data\\";
            // Set filter for file extension and default file extensi on
            dialog.DefaultExt = ".splt";
            // Display OpenFileDialog by calling ShowDialog method
            Nullable <bool> result = dialog.ShowDialog();

            // Get the selected file name and display in a TextBox
            if (result == true)
            {
                // Open document

                filename           = dialog.FileName;
                SplitFileName.Text = filename;
                Debug.WriteLine(filename);
                RunManager.ClearUI();
                SPLT.ReadAndPrint(filename);
                //SPLT.ReadAndPrint(System.IO.Directory.GetCurrentDirectory() + "\\Data\\" + g.GetName() + ".splt");
            }
        }
Beispiel #3
0
 /// <summary>
 /// Stop Timer Button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Stopbtn_Click(object sender, RoutedEventArgs e)
 {
     RunManager.StopButtonClick();
 }
Beispiel #4
0
 /// <summary>
 /// Start Timer Button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Startbtn_Click(object sender, RoutedEventArgs e)
 {
     RunManager.TimerStart();
 }
Beispiel #5
0
        private IntPtr HwndHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            const int WM_HOTKEY = 0x0312;

            if (setHotkeyState != 0)
            {
                Key k = Hotkeys.IsKeyDown();
                if (k == Key.Escape)
                {
                    switch (setHotkeyState)
                    {
                    case 1:
                        set_split_key.Content = "Not set";
                        break;

                    case 2:
                        set_start_key.Content = "Not set";
                        break;

                    case 3:
                        set_reset_key.Content = "Not set";
                        break;
                    }
                    setHotkeyState = 0;
                }
                if (k != Key.None)
                {
                    Debug.WriteLine("Pressed key: " + k.ToString());

                    switch (setHotkeyState)
                    {
                    case 1:
                        UnregisterHotKey(Hotkeys.SplitID);
                        KeyConfig.Config.SplitHK = (uint)KeyInterop.VirtualKeyFromKey(k);
                        RegisterHotKey(KeyConfig.Config.SplitHK, Hotkeys.SplitID);
                        set_split_key.Content = k.ToString();
                        break;

                    case 2:
                        UnregisterHotKey(Hotkeys.StartID);
                        KeyConfig.Config.StartHK = (uint)KeyInterop.VirtualKeyFromKey(k);
                        RegisterHotKey(KeyConfig.Config.StartHK, Hotkeys.StartID);
                        set_start_key.Content = k.ToString();
                        break;

                    case 3:
                        UnregisterHotKey(Hotkeys.ResetID);
                        KeyConfig.Config.ResetHK = (uint)KeyInterop.VirtualKeyFromKey(k);
                        RegisterHotKey(KeyConfig.Config.ResetHK, Hotkeys.ResetID);
                        set_reset_key.Content = k.ToString();
                        break;
                    }

                    setHotkeyState = 0;
                }
            }
            switch (msg)
            {
            case WM_HOTKEY:
                switch (wParam.ToInt32())
                {
                case 9000:

                    if (SPLT.LoadedGame != null)
                    {
                        if (!runInProgress)
                        {
                            RunManager.TimerStart();
                        }
                        else
                        {
                            RunManager.Split();
                        }
                    }


                    handled = true;
                    break;

                case 9001:
                    if (SPLT.LoadedGame != null)
                    {
                        if (!runInProgress)
                        {
                            RunManager.TimerStart();
                        }
                        else
                        {
                            RunManager.StopButtonClick();
                        }
                    }

                    break;

                case 9002:
                    if (SPLT.LoadedGame != null)
                    {
                        RunManager.Reset();
                    }

                    break;
                }
                break;
            }
            return(IntPtr.Zero);
        }
Beispiel #6
0
 /// <summary>
 /// Reset Timer Button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Resetbtn_Click(object sender, RoutedEventArgs e)
 {
     RunManager.Reset();
 }
Beispiel #7
0
 /// <summary>
 /// Split Button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Splitbtn_Click(object sender, RoutedEventArgs e)
 {
     RunManager.Split();
 }
Beispiel #8
0
        /// <summary>
        /// Loads preferences and updates the preferences tab with correct info.
        /// </summary>
        public static void LoadPreferences()
        {
            MainWindow.instance.ShowMSChkBox.IsChecked = ShowMS;
            if (WindowAlwaysOnTop)
            {
                MainWindow.instance.Topmost = true;
                MainWindow.instance.WindowAlwaysOnTopCheckBox.IsChecked = true;
            }
            else
            {
                MainWindow.instance.Topmost = false;
                MainWindow.instance.WindowAlwaysOnTopCheckBox.IsChecked = false;
            }

            try
            {
                if (DefaultGamePath != null)
                {
                    SPLT.ReadAndPrint(DefaultGamePath);
                }
                else
                {
                    MainWindow.instance.Startbtn.IsEnabled = false;
                    MainWindow.instance.Resetbtn.IsEnabled = false;
                    MainWindow.instance.Splitbtn.IsEnabled = false;
                    MainWindow.instance.Stopbtn.IsEnabled  = false;
                }
            } catch
            {
                Debug.WriteLine("failed to set defaultgame");
            }
            try
            {
                switch (DefaultComparisonSplits)
                {
                case 1:
                    MainWindow.instance.ComparisonTimeComboBox.SelectedIndex = 1;
                    //MainWindow.instance.CurrentComparisonTime.SelectedIndex = 0;
                    RunManager.WriteTargetTime(SPLT.LoadedGame.CategoryList[0].PBSplits);
                    MainWindow.instance.ComparisonTimeComboBox.SelectedIndex = 1;
                    break;

                case 2:
                    MainWindow.instance.ComparisonTimeComboBox.SelectedIndex = 2;
                    //MainWindow.instance.CurrentComparisonTime.SelectedIndex = 1;
                    RunManager.WriteTargetTime(SPLT.LoadedGame.CategoryList[0].TargetSplits);
                    MainWindow.instance.ComparisonTimeComboBox.SelectedIndex = 2;
                    break;

                case 3:
                    MainWindow.instance.ComparisonTimeComboBox.SelectedIndex = 3;
                    //MainWindow.instance.CurrentComparisonTime.SelectedIndex = 2;
                    RunManager.WriteTargetTime(SPLT.LoadedGame.CategoryList[0].SOBSplits);
                    MainWindow.instance.ComparisonTimeComboBox.SelectedIndex = 3;
                    break;
                }
            } catch
            {
                Debug.WriteLine("Failed to set defaultComparisonSplits");
            }
            try
            {
                MainWindow.instance.TargetTimeText.Text = SPLT.TimeSpanToString(DefaultTargetTime, false);
            } catch
            {
                Debug.WriteLine("Failed to set defaultTargetTime");
            }

            if (SavePrefsOnQuit)
            {
                MainWindow.instance.SavePreferencesOnQuitChkBox.IsChecked = true;
            }
            else
            {
                MainWindow.instance.SavePreferencesOnQuitChkBox.IsChecked = false;
            }
        }