예제 #1
0
 protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
 {
     if (IsChangeTracked)
     {
         if (ModifierKeys.HasFlag(Keys.Control))
         {
             if (keyData.HasFlag(Keys.Z))
             {
                 if (ModifierKeys.HasFlag(Keys.Shift))
                 {
                     Redo();
                 }
                 else
                 {
                     Undo();
                 }
                 return(true);
             }
             else if (keyData.HasFlag(Keys.Y))
             {
                 Redo();
                 return(true);
             }
         }
     }
     if (keyData.HasFlag(Keys.Enter) || keyData.HasFlag(Keys.Return))
     {
         ConfirmInput();
     }
     return(base.ProcessCmdKey(ref msg, keyData));
 }
예제 #2
0
 protected override bool ProcessDialogKey(System.Windows.Forms.Keys keyData)
 {
     if (keyData == Keys.Tab)
     {
         var FocusedElement = Keyboard.FocusedElement as UIElement;
         if (FocusedElement != null)
         {
             DependencyObject         DestinationElement = null;
             FocusNavigationDirection Direction;
             if (keyData.HasFlag(Keys.Shift))
             {
                 Direction          = FocusNavigationDirection.Last;
                 DestinationElement = GetPrevTab(FocusedElement, null, false);
             }
             else
             {
                 Direction          = FocusNavigationDirection.First;
                 DestinationElement = GetNextTab(FocusedElement, GetGroupParent(FocusedElement, true), false);
             }
             if (DestinationElement == null)
             {
                 return(this.Sink.TabInto(new TraversalRequest(Direction)));
             }
         }
     }
     return(base.ProcessDialogKey(keyData));
 }
예제 #3
0
        /// <summary>
        /// Returns WPF modifiers as <see cref="wpf.ModifierKeys"/> from Forms <see cref="forms.Keys"/>.
        /// </summary>
        /// <param name="mKeys">Forms <see cref="forms.Keys"/> which is about to converted to WPF <see cref="wpf.ModifierKeys"/>.</param>
        public static wpf.ModifierKeys WpfModifiersFromFormsModifiers(forms.Keys mKeys)
        {
            wpf.ModifierKeys wKey = wpf.ModifierKeys.None;
            if (mKeys.HasFlag(forms.Keys.Control))
            {
                wKey = wKey | wpf.ModifierKeys.Control;
            }
            if (mKeys.HasFlag(forms.Keys.Alt))
            {
                wKey = wKey | wpf.ModifierKeys.Alt;
            }
            if (mKeys.HasFlag(forms.Keys.Shift))
            {
                wKey = wKey | wpf.ModifierKeys.Shift;
            }

            return(wKey);
        }
예제 #4
0
        public override void OnMouseMove(PointF location, System.Windows.Forms.Keys keys, System.Windows.Forms.MouseButtons buttons)
        {
            base.OnMouseMove(location, keys, buttons);
            if (mouseDown)
            {
                if (Type == SelectionType.FreeForm)
                {
                    path.AddLine(mouseInit, location);
                    mouseInit = location;
                }
                else
                {
                    path.Dispose();
                    path = new GraphicsPath();
                    var pos = new PointF(
                        Math.Min(mouseInit.X, location.X),
                        Math.Min(mouseInit.Y, location.Y)
                        );
                    var size = new SizeF(
                        Math.Abs(mouseInit.X - location.X),
                        Math.Abs(mouseInit.Y - location.Y)
                        );
                    if (keys.HasFlag(Keys.Shift))
                    {
                        var min = Math.Min(size.Width, size.Height);
                        if (location.X < mouseInit.X && size.Width > min)
                        {
                            pos.X += size.Width - min;
                        }
                        if (location.Y < mouseInit.Y && size.Height > min)
                        {
                            pos.Y += size.Height - min;
                        }
                        size = new SizeF(min, min);
                    }
                    switch (Type)
                    {
                    case SelectionType.Rectangle:
                        path.AddRectangle(new RectangleF(pos, size));
                        break;

                    case SelectionType.Ellipse:
                        path.AddEllipse(new RectangleF(pos, size));
                        break;
                    }
                }
                Invalidate();
            }
        }
예제 #5
0
 protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
 {
     //The problem addressed here had to do with tab wonkiness with MDI forms.
     //When you tabbed forward through the inner WPF control to the end, the tab focus would jump out of the
     //form and into the next control or MDI child window under the MDI form.
     //As best I could tell, the tab logic was being confused by MDI.
     //The solution used here is to reflect out methods on the KeyboardNavigation class
     //to determine what the next/previous item would be in the tab order.
     //(The exact parameters were gleaned by disassembling the private
     //bool Navigate(DependencyObject currentElement, TraversalRequest request, ModifierKeys modifierKeys, DependencyObject firstElement)
     //method on the KeyboardNavigation class.
     //If the destination element is null, then the end of the tab order had been reached.
     //Instead of relying on the base ProcessCmdKey, specifically tell the IKeyboardInputSink HwndSource
     //to move to the beginning or end of the embedded WPF tab order.
     if (keyData == Keys.Tab)
     {
         var FocusedElement = Keyboard.FocusedElement as UIElement;
         if (FocusedElement != null)
         {
             DependencyObject         DestinationElement = null;
             FocusNavigationDirection Direction;
             if (keyData.HasFlag(Keys.Shift))
             {
                 Direction          = FocusNavigationDirection.Last;
                 DestinationElement = GetPrevTab(FocusedElement, null, false);
             }
             else
             {
                 Direction          = FocusNavigationDirection.First;
                 DestinationElement = GetNextTab(FocusedElement, GetGroupParent(FocusedElement, true), false);
             }
             if (DestinationElement == null)
             {
                 return(this.Sink.TabInto(new TraversalRequest(Direction)));
             }
         }
     }
     return(base.ProcessCmdKey(ref msg, keyData));
 }