示例#1
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
        }
示例#2
0
        private void tSB_delete_Click(object sender, EventArgs e)
        {
            ListView.SelectedListViewItemCollection items;
            items = listView_GesturesActions.SelectedItems;
            string msg;

            if (items.Count == 0)
            {
                return;
            }
            else if (items.Count == 1)
            {
                msg = String.Format(MW_msgText_deleteGesture, m_gestures[items[0].Name].Caption);
            }
            else
            {
                msg = MW_msgText_deleteMultiple;
            }


            if (MessageBox.Show(this, msg, MW_msgCaption_warning, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                List <string> curvesToDelete = new List <string>();
                listView_GesturesActions.BeginUpdate();

                for (int i = listView_GesturesActions.SelectedItems.Count; i > 0; i--)
                {
                    string itemId = listView_GesturesActions.SelectedItems[i - 1].Name;
                    if (m_gestures[itemId].ID != TypeOfAction.AppGroupOptions.APP_GROUP_GLOBAL)
                    {
                        if (m_gestures[itemId].IsGroup && !m_gestures.IsEmptyGroup(m_gestures[itemId]))
                        {
                            MessageBox.Show(this, MW_msgText_errNotEmptyGroup, MW_msgCaption_error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            iL_actions.Images.RemoveByKey(m_gestures[itemId].ID);
                            iL_gestures.Images.RemoveByKey(m_gestures[itemId].ID);
                            m_engine.ImgListActions.Images.RemoveByKey(m_gestures[itemId].ID);

                            listView_GesturesActions.ResizeColumn = true; //will resize column
                            listView_GesturesActions.Items.RemoveAt(m_gestures[itemId].Index);
                            bool   classicCurve = m_gestures[itemId].Activator.Type == BaseActivator.Types.ClassicCurve;
                            string curve        = m_gestures.Remove(m_gestures[itemId]);
                            if (curve != string.Empty && classicCurve)
                            {
                                curvesToDelete.Add(curve);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(this, MW_msgText_errCantDelGlobal, MW_msgCaption_error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                listView_GesturesActions.EndUpdate();
                listView_GesturesActions.Refresh(); //will resize column
                m_engine.Network.LoadCurves();
                m_engine.Network.UnlearnCurves(curvesToDelete.ToArray(), false);
                CheckButtonsState();
                listView_GesturesActions.Update();
                SaveSettings();
                RedrawGesture();
            }
        }
示例#3
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
        }