示例#1
0
        /// <summary>
        /// Handler: Opens the terminal if the f12 key is pressed
        /// </summary>
        /// <param name="e"></param>
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            if (e.KeyCode == Keys.F12)
            {
                if (_console == null || _console.IsDisposed)
                {
                    _console = new UserConsole();
                }
                _console.Show();
                _console.BringToFront();
            }
        }
示例#2
0
        /// <summary>
        /// Handler: Opens the terminal if the f12 key is pressed
        /// </summary>
        /// <param name="e"></param>
        protected override void OnKeyDown(KeyEventArgs e)
        {
            ConsoleInterface nullOutput = new ConsoleInterface();

            base.OnKeyDown(e);

            switch (e.KeyCode)
            {
            case Keys.D0:
            case Keys.NumPad0:
                InvisibleInputText += "0";
                break;

            case Keys.D1:
            case Keys.NumPad1:
                InvisibleInputText += "1";
                break;

            case Keys.D2:
            case Keys.NumPad2:
                InvisibleInputText += "2";
                break;

            case Keys.D3:
            case Keys.NumPad3:
                InvisibleInputText += "3";
                break;

            case Keys.D4:
            case Keys.NumPad4:
                InvisibleInputText += "4";
                break;

            case Keys.D5:
            case Keys.NumPad5:
                InvisibleInputText += "5";
                break;

            case Keys.D6:
            case Keys.NumPad6:
                InvisibleInputText += "6";
                break;

            case Keys.D7:
            case Keys.NumPad7:
                InvisibleInputText += "7";
                break;

            case Keys.D8:
            case Keys.NumPad8:
                InvisibleInputText += "8";
                break;

            case Keys.D9:
            case Keys.NumPad9:
                InvisibleInputText += "9";
                break;

            case Keys.Delete:
                if (e.Shift)
                {
                    Globals.PrimaryTimer.InFreeMode = !Globals.PrimaryTimer.InFreeMode;
                }
                else
                {
                    Globals.PrimaryTimer.Target = DateTime.Now;
                }

                return;

            case Keys.Pause:
                Command.GetByType <Freeze>().Execute(new string[0], nullOutput);
                return;

            case Keys.PageUp:
                Globals.PrimaryTimer.Target = Globals.PrimaryTimer.Target.AddDays(1.0);
                return;

            case Keys.PageDown:
                Globals.PrimaryTimer.Target = Globals.PrimaryTimer.Target.AddDays(-1.0);
                return;

            case Keys.Insert:
                Globals.PrimaryTimer.StopAtZero = !Globals.PrimaryTimer.StopAtZero;
                MessageBox.Show(Globals.PrimaryTimer.StopAtZero ? "End Mode: Stop" : "End Mode: Continue");
                return;

            case Keys.Return:
                Globals.SwapTimers();
                return;

            case Keys.F1:
                MessageBox.Show(string.Join(Environment.NewLine,
                                            "F1: Help",
                                            "F10: Collapse/Uncollapse",
                                            "F11: Translucency Mode",
                                            "F12: Console",
                                            "Del: Reset to zero",
                                            "Shift + Del: Idle Mode",
                                            "Enter: Swap Primary/Secondary Timer",
                                            "Ins: Change end mode",
                                            "Pause: Freeze/Unfreeze",
                                            "0930: Set target to 09:30 (Must be in 24h format)",
                                            "Shift + 0930: Set countdown to 9 minutes and 30 seconds",
                                            "Alt + 0930: Set countdown to 9 hours and 30 minutes",
                                            "Page Up: Add 1 day to target",
                                            "Page Dn: Subtract 1 day from to target"
                                            ), "Keyboard Shortcuts");
                return;

            case Keys.F11:
                ToggleWindowTranslucencyMode();
                break;

            case Keys.F10:
                const int COLLAPSE_HEIGHT = 90;

                if (tabs.SelectedIndex == 4)
                {
                    int lastHeigh = Height;
                    tabs.SelectedIndex = 0;
                    Top -= (Height - lastHeigh);

                    //Found this solution on stack
                    tabs.Appearance = TabAppearance.Normal;
                    tabs.ItemSize   = new Size(30, 18);
                }
                else
                {
                    tabs.SelectedIndex = 4;
                    Top   += (Height - COLLAPSE_HEIGHT);
                    Height = COLLAPSE_HEIGHT;

                    tabs.Appearance = TabAppearance.FlatButtons;
                    tabs.ItemSize   = new Size(0, 1);
                }


                break;

            case Keys.F12:
                if (_console == null || _console.IsDisposed)
                {
                    _console = new UserConsole();
                }

                _console.Show();
                _console.BringToFront();
                return;
            }

            if (InvisibleInputText.Length == 4)
            {
                int a = int.Parse(InvisibleInputText.Substring(0, 2), NumberStyles.Integer, CultureInfo.InvariantCulture);
                int b = int.Parse(InvisibleInputText.Substring(2, 2), NumberStyles.Integer, CultureInfo.InvariantCulture);

                //Duration
                if (e.Shift || e.Alt)
                {
                    int hour;
                    int minute;
                    int second;

                    if (e.Alt)
                    {
                        hour   = a;
                        minute = b;
                        second = 0;
                    }
                    else
                    {
                        hour   = 0;
                        minute = a;
                        second = b;
                    }

                    TimeSpan newTarget = new TimeSpan(hour, minute, second);
                    Globals.PrimaryTimer.Target     = DateTime.Now + newTarget;
                    Globals.PrimaryTimer.InFreeMode = false;
                }

                //Target
                else
                {
                    int hour   = a;
                    int minute = b;

                    if (hour < 24 && minute < 60)
                    {
                        Globals.PrimaryTimer.Target     = DateTime.Today.AddHours(hour).AddMinutes(minute);
                        Globals.PrimaryTimer.InFreeMode = false;
                    }
                }

                LastInvisibileInputTextUpdateTime = default;
                InvisibleInputText = "";
            }
            else
            {
                LastInvisibileInputTextUpdateTime = DateTime.Now;
            }
        }