2011-05-23 73 views
2

在下面的代码中,两次调用Zoom(0.1f);Zoom(-0.1f);工作,但我不能触发两个UndoRedoManager.Undo();UndoRedoManager.Redo();呼吁CTRL +ž CTRL +ÿ。我究竟做错了什么?为什么不工作KeyDown CTRL + KEY?

public void WorkspaceKeyDown(KeyEventArgs e) 
{ 
    if (e.Control == true) 
     isCtrlPres = true; 
    if (e.Shift == true) 
     isShiftPres = true; 
    if (e.Control == true && e.KeyCode == Keys.Z) 
    { 
     UndoRedoManager.Undo(); 
    } 
    else if (e.Control == true && e.KeyCode == Keys.Y) 
    { 
     UndoRedoManager.Redo(); 
    } 
    else if (e.Control == true && e.KeyCode == Keys.Oemplus) 
    { 
     Zoom(0.1f); 
    } 
    else if (e.Control == true && e.KeyCode == Keys.OemMinus) 
    { 
     Zoom(-0.1f); 
    } 
+0

你问为什么'按Ctrl +'和'按Ctrl-'不认可? – 2011-05-23 18:56:37

+0

@Rup非常好,我希望我可以upvote编辑。 – 2011-05-23 18:59:01

+0

也许,错误的键盘布局?.. – vines 2011-05-23 19:07:22

回答

0
.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z)));