private void buttonRenameMultiple_Click(object sender, EventArgs e)
        {
            if (listViewOutputs.SelectedItems.Count <= 1)
                return;

            List<string> oldNames = new List<string>();
            foreach (ListViewItem selectedItem in listViewOutputs.SelectedItems) {
                oldNames.Add(selectedItem.SubItems[1].Text);
            }

            using (NameGenerator nameGenerator = new NameGenerator(oldNames)) {
                if (nameGenerator.ShowDialog() == DialogResult.OK) {
                    for (int i = 0; i < listViewOutputs.SelectedItems.Count; i++) {
                        if (i >= nameGenerator.Names.Count) {
                            VixenSystem.Logging.Warning("ConfigControllersOutputs: renaming outputs, and ran out of new names!");
                            break;
                        }
                        int outputIndex = int.Parse(listViewOutputs.SelectedItems[i].Text) - 1;
                        _controller.Outputs[outputIndex].Name = nameGenerator.Names[i];
                    }

                    _populateOutputsList();
                    _populateFormWithOutput(_selectedOutputIndex, true);
                }
            }
        }
Example #2
0
        public void RenameSelectedElements()
        {
            if (treeview.SelectedNodes.Count > 0)
            {
                List <string> oldNames = new List <string>(treeview.SelectedNodes.Select(x => x.Tag as ElementNode).Select(x => x.Name).ToArray());
                NameGenerator renamer  = new NameGenerator(oldNames.ToArray());
                if (renamer.ShowDialog() == DialogResult.OK)
                {
                    for (int i = 0; i < treeview.SelectedNodes.Count; i++)
                    {
                        if (i >= renamer.Names.Count)
                        {
                            Logging.Warn("ConfigElements: bulk renaming elements, and ran out of new names!");
                            break;
                        }
                        (treeview.SelectedNodes[i].Tag as ElementNode).Name = renamer.Names[i];
                    }

                    PopulateNodeTree();
                }
            }
        }
Example #3
0
        public IEnumerable <ElementNode> AddMultipleNodesWithPrompt(ElementNode parent = null)
        {
            List <ElementNode> result = new List <ElementNode>();

            // since we're adding multiple nodes, prompt with the name generation form (which also includes a counter on there).
            using (NameGenerator nameGenerator = new NameGenerator()) {
                if (nameGenerator.ShowDialog() == DialogResult.OK)
                {
                    result.AddRange(
                        nameGenerator.Names.Where(name => !string.IsNullOrEmpty(name)).Select(
                            name => AddNewNode(name, false, parent, true)));
                    if (result == null || result.Count() == 0)
                    {
                        MessageBox.Show("Could not create elements.  Ensure you use a valid name and try again.");
                        return(result);
                    }
                    PopulateNodeTree(result.FirstOrDefault());
                }
            }

            return(result);
        }
Example #4
0
        public bool RenameSelectedElements()
        {
            if (SelectedTreeNodes.Count == 0)
                return false;

            if (SelectedTreeNodes.Count == 1) {
                using (TextDialog dialog = new TextDialog("Item name?", "Rename item", (SelectedNode).Name, true)) {
                    if (dialog.ShowDialog() == DialogResult.OK) {
                        if (dialog.Response != string.Empty && dialog.Response != SelectedNode.Name) {
                            VixenSystem.Nodes.RenameNode(SelectedNode, dialog.Response);
                            PopulateNodeTree();

                            return true;
                        }
                    }
                }
            } else if (SelectedTreeNodes.Count > 1) {
                List<string> oldNames = new List<string>(treeview.SelectedNodes.Select(x => x.Tag as ElementNode).Select(x => x.Name).ToArray());
                NameGenerator renamer = new NameGenerator(oldNames.ToArray());
                if (renamer.ShowDialog() == DialogResult.OK) {
                    for (int i = 0; i < treeview.SelectedNodes.Count; i++) {
                        if (i >= renamer.Names.Count) {
                            Logging.Warn("ConfigElements: bulk renaming elements, and ran out of new names!");
                            break;
                        }
                        VixenSystem.Nodes.RenameNode((treeview.SelectedNodes[i].Tag as ElementNode), renamer.Names[i]);
                    }

                    PopulateNodeTree();

                    return true;
                }
            }

            return false;
        }
Example #5
0
        public IEnumerable<ElementNode> AddMultipleNodesWithPrompt(ElementNode parent = null)
        {
            List<ElementNode> result = new List<ElementNode>();

            // since we're adding multiple nodes, prompt with the name generation form (which also includes a counter on there).
            using (NameGenerator nameGenerator = new NameGenerator()) {
                if (nameGenerator.ShowDialog() == DialogResult.OK) {
                    result.AddRange(
                        nameGenerator.Names.Where(name => !string.IsNullOrEmpty(name)).Select(
                            name => AddNewNode(name, false, parent, true)));
                    if (result == null || result.Count() == 0) {
                        MessageBox.Show("Could not create elements.  Ensure you use a valid name and try again.");
                        return result;
                    }
                    PopulateNodeTree(result.FirstOrDefault());
                }
            }

            return result;
        }
Example #6
0
        public IEnumerable<ElementNode> AddMultipleNodesWithPrompt(ElementNode parent = null)
        {
            List<ElementNode> result = new List<ElementNode>();

            // since we're adding multiple nodes, prompt with the name generation form (which also includes a counter on there).

            string newMultiName = "NewName";
            if (treeview.SelectedNode != null)
                newMultiName = treeview.SelectedNode.Text;

                using (NameGenerator nameGenerator = new NameGenerator(newMultiName))
                {
                    if (nameGenerator.ShowDialog() == DialogResult.OK)
                    {
                        result.AddRange(
                            nameGenerator.Names.Where(name => !string.IsNullOrEmpty(name)).Select(
                                name => AddNewNode(name, false, parent, true)));
                        if (result == null || result.Count() == 0)
                        {
                            //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                            MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form.
                            var messageBox = new MessageBoxForm("Could not create elements.  Ensure you use a valid name and try again.", "",
                                false, false);
                            messageBox.ShowDialog();
                            return result;
                        }
                        PopulateNodeTree(result.FirstOrDefault());
                    }
                }

            return result;
        }
Example #7
0
        private IEnumerable<ElementNode> AddMultipleNodesWithPrompt(ElementNode parent = null)
        {
            List<ElementNode> result = new List<ElementNode>();

            // since we're adding multiple nodes, prompt with the name generation form (which also includes a counter on there).
            using (NameGenerator nameGenerator = new NameGenerator()) {
                if (nameGenerator.ShowDialog() == DialogResult.OK) {
                    result.AddRange(nameGenerator.Names.Where(name => !string.IsNullOrEmpty(name)).Select(name => AddNewNode(name, false, parent, true)));
                    PopulateNodeTree();
                }
            }

            return result;
        }
Example #8
0
        private void RenameSelectedElements()
        {
            if (multiSelectTreeviewElementsGroups.SelectedNodes.Count > 0) {
                List<string> oldNames = new List<string>(multiSelectTreeviewElementsGroups.SelectedNodes.Select(x => x.Tag as ElementNode).Select(x => x.Name).ToArray());
                NameGenerator renamer = new NameGenerator(oldNames.ToArray());
                if (renamer.ShowDialog() == DialogResult.OK) {
                    for (int i = 0; i < multiSelectTreeviewElementsGroups.SelectedNodes.Count; i++) {
                        if (i >= renamer.Names.Count) {
                            VixenSystem.Logging.Warning("ConfigElements: bulk renaming elements, and ran out of new names!");
                            break;
                        }
                        (multiSelectTreeviewElementsGroups.SelectedNodes[i].Tag as ElementNode).Name = renamer.Names[i];
                    }

                    PopulateNodeTree();
                    PopulateFormWithNode(_displayedNode, true);
                }
            }
        }
Example #9
0
        public void RenameSelectedElements()
        {
            if (treeview.SelectedNodes.Count > 0) {
                List<string> oldNames = new List<string>(treeview.SelectedNodes.Select(x => x.Tag as ElementNode).Select(x => x.Name).ToArray());
                NameGenerator renamer = new NameGenerator(oldNames.ToArray());
                if (renamer.ShowDialog() == DialogResult.OK) {
                    for (int i = 0; i < treeview.SelectedNodes.Count; i++) {
                        if (i >= renamer.Names.Count) {
                            Logging.Warn("ConfigElements: bulk renaming elements, and ran out of new names!");
                            break;
                        }
                        (treeview.SelectedNodes[i].Tag as ElementNode).Name = renamer.Names[i];
                    }

                    PopulateNodeTree();
                }
            }
        }