Esempio n. 1
0
        /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnKeyDown(GLKeyEventArgs)"/>

        protected override void OnKeyDown(GLKeyEventArgs e)
        {
            base.OnKeyDown(e);
            if (!e.Handled)
            {
                //System.Diagnostics.Debug.WriteLine("LB KDown " + Name + " " + e.KeyCode);

                if (e.KeyCode == System.Windows.Forms.Keys.Up)
                {
                    FocusUp();
                }
                else if (e.KeyCode == System.Windows.Forms.Keys.Down)
                {
                    FocusDown();
                }

                if ((e.KeyCode == System.Windows.Forms.Keys.Enter || e.KeyCode == System.Windows.Forms.Keys.Return) || (e.Alt && (e.KeyCode == System.Windows.Forms.Keys.Up || e.KeyCode == System.Windows.Forms.Keys.Down)))
                {
                    SelectCurrentFocus();
                }

                if (e.KeyCode == System.Windows.Forms.Keys.Delete || e.KeyCode == System.Windows.Forms.Keys.Escape || e.KeyCode == System.Windows.Forms.Keys.Back)
                {
                    OnOtherKeyPressed(e);
                }
            }
        }
        /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnKeyDown(GLKeyEventArgs)"/>
        protected override void OnKeyDown(GLKeyEventArgs e)
        {
            base.OnKeyDown(e);

            if (!e.Handled && Items.Count > 0)
            {
                if (!DisableChangeKeys && (e.KeyCode == System.Windows.Forms.Keys.Up || e.KeyCode == System.Windows.Forms.Keys.Left))
                {
                    if (SelectedIndex == -1)
                    {
                        SelectedIndex = 0;
                    }
                    else if (SelectedIndex > 0)
                    {
                        SelectedIndex = SelectedIndex - 1;
                    }
                }
                else if (!DisableChangeKeys && (e.KeyCode == System.Windows.Forms.Keys.Down || e.KeyCode == System.Windows.Forms.Keys.Right))
                {
                    if (SelectedIndex == -1)
                    {
                        SelectedIndex = 0;
                    }
                    else if (SelectedIndex < Items.Count - 1)
                    {
                        SelectedIndex = SelectedIndex + 1;
                    }
                }
                else if (e.KeyCode == System.Windows.Forms.Keys.Return)
                {
                    Activate();
                }
            }
        }
 private void dropdownotherkey(GLBaseControl c, GLKeyEventArgs e)
 {
     if (e.KeyCode == System.Windows.Forms.Keys.Escape)
     {
         Deactivate();
     }
 }
Esempio n. 4
0
 /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnKeyPress(GLKeyEventArgs)"/>
 protected override void OnKeyPress(GLKeyEventArgs e)
 {
     if (e.KeyChar == 13)
     {
         OnReturn();
     }
 }
 /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnKeyPress"/>
 protected override void OnKeyPress(GLKeyEventArgs e)
 {
     base.OnKeyPress(e);
     if (e.Handled == false && e.KeyChar == 13)
     {
         OnClick();
     }
 }
Esempio n. 6
0
 void winCanvas_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
 {
     if (this.currentControl != null)
     {
         GLKeyEventArgs args = e.Translate();
         this.currentControl.InvokeEvent(EventType.KeyDown, args);
     }
 }
 /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnKeyPress(GLKeyEventArgs)"/>
 protected override void OnKeyPress(GLKeyEventArgs e)       // forms gets first dibs at keys of children
 {
     base.OnKeyPress(e);
     if (!e.Handled && e.KeyChar == 27)
     {
         Trigger?.Invoke(this, null, "Escape", callertag);
         e.Handled = true;
     }
 }
Esempio n. 8
0
        private void Gc_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (EnsureCurrent)
            {
                glControl.MakeCurrent();
            }
            GLKeyEventArgs ka = new GLKeyEventArgs(e.Alt, e.Control, e.Shift, e.KeyCode, e.KeyValue, e.Modifiers);

            KeyUp?.Invoke(this, ka);
        }
        void WinSoftGLCanvas_KeyUp(object sender, KeyEventArgs e)
        {
            GLEventHandler <GLKeyEventArgs> keyUp = this.glKeyUp;

            if (keyUp != null)
            {
                GLKeyEventArgs arg = e.Translate();
                keyUp(sender, arg);
            }
        }
Esempio n. 10
0
        private void Gc_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
            if (EnsureCurrent)
            {
                glControl.MakeCurrent();
            }
            GLKeyEventArgs ka = new GLKeyEventArgs(e.KeyChar);

            KeyPress?.Invoke(this, ka);
        }
 /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnKeyPress(GLKeyEventArgs)"/>
 protected override void OnKeyPress(GLKeyEventArgs e) // limit keys to whats allowed for a double
 {
     if (AllowedChar(e.KeyChar))
     {
         base.OnKeyPress(e);
     }
     else
     {
         e.Handled = true;
     }
 }
 private void NonMIKeyDown(object o, GLKeyEventArgs e)
 {
     if (e.KeyCode == System.Windows.Forms.Keys.Up)
     {
         Move(-1);
     }
     else if (e.KeyCode == System.Windows.Forms.Keys.Down)
     {
         Move(1);
     }
 }
Esempio n. 13
0
        private void Gc_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (EnsureCurrent)
            {
                glControl.MakeCurrent();
            }
            //  System.Diagnostics.Debug.WriteLine("GLWIN KD " + e.KeyCode);
            GLKeyEventArgs ka = new GLKeyEventArgs(e.Alt, e.Control, e.Shift, e.KeyCode, e.KeyValue, e.Modifiers);

            KeyDown?.Invoke(this, ka);
        }
 protected void Gc_KeyPress(object sender, GLKeyEventArgs e)
 {
     if (currentfocus != null && currentfocus.Enabled)
     {
         if (!(currentfocus is GLForm))
         {
             currentfocus.FindForm()?.OnKeyPress(e);         // reflect to form
         }
         if (!e.Handled)
         {
             currentfocus.OnKeyPress(e);                     // send to control
         }
     }
     else
     {
         OnKeyPress(e);
     }
 }
 protected void Gc_KeyDown(object sender, GLKeyEventArgs e)
 {
     //System.Diagnostics.Debug.WriteLine("Control keydown " + e.KeyCode + " on " + currentfocus?.Name);
     if (currentfocus != null && currentfocus.Enabled)
     {
         if (!(currentfocus is GLForm))
         {
             currentfocus.FindForm()?.OnKeyDown(e);         // reflect to form
         }
         if (!e.Handled)                                    // send to control
         {
             currentfocus.OnKeyDown(e);
         }
     }
     else
     {
         OnKeyDown(e);
     }
 }
Esempio n. 16
0
        /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnKeyDown(GLKeyEventArgs)"/>
        protected override void OnKeyDown(GLKeyEventArgs e)       // forms gets first dibs at keys of children
        {
            base.OnKeyDown(e);
            //System.Diagnostics.Debug.WriteLine("Form key " + e.KeyCode);
            if (!e.Handled && TabChangesFocus && e.KeyCode == System.Windows.Forms.Keys.Tab)
            {
                bool          forward = e.Shift == false;
                GLBaseControl next    = FindNextTabChild(lastchildfocus?.TabOrder ?? -1, forward);
                if (next == null)
                {
                    next = FindNextTabChild(forward ?-1 : int.MaxValue, forward);
                }
                if (next != null)
                {
                    lastchildfocus = next;
                    next.SetFocus();
                }

                e.Handled = true;
            }
        }
        /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnKeyDown(GLKeyEventArgs)"/>
        protected override void OnKeyDown(GLKeyEventArgs e)
        {
            base.OnKeyDown(e);
            if (!e.Handled)
            {
                if (ListBox.Visible)
                {
                    if (e.KeyCode == System.Windows.Forms.Keys.Up)
                    {
                        ListBox.FocusUp();
                    }
                    else if (e.KeyCode == System.Windows.Forms.Keys.Down)
                    {
                        ListBox.FocusDown();
                    }
                    else if (e.KeyCode == System.Windows.Forms.Keys.PageUp)
                    {
                        ListBox.FocusUp(ListBox?.DisplayableItems ?? 0);
                    }
                    else if (e.KeyCode == System.Windows.Forms.Keys.PageDown)
                    {
                        ListBox.FocusDown(ListBox?.DisplayableItems ?? 0);
                    }
                }

                if (e.KeyCode == System.Windows.Forms.Keys.Enter || e.KeyCode == System.Windows.Forms.Keys.Return)
                {
                    if (ListBox.Visible && ListBox.FocusIndex >= 0)       // if we are showing list and there is a focus, we use that
                    {
                        ListBox.SelectCurrentFocus();
                    }
                    else
                    {
                        CancelAutoComplete();                   // close any list box, and select this text, may be empty
                        SelectedEntry?.Invoke(this);
                    }
                }
            }
        }
        /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnKeyDown(GLKeyEventArgs)"/>
        protected override void OnKeyDown(GLKeyEventArgs e)
        {
            base.OnKeyDown(e);
            if (!e.Handled)
            {
                //System.Diagnostics.Debug.WriteLine("KDown " + Name + " " + e.KeyCode);

                if (e.KeyCode == System.Windows.Forms.Keys.Up)
                {
                    repeatdir = 1;
                    OnClicked(1);
                }
                else if (e.KeyCode == System.Windows.Forms.Keys.Down)
                {
                    repeatdir = -1;
                    OnClicked(-1);
                }

                //System.Diagnostics.Debug.WriteLine("Ami start");
                amitimer.Start(100);
                Invalidate();
            }
        }
        /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnKeyDown(GLKeyEventArgs)"/>
        protected override void OnKeyDown(GLKeyEventArgs e)
        {
            base.OnKeyPress(e);
            //System.Diagnostics.Debug.WriteLine("Keydown in {0} {1}", Name, e.KeyCode);

            if (e.KeyCode == System.Windows.Forms.Keys.Left)
            {
                if (FlowDirection == ControlFlowDirection.Right)                // if we are in a flow right menu, its a negative to us
                {
                    Move(-1);
                }
                else if (parentmenu?.FlowDirection == ControlFlowDirection.Right)   // else see if the parent is flow right..
                {
                    parentmenu.Move(-1);
                }
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Right)
            {
                if (FlowDirection == ControlFlowDirection.Right)
                {
                    Move(1);
                }
                else if (parentmenu?.FlowDirection == ControlFlowDirection.Right)
                {
                    parentmenu.Move(1);
                }
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Up)
            {
                if (FlowDirection == ControlFlowDirection.Down)
                {
                    Move(-1);
                }
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Down)
            {
                if (FlowDirection == ControlFlowDirection.Down)
                {
                    Move(1);
                }
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Return)
            {
                if (FlowDirection == ControlFlowDirection.Right && selected == -1)      // if menu bar, and unselected, its like a right
                {
                    Move(1);
                }
                else
                {
                    ActivateSelected();
                }
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Back)
            {
                if (parentmenu?.FlowDirection != ControlFlowDirection.Right)        // if in a up/down, it means close this menu from parent
                {
                    parentmenu?.CloseSubMenus();
                }
                else
                {
                    parentmenu?.CloseMenus();
                }
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Escape)     // full shut down
            {
                GetTopLevelMenu().CloseMenus();
            }
        }
 private void OnOtherKeyPressed(GLKeyEventArgs e)
 {
     OtherKeyPressed?.Invoke(this, e);
 }
        /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.OnKeyDown(GLKeyEventArgs)"/>
        protected override void OnKeyDown(GLKeyEventArgs e)
        {
            base.OnKeyDown(e);
            if (e.KeyCode == System.Windows.Forms.Keys.Down)
            {
                if (e.Control)
                {
                    if (mode != Mode.Day)
                    {
                        mode = mode - 1;
                    }
                }
                else if (mode == Mode.Day)
                {
                    datetimecursor = datetimecursor.SafeAddDays(7);
                }
                else if (mode == Mode.Month)
                {
                    datetimecursor = datetimecursor.SafeAddMonths(4);
                }
                else if (mode == Mode.Decade)
                {
                    datetimecursor = datetimecursor.SafeAddYears(4);
                }
                Invalidate();
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Up)
            {
                if (e.Control)
                {
                    if (mode != Mode.Decade)
                    {
                        mode = mode + 1;
                    }
                }
                else if (mode == Mode.Day)
                {
                    datetimecursor = datetimecursor.SafeAddDays(-7);
                }
                else if (mode == Mode.Month)
                {
                    datetimecursor = datetimecursor.SafeAddMonths(-4);
                }
                else if (mode == Mode.Decade)
                {
                    datetimecursor = datetimecursor.SafeAddYears(-4);
                }
                Invalidate();
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Left)
            {
                if (mode == Mode.Day)
                {
                    datetimecursor = datetimecursor.SafeAddDays(-1);
                }
                else if (mode == Mode.Month)
                {
                    datetimecursor = datetimecursor.SafeAddMonths(-1);
                }
                else if (mode == Mode.Decade)
                {
                    datetimecursor = datetimecursor.SafeAddYears(-1);
                }
                Invalidate();
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Right)
            {
                if (mode == Mode.Day)
                {
                    datetimecursor = datetimecursor.SafeAddDays(1);
                }
                else if (mode == Mode.Month)
                {
                    datetimecursor = datetimecursor.SafeAddMonths(1);
                }
                else if (mode == Mode.Decade)
                {
                    datetimecursor = datetimecursor.SafeAddYears(1);
                }
                Invalidate();
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.PageUp)
            {
                GoLeft(null, null);
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.PageDown)
            {
                GoRight(null, null);
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Return)
            {
                ClickOn(-1);
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.Delete || e.KeyCode == System.Windows.Forms.Keys.Escape || e.KeyCode == System.Windows.Forms.Keys.Back)
            {
                OnOtherKeyPressed(e);
            }

            System.Diagnostics.Debug.WriteLine("Date time now " + datetimecursor.ToLongDateString());
        }
Esempio n. 22
0
 /// <summary> Key Up handler - hook to GLWindowControl</summary>
 public void KeyUp(object sender, GLKeyEventArgs e)
 {
     keyboard.KeyUp(e.Control, e.Shift, e.Alt, e.KeyCode);
 }
Esempio n. 23
0
 protected virtual void OnKeyPress(GLKeyEventArgs e)     // GLForm above control gets this as well, and can cancel call to control by handling it
 {
     KeyPress?.Invoke(this, e);
 }
Esempio n. 24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public static GLKeyEventArgs Translate(this System.Windows.Forms.KeyEventArgs e)
        {
            var args = new GLKeyEventArgs((GLKeys)e.KeyData);

            return(args);
        }