예제 #1
0
 private void OnKeyDown(object sender, KeyEventArgs e)
 {
     if (!IsDropDownOpen)
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             IsDropDownOpen = true;
             // Popup_Opened() will Focus on ComboBoxItem.
             e.Handled = true;
         }
     }
     else
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             CloseDropDown(true);
             e.Handled = true;
         }
         else if (e.Key == Key.Enter)
         {
             CloseDropDown(true);
             e.Handled = true;
         }
         else if (e.Key == Key.Escape)
         {
             SelectedItems.Clear();
             foreach (object o in _initialValue)
             {
                 SelectedItems.Add(o);
             }
             CloseDropDown(true);
             e.Handled = true;
         }
     }
 }
예제 #2
0
 private void OnKeyDown(object sender, KeyEventArgs e)
 {
     if (!IsOpen)
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             IsOpen = true;
             // Calendar will get focus in Calendar_Loaded().
             e.Handled = true;
         }
     }
     else
     {
         if (_calendar.IsKeyboardFocusWithin)
         {
             if (KeyboardUtilities.IsKeyModifyingPopupState(e))
             {
                 CloseDateTimePicker(true);
                 e.Handled = true;
             }
             else
             {
                 this.ManageEnterEscapeKeys(e);
             }
         }
         else if (_timePicker.IsKeyboardFocusWithin && !_timePicker.IsOpen && !e.Handled)
         {
             this.ManageEnterEscapeKeys(e);
         }
     }
 }
예제 #3
0
 private void OnKeyDown(object sender, KeyEventArgs e)
 {
     if (!IsOpen)
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             IsOpen = true;
             // TimeListBox_Loaded() will focus on ListBoxItem.
             e.Handled = true;
         }
     }
     else
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             CloseTimePicker(true);
             e.Handled = true;
         }
         else if (e.Key == Key.Enter)
         {
             CloseTimePicker(true);
             e.Handled = true;
         }
         else if (e.Key == Key.Escape)
         {
             Value = _initialValue;
             CloseTimePicker(true);
             e.Handled = true;
         }
     }
 }
예제 #4
0
        public override void SetDragPositionTopDownView(double?x = null, double?y = null, double?z = null)
        {
            if (!x.HasValue || !z.HasValue)
            {
                return;
            }

            PositionAngle posAngle = _posAngle.GetBasePositionAngle();
            double        dist     = MoreMath.GetDistanceBetween(posAngle.X, posAngle.Z, x.Value, z.Value);
            double        angle    = MoreMath.AngleTo_AngleUnits(posAngle.X, posAngle.Z, x.Value, z.Value);

            if (Rotates)
            {
                angle -= posAngle.Angle;
            }

            if (!KeyboardUtilities.IsCtrlHeld())
            {
                _posAngle.SetOffsetDist(dist);
            }
            if (!KeyboardUtilities.IsShiftHeld())
            {
                _posAngle.SetOffsetAngle(angle);
            }

            MapTracker mapTracker = GetParentMapTracker();

            mapTracker.SetSize((float)_posAngle.GetOffsetDist());
            mapTracker.SetLineWidth((float)_posAngle.GetOffsetAngle());
        }
예제 #5
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            KeyboardUtilities.Disconnect();
            hkm.Enabled = false;
            ArrayList tmp = new ArrayList();

            foreach (GlobalHotKey a in hkm.EnumerateGlobalHotKeys)
            {
                tmp.Add(a);
            }

            foreach (GlobalHotKey VARIABLE in tmp)
            {
                hkm.RemoveGlobalHotKey(VARIABLE);
            }
            hkm.Dispose();
            if (a != null)
            {
                if (a.f != null)
                {
                    a.f.Dispose();
                    RainbowMage.HtmlRenderer.Renderer.Shutdown();
                }
            }
            StopKeyPlay();
            timeEndPeriod(1);
        }
 private void OnKeyDown(object sender, KeyEventArgs e)
 {
     if (!IsOpen)
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             IsOpen = true;
             // Calculator will get focus in CalculatorPopup_Opened().
             e.Handled = true;
         }
     }
     else
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             CloseCalculatorUpDown(true);
             e.Handled = true;
         }
         else if (e.Key == Key.Escape)
         {
             if (EnterClosesCalculator)
             {
                 Value = _initialValue;
             }
             CloseCalculatorUpDown(true);
             e.Handled = true;
         }
     }
 }
예제 #7
0
 private void OnKeyDown(object sender, KeyEventArgs e)
 {
     if (!IsOpen)
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             IsOpen = true;
             // Focus will be on ListBoxItem in Popup_Opened().
             e.Handled = true;
         }
     }
     else
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             CloseColorPicker(true);
             e.Handled = true;
         }
         else if (e.Key == Key.Escape)
         {
             CloseColorPicker(true);
             e.Handled = true;
         }
     }
 }
예제 #8
0
 private void ctxProgramsItem_Opened(object sender, RoutedEventArgs e)
 {
     if (KeyboardUtilities.IsKeyDown(System.Windows.Forms.Keys.ShiftKey))
     {
         ContextMenu menu = (sender as ContextMenu);
         foreach (Control item in menu.Items)
         {
             if (item.Name == "miProgramsItemRunAs")
             {
                 item.Visibility = Visibility.Visible;
                 return;
             }
         }
     }
     else
     {
         ContextMenu menu = (sender as ContextMenu);
         foreach (Control item in menu.Items)
         {
             if (item.Name == "miProgramsItemRunAs")
             {
                 item.Visibility = Visibility.Collapsed;
                 return;
             }
         }
     }
 }
예제 #9
0
 private void OnKeyDown(object sender, KeyEventArgs e)
 {
     if (!IsOpen)
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             IsOpen = true;
             // Calendar will get focus in Calendar_Loaded().
             e.Handled = true;
         }
     }
     else
     {
         if (_calendar.IsKeyboardFocusWithin)
         {
             if (KeyboardUtilities.IsKeyModifyingPopupState(e))
             {
                 CloseDateTimePicker(true);
                 e.Handled = true;
             }
             else if (e.Key == Key.Enter)
             {
                 CloseDateTimePicker(true);
                 e.Handled = true;
             }
             else if (e.Key == Key.Escape)
             {
                 Value = _initialValue;
                 CloseDateTimePicker(true);
                 e.Handled = true;
             }
         }
     }
 }
예제 #10
0
 private void OnKeyDown(object sender, KeyEventArgs e)
 {
     if (!IsOpen)
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             IsOpen = true;
             // ContentPresenter items will get focus in Popup_Opened().
             e.Handled = true;
         }
     }
     else
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             CloseDropDown(true);
             e.Handled = true;
         }
         else if (e.Key == Key.Escape)
         {
             CloseDropDown(true);
             e.Handled = true;
         }
     }
 }
예제 #11
0
        public override void SetDragPositionTopDownView(double?x = null, double?y = null, double?z = null)
        {
            if (!x.HasValue || !z.HasValue)
            {
                return;
            }

            PositionAngle posAngle = GetPositionAngle();
            double        dist     = MoreMath.GetDistanceBetween(posAngle.X, posAngle.Z, x.Value, z.Value);
            double        angle    = MoreMath.AngleTo_AngleUnits(posAngle.X, posAngle.Z, x.Value, z.Value);

            if (!KeyboardUtilities.IsCtrlHeld())
            {
                if (_useRecommendedArrowLength)
                {
                    SetRecommendedSize(dist);
                }
                else
                {
                    GetParentMapTracker().SetSize((float)(Scales ? dist : dist *Config.CurrentMapGraphics.MapViewScaleValue));
                }
            }
            if (!KeyboardUtilities.IsShiftHeld())
            {
                SetYaw(angle);
            }
        }
예제 #12
0
 private void OnKeyDown(object sender, KeyEventArgs e)
 {
     if (!IsOpen)
     {
         if (!KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             return;
         }
         IsOpen    = true;
         e.Handled = true;
     }
     else
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             CloseDropDown(true);
             e.Handled = true;
         }
         else if (e.Key == Key.Escape)
         {
             CloseDropDown(true);
             e.Handled = true;
         }
     }
 }
예제 #13
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     hotKeyManager.Unregister(_hotKeyF10);
     hotKeyManager.Unregister(_hotKeyF12);
     // Dispose the hotkey manager.
     hotKeyManager.Dispose();
     KeyboardUtilities.Disconnect();
 }
 private void MyListView_OnLoaded(object sender, RoutedEventArgs e)
 {
     MyListView.Focus();
     MyListView.SelectedItem = MyListView.Items[0];
     // Have to do this because the ListView doesn't fully select the first item, user would
     // otherwise have to press down twice to get the selection to move to the second item.
     KeyboardUtilities.PressKey(MyListView, Key.Down);
 }
예제 #15
0
        public MainForm()
        {
            InitializeComponent();
            formUpdate();
            KeyBinding.LoadConfig();
            CommonUtilities.GetLatestVersion();

            cbMidiKeyboard.DataSource = KeyboardUtilities.GetKeyboardList();
        }
예제 #16
0
        private void btnFile_Click(object sender, RoutedEventArgs e)
        {
            Button senderButton = sender as Button;

            if (senderButton != null && senderButton.CommandParameter != null)
            {
                string commandString = senderButton.CommandParameter as String;
                if (!string.IsNullOrWhiteSpace(commandString))
                {
                    // Determine if [SHIFT] key is held. Bypass Directory Processing, which will use the Shell to open the item.
                    if (!KeyboardUtilities.IsKeyDown(System.Windows.Forms.Keys.ShiftKey))
                    {
                        // get the file attributes for file or directory
                        FileAttributes attr        = File.GetAttributes(commandString);
                        bool           isDirectory = (attr & FileAttributes.Directory) == FileAttributes.Directory;

                        // if directory, perform special handling
                        if (isDirectory &&
                            Settings.EnableDynamicDesktop &&
                            Window.GetWindow(senderButton)?.Name == "CairoDesktopWindow" &&
                            Startup.DesktopWindow != null)
                        {
                            Startup.DesktopWindow.Navigate(commandString);
                            return;
                        }
                        else if (isDirectory)
                        {
                            FolderHelper.OpenLocation(commandString);
                            return;
                        }
                    }

                    System.Diagnostics.Process proc = new System.Diagnostics.Process();
                    proc.StartInfo.UseShellExecute = true;
                    proc.StartInfo.FileName        = commandString;

                    if (Startup.DesktopWindow != null)
                    {
                        Startup.DesktopWindow.IsOverlayOpen = false;
                    }

                    try
                    {
                        proc.Start();
                        return;
                    }
                    catch
                    {
                        // No 'Open' command associated with this filetype in the registry
                        Interop.Shell.ShowOpenWithDialog(proc.StartInfo.FileName);
                        return;
                    }
                }
            }

            CairoMessage.Show(DisplayString.sError_FileNotFoundInfo, DisplayString.sError_OhNo, MessageBoxButton.OK, MessageBoxImage.Error);
        }
예제 #17
0
        private void pictureBoxDownArrow_Click(object sender, EventArgs e)
        {
            int numMoves = KeyboardUtilities.GetCurrentlyInputtedNumber() ?? 1;

            if (KeyboardUtilities.IsCtrlHeld())
            {
                numMoves = 0;
            }
            mapTab.flowLayoutPanelMapTrackers.MoveDownControl(this, numMoves);
        }
예제 #18
0
        public MainForm()
        {
            InitializeComponent();
            formUpdate();
            KeyBinding.LoadConfig();
            timeBeginPeriod(1);

            Text += $@" Ver{Assembly.GetExecutingAssembly().GetName().Version} ";
            cbMidiKeyboard.DataSource = KeyboardUtilities.GetKeyboardList();
            kc.stopHandler           += StopKeyPlay;
        }
예제 #19
0
 private void buttonMoveTabRight_Click(object sender, EventArgs e)
 {
     if (KeyboardUtilities.IsCtrlHeld() || KeyboardUtilities.IsNumberHeld())
     {
         ObjectOrderingUtilities.Move(true);
     }
     else
     {
         MoveTab(true);
     }
 }
예제 #20
0
 public override void SetDragPositionTopDownView(double?x = null, double?y = null, double?z = null)
 {
     if (KeyboardUtilities.IsCtrlHeld())
     {
         z = null;
     }
     if (KeyboardUtilities.IsShiftHeld())
     {
         x = null;
     }
     GetPositionAngle().SetValues(x, y, z);
 }
예제 #21
0
        private ShellMenuCommandBuilder GetFileCommandBuilder(ShellFile file)
        {
            if (file == null)
            {
                return(new ShellMenuCommandBuilder());
            }

            ShellMenuCommandBuilder builder = new ShellMenuCommandBuilder();

            if (file.IsNavigableFolder)
            {
                if (Settings.Instance.EnableDynamicDesktop && Settings.Instance.FoldersOpenDesktopOverlay &&
                    Settings.Instance.EnableDesktop && !GroupPolicyHelper.NoDesktop)
                {
                    builder.AddCommand(new ShellMenuCommand
                    {
                        Flags = MFT.BYCOMMAND, // enable this entry always
                        Label = DisplayString.sStacks_OpenOnDesktop,
                        UID   = (uint)CairoContextMenuItem.OpenOnDesktop
                    });

                    // If the [SHIFT] key is held, don't change the default action to ours
                    // Only set as the default action for filesystem items because we don't support all shell views
                    if (file.IsFileSystem && !KeyboardUtilities.IsKeyDown(System.Windows.Forms.Keys.ShiftKey))
                    {
                        builder.DefaultItemUID = (uint)CairoContextMenuItem.OpenOnDesktop;
                    }
                }

                if (StacksManager.Instance.StackLocations.All(i => i.Path != file.Path))
                {
                    builder.AddCommand(new ShellMenuCommand
                    {
                        Flags = MFT.BYCOMMAND, // enable this entry always
                        Label = DisplayString.sInterface_AddToStacks,
                        UID   = (uint)CairoContextMenuItem.AddToStacks
                    });
                }
                else
                {
                    builder.AddCommand(new ShellMenuCommand
                    {
                        Flags = MFT.BYCOMMAND, // enable this entry always
                        Label = DisplayString.sInterface_RemoveFromStacks,
                        UID   = (uint)CairoContextMenuItem.RemoveFromStacks
                    });
                }
                builder.AddSeparator();
            }

            return(builder);
        }
예제 #22
0
        private void P_EventPlayed(object sender, MidiEventPlayedEventArgs e)
        {
            switch (e.Event)
            {
            case NoteOnEvent keyon:
                KeyboardUtilities.NoteOn(keyon);

                break;

            case NoteOffEvent keyoff:
                KeyboardUtilities.NoteOff(keyoff);

                break;
            }
        }
예제 #23
0
        public MainForm()
        {
            InitializeComponent();
            formUpdate();
            KeyBinding.LoadConfig();
            timeBeginPeriod(1);

            Task.Run((Action)(() =>
            {
                CommonUtilities.GetLatestVersion();
                this.TimeSync();
            }));

            Text += $@" Ver{Assembly.GetExecutingAssembly().GetName().Version} ";
            cbMidiKeyboard.DataSource = KeyboardUtilities.GetKeyboardList();
            kc.stopHandler           += StopKeyPlay;
        }
예제 #24
0
        private void OnSlotClick(object sender, EventArgs e)
        {
            // Make sure the tab has loaded
            if (_gui.TabControl.SelectedTab == null)
            {
                return;
            }

            ObjectSlot selectedSlot = sender as ObjectSlot;

            selectedSlot.Focus();

            bool isCtrlKeyHeld  = KeyboardUtilities.IsCtrlHeld();
            bool isShiftKeyHeld = KeyboardUtilities.IsShiftHeld();
            bool isAltKeyHeld   = KeyboardUtilities.IsAltHeld();

            DoSlotClickUsingInput(selectedSlot, isCtrlKeyHeld, isShiftKeyHeld, isAltKeyHeld);
        }
예제 #25
0
 private void ListBoxCopied_KeyDown()
 {
     if (KeyboardUtilities.IsDeletishKeyHeld())
     {
         M64CopiedData copiedData = _gui.ListBoxCopied.SelectedItem as M64CopiedData;
         if (copiedData == null || copiedData == M64CopiedData.OneEmptyFrame)
         {
             return;
         }
         int index = _gui.ListBoxCopied.SelectedIndex;
         _gui.ListBoxCopied.Items.Remove(copiedData);
         if (index == _gui.ListBoxCopied.Items.Count)
         {
             index--;
         }
         _gui.ListBoxCopied.SelectedIndex = index;
     }
 }
예제 #26
0
        private void OnSlotClick(object sender, EventArgs e)
        {
            // Make sure the tab has loaded
            if (mainForm.tabControlMain.SelectedTab == null)
            {
                return;
            }

            ObjectSlot selectedSlot = sender as ObjectSlot;

            selectedSlot.Focus();

            bool isCtrlKeyHeld  = KeyboardUtilities.IsCtrlHeld();
            bool isShiftKeyHeld = KeyboardUtilities.IsShiftHeld();
            bool isAltKeyHeld   = KeyboardUtilities.IsAltHeld();
            int? numberHeld     = KeyboardUtilities.GetCurrentlyInputtedNumber();

            DoSlotClickUsingInput(selectedSlot, isCtrlKeyHeld, isShiftKeyHeld, isAltKeyHeld, numberHeld);
        }
예제 #27
0
 private void OpenCloseCairoBox(object sender, RoutedEventArgs e)
 {
     CairoMessage.ShowOkCancel(Localization.DisplayString.sExitCairo_Info, Localization.DisplayString.sExitCairo_Title,
                               CairoMessageImage.Default, Localization.DisplayString.sExitCairo_ExitCairo, Localization.DisplayString.sInterface_Cancel,
                               result =>
     {
         if (result == true)
         {
             if (KeyboardUtilities.IsKeyDown(System.Windows.Forms.Keys.ShiftKey))
             {
                 _cairoApplication.RestartCairo();
             }
             else
             {
                 _cairoApplication.ExitCairo();
             }
         }
     });
 }
예제 #28
0
        protected override void WndProc(ref Message m)
        {
            try
            {
                const int WM_DEVICECHANGE = 0x0219;
                switch (m.Msg)
                {
                case WM_DEVICECHANGE:
                    cbMidiKeyboard.DataSource = KeyboardUtilities.GetKeyboardList();
                    break;
                }
            }

            catch (Exception ex)
            {
            }

            base.WndProc(ref m);
        }
예제 #29
0
        private void InitializeTabRemoval()
        {
            tabControlMain.Click += (se, ev) =>
            {
                if (KeyboardUtilities.IsCtrlHeld())
                {
                    SavedSettingsConfig.RemoveTab(tabControlMain.SelectedTab);
                }
            };

            buttonTabAdd.ContextMenuStrip          = new ContextMenuStrip();
            buttonTabAdd.ContextMenuStrip.Opening += (se, ev) =>
            {
                buttonTabAdd.ContextMenuStrip.Items.Clear();
                SavedSettingsConfig.GetRemovedTabItems().ForEach(
                    item => buttonTabAdd.ContextMenuStrip.Items.Add(item));
            };

            SavedSettingsConfig.InvokeInitiallySavedRemovedTabs();
        }
예제 #30
0
 private void OnKeyDown(object sender, KeyEventArgs e)
 {
     if (!IsOpen)
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             IsOpen    = true;
             e.Handled = true;
         }
     }
     else
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e) ||
             (e.Key == Key.Escape) ||
             (e.Key == Key.Tab))
         {
             CloseEditor();
             e.Handled = true;
         }
     }
 }