//如果inApp不为null, 则为编辑模式 public EditGestureForm(GestureParser gestureParser, AbstractApp inApp, GestureIntent intent = null) { _gestureParser = gestureParser; _app = inApp; _intent = intent; InitializeComponent(); if (_intent != null) { if (inApp.Find(intent.Gesture) != intent) { throw new InvalidOperationException("intent必须是inApp中的"); } Text = "编辑手势"; lb_mnemonic.Text = _intent.Gesture.ToString(); tb_gestureName.Text = _intent.Name; } BeginCapture(); }
private void GestureParser_GestureCaptured(Gesture gesture) { if (gesture.Count() == 0 && gesture.Modifier == GestureModifier.None) { return; } Debug.WriteLine("GestureCaptured: " + gesture); var formerMnemonic = lb_mnemonic.Text; CapturedGesture = gesture; //if (_intent != null) { var found = _app.Find(gesture); if (found != null && (found != _intent)) { lb_errMsg.Text = "相同手势(" + found.Name + ")已存在,点击‘保存’会将其替代"; flowAlert.Visible = true; } else { flowAlert.Visible = false; } } lb_mnemonic.Text = gesture.ToString(); if (formerMnemonic == tb_gestureName.Text || string.IsNullOrEmpty(tb_gestureName.Text)) { tb_gestureName.Text = lb_mnemonic.Text; tb_gestureName.SelectAll(); tb_gestureName.Focus(); } else { btnOk.Focus(); } btnOk.Enabled = true; }