Пример #1
0
        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);
                    }
                }
            }
        }
Пример #2
0
        private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (0 < m_listClipboardElements.Count)
            {
                Dictionary <string, ProjectLayoutElement> dictionaryExistingElements = null;
                if (null != LayoutManager.Instance.ActiveLayout.Element)
                {
                    dictionaryExistingElements = LayoutManager.Instance.ActiveLayout.Element.ToDictionary(x => x.name);
                }

                if (dictionaryExistingElements != null)
                {
                    if (m_listClipboardElements.Exists(
                            zElement => dictionaryExistingElements.ContainsKey(zElement.name)))
                    {
                        const string ELEMENT_NAMES = "ELEMENT_NAMES";
                        var          zQuery        = new QueryPanelDialog("Duplicate Elements Rename", 400, false);
                        zQuery.SetIcon(Properties.Resources.CardMakerIcon);
                        zQuery.AddLabel("Each line has the name of an element to be pasted.", 24);
                        zQuery.AddLabel("Duplicated element names are marked with *", 24);
                        zQuery.AddMultiLineTextBox("Element Name(s)",
                                                   string.Join(Environment.NewLine, m_listClipboardElements.Select(zElement =>
                        {
                            return(zElement.name + (dictionaryExistingElements.ContainsKey(zElement.name) ? "*" : ""));
                        }).ToList()),
                                                   200,
                                                   ELEMENT_NAMES);

                        if (DialogResult.OK == zQuery.ShowDialog(this))
                        {
                            var arrayNames = zQuery.GetString(ELEMENT_NAMES)
                                             .Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                            if (arrayNames.Length != m_listClipboardElements.Count)
                            {
                                MessageBox.Show(zQuery.Form,
                                                "The number of elements names does not match the clipboard. Cancelling paste.", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                return;
                            }

                            for (var nIdx = 0; nIdx < m_listClipboardElements.Count; nIdx++)
                            {
                                AddElements(new string[] { arrayNames [nIdx] }, m_listClipboardElements[nIdx]);
                            }
                        }
                        return;
                    }
                }
                m_listClipboardElements.ForEach(x => AddElements(new string[] { x.name }, x));
            }
        }
Пример #3
0
        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]);
                }
            }
        }