Example #1
0
        public override bool ServeKey(System.Windows.Input.Key k, System.Windows.Input.ModifierKeys mk)
        {
            bool result = base.ServeKey(k, mk);

            ViSDGlobalCount.Process();
            int CurEndPos = vh.TextArea.Caret.Offset;

            SelectVisual(CurBeginPos, CurEndPos);
            return(result);
        }
Example #2
0
        private bool ApplySettings()
        {
            if (ValidateForm())
            {
                var s = Properties.Settings.Default;
                s.Host = hostTextBox.Text.Trim();
                s.Port = int.Parse(portTextBox.Text);

                s.PBXContext = contextTextBox.Text.Trim();
                s.Username   = usernameTextBox.Text.Trim();
                s.Password   = passwordTextBox.Text;

                s.PingInterval   = int.Parse(pingIntervalTextBox.Text);
                s.FOP2Url        = fop2WebInterfaceTextBox.Text.Trim();
                s.FOP2UserPortal = fop2UserPortalTextBox.Text.Trim();

                s.GrabMinLength = int.Parse(grabMinLengthTextBox.Text);

                swi.ModifierKeys modifiers = swi.ModifierKeys.None;
                modifiers |= hotkeyAltCheckBox.Checked ? swi.ModifierKeys.Alt : swi.ModifierKeys.None;
                modifiers |= hotkeyCtrlCheckBox.Checked ? swi.ModifierKeys.Control : swi.ModifierKeys.None;
                modifiers |= hotkeyWinCheckBox.Checked ? swi.ModifierKeys.Windows : swi.ModifierKeys.None;
                modifiers |= hotkeyShiftCheckBox.Checked ? swi.ModifierKeys.Shift : swi.ModifierKeys.None;

                s.GlobalDialHotkey = new DDHotkey((swi.Key)hotkeyComboBox.SelectedValue, modifiers).ToString();

                s.DialCmd_File      = dialcmd_FileTextBox.Text;
                s.DialCmd_WorkDir   = dialcmd_WorkDirTextBox.Text;
                s.DialCmd_Args      = dialcmd_ArgsTextBox.Text;
                s.DialCmd_MinLength = int.Parse(dialcmd_MinLengthTextBox.Text);

                s.Save();

                if (startwithwindowsCheckBox.Checked)
                {
                    RegistryHelper.AddToRunKey();
                }
                else
                if (RegistryHelper.IsInRunKey())
                {
                    RegistryHelper.RemoveFromRunKey();
                }

                if (SettingsChanged != null)
                {
                    SettingsChanged(this, new SettingsChangedEventArgs());
                }

                return(true);
            }
            return(false);
        }
Example #3
0
        private void Connect()
        {
            _autoreconnect = false;
            _authfailed    = false;

            var settings = Properties.Settings.Default;

            settings.Host         = this.hostTextBox.Text;
            settings.Port         = int.Parse(this.portTextBox.Text);
            settings.PingInterval = int.Parse(pingIntervalTextBox.Text);
            settings.Username     = this.usernameTextBox.Text;
            settings.Password     = this.passwordTextBox.Text;
            settings.PBXContext   = this.contextTextBox.Text;
            settings.FOP2Url      = this.fop2WebInterfaceTextBox.Text;

            if (_dialhotkey != null)
            {
                _hotkeymanager.Unregister(_dialhotkey);
            }

            if ((si.Key)hotkeyComboBox.SelectedValue != si.Key.None)
            {
                si.ModifierKeys modifiers = si.ModifierKeys.None;
                modifiers |= hotkeyAltCheckBox.Checked ? si.ModifierKeys.Alt : si.ModifierKeys.None;
                modifiers |= hotkeyCtrlCheckBox.Checked ? si.ModifierKeys.Control : si.ModifierKeys.None;
                modifiers |= hotkeyWinCheckBox.Checked ? si.ModifierKeys.Windows : si.ModifierKeys.None;
                modifiers |= hotkeyShiftCheckBox.Checked ? si.ModifierKeys.Shift : si.ModifierKeys.None;

                _dialhotkey = new HotKey((si.Key)hotkeyComboBox.SelectedValue, modifiers);
                _hotkeymanager.Register(_dialhotkey);

                settings.Hotkey          = (int)_dialhotkey.Key;
                settings.HotkeyModifiers = (int)_dialhotkey.Modifiers;
            }
            else
            {
                _dialhotkey = null;
            }

            var ipendpoint   = string.Format("{0}:{1}", settings.Host, settings.Port);
            var pinginterval = TimeSpan.FromSeconds(settings.PingInterval);

            _client.HeartbeatInterval = pinginterval;
            _client.Connect(ipendpoint);

            this.SetTrayStatus(string.Format("Connecting to {0}", ipendpoint));
        }
        /// <summary>
        /// Returns WPF modifiers as <see cref="wpf.ModifierKeys"/> from Forms <see cref="forms.Keys"/>.
        /// </summary>
        /// <param name="mKeys">Forms <see cref="forms.Keys"/> which is about to converted to WPF <see cref="wpf.ModifierKeys"/>.</param>
        public static wpf.ModifierKeys WpfModifiersFromFormsModifiers(forms.Keys mKeys)
        {
            wpf.ModifierKeys wKey = wpf.ModifierKeys.None;
            if (mKeys.HasFlag(forms.Keys.Control))
            {
                wKey = wKey | wpf.ModifierKeys.Control;
            }
            if (mKeys.HasFlag(forms.Keys.Alt))
            {
                wKey = wKey | wpf.ModifierKeys.Alt;
            }
            if (mKeys.HasFlag(forms.Keys.Shift))
            {
                wKey = wKey | wpf.ModifierKeys.Shift;
            }

            return(wKey);
        }
        /// <summary>
        /// Returns Forms modifiers as <see cref="forms.Keys"/> from WPF <see cref="wpf.ModifierKeys"/>.
        /// </summary>
        /// <param name="mKeys">WPF <see cref="wpf.ModifierKeys"/> which is about to converted to Forms <see cref="forms.Keys"/>.</param>

        public static forms.Keys FormsModifiersFromWpfModifiers(wpf.ModifierKeys mKeys)
        {
            forms.Keys fKey = forms.Keys.None;
            if (mKeys.HasFlag(wpf.ModifierKeys.Control))
            {
                fKey = fKey | forms.Keys.Control;
            }
            if (mKeys.HasFlag(wpf.ModifierKeys.Alt))
            {
                fKey = fKey | forms.Keys.Alt;
            }
            if (mKeys.HasFlag(wpf.ModifierKeys.Shift))
            {
                fKey = fKey | forms.Keys.Shift;
            }

            return(fKey);
        }
Example #6
0
        internal void NotifyListItemClicked(ListBoxItem item)
        {
            switch (SelectionMode)
            {
            case SelectionMode.Single:

                if (!item.IsSelected)
                {
                    item.SetCurrentValue(ListBoxItem.IsSelectedProperty, true);
                }
                else if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
                {
                    item.SetCurrentValue(ListBoxItem.IsSelectedProperty, false);
                }

                UpdateAnchorItem(ItemInfoFromContainer(item));
                break;

            case SelectionMode.Multiple:
                MakeToggleSelection(item);
                break;

            case SelectionMode.Extended:
                ModifierKeys kbModifiers = Keyboard.Modifiers;
                if (kbModifiers.HasFlag(ModifierKeys.Control | ModifierKeys.Shift))
                {
                    MakeAnchorSelection(item, false);
                }
                else if (kbModifiers.HasFlag(ModifierKeys.Control))
                {
                    MakeToggleSelection(item);
                }
                else if (kbModifiers.HasFlag(ModifierKeys.Shift))
                {
                    MakeAnchorSelection(item, true);
                }
                else
                {
                    MakeSingleSelection(item);
                }
                break;
            }
        }
        /// <summary>
        /// Removes WPF <see cref="wpf.Key"/> enum value that is related to <see cref="wpf.ModifierKeys"/>
        /// value (e.g. if modifierKeys contains Alt and Control and if key contains LeftAlt or Right Alt then Alt value will be removed from modifierKeys).
        /// </summary>
        /// <param name="modifierKeys">Modifier keys with value to remove.</param>
        /// <param name="key">Key value to remove from modifiers.</param>
        /// <returns>Returns <see cref="wpf.ModifierKeys"/> without specified related value in <see cref="wpf.Key"/>.</returns>
        public static wpf.ModifierKeys RemoveWpfKeyFromModifierKeys(wpf.ModifierKeys modifierKeys, wpf.Key key)
        {
            if (key == wpf.Key.LeftAlt || key == wpf.Key.RightAlt)
            {
                return(modifierKeys & ~wpf.ModifierKeys.Alt);
            }

            if (key == wpf.Key.LeftCtrl || key == wpf.Key.RightCtrl)
            {
                return(modifierKeys & ~wpf.ModifierKeys.Control);
            }

            if (key == wpf.Key.LeftShift || key == wpf.Key.RightShift)
            {
                return(modifierKeys & ~wpf.ModifierKeys.Shift);
            }

            return(modifierKeys);
        }
        /// <summary>
        /// Describes key combination from WPF key enum types.
        /// </summary>
        /// <param name="triggerKey">Trigger key.</param>
        /// <param name="modifiers">Modifiers combined with the trigger key.</param>
        /// <returns>Retruns descripton of key combination.</returns>
        public static string DescribeWpfBinding(wpf.Key triggerKey, wpf.ModifierKeys modifiers)
        {
            string keyName = GetFriendlyName(triggerKey);

            if (modifiers != wpf.ModifierKeys.None)
            {
                string[] sEnums = modifiers.ToString().Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
                string   result = string.Empty;
                foreach (string en in sEnums)
                {
                    result += en + "+";
                }

                result += keyName;

                return(result);
            }

            return(keyName);
        }
Example #9
0
        public static ModifierKeys ToFusion(this WpfModifier modifier)
        {
            var key = ModifierKeys.None;

            if (modifier.HasFlag(WpfModifier.Alt))
            {
                key |= ModifierKeys.Alt;
            }
            if (modifier.HasFlag(WpfModifier.Control))
            {
                key |= ModifierKeys.Control;
            }
            if (modifier.HasFlag(WpfModifier.Shift))
            {
                key |= ModifierKeys.Shift;
            }
            if (modifier.HasFlag(WpfModifier.Windows))
            {
                key |= ModifierKeys.Windows;                                                    //throw new NotImplementedException("Windows modifier key"); // key |= EtoKey.Windows;
            }
            return(key);
        }
        /// <summary>
        /// Returns tuple with trigger key and modifier keys from <see cref="wpf.KeyEventArgs"/>.
        /// </summary>
        /// <param name="e"><see cref="wpf.KeyEventArgs"/> with information about pressed key and modifiers (system keys).</param>
        public static (wpf.Key TriggerKey, wpf.ModifierKeys ModifierKeys) WpfKeysFromWpfKeyEventArgs(wpf.KeyEventArgs e)
        {
            //System key pressed.
            if (e.Key == wpf.Key.System)
            {
                //SystemKey is now the trigger key.
                if (e.SystemKey != wpf.Key.None)
                {
                    //SystemKey pressed with modifiers
                    if (e.KeyboardDevice.Modifiers != wpf.ModifierKeys.None)
                    {
                        wpf.ModifierKeys modifiers = e.KeyboardDevice.Modifiers;
                        wpf.Key          key       = e.SystemKey;
                        modifiers = RemoveWpfKeyFromModifierKeys(modifiers, key);
                        return(key, modifiers);
                    }
                    //SystemKey is only key pressed (e.g. LeftControl, RightAlt, etc.)
                    else
                    {
                        return(e.SystemKey, wpf.ModifierKeys.None);
                    }
                }
            }
            //Trigger key is a modifier.
            else if (e.KeyboardDevice.Modifiers != wpf.ModifierKeys.None && IsModifier(e.Key))
            {
                //Only modifier keys pressed
                if (e.SystemKey == wpf.Key.None)
                {
                    wpf.ModifierKeys modifiers = e.KeyboardDevice.Modifiers;
                    wpf.Key          key       = e.Key;
                    modifiers = RemoveWpfKeyFromModifierKeys(modifiers, key);
                    return(key, modifiers);
                }
            }

            return(e.Key, e.KeyboardDevice.Modifiers);
        }
Example #11
0
        public static Keys Convert(swi.Key key, swi.ModifierKeys modifier)
        {
            Keys ret = Find(key);

            if (modifier.HasFlag(swi.ModifierKeys.Alt))
            {
                ret |= Keys.Alt;
            }
            if (modifier.HasFlag(swi.ModifierKeys.Control))
            {
                ret |= Keys.Control;
            }
            if (modifier.HasFlag(swi.ModifierKeys.Shift))
            {
                ret |= Keys.Shift;
            }
            if (modifier.HasFlag(swi.ModifierKeys.Windows))
            {
                ret |= Keys.Application;
            }

            return(ret);
        }
Example #12
0
        public static Keys ToEto(this swi.ModifierKeys modifier)
        {
            Keys ret = Keys.None;

            if (modifier.HasFlag(swi.ModifierKeys.Alt))
            {
                ret |= Keys.Alt;
            }
            if (modifier.HasFlag(swi.ModifierKeys.Control))
            {
                ret |= Keys.Control;
            }
            if (modifier.HasFlag(swi.ModifierKeys.Shift))
            {
                ret |= Keys.Shift;
            }
            if (modifier.HasFlag(swi.ModifierKeys.Windows))
            {
                ret |= Keys.Application;
            }

            return(ret);
        }
Example #13
0
        internal static Gdk.EventKey ConvertKeyEvent(System.Windows.Input.ModifierKeys mod, System.Windows.Input.Key key, Gdk.Window rootWindow)
        {
            var state = Gdk.ModifierType.None;

            if ((mod & System.Windows.Input.ModifierKeys.Control) != 0)
            {
                state |= Gdk.ModifierType.ControlMask;
            }
            if ((mod & System.Windows.Input.ModifierKeys.Shift) != 0)
            {
                state |= Gdk.ModifierType.ShiftMask;
            }
            if ((mod & System.Windows.Input.ModifierKeys.Windows) != 0)
            {
                state |= Gdk.ModifierType.MetaMask;
            }
            if ((mod & System.Windows.Input.ModifierKeys.Alt) != 0)
            {
                state |= Gdk.ModifierType.Mod1Mask;
            }

            return(CreateKeyEventFromKeyCode((ushort)KeyInterop.VirtualKeyFromKey(key), state, Gdk.EventType.KeyPress, rootWindow));
        }
Example #14
0
        public static swi.ModifierKeys ConvertModifier(Key key)
        {
            key &= Key.ModifierMask;
            swi.ModifierKeys val = swi.ModifierKeys.None;

            if (key.HasFlag(Key.Alt))
            {
                val |= swi.ModifierKeys.Alt;
            }
            if (key.HasFlag(Key.Control))
            {
                val |= swi.ModifierKeys.Control;
            }
            if (key.HasFlag(Key.Shift))
            {
                val |= swi.ModifierKeys.Shift;
            }
            if (key.HasFlag(Key.Application))
            {
                val |= swi.ModifierKeys.Windows;
            }
            return(val);
        }
        /// <summary>
        ///     Converts from a System.Windows.Forms.Keys to a System.Windows.Input.ModifierKeys
        /// </summary>
        /// <param name="keyData"></param>
        /// <returns></returns>
        internal static SWI.ModifierKeys ToSystemWindowsInputModifierKeys(SWF.Keys keyData)
        {
            SWI.ModifierKeys modifiers = new System.Windows.Input.ModifierKeys();

            if ((keyData & SWF.Keys.Alt) == SWF.Keys.Alt)
            {
                modifiers |= SWI.ModifierKeys.Alt;
            }
            if ((keyData & SWF.Keys.Control) == SWF.Keys.Control)
            {
                modifiers |= SWI.ModifierKeys.Control;
            }
            if ((keyData & SWF.Keys.Shift) == SWF.Keys.Shift)
            {
                modifiers |= SWI.ModifierKeys.Shift;
            }
            if (((keyData & SWF.Keys.LWin) == SWF.Keys.LWin) ||
                ((keyData & SWF.Keys.RWin) == SWF.Keys.RWin))
            {
                modifiers |= SWI.ModifierKeys.Windows;
            }

            return(modifiers);
        }
 public PasswordBoxCommandArgs(System.Windows.Input.Key key, System.Windows.Input.ModifierKeys modifiers, Object commandParameter)
 {
     this.Key              = key;
     this.Modifiers        = modifiers;
     this.CommandParameter = commandParameter;
 }
Example #17
0
 public static Keys ToEtoWithModifier(this swi.Key key, swi.ModifierKeys modifier)
 {
     return(key.ToEto() | modifier.ToEto());
 }
Example #18
0
 /// <summary>
 /// 从WPF系统修饰键转换为修饰键;
 /// </summary>
 /// <param name="e"></param>
 /// <returns></returns>
 public static ModifierKeys ConvertToModifierKeys(SystemInput.ModifierKeys e)
 {
     return((ModifierKeys)((int)e));
 }
Example #19
0
 /// <summary>
 /// Started
 /// </summary>
 protected override void OnStarted(System.Windows.Input.ModifierKeys modifierKeys)
 {
     base.OnStarted(modifierKeys);
 }