private void btnDuplicate_Click(object sender, EventArgs e) { if (0 == listViewElements.SelectedItems.Count) { return; } const string ELEMNAME = "ELEMNAME"; var zQuery = new QueryPanelDialog("Duplicate Element", 400, false); zQuery.SetIcon(Properties.Resources.CardMakerIcon); zQuery.AddLabel("Duplicate Element Names are broken up by a line.", 24); zQuery.AddMultiLineTextBox("Element Name(s)", string.Empty, 200, ELEMNAME); if (1 < listViewElements.SelectedItems.Count) { zQuery.Form.Closing += (o, args) => { if (zQuery.Form.DialogResult == DialogResult.Cancel) { return; } var arrayNames = zQuery.GetString(ELEMNAME) .Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); if (arrayNames.Length != listViewElements.SelectedItems.Count) { MessageBox.Show(zQuery.Form, $"Please specify {listViewElements.SelectedItems.Count} element names.", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); args.Cancel = true; } }; } if (DialogResult.OK == zQuery.ShowDialog(this)) { string[] arrayNames = zQuery.GetString(ELEMNAME) .Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); if (1 == listViewElements.SelectedItems.Count) { AddElements(arrayNames, (ProjectLayoutElement) listViewElements.SelectedItems[0].Tag); } else if (arrayNames.Length == listViewElements.SelectedIndices.Count) { var listIndicies = new List<int>(); foreach (int nIdx in listViewElements.SelectedIndices) { listIndicies.Add(nIdx); } listIndicies.Sort(); for (var nIdx = 0; nIdx < arrayNames.Length; nIdx++) { AddElements(new string[] { arrayNames[nIdx] }, (ProjectLayoutElement)listViewElements.Items[listIndicies[nIdx]].Tag); } } } }
private void btnAddElement_Click(object sender, EventArgs e) { const string ELEMNAME = "ELEMNAME"; var zQuery = new QueryPanelDialog("Add Element", 400, false); zQuery.SetIcon(Properties.Resources.CardMakerIcon); zQuery.AddLabel("Element Names are broken up by a line.", 24); zQuery.AddMultiLineTextBox("Element Name(s)", string.Empty, 200, ELEMNAME); if (DialogResult.OK == zQuery.ShowDialog(this)) { var arrayNames = zQuery.GetString(ELEMNAME).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); if (0 < arrayNames.Length) { AddElements(arrayNames, null); ChangeSelectedElement(arrayNames[0]); } } }