Exemple #1
0
		public Actions(string type, System.Windows.Forms.Keys keys, System.Windows.Forms.Keys modifier, float timer)
		{
			// TODO: Complete member initialization
			this.type = type;
			this.keys = keys;
			this.timer = timer;
			this.keyModifier = modifier;
		}
Exemple #2
0
 public PluginGUIItem(string text, string hint, Image image, Color imageTransparentColor, PluginGUIItemExecuteDelegate executeDelegate, System.Windows.Forms.Keys shortcutKeys, string shortcutKeyDisplayString)
 {
     this.text = text;
     this.hint = hint;
     this.image = image;
     this.imageTransparentColor = imageTransparentColor;
     this.executeDelegate = executeDelegate;
     this.shortcutKeys = shortcutKeys;
     this.shortcutKeyDisplayString = shortcutKeyDisplayString;
 }
Exemple #3
0
        /// <summary>
        /// Creates string name for the key code and key modifiers
        /// </summary>        
        private string GetKeyName(Keys keys, KeyboardState keyboardState)
        {
            var control = String.Empty;
            var shift = String.Empty;
            if ((keyboardState & KeyboardState.Control) == KeyboardState.Control)
                control = "^";
            if ((keyboardState & KeyboardState.Shift) == KeyboardState.Shift)
                shift = "!";

            return control + shift + keys.ToString();
        }
        private static void ProcessKeyEvent(FormsKeys keyCode, Action<Keys> keyAction)
        {
            Keys translatedKey;
            if (!_keysDictionaryForms.TryGetValue(keyCode, out translatedKey))
                translatedKey = Keys.None;

            keyAction(translatedKey);

            // XNA doesn't have handless modifier keys, so we will map general keys to left ones:
            // TODO: consider P/Invoke to get pressed keys and/or determine which key was pressed
            switch (translatedKey)
            {
                case Keys.Shift:
                    keyAction(Keys.LeftShift);
                    break;
                case Keys.Control:
                    keyAction(Keys.LeftControl);
                    break;
                case Keys.Alt:
                    keyAction(Keys.LeftAlt);
                    break;
            }
        }
 public bool IsKeyDown(Keys key)
 {
     return _DownKeys.Contains(key);
 }
Exemple #6
0
        protected internal override void OnOSKeyPress( OSKey _key )
        {
            if( _key == OSKey.Tab ) return;

            base.OnOSKeyPress( _key );
        }
 /// <summary>
 /// Should the camera move up or down?</summary>
 /// <param name="controlScheme">The control scheme instance to extend</param>
 /// <param name="modifierKeys">The camera control's ModifierKeys property</param>
 /// <param name="e">The camera control's event handler's WfMouseEventArgs</param>
 /// <returns>True if the user wants to move the camera up or down</returns>
 /// <remarks>This is used by the fly and walk camera controllers.</remarks>
 public static bool IsElevating(this ControlScheme controlScheme, WfKeys modifierKeys, WfMouseEventArgs e)
 {
     return controlScheme.IsElevating(KeysInterop.ToAtf(modifierKeys), MouseEventArgsInterop.ToAtf(e));
 }
Exemple #8
0
        //How to use:
        //private void Form1_KeyDown(object sender, KeyEventArgs e)
        //{
        //    //Array has to be long enough for the keys to be checked for
        //    byte[] keys = new byte[256];

        //    GetKeyboardState(keys);

        //    if ((keys[(int)Keys.Up] & keys[(int)Keys.Right] & 128) == 128)
        //    {
        //        Console.WriteLine("Up Arrow key and Right Arrow key down.");
        //    }
        //}
        public static bool GetKeyState(System.Windows.Forms.Keys aKeyToCheck)
        {
            //return GetKeyState((int)aKeyToCheck) & 0x8000;
            return(GetKeyState((int)aKeyToCheck) < 0);
        }
Exemple #9
0
 /// <summary>
 /// Method to convert WinForms key to WPF key.
 /// </summary>
 /// <param name="keys">WinForms key.</param>
 /// <returns>WPF key.</returns>
 public static Key FormsKeysToWpfKey(System.Windows.Forms.Keys keys)
 {
     return(FormsKeysToWpfKey((int)keys));
 }
 public KeyEnumWrapper(System.Windows.Forms.Keys key)
 {
     this.key = key;
 }
Exemple #11
0
        protected internal override void OnOSKeyPress( OSKey _key )
        {
            bool bCtrl = Screen.Game.InputMgr.KeyboardState.IsKeyDown( Keys.LeftControl, true ) || Screen.Game.InputMgr.KeyboardState.IsKeyDown( Keys.RightControl, true );
            bool bShortcutKey = Screen.Game.InputMgr.IsShortcutKeyDown();
            bool bShift = Screen.Game.InputMgr.KeyboardState.IsKeyDown( Keys.LeftShift, true ) || Screen.Game.InputMgr.KeyboardState.IsKeyDown( Keys.RightShift, true );

            switch( _key )
            {
                case OSKey.A:
                    if( bShortcutKey )
                    {
                        SelectAll();
                    }
                    break;
                case OSKey.X:
                    if( bShortcutKey )
                    {
                        CopySelectionToClipboard();
                        DeleteSelectedText();
                    }
                    break;
                case OSKey.C:
                    if( bShortcutKey )
                    {
                        CopySelectionToClipboard();
                    }
                    break;
                case OSKey.V:
                    if( bShortcutKey )
                    {
                        PasteFromClipboard();
                    }
                    break;
#if !MONOMAC
                case OSKey.Enter:
#else
                case OSKey.Return:
#endif
                    if( ! IsReadOnly )
                    {
                        TextBlock textBlock = TextBlocks[ Caret.StartTextBlockIndex ];

                        if( bShift )
                        {
                            if( TextInsertedHandler == null || TextInsertedHandler( this, Caret.StartTextBlockIndex, Caret.StartOffset, "\n" ) )
                            {
                                textBlock.Text = textBlock.Text.Insert( Caret.StartOffset, "\n" );
                                Caret.SetSelection( Caret.StartOffset + 1 );
                                mbScrollToCaret = true;
                            }
                        }
                        else
                        {
                            if( textBlock.Text.Length == 0 && textBlock.BlockType != TextBlockType.Paragraph )
                            {
                                if( BlockTypeChangedHandler == null || BlockTypeChangedHandler( this, Caret.StartTextBlockIndex, TextBlockType.Paragraph ) )
                                {
                                    if( BlockIndentLevelChangedHandler == null || BlockIndentLevelChangedHandler( this, Caret.StartTextBlockIndex, 0 ) )
                                    {
                                        textBlock.BlockType = TextBlockType.Paragraph;
                                        textBlock.IndentLevel = 0;
                                        Caret.SetSelection( Caret.StartOffset, _iStartTextBlockIndex: Caret.StartTextBlockIndex ); // Trigger block change handler
                                        mbScrollToCaret = true;
                                    }
                                }
                                break;
                            }
                        
                            TextBlockType newBlockType  = TextBlockType.Paragraph;
                            int iNewBlockIndentLevel    = 0;

                            if( textBlock.Text.Length != 0 )
                            {
                                switch( textBlock.BlockType )
                                {
                                    case TextBlockType.Paragraph:
                                    case TextBlockType.OrderedListItem:
                                    case TextBlockType.UnorderedListItem:
                                        newBlockType = textBlock.BlockType;
                                        iNewBlockIndentLevel = textBlock.IndentLevel;
                                        break;
                                }
                            }

                            if( BlockStartInsertedHandler == null || BlockStartInsertedHandler( this, Caret.StartTextBlockIndex, Caret.StartOffset, newBlockType, iNewBlockIndentLevel ) )
                            {
                                if( Caret.StartOffset == 0 && textBlock.Text.Length > 0 )
                                {
                                    TextBlocks.Insert( Caret.StartTextBlockIndex, new TextBlock( this, "", newBlockType, iNewBlockIndentLevel ) );

                                    Caret.Timer = 0f;
                                }
                                else
                                {
                                    string strNewBlockText = "";
                                    if( Caret.StartOffset < textBlock.Text.Length )
                                    {
                                        strNewBlockText = textBlock.Text.Substring( Caret.StartOffset, textBlock.Text.Length - Caret.StartOffset );
                                        textBlock.Text = textBlock.Text.Remove( Caret.StartOffset );
                                    }

                                    TextBlocks.Insert( Caret.StartTextBlockIndex + 1, new TextBlock( this, strNewBlockText, newBlockType, iNewBlockIndentLevel ) );
                                    Caret.SetSelection( 0 );
                                }

                                Caret.SetSelection( Caret.StartOffset, _iStartTextBlockIndex: Caret.StartTextBlockIndex + 1 );
                                mbScrollToCaret = true;
                            }
                        }
                    }
                    break;
#if !MONOMAC
                case OSKey.Back:
#else
                case OSKey.ForwardDelete:
#endif
                    if( ! IsReadOnly )
                    {
                        if( Caret.HasSelection )
                        {
                            DeleteSelectedText();
                        }
                        else
                        if( Caret.StartOffset > 0 )
                        {
                            if( TextRemovedHandler == null || TextRemovedHandler( this, Caret.StartTextBlockIndex, Caret.StartOffset - 1, Caret.StartTextBlockIndex, Caret.StartOffset ) )
                            {
                                Caret.SetSelection( Caret.StartOffset - 1 );
                                TextBlocks[ Caret.StartTextBlockIndex ].Text = TextBlocks[ Caret.StartTextBlockIndex ].Text.Remove( Caret.StartOffset, 1 );
                                mbScrollToCaret = true;
                            }
                        }
                        else
                        if( Caret.StartTextBlockIndex > 0 )
                        {
                            int iNewCaretOffset = TextBlocks[ Caret.StartTextBlockIndex - 1 ].Text.Length;

                            if( BlockStartRemovedHandler == null || BlockStartRemovedHandler( this, Caret.StartTextBlockIndex ) )
                            {
                                if( iNewCaretOffset > 0 )
                                {
                                    Caret.SetSelection( Caret.StartOffset, _iStartTextBlockIndex: Caret.StartTextBlockIndex - 1 );
                                    TextBlocks[ Caret.StartTextBlockIndex ].Text += TextBlocks[ Caret.StartTextBlockIndex + 1 ].Text;
                                    TextBlocks.RemoveAt( Caret.StartTextBlockIndex + 1 );
                                }
                                else
                                {
                                    TextBlocks.RemoveAt( Caret.StartTextBlockIndex - 1 );
                                    Caret.SetSelection( Caret.StartOffset, _iStartTextBlockIndex: Caret.StartTextBlockIndex - 1 );
                                }

                                Caret.SetSelection( iNewCaretOffset );
                                mbScrollToCaret = true;
                            }
                        }
                    }
                    break;
                case OSKey.Delete:
                    if( ! IsReadOnly )
                    {
                        if( Caret.HasSelection )
                        {
                            DeleteSelectedText();
                        }
                        else
                        if( Caret.StartOffset < TextBlocks[ Caret.StartTextBlockIndex ].Text.Length )
                        {
                            if( TextRemovedHandler == null || TextRemovedHandler( this, Caret.StartTextBlockIndex, Caret.StartOffset, Caret.StartTextBlockIndex, Caret.StartOffset + 1 ) )
                            {
                                TextBlocks[ Caret.StartTextBlockIndex ].Text = TextBlocks[ Caret.StartTextBlockIndex ].Text.Remove( Caret.StartOffset, 1 );
                                mbScrollToCaret = true;
                            }
                        }
                        else
                        if( Caret.StartTextBlockIndex < TextBlocks.Count - 1 )
                        {
                            if( BlockStartRemovedHandler == null || BlockStartRemovedHandler( this, Caret.StartTextBlockIndex + 1 ) )
                            {
                                TextBlocks[ Caret.StartTextBlockIndex ].Text += TextBlocks[ Caret.StartTextBlockIndex + 1 ].Text;
                                TextBlocks.RemoveAt( Caret.StartTextBlockIndex + 1 );

                                Caret.Timer = 0f;
                                mbScrollToCaret = true;
                            }
                        }
                    }
                    break;
                case OSKey.Tab:
                    if( ! IsReadOnly )
                    {
                        int iNewIndentLevel = bShift ? Math.Max( 0, (int)TextBlocks[ Caret.EndTextBlockIndex ].IndentLevel - 1 ) : Math.Min( 4, (int)TextBlocks[ Caret.EndTextBlockIndex ].IndentLevel + 1 );
                        if( BlockIndentLevelChangedHandler == null || BlockIndentLevelChangedHandler( this, Caret.EndTextBlockIndex, iNewIndentLevel ) )
                        {
                            TextBlocks[ Caret.EndTextBlockIndex ].IndentLevel = iNewIndentLevel;
                            Caret.Timer = 0f;
                            mbScrollToCaret = true;
                        }
                    }
                    break;
#if !MONOMAC
                case OSKey.Left: {
#else
                case OSKey.LeftArrow: {
#endif
                    int iNewTextBlockIndex  = bShift || bCtrl ? Caret.EndTextBlockIndex : Caret.StartTextBlockIndex;
                    int iNewOffset          = ( bShift || bCtrl ? Caret.EndOffset : Caret.StartOffset ) - 1;

                    if( bCtrl )
                    {
                        if( iNewOffset > 0 )
                        {
                            iNewOffset = TextBlocks[ iNewTextBlockIndex ].Text.LastIndexOf( ' ', iNewOffset - 1, iNewOffset - 1 ) + 1;
                        }
                    }
                    else
                    if( ! bShift && Caret.HasSelection )
                    {
                        if( Caret.HasBackwardSelection )
                        {
                            iNewOffset = Caret.EndOffset;
                            iNewTextBlockIndex = Caret.EndTextBlockIndex;
                        }
                        else
                        {
                            iNewOffset++;
                        }
                    }

                    if( iNewOffset < 0 && iNewTextBlockIndex > 0 )
                    {
                        iNewTextBlockIndex--;
                        iNewOffset = TextBlocks[ iNewTextBlockIndex ].Text.Length;
                    }

                    if( bShift )
                    {
                        Caret.SetSelection( Caret.StartOffset, iNewOffset, _iEndTextBlockIndex: iNewTextBlockIndex );
                    }
                    else
                    {
                        Caret.SetSelection( iNewOffset, _iStartTextBlockIndex: iNewTextBlockIndex );
                    }

                    mbScrollToCaret = true;
                    break;
                }
#if !MONOMAC
                case OSKey.Right: {
#else
                case OSKey.RightArrow: {
#endif
                    int iNewTextBlockIndex  = bShift || bCtrl ? Caret.EndTextBlockIndex : Caret.StartTextBlockIndex;
                    int iNewOffset          = ( bShift || bCtrl ? Caret.EndOffset : Caret.StartOffset ) + 1;

                    if( bCtrl )
                    {
                        string strText = TextBlocks[ iNewTextBlockIndex ].Text;

                        if( iNewOffset < strText.Length )
                        {
                            iNewOffset = strText.IndexOf( ' ', iNewOffset, strText.Length - iNewOffset ) + 1;

                            if( iNewOffset == 0 )
                            {
                                iNewOffset = strText.Length;
                            }
                        }
                    }
                    else
                    if( ! bShift && Caret.HasSelection )
                    {
                        if( Caret.HasForwardSelection )
                        {
                            iNewOffset = Caret.EndOffset;
                            iNewTextBlockIndex = Caret.EndTextBlockIndex;
                        }
                        else
                        {
                            iNewOffset--;
                        }
                    }

                    if( iNewOffset > TextBlocks[ iNewTextBlockIndex ].Text.Length && iNewTextBlockIndex < TextBlocks.Count - 1 )
                    {
                        iNewTextBlockIndex++;
                        iNewOffset = 0;
                    }

                    if( bShift )
                    {
                        Caret.SetSelection( Caret.StartOffset, iNewOffset, _iEndTextBlockIndex: iNewTextBlockIndex );
                    }
                    else
                    {
                        Caret.SetSelection( iNewOffset, _iStartTextBlockIndex: iNewTextBlockIndex );
                    }

                    mbScrollToCaret = true;
                    break;
                }
                case OSKey.End:
                    Caret.MoveEnd( bShift );
                    mbScrollToCaret = true;
                    break;
                case OSKey.Home:
                    Caret.MoveStart( bShift );
                    mbScrollToCaret = true;
                    break;
#if !MONOMAC
                case OSKey.Up:
#else
                case OSKey.UpArrow:
#endif
                    Caret.MoveUp( bShift );
                    mbScrollToCaret = true;
                    break;
#if !MONOMAC
                case OSKey.Down:
#else
                case OSKey.DownArrow:
#endif
                    Caret.MoveDown( bShift );
                    mbScrollToCaret = true;
                    break;
                case OSKey.PageUp: {
                    Point target = GetPositionForCaret( Caret.EndTextBlockIndex, Caret.EndOffset );
                    target.Y -= LayoutRect.Height;
                    SetCaretPosition( target, bShift );
                    mbScrollToCaret = true;
                    break;
                }
                case OSKey.PageDown: {
                    Point target = GetPositionForCaret( Caret.EndTextBlockIndex, Caret.EndOffset );
                    target.Y += LayoutRect.Height;
                    SetCaretPosition( target, bShift );
                    mbScrollToCaret = true;
                    break;
                }
                default:
                    base.OnOSKeyPress( _key );
                    break;
            }
        }
        protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
        {
            // If we were just sitting next to a bolded parenthesis, we'll
            //   carry the bold with us because the "SelectionChanged" event
            //   does not appear to fire as we type.
            if (this.SelectionLength == 0 && this.SelectionFont != this.Font)
                this.SelectionFont = this.Font;

            if (e.KeyCode == System.Windows.Forms.Keys.C && e.Modifiers == (System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift))
            {
                #region CTRL-SHIFT-C
                this._parsing = true;
                try
                {
                    this.CommentSelected();
                    this.Parse();
                }
                finally
                {
                    this._parsing = false;
                    e.Handled = true;
                }
                #endregion
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.U && e.Modifiers == (System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift))
            {
                #region CTRL-SHIFT-U
                this._parsing = true;
                try
                {
                    this.UncommentSelected();
                    this.Parse();
                }
                finally
                {
                    this._parsing = false;
                    e.Handled = true;
                }
                #endregion
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Tab)
            {
                #region TAB Key
                this.EndAutoComplete();

                if (e.Modifiers == System.Windows.Forms.Keys.Shift)
                {
                    if (this.SelectionLength > 0)
                    {
                        // Unindent all selected lines.
                        this._parsing = true;
                        try
                        {
                            this.UnindentSelected();
                            this.Parse();
                        }
                        //catch (Exception ex)
                        //{ }
                        finally
                        {
                            this._parsing = false;
                            e.Handled = true;
                        }
                    }
                    else
                    {
                        // Remove a single TAB char.
                        int iLnSt = this.GetFirstCharIndexOfCurrentLine();
                        this._parsing = true;
                        this.SuspendRefresh();
                        this.SuspendScroll();
                        try
                        {
                            if (this.SelectionStart > iLnSt && this.Text.Substring(this.SelectionStart - 1, 1) == "\t")
                            {
                                //int selStart = this.SelectionStart;
                                //string text = string.Empty;
                                //if (this.SelectionStart - 1 > 0)
                                //    text = this.Text.Substring(0, this.SelectionStart - 1);
                                //text += this.Text.Substring(this.SelectionStart);
                                //this.Parse(text);
                                //this.SelectionStart = selStart - 1;

                                // If we simulate a keypress rather then actually
                                //   alter the control's "Text" property, then we
                                //   don't have to parse the entire block of text
                                //   for color.
                                System.Windows.Forms.Message msg = new System.Windows.Forms.Message();
                                msg.HWnd = new IntPtr(5572486);
                                msg.Msg = (int)Win32Messages.WM_CHAR;
                                msg.LParam = new IntPtr(917505);
                                // We're passing a "Backspace" key instead of the tab.
                                msg.WParam = new IntPtr(8);
                                this.WndProc(ref msg);
                            }
                        }
                        finally
                        {
                            this.ResumeRefresh();
                            this.ResumeScroll();
                            this._parsing = false;
                            e.Handled = true;
                        }
                    }
                }
                else if (this.SelectionLength > 0)
                {
                    // Indent all selected lines.
                    this._parsing = true;
                    try
                    {
                        this.IndexSelected();
                        this.DoParse(this.SelectionStart, this.SelectionLength);
                    }
                    //catch (Exception ex)
                    //{ }
                    finally
                    {
                        this._parsing = false;
                        e.Handled = true;
                    }
                }
                // If we fall out completely, it's just a standard TAB key-press, so
                //   we don't need to do anything.
                #endregion
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Enter || e.KeyCode == System.Windows.Forms.Keys.Space)
            {
                #region ENTER / SPACE Key
                int iLn = this.GetLineFromCharIndex(this.SelectionStart);
                bool inAutoComplete = this._autoCompMenu != null && this._autoCompMenu.SelectedIndex > -1;
                try
                {
                    // First thing we want to do is check to see if we were in the
                    //   middle of an "Auto Complete" operation.
                    if (inAutoComplete)
                    {
                        // If the AutoComplete list is open and has an item selected,
                        //   we need to insert the selected text instead of
                        //   inserting the carriage return.
                        this.SuspendRefresh();
                        this.SuspendScroll();
                        this._parsing = true;
                        int selStart = this.SelectionStart,
                            selLength = this.SelectionLength,
                            dotIdx = this.Text.Substring(0, this.SelectionStart + this.SelectionLength).LastIndexOf('.');

                        if (this._autoCompMenu.Tag.ToString() == "Table")
                        {
                            string[] tblNm = this._autoCompMenu.Items[this._autoCompMenu.SelectedIndex].ToString().Split('.');
                            int qualSt = this.Text.Substring(0, dotIdx).LastIndexOf(' ') + 1;
                            this.Select(qualSt, selStart + selLength - qualSt);
                            if (tblNm[1].EndsWith("()"))
                            {
                                // Function
                                string newText = string.Format("[{0}].{1}", tblNm[0], tblNm[1]);
                                this.SelectedText = newText;
                                this.Select(qualSt + newText.Length - 1, 0);
                            }
                            else if (tblNm[1].EndsWith(" SP"))
                                // Stored Proceedure
                                this.SelectedText = string.Format("EXEC [{0}].{1} ", tblNm[0], tblNm[1]);
                            else
                                // Table or View
                                this.SelectedText = string.Format("[{0}].[{1}]", tblNm[0], tblNm[1]);
                        }
                        else
                        {
                            this.Select(dotIdx, selStart + selLength - dotIdx);
                            this.SelectedText = string.Format(".[{0}]", this._autoCompMenu.Items[this._autoCompMenu.SelectedIndex].ToString());
                        }

                        // We only want to suppress the key press if they pushed "ENTER", not "SPACE".
                        if (e.KeyCode == System.Windows.Forms.Keys.Enter)
                        {
                            e.Handled = true;
                            e.SuppressKeyPress = true;
                        }
                    }

                    // We *always* want to terminate the autocomplete menu at this 
                    //   point, if it's active.  Either we just did an autocomplete
                    //   or the user made a keypress which bypassed the auto-
                    //   complete.  Either way, we're done with it.
                    this.EndAutoComplete();

                    //// If we weren't just doing an auto-complete, pressing space bar
                    ////   should start one, since we're not waiting for a '.' key
                    ////   press anymore.
                    //if (!inAutoComplete)
                    //    this.ShowAutoComplete(this._autoCompleteTables.ToArray(), AutoCompleteType.Table);

                    #region New Line - Tab-In moved to "KeyUp" event handler
                        //if (!e.SuppressKeyPress)
                        //{
                        //    // When the user hits the return key, we want to keep the
                        //    //   cursor "tabbed" in to match the previous line.
                        //    if (this.Lines.Length > 1)
                        //    {
                        //        string lnTxt = this.Lines[iLn];
                        //        if (lnTxt.StartsWith("\t") || lnTxt.StartsWith(" "))
                        //        {
                        //            // If the current line (we haven't actually processed the
                        //            //   carriage-return yet) has any whitespace, we want to make
                        //            //   the next line have the same leading whitespace.
                        //            string newTxt = ("\n" + lnTxt.Substring(0, lnTxt.Length - lnTxt.TrimStart('\t', ' ').Length));
                        //            this.InsertText(newTxt, this.SelectionStart, false);
                        //            this.Select(this.SelectionStart + newTxt.Length, 0);
                        //            // Tell the base event that we processed this key manually and
                        //            //   not to paste the 'newline' character
                        //            e.Handled = true;
                        //        }
                        //    }
                        //}
                        #endregion
                }
                finally
                {
                    this._parsing = false;
                    this.ResumeScroll();
                    this.ResumeRefresh();
                }

                // When the user hits the enter key, we want to parse the line
                //   we just left.  Keep in mind that this method is called
                //   before the NewLine character actually moves the cursor
                //   to the next line.
                // We only need to do this parsing if the cursor was not at the
                //   beginning of the line we were on.
                // LOGIC: If the cursor was at the beginning of the line, then either
                //   no text was entered on that line, or we just moved any text
                //   on the line down to the next line.
                if (e.KeyCode == System.Windows.Forms.Keys.Enter && !e.SuppressKeyPress)
                {
                    int iSt = this.GetFirstCharIndexFromLine(iLn);
                    if (this.SelectionStart != this.GetFirstCharIndexFromLine(iLn))
                    {
                        //int iCnt = this.SelectionStart - iSt;
                        //this.DoParse(iSt, iCnt);
                        this.ParseCurrentLine();
                    }
                }
                #endregion
            }
            else if (e.KeyValue == 191)
            {
                #region SLASH Key
                // If the user closes a comment block /*  */ we need to make sure we
                //   haven't made anything after the closing block green already.
                if (this.SelectionStart > 0 && this.SelectionStart < this.Text.Length - 1 && this.Text.Substring(this.SelectionStart - 1, 1) == "*")
                {
                    int endBlock = this.Text.IndexOf("/*", this.SelectionStart + 1) - 1;
                    this.DoParse(this.SelectionStart + 1, ((endBlock > 0)
                                                            ? endBlock
                                                            : this.Text.Length)
                                            - (this.SelectionStart + 1), false);
                }
                #endregion
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Delete)
            {
                #region DELETE Key
                //string cmpStr = this.Text.Substring(this.SelectionStart, 2);
                //if (this.SelectionStart < (this.Text.Length - 2) && (cmpStr == "/*" || cmpStr == "*/"))
                //{
                //    int endBlock = this.Text.IndexOf("/*", this.SelectionStart + 2);
                //    this.DoParse(this.SelectionStart + 1, ((endBlock > 0) ? endBlock : this.Text.Length) - (this.SelectionStart + 1), false);
                //}

                // In case we just deleted a parenthesis, we need to "unbold"
                //   any characters we might have stored a reference to.
                int iSelStart = this.SelectionStart,
                    iSelLength = this.SelectionLength;
                this._parsing = true;
                try
                {
                    for (int i = 0; i < this._bldChars.Count; i++)
                    {
                        this.Select(this._bldChars[i], 1);
                        this.SelectionFont = this.Font;
                    }
                    this._bldChars.Clear();
                }
                catch { }
                finally
                {
                    if (this._selDir == AdvRichTextBox.SelectDirection.Backword)
                        this.Select(iSelStart + iSelLength, -iSelLength);
                    else
                        this.Select(iSelStart, iSelLength);
                    this._parsing = false;
                }
                #endregion
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Back)
            {
                #region BACKSPACE Key
                //if (this.SelectionStart > 2)
                //{
                //    string cmpStr = this.Text.Substring(this.SelectionStart - 2, 2);
                //    if (this.SelectionStart < (this.Text.Length - 2) && (cmpStr == "/*" || cmpStr == "*/"))
                //    {
                //        int endBlock = this.Text.IndexOf("/*", this.SelectionStart);
                //        this.DoParse(this.SelectionStart, ((endBlock > 0) ? endBlock : this.Text.Length) - (this.SelectionStart), false);
                //    }
                //}
                #endregion
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Up)
            {
                #region UP Key
                if (this._autoCompMenu != null && !this._autoCompMenu.IsDisposed)
                {
                    e.Handled = true;
                    if (this._autoCompMenu.SelectedIndex > 0)
                        this._autoCompMenu.SelectedIndex--;
                }
                #endregion
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Down)
            {
                #region DOWN Key
                if (this._autoCompMenu != null && !this._autoCompMenu.IsDisposed)
                {
                    e.Handled = true;
                    if (this._autoCompMenu.SelectedIndex < this._autoCompMenu.Items.Count - 1)
                        this._autoCompMenu.SelectedIndex++;
                }
                #endregion
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Left)
            {
                #region LEFT Key
                if (this.SelectionStart <= this._autoCompStart || this.CurrentLine != this._autoCompLine)
                    this.EndAutoComplete();
                #endregion
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Right)
            {
                #region RIGHT Key
                if (this.CurrentLine != this._autoCompLine)
                    this.EndAutoComplete();
                #endregion
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Home)
            {
                #region HOME Key
                this.EndAutoComplete();

                // Move all this code to the AdvRichTextBox control class.

                //// If the user was holding the CTRL key when they pressed home, then
                ////   we just move to the very beginning of the document.
                //if (e.Control)
                //{
                //    if (e.Shift)
                //        //this.Select(0, this.SelectionStart + this.SelectionLength);
                //        this.Select(this.SelectionStart, 0 - this.SelectionStart);
                //    else
                //        this.Select(0, 0);
                //    e.Handled = true;
                //}
                //else
                //{
                //    // If the user presses the "HOME" key, then we want to move the
                //    //   cursor inteligently to either the beginning of the line,
                //    //   or the beginning of the actual text.
                //    int curLn = this.GetLineFromCharIndex(this.SelectionStart),
                //        curPos = this.SelectionStart,
                //        lnStart = this.GetFirstCharIndexFromLine(curLn);

                //    // If the current line doesn't begin with any whitespace, then we
                //    //   have nothing to do here.
                //    string lnTxt = this.Lines[curLn];
                //    if (lnTxt.StartsWith("\t") || lnTxt.StartsWith(" "))
                //    {
                //        int wsCharCnt = (lnTxt.Length - lnTxt.TrimStart('\t', ' ').Length),
                //            selLen = lnStart - (curPos + SelectionLength);
                //        if (this.SelectionStart == (lnStart + wsCharCnt))
                //        {
                //            // If we're at the beginning of the text, then move to the
                //            //   first of the line.
                //            if (e.Shift)
                //                //this.Select(lnStart, (curPos + this.SelectionLength) - lnStart);
                //                this.Select(curPos + this.SelectionLength, selLen);
                //            else
                //                this.Select(lnStart, 0);
                //        }
                //        else
                //        {
                //            // If the cursor is already at the beginning of the line,
                //            //   or anywhere else in the line, then move to the end
                //            //   of the whitespace.
                //            if (e.Shift)
                //                //this.Select(lnStart + wsCharCnt, (curPos - (lnStart + wsCharCnt)) + this.SelectionLength);
                //                this.Select(curPos + this.SelectionLength, selLen + wsCharCnt);
                //            else
                //                this.Select(lnStart + wsCharCnt, 0);
                //        }
                //        e.Handled = true;
                //    }
                //}
                #endregion
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.End)
            {
                #region END Key
                this.EndAutoComplete();

                // Moved this code to the "AdvRichTextBox" control class.

                //if (e.Control)
                //{
                //    // If the users isn't holding the CTRL key, then it's just a
                //    //   standard End-of-Line keypress & we'll let the baes class
                //    //   deal with it.
                //    if (e.Shift)
                //    {
                //        // User wants to select everything from here to the end of the document.
                //        this.Select(this.SelectionStart, this.Text.Length - this.SelectionStart);
                //    }
                //    else
                //    {
                //        // Just move the cursor to the very end of the document.
                //        this.Select(this.Text.Length, 0);
                //    }
                //    e.Handled = true;
                //}
                #endregion
            }
            else if (e.KeyValue == 56)
            {
                #region ASTRISK Key
                // The ASTRISK (*) will always close the AutoComplete menu,
                //   since this effectively means "All Fields".
                this.EndAutoComplete();
                #endregion
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.F9)
            {
                this.Parse();
            }
            else if (e.KeyData != System.Windows.Forms.Keys.Shift && this.IsInputKey(e.KeyData) && !e.Control && !e.Alt)
            {
                #region Any Other Input Character
                if (this._autoCompMenu != null)
                {
                    if ((e.KeyValue >= 65 && e.KeyValue <= 90) || e.KeyValue == 189)
                    { }
                    else if (this._autoCompMenu.SelectedIndex > -1)
                    {
                        try
                        {
                            // If the AutoComplete list is open and has an item selected,
                            //   we need to insert the selected text followed by a 
                            //   single space character.
                            this.SuspendRefresh();
                            this._parsing = true;
                            int selStart = this.SelectionStart,
                                selLength = this.SelectionLength,
                                dotIdx = this.Text.Substring(0, this.SelectionStart + this.SelectionLength).LastIndexOf('.');

                            //System.Windows.Forms.KeysConverter kc = new System.Windows.Forms.KeysConverter();
                            this.Select(dotIdx, selStart + selLength - dotIdx);
                            this.SelectedText = string.Format(".[{0}]", this._autoCompMenu.Items[this._autoCompMenu.SelectedIndex].ToString());
                            this.EndAutoComplete();
                        }
                        finally
                        {
                            this._parsing = false;
                            this.ResumeRefresh();
                        }
                    }
                }
                #endregion
            }

            if (e.Handled)
                e.SuppressKeyPress = true;
            this._lastKeyPress = e.KeyData;
            base.OnKeyDown(e);
        }
 public BrowserKeyDownEventArgs(bool bAlt,bool bCtrl,bool bShift,bool OnEditor,
                                int keyCode,char key)
 {
     _alt = bAlt;
     _ctrl = bCtrl;
     _shift = bShift;
     _FocusOnEditableField = OnEditor;
     _keyCode = (System.Windows.Forms.Keys)keyCode;
     _key = key;
 }
        private void LoadConfig()
        {
            string configFile = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Moe_config.ini";

            //读取配置文件
            if (System.IO.File.Exists(configFile))
            {
                try
                {
                    string[] lines = System.IO.File.ReadAllLines(configFile);
                    downloadC.NumOnce = Int32.Parse(lines[0]);
                    if (lines[1] != "." && System.IO.Directory.Exists(lines[1]))
                        DownloadControl.SaveLocation = lines[1];

                    if (lines[2].Contains(';'))
                    {
                        string[] parts = lines[2].Split(';');
                        //itmJpg.IsChecked = parts[0].Equals("1");
                        addressType = (AddressType)Enum.Parse(typeof(AddressType), parts[0]);

                        if (parts[1] == "1")
                        {
                            //GlassHelper.noBlur = false;
                        }

                        if (parts.Length > 2)
                        {
                            numOfLoading = Int32.Parse(parts[2]);
                            if (numOfLoading < 4) numOfLoading = 5;
                        }
                        if (parts.Length > 3)
                        {
                            itmMaskViewed.IsChecked = parts[3].Equals("1");
                        }
                        if (parts.Length > 4)
                        {
                            string[] words = parts[4].Split('|');
                            foreach (string word in words)
                            {
                                //if (word.Trim().Length > 0)
                                //txtSearch.Items.Add(word);
                                searchControl.AddUsedItem(word);
                            }
                        }
                        //if (!txtSearch.Items.Contains("thighhighs"))
                        //txtSearch.Items.Add("thighhighs");
                        if (parts.Length > 5)
                        {
                            Proxy = parts[5];
                        }
                        if (parts.Length > 6)
                        {
                            bossKey = (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), parts[6]);
                        }
                        if (parts.Length > 7)
                        {
                            itmSmallPre.IsChecked = parts[7].Equals("1");
                        }
                        if (parts.Length > 8)
                        {
                            ProxyType = (ProxyType)Enum.Parse(typeof(ProxyType), parts[8]);
                        }
                        if (parts.Length > 9)
                        {
                            try
                            {
                                //Size pos = Size.Parse(parts[9]);
                                var posItem = parts[9].Split(',');
                                Size pos = new Size(int.Parse(posItem[0]), int.Parse(posItem[1]));
                                if (pos.Width > MinWidth && pos.Height > MinHeight)
                                {
                                    //rememberPos = true;
                                    //Left = pos.X;
                                    //Top = pos.Y;
                                    //startPos.Width = pos.Width;
                                    //startPos.Height = pos.Height;
                                    Width = pos.Width;
                                    Height = pos.Height;
                                }
                            }
                            catch { }
                        }
                        if (parts.Length > 10)
                        {
                            togglePram.IsChecked = parts[10].Equals("1");
                            if (togglePram.IsChecked.Value)
                            {
                                //grdParam.Width = 0;
                                //grdParam.Opacity = 0;
                            }
                            else
                            {
                                grdParam.Width = 479;
                                grdParam.Opacity = 1;
                            }
                        }
                        if (parts.Length > 11)
                        {
                            PreFetcher.CachedImgCount = int.Parse(parts[11]);
                        }
                        if (parts.Length > 12)
                        {
                            downloadC.IsSepSave = parts[12].Equals("1");
                        }
                        if (parts.Length > 13)
                        {
                            itmxExplicit.IsChecked = parts[13].Equals("1");
                            showExplicit = !itmxExplicit.IsChecked;
                        }
                        if (parts.Length > 14)
                        {
                            namePatter = parts[14];
                        }
                        if (parts.Length > 15)
                        {
                            txtNum.Text = parts[15];
                        }
                        if (parts.Length > 16)
                        {
                            bgSt = (System.Windows.Media.Stretch)Enum.Parse(typeof(System.Windows.Media.Stretch), parts[16]);
                        }
                        if (parts.Length > 17)
                        {
                            bgHe = (System.Windows.Media.AlignmentX)Enum.Parse(typeof(System.Windows.Media.AlignmentX), parts[17]);
                        }
                        if (parts.Length > 18)
                        {
                            bgVe = (System.Windows.Media.AlignmentY)Enum.Parse(typeof(System.Windows.Media.AlignmentY), parts[18]);
                        }
                        if (parts.Length > 19)
                        {
                            bgOp = double.Parse(parts[19]);
                        }
                    }
                    //else itmJpg.IsChecked = lines[2].Trim().Equals("1");
                    else addressType = (AddressType)Enum.Parse(typeof(AddressType), lines[2].Trim());

                    for (int i = 3; i < lines.Length; i++)
                    {
                        if (lines[i].Trim().Length > 0)
                        {
                            if (lines[i].Contains(':'))
                            {
                                string[] parts = lines[i].Trim().Split(':');
                                viewedIds[parts[0]] = new ViewedID();
                                viewedIds[parts[0]].AddViewedRange(parts[1]);
                            }
                            else
                            {
                                //向前兼容
                                if (i - 3 >= SiteManager.Instance.Sites.Count) break;
                                viewedIds[SiteManager.Instance.Sites[i - 3].ShortName] = new ViewedID();
                                viewedIds[SiteManager.Instance.Sites[i - 3].ShortName].AddViewedRange(lines[i].Trim());
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "读取配置文件失败\r\n" + ex.Message, "Moe Loader", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }

            switch (addressType)
            {
                case AddressType.Ori:
                    itmTypeOri.IsChecked = true;
                    break;
                case AddressType.Jpg:
                    itmTypeJpg.IsChecked = true;
                    break;
                case AddressType.Pre:
                    itmTypePreview.IsChecked = true;
                    break;
                case AddressType.Small:
                    itmTypeSmall.IsChecked = true;
                    break;
            }

            //string logoPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\logo.png";
            //if (System.IO.File.Exists(logoPath))
            //{
                //image.Source = new BitmapImage(new Uri(logoPath, UriKind.Absolute));
            //}
            //else image.Source = new BitmapImage(new Uri("Images/logo1.png", UriKind.Relative));
        }
        public MainWindow()
        {
            InitializeComponent();

            if (!System.IO.File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\nofont.txt"))
            {
                FontFamily = new FontFamily("Microsoft YaHei");
            }

            //MaxWidth = System.Windows.SystemParameters.MaximizedPrimaryScreenWidth;
            //MaxHeight = System.Windows.SystemParameters.MaximizedPrimaryScreenHeight;
            /////////////////////////////////////// init image site list //////////////////////////////////
            Dictionary<string, MenuItem> dicSites = new Dictionary<string, MenuItem>();
            List<MenuItem> tempSites = new List<MenuItem>();
            int index = 0;
            foreach (ImageSite site in SiteManager.Instance.Sites)
            {
                MenuItem menuItem = null;
                //group by shortName
                if (dicSites.ContainsKey(site.ShortName))
                {
                    menuItem = dicSites[site.ShortName];
                }
                else
                {
                    int space = site.SiteName.IndexOf(' ');
                    if (space > 0)
                        menuItem = new MenuItem() { Header = site.SiteName.Substring(0, space) };
                    else menuItem = new MenuItem() { Header = site.SiteName };

                    menuItem.Style = Resources["SimpleMenuItem"] as Style;
                    dicSites.Add(site.ShortName, menuItem);
                }
                MenuItem subItem = new MenuItem() { Header = site.SiteName, ToolTip = site.ToolTip, DataContext = index++ };
                subItem.Click += new RoutedEventHandler(menuItem_Click);
                subItem.Style = Resources["SimpleMenuItem"] as Style;
                menuItem.Items.Add(subItem);
            }
            index = 0;
            foreach (ImageSite site in SiteManager.Instance.Sites)
            {
                MenuItem menuItem = dicSites[site.ShortName];
                if (menuItem == null) continue;
                if (menuItem.Items.Count == 1)
                {
                    menuItem = menuItem.Items[0] as MenuItem;
                }

                //menuItem.Icon = new BitmapImage(new Uri("/Images/site" + (index++) + ".ico", UriKind.Relative));
                System.IO.Stream iconStr = site.IconStream;
                if (iconStr != null)
                {
                    BitmapImage ico = new BitmapImage();
                    ico.CacheOption = BitmapCacheOption.Default;
                    ico.BeginInit();
                    ico.StreamSource = site.IconStream;
                    ico.EndInit();
                    menuItem.Icon = ico;
                }
                tempSites.Add(menuItem);

                dicSites[site.ShortName] = null;
            }
            siteMenu.ItemsSource = tempSites;
            siteMenu.Header = SiteManager.Instance.Sites[comboBoxIndex].ShortName;
            siteMenu.Icon = tempSites[0].Icon;
            siteText.Text = "当前站点 " + SiteManager.Instance.Sites[comboBoxIndex].ShortName;
            //comboBox1.ItemsSource = tempSites;
            //comboBox1.SelectedIndex = 0;
            /////////////////////////////////////////////////////////////////////////////////////////////

            viewedIds = new Dictionary<string, ViewedID>(SiteManager.Instance.Sites.Count);

            Proxy = "127.0.0.1:8000";
            ProxyType = MoeLoader.ProxyType.System;
            bossKey = System.Windows.Forms.Keys.Subtract;

            LoadConfig();
            //itmxExplicit.IsChecked = !showExplicit;

            MainW = this;
        }
Exemple #16
0
 public void ModifiedKeyPress(System.Windows.Forms.Keys key, params System.Windows.Forms.Keys[] modifiers)
 {
     KeyboardInputProvider.ModifiedKeyPress(key, modifiers);
 }
Exemple #17
0
 public UdpMessage Key(System.Windows.Forms.Keys key)
 => new UdpMessage(nameof(Key), key.ToString());
Exemple #18
0
 private bool IsSwitchKey(System.Windows.Forms.Keys key)
 {
     return(key.Equals(switchKey));
 }
Exemple #19
0
 internal ShortcutKey(VirtualKey key, ICollection<VirtualKey> modifiers)
     : this()
 {
     this.Key = key;
     this.ModifiersInternal = modifiers;
 }
Exemple #20
0
 public KeyBind(System.Windows.Forms.Keys key)
 {
     Type = KeyType.Keyboard;
     Code = (uint)key;
 }
        private void Keyboard_KeyPressed(System.Windows.Forms.Keys pressedKey)
        {
            switch (pressedKey)
            {
            case System.Windows.Forms.Keys.Left:
                buttonIndex = (--buttonIndex % 3);
                break;

            case System.Windows.Forms.Keys.Right:
                buttonIndex = (++buttonIndex % 3);
                break;

            default:
                break;
            }
            if (buttonIndex < 0)
            {
                buttonIndex += 3;
            }

            switch (pressedKey)
            {
            case System.Windows.Forms.Keys.Left:
            case System.Windows.Forms.Keys.Right:
                switchButton(buttonIndex);
                XingKongScreen.FreshScreen();
                //防止过多刷新导致眼花……,重置剩余刷新时间
                remaningSeconds = 7;
                break;

            case System.Windows.Forms.Keys.Enter:
                if (btNext.IsChecked)
                {
                    pageIndex++;
                    pageIndex = pageIndex % pageCount;
                }
                else if (btPrev.IsChecked)
                {
                    pageIndex--;
                    if (pageIndex < 0)
                    {
                        pageIndex += pageCount;
                    }
                }
                LogData("PageIndex: " + pageIndex);
                //切换页
                List <EntityHelper.HostInfoEntity> page = pageManager.GetPageByIndex(pageIndex);
                for (int i = 0; i < 4; i++)
                {
                    if (i > (page.Count - 1))
                    {
                        setAreaContent(i, null);
                    }
                    else
                    {
                        setAreaContent(i, page[i]);
                    }
                }
                //防止过多刷新导致眼花……,重置剩余刷新时间
                remaningSeconds = 7;
                currentWindow.Draw();
                XingKongScreen.FreshScreen();
                break;

            case System.Windows.Forms.Keys.Escape:
                Suspend();
                Quit();
                break;

            default:
                break;
            }
        }
Exemple #22
0
 public bool IsActive(System.Windows.Forms.Keys key)
 {
     return(Type == KeyType.Keyboard && Code == (uint)key);
 }
 /// <summary>
 /// Is key an input key for camera motion?</summary>
 /// <param name="controlScheme">The control scheme instance to extend</param>
 /// <param name="key">Key to test</param>
 /// <returns>True iff key is input key for camera motion</returns>
 public static bool IsInputKey(this ControlScheme controlScheme, WfKeys key)
 {
     return controlScheme.IsInputKey(KeysInterop.ToAtf(key));
 }
 public static bool KeyPressed(System.Windows.Forms.Keys key)
 {
     return(ScriptProcessor.Instance.KeyBuffer[(int)key] != 0);
 }
Exemple #25
0
 //----------------------------------------------------------------------
 protected internal override void OnOSKeyPress( OSKey _key )
 {
     switch( _key )
     {
         case OSKey.Home:
             Scrollbar.Offset = 0;
             break;
         case OSKey.End:
             Scrollbar.Offset = Scrollbar.Max;
             break;
         case OSKey.PageUp:
             Scrollbar.Offset -= LayoutRect.Height;
             break;
         case OSKey.PageDown:
             Scrollbar.Offset += LayoutRect.Height;
             break;
     #if !MONOMAC
         case OSKey.Enter:
     #else
         case OSKey.Return:
     #endif
             if( ValidateHandler != null && SelectedNode != null )
             {
                 ValidateHandler( this );
             }
             break;
         case OSKey.Delete:
             if( RemoveHandler != null )
             {
                 RemoveHandler(this);
             }
             break;
     }
 }
Exemple #26
0
 public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint control, System.Windows.Forms.Keys keys);
    private void KeyDown(Keys key)
    {
      if (!selectingKey)
      {
        KeyBoard.KeyDown -= KeyDown;
        return;
      }

      selectingKey = false;
      SelectButtonName = key.ToString();
    }
 protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
 {
     throw null;
 }
 public bool WasKeyPressed(Keys key)
 {
     return _PressedKeys.Contains(key);
 }
Exemple #30
0
 public static bool IsKeyDown(System.Windows.Forms.Keys key)
 {
     return((GetAsyncKeyState(key) & 0x8000) != 0);
 }
Exemple #31
0
 public void KeyUp(System.Windows.Forms.Keys key)
 {
     KeyboardInputProvider.KeyUp(key);
 }
        public void Window_KeyDown(object sender, KeyEventArgs e)
        {
            //if(MainWindow.Instance.IsActive != true)
            //{
            //    MainWindow.Instance.Activate();
            //}
            if (ControlBoard.Instance.IsActive && (e.Key == Key.Up || e.Key == Key.Down))
            {
                //MessageBox.Show("tab");
                //if (System.Windows.Forms.Screen.AllScreens.Length == 1)
                //{
                //    ControlBoard.Instance.Topmost = true;
                //    Topmost = false;
                //    ControlBoard.Instance.Activate();
                //}
            }
            if (Game.Instance._isInBetting)
            {
                System.Windows.Forms.Keys keycode = System.Windows.Forms.Keys.Space;

                if (e.Key == Key.System)
                {
                    if (e.SystemKey == Key.F10)
                    {
                        keycode = System.Windows.Forms.Keys.F10;
                        //e.Handled = true;
                    }
                    if (e.SystemKey == Key.F9)
                    {
                        keycode = System.Windows.Forms.Keys.F9;
                        //e.Handled = true;
                    }
                    if (e.SystemKey == Key.F8)
                    {
                        keycode = System.Windows.Forms.Keys.F8;
                        //e.Handled = true;
                    }
                    if (e.SystemKey == Key.PageUp)
                    {
                        keycode = System.Windows.Forms.Keys.PageUp;
                        //e.Handled = true;
                    }
                    if (e.SystemKey == Key.PageDown)
                    {
                        keycode = System.Windows.Forms.Keys.PageDown;
                        //e.Handled = true;
                    }
                    if (e.SystemKey == Key.Home)
                    {
                        keycode = System.Windows.Forms.Keys.Home;
                        //e.Handled = true;
                    }
                    if (e.SystemKey == Key.Help)
                    {
                        keycode = System.Windows.Forms.Keys.Help;
                        //e.Handled = true;
                    }
                    if (e.SystemKey == Key.End)
                    {
                        keycode = System.Windows.Forms.Keys.End;
                        //e.Handled = true;
                    }
                    if (e.SystemKey == Key.Insert)
                    {
                        keycode = System.Windows.Forms.Keys.Insert;
                        //e.Handled = true;
                    }
                }
                else
                {
                    keycode = (System.Windows.Forms.Keys)KeyInterop.VirtualKeyFromKey(e.Key);
                }

                var keymodel = _keyMap[(int)keycode];
                if (keymodel.IsKey)
                {
                    keymodel.Pressed = true;
                }
                e.Handled = true;
            }
        }
 public void KeyDown(System.Windows.Forms.Keys key)
 {
     _inputSimulator.Keyboard.KeyDown((VirtualKeyCode)key);
 }
Exemple #34
0
 internal static extern int RegisterHotKey(IntPtr hWnd, int id, HotKey.MOD_KEY fsModifiers, System.Windows.Forms.Keys vk);
Exemple #35
0
 public Operation_Element_SetHotkeyAnimation(ElementInfo e, System.Windows.Forms.Keys key, float time)
     : base(e)
 {
     Key  = key;
     Time = time;
 }
 public static void SendKey(IntPtr hWnd, Keys key) => SendKey(hWnd, (int)key);
Exemple #37
0
 public ShortcutKey(VirtualKey key, params VirtualKey[] modifiers)
 {
     this.Key = key;
     this.Modifiers = modifiers;
     this.ModifiersInternal = modifiers;
 }
Exemple #38
0
        protected internal virtual void OnOSKeyPress( OSKey _key )
        {
            if( _key == OSKey.Tab )
            {
                List<Direction> directions = new List<Direction>();

                if( Screen.Game.InputMgr.KeyboardState.Native.IsKeyDown( Keys.LeftShift ) || Screen.Game.InputMgr.KeyboardState.Native.IsKeyDown( Keys.RightShift ) )
                {
                    directions.Add( Direction.Left );
                    directions.Add( Direction.Up );
                }
                else
                {
                    directions.Add( Direction.Right );
                    directions.Add( Direction.Down );
                }

                foreach( Direction direction in directions )
                {
                    Widget widget = GetSibling( direction, this );

                    if( widget != null )
                    {
                        Widget focusableWidget = widget.GetFirstFocusableDescendant( direction );

                        if( focusableWidget != null )
                        {
                            Screen.Focus( focusableWidget );
                            break;
                        }
                    }
                }
            }
            else
            {
                if( Parent != null ) Parent.OnOSKeyPress( _key );
            }
        }
Exemple #39
0
        public EventMethod HandleDesktopKeyEvent(System.Windows.Forms.Keys vkCode, System.Windows.Input.Key inputKey)
        {
            EventMethod method = null;

            if (Desktop.WindowManager.CurrentActiveWindow == ActiveWindow.CHARACTERS_AND_CROWDS)
            {
                if (inputKey == Key.C && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanCloneCrowdMember)
                    {
                        method = this.CloneCrowdMember;
                    }
                }
                else if (inputKey == Key.X && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanCutCrowdMember)
                    {
                        method = this.CutCrowdMember;
                    }
                }
                else if (inputKey == Key.V && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanPasteCrowdMember)
                    {
                        method = this.PasteCrowdMember;
                    }
                }
                else if (inputKey == Key.L && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanLinkCrowdMember)
                    {
                        method = this.LinkCrowdMember;
                    }
                }
                else if (inputKey == Key.E && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanEditCharacterCrowd)
                    {
                        method = this.EditCharacterCrowd;
                    }
                }
                else if (inputKey == Key.F && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanFlattenCopyCrowd)
                    {
                        method = this.FlattenCopyCrowd;
                    }
                }
                else if (inputKey == Key.N && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanEnterFlattenNumber)
                    {
                        method = this.EnterFlattenNumber;
                    }
                }
                else if (inputKey == Key.M && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanCloneMemberships)
                    {
                        method = this.CloneMemberships;
                    }
                }
                else if ((inputKey == Key.OemPlus || inputKey == Key.Add) && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanAddCharacterCrowdMember)
                    {
                        method = this.AddCharacterCrowdMember;
                    }
                }
                else if ((inputKey == Key.OemPlus || inputKey == Key.Add) && Keyboard.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift))
                {
                    method = this.AddCrowd;
                }
                else if ((inputKey == Key.OemMinus || inputKey == Key.Subtract || inputKey == Key.Delete) && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanDeleteCrowdMember)
                    {
                        method = this.DeleteCrowdMember;
                    }
                }
                else if (inputKey == Key.R && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanAddToRoster)
                    {
                        method = AddToRoster;
                    }
                }
                else if (inputKey == Key.S && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    method = Save;
                }
            }

            return(method);
        }
Exemple #40
0
        private void OnKeyDown(Keys keys)
        {
            var recorderKey = Settings.Current.RecorderKey;

              if ((keys & recorderKey) == recorderKey && !keyPressed)
              {
            keyPressed = true;
            if (ClientModel.Recorder != null)
              ClientModel.Recorder.Start();
              }
        }
 public static Key FormsKeysToWpfKey(System.Windows.Forms.Keys keys)
 {
     return(KeyInterop.KeyFromVirtualKey((int)keys));
 }
Exemple #42
0
        private void OnKeyUp(Keys keys)
        {
            var recorderKey = Settings.Current.RecorderKey;

              if ((keys & recorderKey) == recorderKey && keyPressed)
              {
            keyPressed = false;
            if (ClientModel.Recorder != null)
              ClientModel.Recorder.Stop();
              }
        }
Exemple #43
0
        protected internal override void OnOSKeyPress( OSKey _key )
        {
            bool bCtrl = Screen.Game.InputMgr.KeyboardState.IsKeyDown( Keys.LeftControl, true ) || Screen.Game.InputMgr.KeyboardState.IsKeyDown( Keys.RightControl, true );
            bool bShortcutKey = Screen.Game.InputMgr.IsShortcutKeyDown();
            bool bShift = Screen.Game.InputMgr.KeyboardState.IsKeyDown( Keys.LeftShift, true ) || Screen.Game.InputMgr.KeyboardState.IsKeyDown( Keys.RightShift, true );

            switch( _key )
            {
                case OSKey.A:
                    if( bShortcutKey )
                    {
                        SelectAll();
                    }
                    break;
                case OSKey.X:
                    if( bShortcutKey && mPasswordChar == '\0' )
                    {
                        CopySelectionToClipboard();
                        DeleteSelectedText();
                    }
                    break;
                case OSKey.C:
                    if( bShortcutKey && mPasswordChar == '\0' )
                    {
                        CopySelectionToClipboard();
                    }
                    break;
                case OSKey.V:
                    if( bShortcutKey )
                    {
                        PasteFromClipboard();
                    }
                    break;
            #if !MONOMAC
                case OSKey.Enter:
            #else
                case OSKey.Return:
            #endif
                    if( ! IsReadOnly && ValidateHandler != null ) ValidateHandler( this );
                    break;
            #if !MONOMAC
                case OSKey.Back:
            #else
                case OSKey.ForwardDelete:
            #endif
                    if( ! IsReadOnly && Text.Length > 0 )
                    {
                        if( SelectionOffset != 0 )
                        {
                            DeleteSelectedText();
                        }
                        else
                        if( CaretOffset > 0 )
                        {
                            CaretOffset--;

                            if( TextRemovedHandler != null ) TextRemovedHandler( this, CaretOffset, 1 );
                            Text = Text.Remove( CaretOffset, 1 );
                        }
                    }
                    break;
                case OSKey.Delete:
                    if( ! IsReadOnly && Text.Length > 0 )
                    {
                        if( SelectionOffset != 0 )
                        {
                            DeleteSelectedText();
                        }
                        else
                        if( CaretOffset < Text.Length )
                        {
                            if( TextRemovedHandler != null ) TextRemovedHandler( this, CaretOffset, 1 );
                            Text = Text.Remove( CaretOffset, 1 );
                        }
                    }
                    break;
                case OSKey.Escape:
                    if( ! IsReadOnly && CanBeEscapeCleared && Text.Length > 0 )
                    {
                        SelectAll();
                        DeleteSelectedText();
                    }
                    break;
            #if !MONOMAC
                case OSKey.Left:
            #else
                case OSKey.LeftArrow:
            #endif
                    if( bShift )
                    {
                        if( bCtrl )
                        {
                            int iNewSelectionTarget = CaretOffset + SelectionOffset;

                            if( iNewSelectionTarget > 0 )
                            {
                                iNewSelectionTarget = Text.LastIndexOf( ' ', Math.Max( iNewSelectionTarget - 2, 0 ) ) + 1;
                            }

                            SelectionOffset = iNewSelectionTarget - CaretOffset;
                        }
                        else
                        {
                            SelectionOffset--;
                        }
                    }
                    else
                    {
                        int iNewCaretOffset = CaretOffset - 1;

                        if( bCtrl )
                        {
                            SelectionOffset = 0;

                            if( iNewCaretOffset > 0 )
                            {
                                iNewCaretOffset = Text.LastIndexOf( ' ', iNewCaretOffset - 1 ) + 1;
                            }
                        }
                        else
                        if( SelectionOffset != 0 )
                        {
                            iNewCaretOffset = ( SelectionOffset > 0 ) ? CaretOffset : CaretOffset + SelectionOffset;
                            SelectionOffset = 0;
                        }
                        CaretOffset = iNewCaretOffset;
                    }
                    break;
            #if !MONOMAC
                case OSKey.Right:
            #else
                case OSKey.RightArrow:
            #endif
                    if( bShift )
                    {
                        if( bCtrl )
                        {
                            int iNewSelectionTarget = CaretOffset + SelectionOffset;

                            if( iNewSelectionTarget < Text.Length )
                            {
                                iNewSelectionTarget = Text.IndexOf( ' ', iNewSelectionTarget, Text.Length - iNewSelectionTarget ) + 1;

                                if( iNewSelectionTarget == 0 )
                                {
                                    iNewSelectionTarget = Text.Length;
                                }

                                SelectionOffset = iNewSelectionTarget - CaretOffset;
                            }
                        }
                        else
                        {
                            SelectionOffset++;
                        }
                    }
                    else
                    {
                        int iNewCaretOffset = CaretOffset + 1;

                        if( bCtrl )
                        {
                            if( iNewCaretOffset < Text.Length )
                            {
                                iNewCaretOffset = Text.IndexOf( ' ', iNewCaretOffset, Text.Length - iNewCaretOffset ) + 1;

                                if( iNewCaretOffset == 0 )
                                {
                                    iNewCaretOffset = Text.Length;
                                }
                            }
                        }
                        else
                        if( SelectionOffset != 0 )
                        {
                            iNewCaretOffset = ( SelectionOffset < 0 ) ? CaretOffset : CaretOffset + SelectionOffset;
                        }
                        CaretOffset = iNewCaretOffset;
                    }
                    break;
                case OSKey.End:
                    if( bShift )
                    {
                        SelectionOffset = Text.Length - CaretOffset;
                    }
                    else
                    {
                        CaretOffset = Text.Length;
                    }
                    break;
                case OSKey.Home:
                    if( bShift )
                    {
                        SelectionOffset = -CaretOffset;
                    }
                    else
                    {
                        CaretOffset = 0;
                    }
                    break;
                case OSKey.Tab:
                    if( LookupHandler != null )
                    {
                        if( CaretOffset > 0 && ( CaretOffset == Text.Length || Text[CaretOffset] == ' ' ) )
                        {
                            int iOffset = Text.LastIndexOf( ' ', CaretOffset - 1 );

                            iOffset++;

                            string strLookup = Text.Substring( iOffset, CaretOffset - iOffset );
                            if( strLookup != "" )
                            {
                                string strResult = LookupHandler( strLookup );
                                if( ! string.IsNullOrEmpty( strResult ) )
                                {
                                    Text = Text.Substring( 0, iOffset ) + strResult + Text.Substring( CaretOffset );
                                    CaretOffset = iOffset + strResult.Length;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        base.OnOSKeyPress( _key );
                    }
                    break;
                default:
                    base.OnOSKeyPress( _key );
                    break;
            }
        }
Exemple #44
0
            public static void AddKey(string menuName, string name, string defaultName, Keys Keys, KeyBindType type, bool enabled = false)
            {
                var subMeun = miscMenu["SharpShooter.MiscSettings." + menuName] as Menu;

                subMeun?.Add(new MenuKeyBind(name, defaultName, Keys, type)
                {
                    Active = enabled
                });
            }
 /// <summary>
 /// Is the keyboard being used to move the camera? If the camera controller allows
 /// for this kind of control, then it can check in the OnKeyDown event handler if
 /// the user is intending to move the camera.</summary>
 /// <param name="controlScheme">The control scheme instance to extend</param>
 /// <param name="modifierKeys">The Control's ModifierKeys property</param>
 /// <param name="e">The key event from the KeyDown event handler, for example</param>
 /// <returns>True if the user is trying to move the camera using the keyboard</returns>
 public static bool IsControllingCamera(this ControlScheme controlScheme, WfKeys modifierKeys, WfKeyEventArgs e)
 {
     return controlScheme.IsControllingCamera(KeysInterop.ToAtf(modifierKeys), KeyEventArgsInterop.ToAtf(e));
 }
Exemple #46
0
 public void KeyUp(System.Windows.Forms.Keys key)
 {
     downKeys.Remove(key);
 }
 /// <summary>
 /// Should the camera turn around in-place? This means that the look-at direction
 /// changes, but the eye point remains stationary.</summary>
 /// <param name="controlScheme">The control scheme instance to extend</param>
 /// <param name="modifierKeys">The camera control's ModifierKeys property</param>
 /// <param name="e">The camera control's event handler's AtfMouseEventArgs</param>
 /// <returns>True if the user wants to turn the camera around in place</returns>
 /// <remarks>This is used by the fly and walk camera controllers.</remarks>
 public static bool IsTurning(this ControlScheme controlScheme, WfKeys modifierKeys, AtfMouseEventArgs e)
 {
     return controlScheme.IsTurning(KeysInterop.ToAtf(modifierKeys), e);
 }
Exemple #48
0
 public bool IsKeyDown(System.Windows.Forms.Keys key)
 {
     return(downKeys.Contains(key));
 }
Exemple #49
0
 /// <summary>
 /// Converts a System.Windows.Forms.Keys to an Sce.Atf.Input.Keys</summary>
 /// <param name="keys">WfKeys enum</param>
 /// <returns>Converted AtfKeys enum</returns>
 public static AtfKeys ToAtf(WfKeys keys)
 {
     return (AtfKeys)keys;
 }
        public void KeyUp(System.Windows.Forms.Keys key)
        {
            IntPtr hWndMain = this.Info.raw.MainWindowHandle;

            NativeMethods.PostMessage(hWndMain, NativeMethods.WM_KEYUP, key, IntPtr.Zero);
        }
Exemple #51
0
 /// <summary>
 /// �����¼�
 /// </summary>
 /// <param name="type"></param>
 /// <param name="keyCode"></param>
 public KeyBoardEvent(KeyBoardType type, System.Windows.Forms.Keys keyCode)
 {
     this.type = type;
     this.keyCode = keyCode;
 }
Exemple #52
0
 public static extern short GetAsyncKeyState(System.Windows.Forms.Keys vKey);
Exemple #53
0
 public static bool IsKeyDown(System.Windows.Forms.Keys key)
 {
     return(IsKeyDown((int)key));
 }
Exemple #54
0
        //Handle keyboard down
        void HandleKeyboardDown(MSG windowMessage, ref bool messageHandled)
        {
            try
            {
                //Get the pressed keys
                KeysVirtual usedVirtualKey = (KeysVirtual)windowMessage.wParam;

                //Check pressed key modifier
                KeysVirtual?usedModifierKey        = null;
                System.Windows.Forms.Keys keysData = (System.Windows.Forms.Keys)(int) usedVirtualKey | System.Windows.Forms.Control.ModifierKeys;
                if (keysData.HasFlag(System.Windows.Forms.Keys.Control))
                {
                    usedModifierKey = KeysVirtual.Control;
                }
                else if (keysData.HasFlag(System.Windows.Forms.Keys.Alt))
                {
                    usedModifierKey = KeysVirtual.Alt;
                }
                else if (keysData.HasFlag(System.Windows.Forms.Keys.Shift))
                {
                    usedModifierKey = KeysVirtual.Shift;
                }

                //Check if a textbox is focused
                bool             focusedTextBox   = false;
                FrameworkElement frameworkElement = (FrameworkElement)Keyboard.FocusedElement;
                if (frameworkElement != null && frameworkElement.GetType() == typeof(TextBox))
                {
                    focusedTextBox = true;
                }

                //Check the pressed key
                if (usedVirtualKey == KeysVirtual.Tab && usedModifierKey == KeysVirtual.Shift)
                {
                    PlayInterfaceSound(vConfigurationCtrlUI, "Move", false);
                }
                else if (usedVirtualKey == KeysVirtual.Tab)
                {
                    PlayInterfaceSound(vConfigurationCtrlUI, "Move", false);
                }
                else if (usedVirtualKey == KeysVirtual.F13)
                {
                    PlayInterfaceSound(vConfigurationCtrlUI, "Click", false);
                }
                else if (usedVirtualKey == KeysVirtual.Home)
                {
                    PlayInterfaceSound(vConfigurationCtrlUI, "Click", false);
                }
                else if (usedVirtualKey == KeysVirtual.Prior)
                {
                    PlayInterfaceSound(vConfigurationCtrlUI, "Click", false);
                }
                else if (usedVirtualKey == KeysVirtual.End)
                {
                    PlayInterfaceSound(vConfigurationCtrlUI, "Click", false);
                }
                else if (usedVirtualKey == KeysVirtual.Next)
                {
                    PlayInterfaceSound(vConfigurationCtrlUI, "Click", false);
                }
                else if (usedVirtualKey == KeysVirtual.Left)
                {
                    PlayInterfaceSound(vConfigurationCtrlUI, "Move", false);
                }
                else if (usedVirtualKey == KeysVirtual.Up)
                {
                    PlayInterfaceSound(vConfigurationCtrlUI, "Move", false);
                    NavigateUp(ref messageHandled);
                }
                else if (usedVirtualKey == KeysVirtual.Right)
                {
                    PlayInterfaceSound(vConfigurationCtrlUI, "Move", false);
                }
                else if (usedVirtualKey == KeysVirtual.Down)
                {
                    PlayInterfaceSound(vConfigurationCtrlUI, "Move", false);
                    NavigateDown(ref messageHandled);
                }
                else if (usedVirtualKey == KeysVirtual.Space)
                {
                    if (!focusedTextBox)
                    {
                        PlayInterfaceSound(vConfigurationCtrlUI, "Confirm", false);
                    }
                }
                else if (usedVirtualKey == KeysVirtual.BackSpace)
                {
                    if (vFilePickerOpen && !focusedTextBox)
                    {
                        PlayInterfaceSound(vConfigurationCtrlUI, "Confirm", false);
                    }
                }
            }
            catch { }
        }
 public GroupEntry(string name, Keys shortcutKey, bool startup, IEnumerable<FolderEntry> folders) {
     Name = name;
     Startup = startup;
     ShortcutKey = shortcutKey;
     Folders = new ParentedCollection<FolderEntry>(this, folders);
     Folders.CollectionChanged += Folders_CollectionChanged;
     RefreshIcon();
 }
 /// <summary>TODO</summary>
 public HexEventArgs(HexCoords coords, System.Windows.Forms.Keys modifierKeys)
     : this(coords, new System.Windows.Forms.MouseEventArgs(System.Windows.Forms.MouseButtons.None, 0, 0, 0, 0), modifierKeys)
 {
 }
 public bool IsKeyUp(Keys key)
 {
     return !_DownKeys.Contains(key);
 }
 public HexEventArgs(HexCoords coords, System.Windows.Forms.MouseEventArgs e, System.Windows.Forms.Keys modifierKeys)
     : base(e.Button, e.Clicks, e.X, e.Y, e.Delta)
 {
     Coords = coords;
 }
 public bool WasKeyReleased(Keys key)
 {
     return _ReleasedKeys.Contains(key);
 }
Exemple #60
0
 /// <summary>
 /// Initialize the values to the default value
 /// </summary>
 private void InitValues()
 {
     _mAlt = false;
     _mCtrl = false;
     _mShift = false;
     _enabled = false;
     _hKey = System.Windows.Forms.Keys.A;
 }