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!"); } } }
private void button3_Click(object sender, EventArgs e) { if (buttonWidth.Text == "") { buttonWidth.Text = "80"; } if (buttonHeight.Text == "") { buttonHeight.Text = "28"; } if (buttonTargetList.Text == null) { buttonTargetList.SelectedIndex = 0; } Demobutton.Tag = textX.Text + "_" + textY.Text; Form1 lForm1 = (Form1)this.Owner;//把Form2的父窗口指針賦給lForm1 lForm1.Rebutton = Demobutton; lForm1.RebuttonTarget = buttonTargetList.SelectedItem.ToString(); for (int i = 0; i < memoryData.ButtonData.Count; i++) { ButtonObjstruct edit = (ButtonObjstruct)memoryData.ButtonData[i]; if (edit.name == buttonName) { edit.AlignImage = Demobutton.ImageAlign.ToString(); edit.AlignText = Demobutton.TextAlign.ToString(); edit.backColor = Demobutton.BackColor.ToArgb(); if (Demobutton.Image != null) { edit.backImage = imagePath; } else { edit.backImage = null; } edit.command = buttonTargetList.Text; edit.font = Demobutton.Font; edit.forecolor = Demobutton.ForeColor.ToArgb(); edit.height = Demobutton.Size.Height; edit.text = Demobutton.Text; edit.width = Demobutton.Size.Width; edit.x = int.Parse(textX.Text); edit.y = int.Parse(textY.Text); if (backgroundimage.Checked == true) { edit.useBackIMG = true; edit.useBackColor = false; edit.backImage = imagePath; } else if (backgroundcolor.Checked == true) { edit.useBackIMG = false; edit.useBackColor = true; edit.backImage = ""; } else if (backgroundcolor.Checked == false && backgroundimage.Checked == false) { edit.useBackIMG = false; edit.useBackColor = false; edit.backImage = ""; } memoryData.ButtonData[i] = edit; break; } } this.Close(); }
private void layerRenameCmd_Click(object sender, EventArgs e) { if (layerListBox.SelectedItem != null) { if (layerListBox.SelectedIndex != 0) { for (int i = 0; i < memoryData.LayerData.Count; i++) { Layerstruct getVal = (Layerstruct)memoryData.LayerData[i]; if (getVal.name == layerListBox.Text) { getVal.name = layerName.Text; memoryData.LayerData[i] = getVal; break; } } for (int i = 0; i < memoryData.LabelData.Count; i++) { LabelObjstruct edit = (LabelObjstruct)memoryData.LabelData[i]; if (edit.layer == layerListBox.Text) { edit.layer = layerName.Text; memoryData.LabelData[i] = edit; } } for (int i = 0; i < memoryData.ButtonData.Count; i++) { ButtonObjstruct edit = (ButtonObjstruct)memoryData.ButtonData[i]; if (edit.layer == layerListBox.Text) { edit.layer = layerName.Text; memoryData.ButtonData[i] = edit; } } for (int i = 0; i < memoryData.InputData.Count; i++) { InputObjectstruct edit = (InputObjectstruct)memoryData.InputData[i]; if (edit.layer == layerListBox.Text) { edit.layer = layerName.Text; memoryData.InputData[i] = edit; } } for (int i = 0; i < memoryData.OutputButtonData.Count; i++) { OutputButtonObjectstruct edit = (OutputButtonObjectstruct)memoryData.OutputButtonData[i]; if (edit.layer == layerListBox.Text) { edit.layer = layerName.Text; memoryData.OutputButtonData[i] = edit; } } for (int i = 0; i < memoryData.OutputTextData.Count; i++) { OutputTextObjectstruct edit = (OutputTextObjectstruct)memoryData.OutputTextData[i]; if (edit.layer == layerListBox.Text) { edit.layer = layerName.Text; memoryData.OutputTextData[i] = edit; } } for (int i = 0; i < memoryData.OutputPopData.Count; i++) { OutputPopObjectstruct edit = (OutputPopObjectstruct)memoryData.OutputPopData[i]; if (edit.layer == layerListBox.Text) { edit.layer = layerName.Text; memoryData.OutputPopData[i] = edit; } } for (int i = 0; i < memoryData.PictureData.Count; i++) { PictureboxObjectstruct edit = (PictureboxObjectstruct)memoryData.PictureData[i]; if (edit.layer == layerListBox.Text) { edit.layer = layerName.Text; memoryData.PictureData[i] = edit; } } for (int i = 0; i < memoryData.AlarmData.Count; i++) { AlarmObjectstruct edit = (AlarmObjectstruct)memoryData.AlarmData[i]; if (edit.layer == layerListBox.Text) { edit.layer = layerName.Text; memoryData.AlarmData[i] = edit; } } layerListBox.Items[layerListBox.SelectedIndex] = layerName.Text; } else { MessageBox.Show("bottom layer can not rename!"); } } }
private void config_ButtonObject_Load(object sender, EventArgs e) { for (int i = 0; i < getLayerItem.Items.Count; i++) { buttonTargetList.Items.Add(getLayerItem.Items[i].ToString()); } buttonTargetList.SelectedIndex = 0; for (int i = 0; i < memoryData.ButtonData.Count; i++) { ButtonObjstruct lo = (ButtonObjstruct)memoryData.ButtonData[i]; if (lo.name == buttonName) { if (lo.AlignText == "BottomCenter") { textAlign.SelectedIndex = 0; Demobutton.TextAlign = ContentAlignment.BottomCenter; } else if (lo.AlignText == "BottomLeft") { textAlign.SelectedIndex = 1; Demobutton.TextAlign = ContentAlignment.BottomLeft; } else if (lo.AlignText == "BottomRight") { textAlign.SelectedIndex = 2; Demobutton.TextAlign = ContentAlignment.BottomRight; } else if (lo.AlignText == "MiddleCenter") { textAlign.SelectedIndex = 3; Demobutton.TextAlign = ContentAlignment.MiddleCenter; } else if (lo.AlignText == "MiddleLeft") { textAlign.SelectedIndex = 4; Demobutton.TextAlign = ContentAlignment.MiddleLeft; } else if (lo.AlignText == "MiddleRight") { textAlign.SelectedIndex = 5; Demobutton.TextAlign = ContentAlignment.MiddleRight; } else if (lo.AlignText == "TopCenter") { textAlign.SelectedIndex = 6; Demobutton.TextAlign = ContentAlignment.TopCenter; } else if (lo.AlignText == "TopLeft") { textAlign.SelectedIndex = 7; Demobutton.TextAlign = ContentAlignment.TopLeft; } else if (lo.AlignText == "TopRight") { textAlign.SelectedIndex = 8; Demobutton.TextAlign = ContentAlignment.TopRight; } if (lo.AlignImage == "BottomCenter") { imageAlign.SelectedIndex = 0; Demobutton.ImageAlign = ContentAlignment.BottomCenter; } else if (lo.AlignImage == "BottomLeft") { imageAlign.SelectedIndex = 1; Demobutton.ImageAlign = ContentAlignment.BottomLeft; } else if (lo.AlignImage == "BottomRight") { imageAlign.SelectedIndex = 2; Demobutton.ImageAlign = ContentAlignment.BottomRight; } else if (lo.AlignImage == "MiddleCenter") { imageAlign.SelectedIndex = 3; Demobutton.ImageAlign = ContentAlignment.MiddleCenter; } else if (lo.AlignImage == "MiddleLeft") { imageAlign.SelectedIndex = 4; Demobutton.ImageAlign = ContentAlignment.MiddleLeft; } else if (lo.AlignImage == "MiddleRight") { imageAlign.SelectedIndex = 5; Demobutton.ImageAlign = ContentAlignment.MiddleRight; } else if (lo.AlignImage == "TopCenter") { imageAlign.SelectedIndex = 6; Demobutton.ImageAlign = ContentAlignment.TopCenter; } else if (lo.AlignImage == "TopLeft") { imageAlign.SelectedIndex = 7; Demobutton.ImageAlign = ContentAlignment.TopLeft; } else if (lo.AlignImage == "TopRight") { imageAlign.SelectedIndex = 8; Demobutton.ImageAlign = ContentAlignment.TopRight; } Demobutton.BackColor = Color.FromArgb(lo.backColor); if (lo.backImage != null && lo.backImage != "") { Demobutton.Image = Image.FromFile(lo.backImage); imagePath = lo.backImage; } if (lo.useBackIMG == true) { backgroundimage.Checked = true; } else if (lo.useBackColor == true) { backgroundcolor.Checked = true; } Demobutton.AutoSize = true; buttonTargetList.SelectedItem = lo.command; Demobutton.Font = lo.font; Demobutton.ForeColor = Color.FromArgb(lo.forecolor); //buttonHeight .Text = lo.height.ToString(); //buttonWidth.Text = lo.width.ToString(); //Demobutton.Size = new Size(lo.width, lo.height); buttonText.Text = lo.text; Demobutton.Text = lo.text; buttonWidth.Text = Demobutton.Size.Width.ToString(); buttonHeight.Text = Demobutton.Size.Height.ToString(); textX.Text = lo.x.ToString(); textY.Text = lo.y.ToString(); } } }