Пример #1
0
        private void gesture_delete_btn_Click(object sender, EventArgs e)
        {
            if (m_nWavingGestureIdx < 0)
            {
                MessageBox.Show("Please select waving gesture!", "Selected Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else
            {
                m_strWavingGestureNames.RemoveAt(m_nWavingGestureIdx);
                m_strWavingGestureEvents.RemoveAt(m_nWavingGestureIdx);
                m_strWavingGestureParts.RemoveAt(m_nWavingGestureIdx);

                using (CsvFileWriter wavingGestureDataWriter = new CsvFileWriter(Application.StartupPath + "/TrainedData/WavingGestures/WavingGestures.csv"))
                {
                    for (int i = 0; i < m_strWavingGestureNames.Count; i++)
                    {
                        CsvRow row = new CsvRow();
                        row.Add(m_strWavingGestureNames[i]);
                        row.Add(m_strWavingGestureParts[i][0]);
                        row.Add(m_strWavingGestureParts[i][1]);
                        row.Add(m_strWavingGestureParts[i][2]);
                        row.Add(m_strWavingGestureEvents[i]);
                        wavingGestureDataWriter.WriteRow(row);
                    }
                }

                waving_gesture_list.Clear();
                m_wavingGestureImages.Images.Clear();

                for (int i = 0; i < m_strWavingGestureNames.Count; i++)
                {
                    try
                    {
                        Bitmap bitmap = (Bitmap)Image.FromFile(Application.StartupPath + "/TrainedData/TrainedGestures/" + m_strWavingGestureParts[i][0] + ".bmp");
                        m_wavingGestureImages.Images.Add(bitmap);
                    }
                    catch
                    {
                        Console.WriteLine("This is not an image file");
                    }
                }

                waving_gesture_list.View           = View.LargeIcon;
                m_wavingGestureImages.ImageSize    = new Size(32, 32);
                waving_gesture_list.LargeImageList = m_gestureImages;

                for (int i = 0; i < m_strWavingGestureNames.Count; i++)
                {
                    ListViewItem item = new ListViewItem();
                    item.ImageIndex = i;
                    item.Text       = m_strWavingGestureNames[i];
                    waving_gesture_list.Items.Add(item);
                }

                if (waving_gesture_list.Items.Count <= 0)
                {
                    gesture_edit_btn.Enabled   = false;
                    gesture_delete_btn.Enabled = false;
                }

                MessageBox.Show("Delete completed!", "Selected Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }