コード例 #1
0
 protected override void OnSelectedIndexChanged(EventArgs e)
 {
     if (this.SelectedIndices.Count == 0)
     {
         m_selectedItemCurve = string.Empty;
     }
     else if (this.SelectedIndices.Count == 1)
     {
         m_selectedItemCurve = m_gestures[this.SelectedItems[0].Name].Activator.ID;
     }
     else
     {
         string selectedItemCurve = m_gestures[this.SelectedItems[0].Name].Activator.ID;
         bool   allSame           = true;
         foreach (ListViewItem item in this.SelectedItems)
         {
             if (m_gestures[item.Name].Activator.ID != selectedItemCurve)
             {
                 allSame = false;
             }
         }
         if (allSame)
         {
             m_selectedItemCurve = selectedItemCurve;
         }
         else
         {
             m_selectedItemCurve = string.Empty;
         }
     }
     //if (m_seledtedGroup != null)
     //    GroupItemHit(m_seledtedGroup);
     foreach (MyGesture gest in m_gestures.MatchedGestures(m_selectedItemCurve))
     {
         try { this.Invalidate(gest.Bounds); }
         catch { }
     }
     foreach (MyGesture gest in m_gestures.MatchedGestures(m_prevItemCurve))
     {
         try { this.Invalidate(gest.Bounds); }
         catch { }
     }
     m_prevItemCurve = m_selectedItemCurve;
     base.OnSelectedIndexChanged(e);
 }
コード例 #2
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
        }