private ListViewItem CreateItemListWorkshops(MyWorkshop mw) { ListViewItem lvi = new ListViewItem(mw.Name); lvi.SubItems.Add(mw.Chief.FullName); lvi.SubItems.Add(mw.NumberOfWorkers.ToString()); lvi.SubItems.Add(mw[0].Name + "..."); return(lvi); }
private void AddItemListWorkshopsForFile(MyWorkshop mw) { ListViewItem lvi = new ListViewItem(mw.Name); lvi.SubItems.Add(mw.Chief.FullName); lvi.SubItems.Add(mw.NumberOfWorkers.ToString()); lvi.SubItems.Add(mw[0].Name + "..."); listWorkshops.Items.Add(lvi); }
private void listWorkshops_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { if (listWorkshops.FocusedItem != null) { if (workshops.ContainsKey(listWorkshops.FocusedItem.Text)) { currentWorkshop = workshops[listWorkshops.FocusedItem.Text]; } } }
private void AddItemListWorkshops(MyWorkshop mw) { ListViewItem lvi = new ListViewItem(mw.Name); lvi.SubItems.Add(mw.Chief.FullName); lvi.SubItems.Add(mw.NumberOfWorkers.ToString()); lvi.SubItems.Add(mw[0].Name + "..."); listWorkshops.Items.Add(lvi); listWorkshops.Items[listWorkshops.Items.IndexOf(lvi)].Focused = true; listWorkshops.Items[listWorkshops.Items.IndexOf(lvi)].Selected = true; }
public void Paste() { Form1 frm = (Form1)this.MdiParent; currentWorkshop = frm.BufferedWorkshop; if (!workshops.ContainsKey(currentWorkshop.Name)) { workshops.Add(currentWorkshop.Name, currentWorkshop); AddItemListWorkshops(currentWorkshop); } frm.BufferedWorkshop = null; }
private void OuterAdd(MyWorkshop[] works) { for (int i = 0; i < works.Length; i++) { if (!workshops.ContainsKey(works[i].Name)) { workshops.Add(works[i].Name, works[i]); AddItemListWorkshopsForFile(works[i]); currentWorkshop = works[i]; } } listWorkshops.Items[listWorkshops.Items.Count - 1].Focused = true; listWorkshops.Items[listWorkshops.Items.Count - 1].Selected = true; }
//private void listWorkshops_SelectedIndexChanged(object sender, EventArgs e) //{ // currentWorkshop = workshops[listWorkshops.FocusedItem.Text]; //} private void EditWorkshop() { if (listWorkshops.FocusedItem != null) { int index = listWorkshops.Items.IndexOf(listWorkshops.FocusedItem); workshops.Remove(currentWorkshop.Name); EditItemForm eif = new EditItemForm(currentWorkshop); eif.ShowDialog(); currentWorkshop = eif.EditedWorkshop; workshops.Add(currentWorkshop.Name, currentWorkshop); ListViewItem lvi2 = CreateItemListWorkshops(currentWorkshop); listWorkshops.Items[index] = lvi2; } else { MessageBox.Show("Выберите элемент из списка"); } }
private void Add() { AddItemForm aif = new AddItemForm(); aif.ShowDialog(); if (aif.AddedWorkshop.Name != "Отмена") { if (aif.AddedWorkshop.Name != "" && aif.AddedWorkshop.ListOfTheProductRange.Count > 0) { currentWorkshop = aif.AddedWorkshop; workshops.Add(currentWorkshop.Name, currentWorkshop); AddItemListWorkshops(currentWorkshop); } else { MessageBox.Show("Введены неверные данные"); return; } } else { return; } }
public EditItemForm(MyWorkshop editedWorkshop) { InitializeComponent(); mw = editedWorkshop; }