private ToolStripMenuItem[] tSMI_arrayMenu(MyGesture gesture) { double[] lvl = new double[] { }; string postfix = string.Empty; switch (gesture.Action.Name) { case TypeOfAction.WindowOptions.WND_TRANSPARENT: lvl = TypeOfAction.WindowOptions.TransparencyLvl; postfix = "%"; break; case TypeOfAction.VolumeOptions.VOLUME_SET: lvl = TypeOfAction.VolumeOptions.VolumeLvl; postfix = "%"; break; //case TypeOfAction.SpecialControl.SPECIAL_ZOOM: // lvl = TypeOfAction.SpecialControl.ZoomLvl; // postfix = "x"; // break; } ToolStripMenuItem[] items = new ToolStripMenuItem[lvl.Length]; for (int i = 0; i < lvl.Length; i++) { items[i] = new ToolStripMenuItem(); items[i].Text = String.Format("{0} {1}", lvl[i], postfix); items[i].Name = gesture.ID; items[i].Tag = lvl[i].ToString(); } return(items); }
public MyGesture(string id, MyGesture newGesture, MyGesture group) : base(id) { m_action = (BaseActionClass)newGesture.Action.Clone(); m_activator = new MouseActivator(newGesture.m_activator); m_group = group; base.SetItem(newGesture); }
public MyGesture(MyGesture newGesture) : base(newGesture.ID) { m_action = (BaseActionClass)newGesture.Action.Clone(); m_activator = new MouseActivator(newGesture.m_activator); m_group = newGesture.AppGroup; base.SetItem(newGesture); }
private MyGesture(bool isGlobalGroup) : base(TypeOfAction.AppGroupOptions.APP_GROUP_GLOBAL) { m_caption = Languages.Translation.GetText(TypeOfAction.AppGroupOptions.APP_GROUP_GLOBAL); m_action = new AppGroupOptions(AppGroupOptions.APP_GROUP_GLOBAL); m_action.Details = TypeOfAction.AppGroupOptions.APP_GROUP_GLOBAL; m_activator = new MouseActivator(string.Empty, MouseActivator.Types.Undefined); m_group = null; base.SetMainListItem(); }
public static string CreateUniqueId(MyGesture gest, GesturesCollection gestures) { string name = gest.Action.Name; int postfix = 1; while (gestures[name + postfix.ToString()] != null) { postfix++; } return(name + postfix.ToString()); }
public MyGesture(SerializationInfo info, StreamingContext context) : base(info, context) { try { m_action = (BaseActionClass)info.GetValue("Action", typeof(BaseActionClass)); } catch { m_action = new BaseActionClass(); } try { m_activator = (MouseActivator)info.GetValue("Activator", typeof(MouseActivator)); } catch { m_activator = null; } try { m_group = (MyGesture)info.GetValue("Group", typeof(MyGesture)); } catch { m_group = null; } base.SetMainListItem(); m_action.CheckScriptForMouse(); }
void cMS_MatchedGestures_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)e.ClickedItem; // do not close context menu when it contains dropdown menu - it has to open the context menu if (item.DropDown.Items.Count == 0) { form_top.CloseContextMenuAsync(); } m_execute = learntGestures[item.Name]; switch (m_execute.Action.Name) { case TypeOfAction.SpecialOptions.SPECIAL_ZOOM: //int area_width = Math.Abs(area_right - area_left); //int area_height = Math.Abs(area_bottom - area_top); //ga.gAction.Details = string.Format("{0}:{1}:{2}:{3}", area_left, area_top, area_width, area_height); m_execute.Action.Details = string.Format("{0}:{1}:{2}:{3}", 10, 10, 100, 100); break; case TypeOfAction.WindowOptions.WND_TRANSPARENT: if (item.Tag != null) { m_execute.Action.Details = item.Tag.ToString(); } else { return; } break; case TypeOfAction.VolumeOptions.VOLUME_SET: if (item.Tag != null) { m_execute.Action.Details = item.Tag.ToString(); } else { return; } break; } Thread threadExecuteAction = new Thread(new ThreadStart(ExecuteAction)); threadExecuteAction.Name = "Execute Action"; threadExecuteAction.Start(); //ExecuteAction(); }
void MyMouse_WheelBtnAction(MouseEventArgs trigger, ExtraMouseActions action) { Debug.WriteLine(string.Format("MyEngine: WheelBtnAction Trigger: {0} Action: {1}", trigger.Button, action)); if (!m_wheelBtnUsed) { form_top.CloseContextMenu(); } m_cursorPosition = trigger.Location; m_hwndForeWnd = Win32.GetForegroundWindow(); //m_hwndWndToUse = GetWindowToUse(trigger.Location); string name = WheelButton.GetName(trigger.Button); GesturesCollection recognizedGestures = GetRecognizedGestures(name); if (recognizedGestures.Count == 0) { return; } MyGesture gestToExecute = recognizedGestures[0]; if (!m_wheelBtnUsed) { m_wheelBtnUsed = true; ExecuteImplicitOnlyAction(gestToExecute.Action, KeystrokesOptions.MouseAction.TriggerDown, true); } switch (action) { case ExtraMouseActions.WheelDown: ExecuteImplicitOnlyAction(gestToExecute.Action, KeystrokesOptions.MouseAction.WheelDown, false); break; case ExtraMouseActions.WheelUp: ExecuteImplicitOnlyAction(gestToExecute.Action, KeystrokesOptions.MouseAction.WheelUp, false); break; case ExtraMouseActions.None: ExecuteImplicitOnlyAction(gestToExecute.Action, KeystrokesOptions.MouseAction.TriggerUp, false); m_wheelBtnUsed = false; break; } }
private ToolStripMenuItem tSMI_dropDownMenu(MyGesture gesture) { //ToolStripMenuItem tSMI_menu = new ToolStripMenuItem(); //tSMI_menu.Image = gesture.ImageList.Images[gesture.ID]; //tSMI_menu.Text = gesture.ListItem.Caption; //tSMI_menu.Name = gesture.ID; ToolStripMenuItem tSMI_menu = gesture.ToToolStripMenuItem(m_imgListActions); tSMI_menu.DropDown = new ContextMenuStrip(); ((ContextMenuStrip)tSMI_menu.DropDown).Text = form_top.CmsMatchedGestures.Text;//cMS_MatchedGestures.Text; ((ContextMenuStrip)tSMI_menu.DropDown).ShowImageMargin = false; ((ContextMenuStrip)tSMI_menu.DropDown).ShowCheckMargin = false; ((ContextMenuStrip)tSMI_menu.DropDown).ItemClicked += new ToolStripItemClickedEventHandler(cMS_MatchedGestures_ItemClicked); ToolStripMenuItem[] items = tSMI_arrayMenu(gesture); foreach (ToolStripMenuItem item in items) { //form_top.AddItemToCms((ContextMenuStrip)tSMI_menu.DropDown, item); //form_top.AddItemToCms(item); tSMI_menu.DropDownItems.Add(item); } return(tSMI_menu); }
//void MyMouse_MouseBrowseWheel(ExtraMouseHook.WheelAction wheelAction) //{ // switch (wheelAction) // { // case WheelAction.Down: // m_mouse.SimulateMouseAction(MouseAction.LeftDoubleClick); // break; // case WheelAction.Up: // KeyInput.ExecuteKeyInput(AllKeys.KEY_BACK); // break; // } //} void MyMouse_DoubleBtnAction(MouseEventArgs trigger, MouseEventArgs modifier, bool notifyOnly) { Debug.WriteLine(string.Format("MyEngine: DoubleBtnAction {0}/{1} NotifyOnly: {2}", trigger.Button, modifier.Button, notifyOnly)); form_top.CloseContextMenu(); m_cursorPosition = modifier.Location; m_hwndForeWnd = Win32.GetForegroundWindow(); //m_hwndWndToUse = GetWindowToUse(modifier.Location); string name = DoubleButton.GetName(trigger.Button, modifier.Button); if (notifyOnly) { ShowToolTip(name); } else { //form_top.CloseContextMenu(); GesturesCollection recognizedGestures = GetRecognizedGestures(name); if (recognizedGestures.Count == 0) { return; } if (recognizedGestures.Count == 1 && recognizedGestures[0].IsImplicitOnly) { MyGesture gestToExecute = recognizedGestures[0]; ExecuteImplicitOnlyAction(gestToExecute.Action, KeystrokesOptions.MouseAction.ModifierClick, true); } else { m_dblBtnGesturesToExecute = recognizedGestures; //ExecuteDblBtnGestures(); Thread threadExecuteDblBtnGestures = new Thread(new ThreadStart(ExecuteDblBtnGestures)); threadExecuteDblBtnGestures.Start(); } } }
private void ExecuteRecognizedGestures(GesturesCollection recognizedGestures) { //form_top.ClearContextMenu(); int threadID = Thread.CurrentThread.ManagedThreadId; int index = 0; MyGesture gest; switch (recognizedGestures.Count) { case 0: // if curve wasnt recognize then hide form_transparent //form_top.MakeNonTopMost(); break; case 1: gest = recognizedGestures[index]; if (gest.ExecutionType == ExecuteType.Implicit || gest.ExecutionType == ExecuteType.ImplicitIfUnique) { Debug.WriteLine("Execute : " + gest.ID); switch (gest.Action.Name) { case TypeOfAction.SpecialOptions.SPECIAL_ZOOM: //int area_width = Math.Abs(area_right - area_left); //int area_height = Math.Abs(area_bottom - area_top); //recognizedGestures[0].gAction.Details = string.Format("{0}:{1}:{2}:{3}", area_left, area_top, area_width, area_height); gest.Action.Details = string.Format("{0}:{1}:{2}:{3}", 10, 10, 100, 100); goto default; //break; case TypeOfAction.WindowOptions.WND_TRANSPARENT: case TypeOfAction.VolumeOptions.VOLUME_SET: ToolStripMenuItem[] items = tSMI_arrayMenu(gest); if (threadID == m_threadID) { lock (this) { form_top.ClearContextMenu(); } } else { break; } for (int i = 0; i < items.Length; i++) { if (threadID == m_threadID) { lock (this) { form_top.AddItemToCms(items[i]); } } else { break; } } //foreach (ToolStripMenuItem item in items) // form_top.AddItemToCms(cMS_MatchedGestures, item); if (threadID == m_threadID) { lock (this) { form_top.ShowContextMenu(); } } break; default: // gesture was recognized therefore hide the form_transparent //form_top.MakeNonTopMost(); m_execute = gest; //Thread threadExecuteAction = new Thread(new ThreadStart(ExecuteAction)); //threadExecuteAction.Name = "Execute Action"; //threadExecuteAction.Start(); // no need to do it in thread as it is already in one ExecuteAction(); break; } break; } else { goto default; } //break; default: if (threadID == m_threadID) { lock (this) { form_top.ClearContextMenu(); } } for (int i = 0; i < recognizedGestures.Count; i++) { gest = recognizedGestures[i]; if (gest.ExecutionType == ExecuteType.Implicit) { index = i; goto case 1; } if (threadID == m_threadID) { lock (this) { switch (gest.Action.Name) { case TypeOfAction.WindowOptions.WND_TRANSPARENT: case TypeOfAction.VolumeOptions.VOLUME_SET: //case TypeOfAction.SpecialControl.SPECIAL_ZOOM: //form_top.AddItemToCms(cMS_MatchedGestures, tSMI_dropDownMenu(gest)); form_top.AddItemToCms(tSMI_dropDownMenu(gest)); break; default: //ToolStripMenuItem item = new ToolStripMenuItem(); //item.Image = gest.ImageList.Images[gest.ID]; //item.Name = gest.ID; //item.Text = gest.Caption; //form_top.AddItemToCms(cMS_SameGestures, item); //form_top.AddItemToCms(cMS_MatchedGestures, gest.ToToolStripMenuItem(m_imgListActions)); form_top.AddItemToCms(gest.ToToolStripMenuItem(m_imgListActions)); break; } } } } if (threadID == m_threadID) { lock (this) { form_top.ShowContextMenu(); } } break; } }