Beispiel #1
0
 bool ProcessKeyDownOnFloatingObjectSelected(KeyStroke ks)
 {
     if ((((ks.KeyCode != VirtualKey.Z) || (ks.Modifiers != VirtualKeyModifiers.Control)) && ((ks.KeyCode != VirtualKey.Y) || (ks.Modifiers != VirtualKeyModifiers.Control))) && (HasSelectedFloatingObject() || FloatingObjectKeyMap.ContainsKey(ks)))
     {
         SpreadAction action = null;
         if (FloatingObjectKeyMap.TryGetValue(ks, out action) && (action != null))
         {
             ActionEventArgs e = new ActionEventArgs();
             action(this, e);
             return(e.Handled);
         }
     }
     return(false);
 }
Beispiel #2
0
 void OnKeyUp(object sender, KeyRoutedEventArgs e)
 {
     UpdateCursorType();
     if (!IsEditing)
     {
         bool       flag;
         bool       flag2;
         VirtualKey keyCode = e.Key;
         KeyboardHelper.GetMetaKeyState(out flag, out flag2);
         VirtualKeyModifiers none = VirtualKeyModifiers.None;
         if (flag2)
         {
             none |= VirtualKeyModifiers.Control;
         }
         if (flag)
         {
             none |= VirtualKeyModifiers.None | VirtualKeyModifiers.Shift;
         }
         KeyStroke stroke = new KeyStroke(keyCode, none, true);
         if (KeyMap.ContainsKey(stroke))
         {
             SpreadAction action = KeyMap[stroke];
             if (action != null)
             {
                 ActionEventArgs args = new ActionEventArgs();
                 action(this, args);
                 if (args.Handled)
                 {
                     e.Handled = true;
                 }
             }
         }
     }
     if (IsDragDropping)
     {
         SwitchDragDropIndicator();
     }
 }
Beispiel #3
0
        void OnKeyDown(object sender, KeyRoutedEventArgs e)
        {
            if ((_tabStrip != null) && _tabStrip.IsEditing)
            {
                if ((e.Key == (VirtualKey)13) || (e.Key == (VirtualKey)9))
                {
                    _tabStrip.StopTabEditing(false);
                    e.Handled = true;
                }
                else if (e.Key == (VirtualKey)0x1b)
                {
                    _tabStrip.StopTabEditing(true);
                }
                return;
            }

            bool flag2;
            bool flag3;
            bool flag4;
            bool flag = AllowEnterEditing(e);

            if (InputDeviceType == InputDeviceType.Touch)
            {
                RefreshSelection();
            }
            InputDeviceType = InputDeviceType.Keyboard;
            UpdateCursorType();
            VirtualKey keyCode = e.Key;

            if (keyCode == VirtualKey.Enter)
            {
                Worksheet activeSheet = ActiveSheet;
                if (EditorInfo.Sheet != activeSheet)
                {
                    int index = activeSheet.Workbook.Sheets.IndexOf(EditorInfo.Sheet);
                    activeSheet.Workbook.ActiveSheetIndex = index;
                    StopCellEditing(false);
                    e.Handled = true;
                    return;
                }
            }
            KeyboardHelper.GetMetaKeyState(out flag3, out flag2, out flag4);
            VirtualKeyModifiers none = VirtualKeyModifiers.None;

            if (flag2)
            {
                none |= VirtualKeyModifiers.Control;
            }
            if (flag3)
            {
                none |= VirtualKeyModifiers.None | VirtualKeyModifiers.Shift;
            }
            if (flag4)
            {
                none |= VirtualKeyModifiers.Menu;
            }
            KeyStroke ks = new KeyStroke(keyCode, none, false);

            if (ProcessKeyDownOnFloatingObjectSelected(ks))
            {
                e.Handled = true;
            }
            else
            {
                if (KeyMap.ContainsKey(ks))
                {
                    SpreadAction action = KeyMap[ks];
                    if (action != null)
                    {
                        CloseDragFillPopup();
                        ActionEventArgs args = new ActionEventArgs();
                        action(this, args);
                        if (args.Handled)
                        {
                            e.Handled = true;
                        }
                    }
                }
                if (IsDragDropping)
                {
                    SwitchDragDropIndicator();
                }
                else
                {
                    if (!IsEditing && flag)
                    {
                        // Enter状态表示因键盘输入触发,Edit状态表示双击触发
                        StartCellEditing(true, null, EditorStatus.Enter);
                    }
                    if (!IsEditing)
                    {
                        FocusInternal();
                    }
                }
            }
        }