Example #1
0
        void tSMI_groupItem_Click(object sender, EventArgs e)
        {
            string groupKey = ((ToolStripMenuItem)sender).Name;

            if (m_copyGestures)
            {
                ListView.SelectedListViewItemCollection items = listView_GesturesActions.SelectedItems;
                for (int i = 0; i < items.Count; i++)
                {
                    string itemId = items[i].Name;
                    string id     = MyGesture.CreateUniqueId(m_gestures[itemId], m_gestures);
                    //MyGesture gest = new MyGesture(id);
                    //gest.SetItem(m_gestures[pos]);
                    //gest.Activator = m_gestures[pos].Activator;
                    //gest.Action = m_gestures[pos].Action;
                    //gest.AppGroup = m_gestures[groupKey];
                    MyGesture gest = new MyGesture(id, m_gestures[itemId], m_gestures[groupKey]);
                    gest.SetActionIcon(iL_actions);
                    gest.SetActionIcon(m_engine.ImgListActions);
                    gest.SetGestureIcon(iL_gestures);

                    int index = m_gestures.AutoInsert(new MyGesture(gest));
                    listView_GesturesActions.ResizeColumn = true; //will resize columns at the end
                    listView_GesturesActions.Items.Insert(index, m_gestures[index]);
                }
                listView_GesturesActions.Refresh(); //will resize columns at the end
                listView_GesturesActions.Update();
                //listView_GesturesActions.ReselectItems();
                SaveSettings();
                RedrawGesture();
            }
            else //add new gestures
            {
                Form_addGesture addGesture = new Form_addGesture();
                addGesture.SelectedGroups = new List <MyGesture>()
                {
                    m_gestures[groupKey]
                };
                addGesture.Gestures      = new GesturesCollection(m_gestures.GetAll().ToArray());
                addGesture.ShowInTaskbar = false;
                addGesture.MyNNetwork    = new MyNeuralNetwork(m_engine.Network);
                addGesture.MyNNetwork.LoadCurves();
                if (addGesture.ShowDialog() == DialogResult.OK)
                {
                    listView_GesturesActions.BeginUpdate();
                    foreach (MyGesture gesture in addGesture.NewGestures)
                    {
                        gesture.SetActionIcon(iL_actions);
                        gesture.SetActionIcon(m_engine.ImgListActions);
                        gesture.SetGestureIcon(iL_gestures);
                        int index = m_gestures.AutoInsert(new MyGesture(gesture));
                        listView_GesturesActions.ResizeColumn = true; //will resize columns at the end
                        // do not insert it because it should be added into collapsed group
                        if (index != -1)
                        {
                            listView_GesturesActions.Items.Insert(index, m_gestures[index]);
                        }
                    }
                    listView_GesturesActions.EndUpdate();
                    listView_GesturesActions.Refresh(); //will resize columns at the end
                    m_engine.Network = addGesture.MyNNetwork;
                    CheckButtonsState();
                    SaveSettings();
                    RedrawGesture();
                }
            }
        }
Example #2
0
        void tSMI_groupItem_Click(object sender, EventArgs e)
        {
            string groupKey = ((ToolStripMenuItem)sender).Name;
            if (m_copyGestures)
            {
                ListView.SelectedListViewItemCollection items = listView_GesturesActions.SelectedItems;
                for (int i = 0; i < items.Count; i++)
                {
                    string itemId = items[i].Name;
                    string id = MyGesture.CreateUniqueId(m_gestures[itemId], m_gestures);
                    //MyGesture gest = new MyGesture(id);
                    //gest.SetItem(m_gestures[pos]);
                    //gest.Activator = m_gestures[pos].Activator;
                    //gest.Action = m_gestures[pos].Action;
                    //gest.AppGroup = m_gestures[groupKey];
                    MyGesture gest = new MyGesture(id, m_gestures[itemId], m_gestures[groupKey]);
                    gest.SetActionIcon(iL_actions);
                    gest.SetActionIcon(m_engine.ImgListActions);
                    gest.SetGestureIcon(iL_gestures);

                    int index = m_gestures.AutoInsert(new MyGesture(gest));
                    listView_GesturesActions.ResizeColumn = true; //will resize columns at the end
                    listView_GesturesActions.Items.Insert(index, m_gestures[index]);
                }
                listView_GesturesActions.Refresh(); //will resize columns at the end    
                listView_GesturesActions.Update();
                //listView_GesturesActions.ReselectItems();
                SaveSettings();
                RedrawGesture();
            }
            else //add new gestures
            {
                Form_addGesture addGesture = new Form_addGesture();
                addGesture.SelectedGroups = new List<MyGesture>() { m_gestures[groupKey] };
                addGesture.Gestures = new GesturesCollection(m_gestures.GetAll().ToArray());
                addGesture.ShowInTaskbar = false;
                addGesture.MyNNetwork = new MyNeuralNetwork(m_engine.Network);
                addGesture.MyNNetwork.LoadCurves();
                if (addGesture.ShowDialog() == DialogResult.OK)
                {
                    listView_GesturesActions.BeginUpdate();
                    foreach (MyGesture gesture in addGesture.NewGestures)
                    {
                        gesture.SetActionIcon(iL_actions);
                        gesture.SetActionIcon(m_engine.ImgListActions);
                        gesture.SetGestureIcon(iL_gestures);
                        int index = m_gestures.AutoInsert(new MyGesture(gesture));
                        listView_GesturesActions.ResizeColumn = true; //will resize columns at the end
                        // do not insert it because it should be added into collapsed group
                        if (index != -1)
                            listView_GesturesActions.Items.Insert(index, m_gestures[index]);
                    }
                    listView_GesturesActions.EndUpdate();
                    listView_GesturesActions.Refresh(); //will resize columns at the end               
                    m_engine.Network = addGesture.MyNNetwork;
                    CheckButtonsState();
                    SaveSettings();
                    RedrawGesture();
                }
            }

        }