private void layerDelAllCmd_Click(object sender, EventArgs e) { string message = "target : " + layerListBox.SelectedItem.ToString(); string caption = "delete layer"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; result = MessageBox.Show(message, caption, buttons); if (result == System.Windows.Forms.DialogResult.Yes) { for (int layerindex = 1; layerindex < memoryData.LayerData.Count; layerindex++) { for (int i = memoryData.ButtonData.Count - 1; i >= 0; i--) { ButtonObjstruct tar = (ButtonObjstruct)memoryData.ButtonData[i]; if (tar.layer == layerListBox.Items[layerindex].ToString()) { memoryData.ButtonData.Remove(tar); int index = memoryData.iconTemp.IndexOf(tar.name); if (index != -1) { memoryData.iconTemp.RemoveAt(index); memoryData.iconDelTemp.Add(tar.name); } } } for (int i = memoryData.LabelData.Count - 1; i >= 0; i--) { LabelObjstruct tar = (LabelObjstruct)memoryData.LabelData[i]; if (tar.layer == layerListBox.Items[layerindex].ToString()) { memoryData.LabelData.Remove(tar); int index = memoryData.iconTemp.IndexOf(tar.name); if (index != -1) { memoryData.iconTemp.RemoveAt(index); memoryData.iconDelTemp.Add(tar.name); } } } for (int i = memoryData.InputData.Count - 1; i >= 0; i--) { InputObjectstruct tar = (InputObjectstruct)memoryData.InputData[i]; if (tar.layer == layerListBox.Items[layerindex].ToString()) { memoryData.InputData.Remove(tar); int index = memoryData.iconTemp.IndexOf(tar.name); if (index != -1) { memoryData.iconTemp.RemoveAt(index); memoryData.iconDelTemp.Add(tar.name); } } } for (int i = memoryData.OutputButtonData.Count - 1; i >= 0; i--) { OutputButtonObjectstruct tar = (OutputButtonObjectstruct)memoryData.OutputButtonData[i]; if (tar.layer == layerListBox.Items[layerindex].ToString()) { memoryData.OutputButtonData.Remove(tar); int index = memoryData.iconTemp.IndexOf(tar.name); if (index != -1) { memoryData.iconTemp.RemoveAt(index); memoryData.iconDelTemp.Add(tar.name); } } } for (int i = memoryData.OutputTextData.Count - 1; i >= 0; i--) { OutputTextObjectstruct tar = (OutputTextObjectstruct)memoryData.OutputTextData[i]; if (tar.layer == layerListBox.Items[layerindex].ToString()) { memoryData.OutputTextData.Remove(tar); int index = memoryData.iconTemp.IndexOf(tar.name); if (index != -1) { memoryData.iconTemp.RemoveAt(index); memoryData.iconDelTemp.Add(tar.name); } } } for (int i = memoryData.OutputPopData.Count - 1; i >= 0; i--) { OutputPopObjectstruct tar = (OutputPopObjectstruct)memoryData.OutputPopData[i]; if (tar.layer == layerListBox.Items[layerindex].ToString()) { memoryData.OutputPopData.Remove(tar); int index = memoryData.iconTemp.IndexOf(tar.name); if (index != -1) { memoryData.iconTemp.RemoveAt(index); memoryData.iconDelTemp.Add(tar.name); } } } for (int i = memoryData.PictureData.Count - 1; i >= 0; i--) { PictureboxObjectstruct tar = (PictureboxObjectstruct)memoryData.PictureData[i]; if (tar.layer == layerListBox.Items[layerindex].ToString()) { memoryData.PictureData.Remove(tar); int index = memoryData.iconTemp.IndexOf(tar.name); if (index != -1) { memoryData.iconTemp.RemoveAt(index); memoryData.iconDelTemp.Add(tar.name); } } } for (int i = memoryData.AlarmData.Count - 1; i >= 0; i--) { AlarmObjectstruct tar = (AlarmObjectstruct)memoryData.AlarmData[i]; if (tar.layer == layerListBox.Items[layerindex].ToString()) { for (int am = 0; am < memoryData.AlarmMonitorValue.Count; am++) { AlarmMoniTorNV edit = (AlarmMoniTorNV)memoryData.AlarmMonitorValue[am]; if (edit.name == tar.name) { memoryData.AlarmMonitorValue.Remove(edit); break; } } memoryData.AlarmData.Remove(tar); int index = memoryData.iconTemp.IndexOf(tar.name); if (index != -1) { memoryData.iconTemp.RemoveAt(index); memoryData.iconDelTemp.Add(tar.name); } } } } } for (int i = layerListBox.Items.Count - 1; i > 0; i--) { layerListBox.Items.RemoveAt(i); memoryData.LayerData.RemoveAt(i); } }
private void layerDelCmd_Click(object sender, EventArgs e) { if (layerListBox.SelectedItem != null) { if (layerListBox.SelectedIndex != 0) { string tarName = layerListBox.Text; string message = "target : " + layerListBox.SelectedItem.ToString(); string caption = "delete layer"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; result = MessageBox.Show(message, caption, buttons); if (result == System.Windows.Forms.DialogResult.Yes) { for (int i = memoryData.AlarmData.Count - 1; i >= 0; i--) { AlarmObjectstruct tar = (AlarmObjectstruct)memoryData.AlarmData[i]; if (tar.layer == tarName) { memoryData.AlarmData.Remove(tar); int index = memoryData.iconTemp.IndexOf(tar.name); if (index != -1) { memoryData.iconTemp.RemoveAt(index); memoryData.iconDelTemp.Add(tar.name); } } for (int a = 0; a < memoryData.AlarmMonitorValue.Count; a++) { AlarmMoniTorNV mtar = (AlarmMoniTorNV)memoryData.AlarmMonitorValue[a]; if (mtar.name == tar.name) { memoryData.AlarmMonitorValue.Remove(mtar); break; } } } for (int i = memoryData.ButtonData.Count - 1; i >= 0; i--) { ButtonObjstruct tar = (ButtonObjstruct)memoryData.ButtonData[i]; if (tar.layer == tarName) { memoryData.ButtonData.Remove(tar); int index = memoryData.iconTemp.IndexOf(tar.name); if (index != -1) { memoryData.iconTemp.RemoveAt(index); memoryData.iconDelTemp.Add(tar.name); } } } for (int i = memoryData.InputData.Count - 1; i >= 0; i--) { InputObjectstruct tar = (InputObjectstruct)memoryData.InputData[i]; if (tar.layer == tarName) { memoryData.InputData.Remove(tar); int index = memoryData.iconTemp.IndexOf(tar.name); if (index != -1) { memoryData.iconTemp.RemoveAt(index); memoryData.iconDelTemp.Add(tar.name); } } } for (int i = memoryData.LabelData.Count - 1; i >= 0; i--) { LabelObjstruct tar = (LabelObjstruct)memoryData.LabelData[i]; if (tar.layer == tarName) { memoryData.LabelData.Remove(tar); int index = memoryData.iconTemp.IndexOf(tar.name); if (index != -1) { memoryData.iconTemp.RemoveAt(index); memoryData.iconDelTemp.Add(tar.name); } } } for (int i = memoryData.OutputButtonData.Count - 1; i >= 0; i--) { OutputButtonObjectstruct tar = (OutputButtonObjectstruct)memoryData.OutputButtonData[i]; if (tar.layer == tarName) { memoryData.OutputButtonData.Remove(tar); int index = memoryData.iconTemp.IndexOf(tar.name); if (index != -1) { memoryData.iconTemp.RemoveAt(index); memoryData.iconDelTemp.Add(tar.name); } } } for (int i = memoryData.OutputPopData.Count - 1; i >= 0; i--) { OutputPopObjectstruct tar = (OutputPopObjectstruct)memoryData.OutputPopData[i]; if (tar.layer == tarName) { memoryData.OutputPopData.Remove(tar); int index = memoryData.iconTemp.IndexOf(tar.name); if (index != -1) { memoryData.iconTemp.RemoveAt(index); memoryData.iconDelTemp.Add(tar.name); } } } for (int i = memoryData.OutputTextData.Count - 1; i >= 0; i--) { OutputTextObjectstruct tar = (OutputTextObjectstruct)memoryData.OutputTextData[i]; if (tar.layer == tarName) { memoryData.OutputTextData.Remove(tar); int index = memoryData.iconTemp.IndexOf(tar.name); if (index != -1) { memoryData.iconTemp.RemoveAt(index); memoryData.iconDelTemp.Add(tar.name); } } } for (int i = memoryData.PictureData.Count - 1; i >= 0; i--) { PictureboxObjectstruct tar = (PictureboxObjectstruct)memoryData.PictureData[i]; if (tar.layer == tarName) { memoryData.PictureData.Remove(tar); int index = memoryData.iconTemp.IndexOf(tar.name); if (index != -1) { memoryData.iconTemp.RemoveAt(index); memoryData.iconDelTemp.Add(tar.name); } } } for (int i = 0; i < memoryData.LayerData.Count; i++) { Layerstruct getVal = (Layerstruct)memoryData.LayerData[i]; if (getVal.name == tarName) { memoryData.LayerData.Remove(memoryData.LayerData[i]); //layerListBox.Items.Remove(layerListBox.SelectedItem); layerListBox.Items.RemoveAt(layerListBox.SelectedIndex); break; } } } } else { MessageBox.Show("bottom layer can not delete!"); } } }