예제 #1
0
 private void button_next_Click(object sender, EventArgs e)
 {
     if (btn_next.DialogResult == DialogResult.OK)
     {
         if (!m_appMode)
         {
             m_network = uc_gesture.MyNNetwork;
             foreach (MyGesture group in uc_actions.NewGroups)
             {
                 m_newGestures.Add(group);
             }
             foreach (MyGesture group in uc_actions.SelectedGroups)
             {
                 string    id   = MyGesture.CreateUniqueId(m_tempGesture, m_gestures);
                 MyGesture gest = new MyGesture(id);
                 gest.SetItem(m_tempGesture);
                 gest.Activator = m_tempGesture.Activator;
                 gest.Action    = m_tempGesture.Action;
                 gest.AppGroup  = group;
                 m_newGestures.Add(gest);
                 m_gestures.Add(gest);
             }
         }
         else
         {
             string    id   = MyGesture.CreateUniqueId(m_tempGesture, m_gestures);
             MyGesture gest = new MyGesture(id);
             gest.SetItem(m_tempGesture);
             gest.Action    = m_tempGesture.Action;
             gest.Activator = new MouseActivator(string.Empty, MouseActivator.Types.Undefined);
             m_newGestures.Add(gest);
         }
     }
     MoveToPage(m_currentControl.Next);
 }
예제 #2
0
        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;

        }
예제 #3
0
 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;
 }
예제 #4
0
        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
        }
예제 #5
0
        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
        }