示例#1
0
        private void BtnConfirmation_Click(object sender, EventArgs e)
        {
            commandLine = new CommandItemViewItem
            {
                CommandLine = txtCommandLine.Text,
                Image       = picFileImage.Image
            };

            if (isImagedChanged)
            {
                commandLine.CreateImageKey();
            }

            Close();

            txtCommandLine.Text = string.Empty;
            picFileImage.Image  = null;
        }
示例#2
0
        private void CreateSubNode(TreeNode node, string caption)
        {
            var group = GetGroup(node);

            if (node.Level == 0)
            {
                var nodePrompt = editForm.ShowPrompt(caption, null);
                if (string.IsNullOrWhiteSpace(nodePrompt))
                {
                    return;
                }

                var newNode = new TreeNode
                {
                    Text             = nodePrompt,
                    Name             = nodePrompt,
                    ContextMenuStrip = new ContextMenuStrip()
                };

                var newCommandItem = new CommandItemViewItem {
                    Name = nodePrompt
                };
                group.CommandItems.Add(newCommandItem);

                if (ValidateCollection(newNode, node.Nodes))
                {
                    newNode.ContextMenuStrip.Items.Add(NewUrl, null, (sender, e) => CreateSubNode(newNode, NewCommandLine));
                    newNode.ContextMenuStrip.Items.Add(Edit, null, (sender, e) => EditTreeNode(newNode, Edit));
                    node.Expand();
                }
            }
            else if (node?.Level == 1)
            {
                var newCommandLine = commandLineEditForm.ShowPrompt(string.Empty, null);
                if (newCommandLine is null)
                {
                    return;
                }

                var newCommandLineNode = new HiddenCheckBoxTreeNode
                {
                    Text             = newCommandLine.CommandLine,
                    Name             = newCommandLine.CommandLine,
                    ContextMenuStrip = new ContextMenuStrip()
                };

                if (ValidateCollection(newCommandLineNode, node.Nodes))
                {
                    var commandItem = GetCommandItem(node, group);
                    commandItem.CommandLine = newCommandLine.CommandLine;
                    commandItem.Image       = newCommandLine.Image;

                    commandItem.CreateImageKey();
                    StateImageList.Images.Add(commandItem.ImageKey, commandItem.Image);
                    newCommandLineNode.StateImageKey = commandItem.ImageKey;

                    node.ContextMenuStrip = new ContextMenuStrip();
                    node.ContextMenuStrip.Items.Add(Edit, null, (sender, e) => EditTreeNode(node, Edit));
                    newCommandLineNode.ContextMenuStrip.Items.Add(Edit, null, (sender, e) => EditCommandLineNode(newCommandLineNode));
                    node.Expand();
                }
            }
        }