private void button_motion_list_modify_Click(object sender, EventArgs e) { try { ListView.SelectedListViewItemCollection items = listView_motion_data.SelectedItems; if (items.Count > 0) { ListViewItem lvItem = items[0]; AddMotionData motionDataAdd = new AddMotionData(AddMotionData.MotionDataMode.Modify); motionDataAdd.ItemName = lvItem.Text; for (int i = 1; i < items[0].SubItems.Count; i++) { string posVal = lvItem.SubItems[i].Text; if (posVal == null) { motionDataAdd.ListAxisPosValue.Add(""); } else { motionDataAdd.ListAxisPosValue.Add(posVal); } } if (motionDataAdd.ShowDialog() == DialogResult.OK) { lvItem.Text = motionDataAdd.ItemName; for (int i = 0; i < motionDataAdd.ListAxisPosValue.Count; i++) { lvItem.SubItems[i + 1].Text = String.Format("{0}", motionDataAdd.ListAxisPosValue[i]); } } SaveData(Application.StartupPath.ToString() + "\\motionAbsPosData"); } } catch (Exception E) { LogFile.LogExceptionErr(E.ToString()); MessageBox.Show(E.Message); } }
private void button_motion_list_add_Click(object sender, EventArgs e) { try { AddMotionData motionDataAdd = new AddMotionData(AddMotionData.MotionDataMode.Add); if (motionDataAdd.ShowDialog() == DialogResult.OK) { ListViewItem item = new ListViewItem(motionDataAdd.ItemName); for (int i = 0; i < motionDataAdd.ListAxisPosValue.Count; i++) { item.SubItems.Add(String.Format("{0}", motionDataAdd.ListAxisPosValue[i])); } listView_motion_data.Items.Add(item); SaveData(Application.StartupPath.ToString() + "\\motionAbsPosData"); } } catch (Exception E) { LogFile.LogExceptionErr(E.ToString()); MessageBox.Show(E.Message); } }