private void HandleIntentReadyToExecute(GestureIntent intent) { if (!ShowPath && !ShowCommandName) { return; } Debug.WriteLine("WhenIntentReadyToExecute"); if (ShowCommandName) { ShowLabel(Color.White, _labelText, _systemColor);////Color.FromArgb(120, 0, 80, 0)); } //draw DrawAndUpdate(); //clear if (ShowPath) { _pathVisible = false; } if (ShowCommandName) { _labelChanged = false; } if (ViewFadeOut) { FadeOut(); } else { EndView(); } }
private void WhenIntentRecognized(GestureIntent intent) { if (!ShowPath && !ShowCommandName) { return; } Debug.WriteLine("IntentRecognized"); if (ShowCommandName) { var modifierText = intent.Gesture.Modifier.ToMnemonic(); var newLabelText = (modifierText == String.Empty ? String.Empty : (modifierText + " ")) + intent.Name; ShowLabel(Color.White, newLabelText, Color.FromArgb(70, 0, 0, 0)); } if (!_recognized && ShowPath) { _recognized = true; _pathPen = _tempMainPen; //_dirtyRegion.MakeInfinite(); ResetPathDirtyRect(); } DrawAndUpdate(true); if (ShowCommandName) { _labelChanged = false; } }
private void LoadCommandView(GestureIntent intent) { var cmdView = Controller.CommandViewFactory.GetCommandView(intent.Command); if (cmdView != null) { //如果目标视图实现了该接口,则注入选中的app var view = cmdView as ITargetAppAware; if (view != null) { view.TargetApp = GetSelectedAppOrGlobal(); } cmdView.CommandValueChanged -= CommandValueChangedHandler; cmdView.CommandValueChanged += CommandValueChangedHandler; //如果就是先前那个,则不用清除再加载了 if (!panel_commandView.Controls.Contains(cmdView)) { panel_commandView.Controls.Clear(); panel_commandView.Controls.Add(cmdView); } } }
private void HandleIntentRecognized(GestureIntent intent) { if (!ShowPath && !ShowCommandName) { return; } Debug.WriteLine("IntentRecognized"); if (ShowCommandName) { var modifierText = intent.Gesture.Modifier.ToMnemonic(); var newLabelText = intent.Name + (modifierText == String.Empty ? String.Empty : (" " + modifierText)); ShowLabel(Color.White, newLabelText, Color.FromArgb(120, 0, 0, 0)); } if (!_isCurrentRecognized && ShowPath) { _isCurrentRecognized = true; _recognizeStateChanged = true; _pathPen = _tempMainPen; //ResetPathDirtyRect(); } DrawAndUpdate(); if (ShowCommandName) { _labelChanged = false; } _recognizeStateChanged = false; }
//Add Gesture private void btnAddGesture_Click(object sender, EventArgs e) { var app = GetSelectedAppOrGlobal(); if (app == null) { return; } using (var addGestureForm = new AddGestureForm(Controller.GestureParser)) { var ok = addGestureForm.ShowDialog(); if (ok == DialogResult.OK) { var gesture = addGestureForm.CapturedGesture; var name = addGestureForm.GestureName; var gestureIntent = new GestureIntent() { Command = new HotKeyCommand(), Gesture = gesture, Name = name }; AddOrReplaceGestureIntent(gestureIntent); AdjustListGestureIntentsColumnSize(); //add to model app.GestureIntents.AddOrReplace(gestureIntent); } } }
public OrderableIntent(GestureIntent from) { var t = from.GetType(); foreach (var fieldInf in t.GetFields()) { fieldInf.SetValue(this, fieldInf.GetValue(from)); } foreach (var propInf in t.GetProperties()) { propInf.SetValue(this, propInf.GetValue(from, null), null); } }
private void WhenIntentReadyToExecute(GestureIntent intent) { if (!ShowPath && !ShowCommandName) { return; } #if DEBUG Console.WriteLine("WhenIntentReadyToExecute"); #endif //update if (ShowPath) { ResetPathDirtyRect(); } if (ShowCommandName)// && !_gestureParser.PathTracker.IsSuspended { var modifierText = intent.Gesture.Modifier.ToMnemonic(); var newLabelText = (modifierText == String.Empty ? String.Empty : (modifierText + " ")) + intent.Name; ShowLabel(Color.White, newLabelText, Color.FromArgb(120, 0, 0, 0)); } //draw DrawAndUpdate(); //clear if (ShowPath) { _pathVisible = false; } if (ShowCommandName) { _labelChanged = false; } if (ViewFadeOut) { FadeOutTo(0); } else { EndView(); } }
private void LoadCommand(GestureIntent intent) { //SuspendDrawingControl.SuspendDrawing(group_Command); if (!group_Command.Enabled) { group_Command.Enabled = true; } if (group_Command.Text != intent.Name) { group_Command.Text = string.Format("手势 \"{0}\" 的参数", intent.Name); } //根据intent的Gesture是否包WheelDirection来决定是显示“滚动滚轮时立即执行”选框 //check_executeOnMouseWheeling.Text = "识别手势时立即执行"; check_executeOnMouseWheeling.Visible = (intent.Gesture.Modifier != GestureModifier.None); if (check_executeOnMouseWheeling.Visible) //设定其值 { check_executeOnMouseWheeling.Checked = intent.ExecuteOnModifier; } //修改下拉框 bool itemMatched = false; foreach (CommandTypesComboBoxItem item in combo_CommandTypes.Items) { if (item.CommandType == intent.Command.GetType()) { //如果与前一个command相同,则不会引发changed事件,需要手动修改。 if (combo_CommandTypes.SelectedItem == item) { LoadCommandView(intent); } combo_CommandTypes.SelectedItem = item; itemMatched = true; break; } } if (!itemMatched) { combo_CommandTypes.SelectedIndex = -1; } //SuspendDrawingControl.ResumeDrawing(group_Command); }
private ListViewItem AddGestureIntent(GestureIntent intent) { var item = new ListViewItem(intent.Name) { Tag = intent }; var mnemonic = intent.Gesture.ToString(); item.SubItems.Add(mnemonic); item.SubItems.Add(intent.Command.Description()); listGestureIntents.Items.Add(item); return(item); }
private void WhenIntentExecuted(GestureIntent intent, GestureIntent.ExecutionResult result) { //todo:Test return; if (!ShowPath && !ShowCommandName) { return; } #if DEBUG Console.WriteLine("IntentExecuted"); #endif if (ShowPath) { ResetPathDirtyRect(); } if (ShowCommandName) { ShowLabel(Color.White, intent.Name, Color.FromArgb(150, 0, 0, 0)); } DrawAndUpdate(); if (ShowPath) { _pathVisible = false; } if (ShowCommandName) { _labelChanged = false; } if (ViewFadeOut) { FadeOutTo(0); } else { EndView(); } }
private void HandleIntentReadyToExecute(GestureIntent intent) { if (!ShowPath && !ShowCommandName) { return; } Debug.WriteLine("WhenIntentReadyToExecute"); //update //if (ShowPath) ResetPathDirtyRect(); if (ShowCommandName)// && !_gestureParser.PathTracker.IsSuspended { //var modifierText = intent.Gesture.Modifier.ToMnemonic(); //var newLabelText = (modifierText == String.Empty ? String.Empty : (modifierText + " ")) + intent.Name; //if (!newLabelText.Equals(_labelText)) //{ ShowLabel(Color.White, _labelText, Color.FromArgb(120, 0, 0, 0)); //} } //draw DrawAndUpdate(); //clear if (ShowPath) { _pathVisible = false; } if (ShowCommandName) { _labelChanged = false; } if (ViewFadeOut) { FadeOut(); } else { EndView(); } }
//如果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 AddOrReplaceGestureIntent(GestureIntent intent) { listGestureIntents.BeginUpdate(); foreach (ListViewItem item in listGestureIntents.Items) { var current = item.Tag as GestureIntent; if (current.Gesture.Equals(intent.Gesture)) { listGestureIntents.Items.Remove(item); break; } } var i = AddGestureIntent(intent); i.Selected = true; listGestureIntents.Focus(); listGestureIntents.EnsureVisible(i.Index); listGestureIntents.EndUpdate(); }
private void HandleCommandReportStatus(string status, GestureIntent intent) { if (ShowCommandName) { var modifierText = intent.Gesture.Modifier.ToMnemonic(); var newLabelText = (modifierText == String.Empty ? String.Empty : (modifierText + " ")) + intent.Name + status; if (newLabelText.Equals(_labelText)) { return; } _labelText = newLabelText; ShowLabel(Color.White, newLabelText, Color.FromArgb(70, 0, 0, 0)); DrawAndUpdate(); if (ShowCommandName) { _labelChanged = false; } } }