public ClassicCurve(List<PointF> points, GesturesCollection gestures) { string name = "curve_name"; int postfix = 1; while (gestures.GetCurve(name + postfix.ToString()) != null) postfix++; m_id = name + postfix.ToString(); m_points = MyCurve.CreateExactPath(points, 20, 20); m_bezierCurve = MyCurve.CreateBezierCurve(points); m_type = Types.ClassicCurve; }
public UC_W_baseGesture() { InitializeComponent(); m_gesturesCollection = new GesturesCollection(); gB_gesture.Text = Translation.GetText("W_G_gB_gesture"); lbl_instructions.Text = Translation.GetText("W_G_lbl_instructions"); gB_preview.Text = Translation.GetText("W_G_gB_preview"); gB_activation.Text = Translation.GetText("W_G_gB_activation"); gB_description.Text = Translation.GetText("W_G_gB_description"); toolTip1.SetToolTip(pB_animation, Translation.GetText("W_G_tT_animation")); // Click to animate the gesture. }
public UC_W_baseGesture() { InitializeComponent(); m_gesturesCollection = new GesturesCollection(); gB_gesture.Text = Translation.GetText("W_G_gB_gesture"); lbl_instructions.Text = Translation.GetText("W_G_lbl_instructions"); gB_preview.Text = Translation.GetText("W_G_gB_preview"); gB_activation.Text = Translation.GetText("W_G_gB_activation"); gB_description.Text = Translation.GetText("W_G_gB_description"); toolTip1.SetToolTip(pB_animation, Translation.GetText("W_G_tT_animation")); // Click to animate the gesture. }
public void AddGesturesCollection(GesturesCollection gestures) { m_gestures = gestures; this.ViewMode = (ViewModes)Config.User.LW_viewMode; this.Items.AddRange(gestures.GetAll().ToArray()); //m_gestures.UpdateCollapsedGroups(); //this.Columns[this.Columns.Count - 1].Width = -2; foreach (MyGesture group in m_gestures.Groups) { CollapseExpandGroup(this.Items[group.Index]); } SetLastColumnWidthToEnd(); }
public ClassicCurve(List <PointF> points, GesturesCollection gestures) { string name = "curve_name"; int postfix = 1; while (gestures.GetCurve(name + postfix.ToString()) != null) { postfix++; } m_id = name + postfix.ToString(); m_points = MyCurve.CreateExactPath(points, 20, 20); m_bezierCurve = MyCurve.CreateBezierCurve(points); m_type = Types.ClassicCurve; }
public static void SaveGestures(GesturesCollection gestures) { Stream stream = null; try { stream = File.Open(Config.Default.FilesLocation + GESTURES, FileMode.Create); BinaryFormatter bFormatter = new BinaryFormatter(); bFormatter.Serialize(stream, gestures); } catch (Exception ex) { Debug.WriteLine(ex.Message); } finally { if (stream != null) stream.Close(); } }
public static GesturesCollection LoadGestures() { GesturesCollection gestures = new GesturesCollection(); Stream stream = null; try { stream = File.Open(Config.Default.FilesLocation + GESTURES, FileMode.Open); BinaryFormatter bFormatter = new BinaryFormatter(); gestures = (GesturesCollection)bFormatter.Deserialize(stream); } catch (Exception ex) { Debug.WriteLine(ex.Message); gestures.Add(MyGesture.GlobalGroup); } finally { if (stream != null) stream.Close(); } return gestures; }
public void AddGesturesCollection(GesturesCollection gestures) { m_gestures = gestures; this.ViewMode = (ViewModes)Config.User.LW_viewMode; this.Items.AddRange(gestures.GetAll().ToArray()); //m_gestures.UpdateCollapsedGroups(); //this.Columns[this.Columns.Count - 1].Width = -2; foreach (MyGesture group in m_gestures.Groups) CollapseExpandGroup(this.Items[group.Index]); SetLastColumnWidthToEnd(); }
private GesturesCollection GetRecognizedGestures(string name) { GesturesCollection recognizedGestures = new GesturesCollection(); m_hwndWindowToUse = GetWindowToUse(m_cursorPosition); IntPtr hwnd = m_hwndWindowToUse;// GetWindowToUse(m_cursorPosition); //m_hwndWndToUse; //if (Config.User.handleWndUnderCursor) // hwnd = m_mouse.ActiveWindow; //else // hwnd = m_hwndWndToUse; foreach (MyGesture gesture in learntGestures.MatchedGestures(name)) { if (gesture.IsActive(hwnd)) { recognizedGestures.Add(gesture); if (gesture.ExecutionType == ExecuteType.Implicit || gesture.IsImplicitOnly) { recognizedGestures.Clear(); recognizedGestures.Add(gesture); break; } } } return recognizedGestures; }
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; } }
//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 tSB_modify_Click(object sender, EventArgs e) { if (listView_GesturesActions.SelectedItems.Count == 0 || !PossibleToModify()) { return; } GesturesCollection modify = new GesturesCollection(); GesturesCollection gestures = new GesturesCollection(m_gestures.GetAll().ToArray()); List <string> curvesToDelete = new List <string>(); for (int i = listView_GesturesActions.SelectedItems.Count; i > 0; i--) { string itemId = listView_GesturesActions.SelectedItems[i - 1].Name; modify.Add(new MyGesture(gestures[itemId])); bool classicCurve = gestures[itemId].Activator.Type == BaseActivator.Types.ClassicCurve; string curve = gestures.Remove(gestures[itemId]); if (curve != string.Empty && classicCurve) { curvesToDelete.Add(curve); } } modify.Reverse(); //GesturesCollection gestures = new GesturesCollection(m_gestures.ToArray()); //gestures.RemoveAt(index); Form_modifyGesture modifyGesture = new Form_modifyGesture(); modifyGesture.ModifiedGestures = modify.ToArray(); modifyGesture.Gestures = gestures; modifyGesture.ShowInTaskbar = false; modifyGesture.MyNNetwork = new MyNeuralNetwork(m_engine.Network); modifyGesture.MyNNetworkOriginal = new MyNeuralNetwork(m_engine.Network); modifyGesture.MyNNetwork.LoadCurves(); modifyGesture.MyNNetwork.UnlearnCurves(curvesToDelete.ToArray(), true); if (modify.Count == 1 && modify[0].IsGroup) { modifyGesture.AppMode = true; } if (modifyGesture.ShowDialog() == DialogResult.OK) { m_engine.Network = modifyGesture.MyNNetwork; CheckButtonsState(); listView_GesturesActions.BeginUpdate(); foreach (MyGesture gesture in modifyGesture.ModifiedGestures) { int index = m_gestures[gesture.ID].Index; m_gestures[index] = new MyGesture(gesture); m_gestures[index].SetActionIcon(iL_actions); m_gestures[index].SetGestureIcon(iL_gestures); m_gestures[index].SetActionIcon(m_engine.ImgListActions); if (m_gestures.MatchedGestures(m_gestures[index].Activator.ID).Count == 1) { m_gestures[index].SetGestureIcon(iL_gestures); } listView_GesturesActions.Items[index] = m_gestures[index]; } listView_GesturesActions.EndUpdate(); listView_GesturesActions.Refresh(); //will resize column listView_GesturesActions.Update(); SaveSettings(); RedrawGesture(); } else { } // DialogResult.Cancel }
private void tSB_modify_Click(object sender, EventArgs e) { if (listView_GesturesActions.SelectedItems.Count == 0 || !PossibleToModify()) return; GesturesCollection modify = new GesturesCollection(); GesturesCollection gestures = new GesturesCollection(m_gestures.GetAll().ToArray()); List<string> curvesToDelete = new List<string>(); for (int i = listView_GesturesActions.SelectedItems.Count; i > 0; i--) { string itemId = listView_GesturesActions.SelectedItems[i - 1].Name; modify.Add(new MyGesture(gestures[itemId])); bool classicCurve = gestures[itemId].Activator.Type == BaseActivator.Types.ClassicCurve; string curve = gestures.Remove(gestures[itemId]); if (curve != string.Empty && classicCurve) curvesToDelete.Add(curve); } modify.Reverse(); //GesturesCollection gestures = new GesturesCollection(m_gestures.ToArray()); //gestures.RemoveAt(index); Form_modifyGesture modifyGesture = new Form_modifyGesture(); modifyGesture.ModifiedGestures = modify.ToArray(); modifyGesture.Gestures = gestures; modifyGesture.ShowInTaskbar = false; modifyGesture.MyNNetwork = new MyNeuralNetwork(m_engine.Network); modifyGesture.MyNNetworkOriginal = new MyNeuralNetwork(m_engine.Network); modifyGesture.MyNNetwork.LoadCurves(); modifyGesture.MyNNetwork.UnlearnCurves(curvesToDelete.ToArray(), true); if (modify.Count == 1 && modify[0].IsGroup) { modifyGesture.AppMode = true; } if (modifyGesture.ShowDialog() == DialogResult.OK) { m_engine.Network = modifyGesture.MyNNetwork; CheckButtonsState(); listView_GesturesActions.BeginUpdate(); foreach (MyGesture gesture in modifyGesture.ModifiedGestures) { int index = m_gestures[gesture.ID].Index; m_gestures[index] = new MyGesture(gesture); m_gestures[index].SetActionIcon(iL_actions); m_gestures[index].SetGestureIcon(iL_gestures); m_gestures[index].SetActionIcon(m_engine.ImgListActions); if (m_gestures.MatchedGestures(m_gestures[index].Activator.ID).Count == 1) m_gestures[index].SetGestureIcon(iL_gestures); listView_GesturesActions.Items[index] = m_gestures[index]; } listView_GesturesActions.EndUpdate(); listView_GesturesActions.Refresh(); //will resize column listView_GesturesActions.Update(); SaveSettings(); RedrawGesture(); } else { } // DialogResult.Cancel }
public Form_engine() { InitializeComponent(); m_theForm = this; m_trayIcons = new List<NotifyIcon>(); //m_privateClipboards = new ReadOnlyCollection<ClipData>[ControlItems.UC_clipboard.CLIPS_COUNT]; m_privateTextClipboards = new string[ControlItems.UC_clipboard.CLIPS_COUNT]; // create directory for storing configuration and gestures if it doesn't exists // otherwise nothing will be saved if (!System.IO.Directory.Exists(Config.Default.FilesLocation)) { try { System.IO.Directory.CreateDirectory(Config.Default.FilesLocation); } catch { } } m_gestures = FileOptions.LoadGestures(); List<PrgNamePath> whiteList, blackList, finalList; FileOptions.LoadLists(out whiteList, out blackList, out finalList); m_engine = new MyEngine(); m_engine.LearntGestures = m_gestures; m_engine.Network.Curves = m_gestures.GetCurves(); m_engine.Network.CheckParams(); m_engine.AppStateChanged += new MyEngine.DlgAppStateChanged(AppStateChanged); m_engine.FinalList = finalList; m_engine.SetImageList(); m_engine.ApplySettings(); Microsoft.Win32.SystemEvents.DisplaySettingsChanged += new EventHandler(SystemEvents_DisplaySettingsChanged); Microsoft.Win32.SystemEvents.PowerModeChanged += new Microsoft.Win32.PowerModeChangedEventHandler(SystemEvents_PowerModeChanged); //RegistryEdit.SetWin7AntiBug(); //RegistryEdit.RemWin7AntiBug(); m_activeGestures = true; Translate(); }