Esempio n. 1
0
        private void FolderContextMenuItem_OnClick(object sender, EventArgs e)
        {
            MenuItem menuItem = (MenuItem)sender;

            if (menuItem.Text == "New Command")
            {
                Form newCommandForm = new NewCommandForm(this);
                newCommandForm.Show();
                Hide();
            }
            else if (menuItem.Text == "Delete Folder")
            {
                var confirmResult = MessageBox.Show("Are you sure? Deleting a folder will also delete all its commands.", "Confirm Delete", MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    var folder = settings.Profile.Folders.First(f => f.Name == treeView1.SelectedNode.Text);
                    settings.Profile.Folders.Remove(folder);
                    dataRepository.SaveProfile(settings.Profile);
                    treeView1.Nodes.Remove(treeView1.SelectedNode);
                }
            }
        }
Esempio n. 2
0
        private void CommandContextMenuItem_OnClick(object sender, EventArgs e)
        {
            MenuItem menuItem = (MenuItem)sender;

            if (menuItem.Text == "Edit Command")
            {
                Form newCommandForm = new NewCommandForm(this, treeView1.SelectedNode.Parent.Text, treeView1.SelectedNode.Text);
                Hide();
                newCommandForm.Show();
            }
            else if (menuItem.Text == "Delete Command")
            {
                var confirmResult = MessageBox.Show("Are you sure? You want to delete this command?.", "Confirm Delete", MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    var folder  = settings.Profile.Folders.First(f => f.Name == treeView1.SelectedNode.Parent.Text);
                    var command = folder.Commands.First(c => c.Name == treeView1.SelectedNode.Text);
                    folder.Commands.Remove(command);
                    dataRepository.SaveProfile(settings.Profile);
                    treeView1.Nodes.Remove(treeView1.SelectedNode);
                }
            }
        }