示例#1
0
        private object BackEndInsert(String name, RightClickShellType type, String Target, String Source)
        {
            RightClickShell added;
            RightClickShell parent = (DirectoryShell)treeView1.SelectedNode.Tag;

            switch (type)
            {
            case RightClickShellType.DirectoryShell:
                added = new DirectoryShell()
                {
                    Name = name
                };
                insert_deleted.Add(ref parent, ref added);
                break;

            case RightClickShellType.ExecutableShell:
                added = new ExecutableShell()
                {
                    Name = name, Command = ExecutableShell.CreateCommandFromSorceAndTarget(target: txtTarget.Text, source: txtSource.Text), HaveIcon = txtSource.Text + "\\" + txtTarget.Text
                };
                insert_deleted.Add(ref parent, ref added);
                break;

            default:
                added = new DirectoryShell()
                {
                    Name = name
                };
                throw new Exception("not a intended rightclickshelltype");
            }
            return(added);
        }
示例#2
0
        private static void Insert()
        {
            Console.Write("Name:");
            String name = Console.ReadLine();

            Console.Write("Type:");
            RightClickShellType type = (RightClickShellType)int.Parse(Console.ReadLine());
            RightClickShell     added;

            switch (type)
            {
            case RightClickShellType.DirectoryShell:
                added = new DirectoryShell()
                {
                    Name = name
                };
                insert_deleted.Add(ref cursor, ref added);
                break;

            case RightClickShellType.ExecutableShell:
                added = new ExecutableShell()
                {
                    Name = name, Command = "MyCommand"
                };
                insert_deleted.Add(ref cursor, ref added);
                break;
            }
        }
示例#3
0
        private void btnApplyofEdit_Click(object sender, EventArgs e)
        {
            TreeNode            current_node = treeView1.SelectedNode;
            RightClickShellType AddType      = CheckRadioButton();

            if (txtName.Text == String.Empty)
            {
                MessageBox.Show("Your Name is empty!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (AddType == RightClickShellType.ExecutableShell)
            {
                if (txtSource.Text == String.Empty || txtTarget.Text == String.Empty)
                {
                    MessageBox.Show("Your Name is empty!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
            /* Back-end stuff*/
            RightClickShell current_shell = (RightClickShell)current_node.Tag;

            insert_deleted.EditNode(ref current_shell, name: txtName.Text, target: txtTarget.Text, source: txtSource.Text, cbIcon.Checked);
            current_node.Text = txtName.Text;
            if (cbIcon.Checked)
            {
                if (string.IsNullOrWhiteSpace(txtSource.Text) || string.IsNullOrWhiteSpace(txtTarget.Text))
                {
                    MessageBox.Show("Missing source or target", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                Icon icon = Icon.ExtractAssociatedIcon(txtSource.Text + "\\" + txtTarget.Text);
                treeView1.ImageList.Images.Add(icon);
                current_node.SelectedImageIndex = treeView1.ImageList.Images.Count - 1;
                current_node.ImageIndex         = treeView1.ImageList.Images.Count - 1;
            }
            else
            {
                treeView1.ImageList.Images.RemoveAt(treeView1.ImageList.Images.Count - 1);
                current_node.SelectedImageIndex = -1;
                current_node.ImageIndex         = -1;
            }

            btnAdd.Enabled            = true;
            btnDelete.Enabled         = true;
            btnExpandCollapse.Enabled = true;
            btnCancel.Hide();
            btnApplyofEdit.Hide();
            btnRevert.Show();
            btnApply.Show();
            rdBtnDirectory.Checked  = false;
            rdBtnExecutable.Checked = false;
            rdBtnDirectory.Enabled  = true;
            rdBtnExecutable.Enabled = true;
            cbIcon.Checked          = false;
        }
示例#4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode != null)
            {
                if (((RightClickShell)treeView1.SelectedNode.Tag).Type != RightClickShellType.DirectoryShell)
                {
                    MessageBox.Show("You Cannot Add into This.", "Error");
                    return;
                }
                RightClickShellType AddType = CheckRadioButton();
                RightClickShell     p       = (DirectoryShell)treeView1.SelectedNode.Tag;
                object tag = insert_deleted.AddWithInformations(txtName.Text, txtTarget.Text, txtSource.Text, AddType, ref p, cbIcon.Checked);
                if (string.IsNullOrWhiteSpace(txtName.Text))
                {
                    MessageBox.Show("Fill name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                else
                {
                    TreeNode current_node = treeView1.SelectedNode;
                    TreeNode target_node  = new TreeNode();
                    target_node.Text = "*" + txtName.Text;
                    target_node.Tag  = tag;
                    current_node.Nodes.Add(target_node);
                    if (cbIcon.Checked)
                    {
                        Icon icon = Icon.ExtractAssociatedIcon(txtSource.Text + "\\" + txtTarget.Text);
                        treeView1.ImageList.Images.Add(icon);
                        target_node.SelectedImageIndex = treeView1.ImageList.Images.Count - 1;
                        target_node.ImageIndex         = treeView1.ImageList.Images.Count - 1;
                    }
                }
            }
            else
            {
                MessageBox.Show("Select a node", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            txtName.ResetText();
            txtSource.ResetText();
            txtTarget.ResetText();
            cbIcon.Checked = false;
        }