2011-05-23 49 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)));