Exemplo n.º 1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            u3tbChooseButton chooseDlg = new u3tbChooseButton();

            chooseDlg.lbButtonsList.Items.Clear();
            foreach (u3tbButton button in buttonsList)
            {
                chooseDlg.lbButtonsList.Items.Add(button);
            }
            if (chooseDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (chooseDlg.lbButtonsList.CheckedItems.Count > 0)
                {
                    u3tbButton        button = chooseDlg.lbButtonsList.CheckedItems[0] as u3tbButton;
                    int               index  = chooseDlg.lbButtonsList.CheckedIndices[0];
                    u3tbAddButtonForm addDlg = new u3tbAddButtonForm();
                    if (addDlg.ShowDialogEdit(button) == System.Windows.Forms.DialogResult.OK)
                    {
                        u3tbButton newButton = new u3tbButton();
                        newButton.title = addDlg.textTitle.Text;
                        if (addDlg.cbType.Text == "Command")
                        {
                            newButton.type    = u3tbButtonType.ButtonCommand;
                            newButton.command = addDlg.textCommand.Text;
                            newButton.param1  = addDlg.textParam1.Text;
                        }
                        if (addDlg.cbType.Text == "Notepad")
                        {
                            newButton.type = u3tbButtonType.ButtonNotepad;
                        }
                        buttonsList.RemoveAt(index);
                        buttonsList.Insert(index, newButton);
                        createButtons();
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            u3tbChooseButton chooseDlg = new u3tbChooseButton();

            chooseDlg.lbButtonsList.Items.Clear();
            foreach (u3tbButton button in buttonsList)
            {
                chooseDlg.lbButtonsList.Items.Add(button);
            }
            if (chooseDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (chooseDlg.lbButtonsList.CheckedItems.Count > 0)
                {
                    foreach (u3tbButton button in chooseDlg.lbButtonsList.CheckedItems)
                    {
                        if (button.type == u3tbButtonType.ButtonNotepad)
                        {
                            if (File.Exists(u3tbUtilities.getHomePath() + "\\" + button.title_no_spaces() + ".rtf"))
                            {
                                switch (MessageBox.Show(
                                            "The file containing your note exists on the disk.\nDo you want to remove it?",
                                            "u3Toolbox",
                                            MessageBoxButtons.YesNoCancel))
                                {
                                case System.Windows.Forms.DialogResult.Yes:
                                    switch (MessageBox.Show(
                                                "Are you sure you want to remove the file\n" + u3tbUtilities.getHomePath() + "\\" + button.title_no_spaces() + ".rtf ?",
                                                "u3Toolbox",
                                                MessageBoxButtons.YesNoCancel))
                                    {
                                    case System.Windows.Forms.DialogResult.Yes:
                                        try
                                        {
                                            File.Delete(u3tbUtilities.getHomePath() + "\\" + button.title_no_spaces() + ".rtf");
                                        }
                                        catch
                                        {
                                            MessageBox.Show("Couldn't delete the file\n" +
                                                            u3tbUtilities.getHomePath() + "\\" + button.title_no_spaces() + ".rtf\n" +
                                                            "Leaving it in its current location."
                                                            );
                                        }
                                        buttonsList.Remove(button);
                                        break;

                                    case System.Windows.Forms.DialogResult.No:
                                        continue;

                                    case System.Windows.Forms.DialogResult.Cancel:
                                        continue;
                                    }
                                    break;

                                case System.Windows.Forms.DialogResult.No:
                                    switch (MessageBox.Show(
                                                "Preserving the file\n" + u3tbUtilities.getHomePath() + "\\" + button.title_no_spaces() + ".rtf\n" +
                                                "Do you want to move it to your documents folder?",
                                                "u3Toolbox",
                                                MessageBoxButtons.YesNoCancel))
                                    {
                                    case System.Windows.Forms.DialogResult.Yes:
                                        try
                                        {
                                            File.Move(
                                                u3tbUtilities.getHomePath() + "\\" + button.title_no_spaces() + ".rtf",
                                                u3tbUtilities.getMyDocumentsPath() + "\\" + button.title_no_spaces() + ".rtf"
                                                );
                                        }
                                        catch
                                        {
                                            MessageBox.Show("Couldn't move the file\n" +
                                                            u3tbUtilities.getHomePath() + "\\" + button.title_no_spaces() + ".rtf\n" +
                                                            "to " + u3tbUtilities.getMyDocumentsPath() + "\\" + button.title_no_spaces() + ".rtf !\n" +
                                                            "Leaving it in its current location."
                                                            );
                                        }
                                        buttonsList.Remove(button);
                                        break;

                                    case System.Windows.Forms.DialogResult.No:
                                        buttonsList.Remove(button);
                                        break;

                                    case System.Windows.Forms.DialogResult.Cancel:
                                        continue;
                                    }
                                    break;

                                case System.Windows.Forms.DialogResult.Cancel:
                                    continue;
                                }
                            }
                            else
                            {
                                buttonsList.Remove(button);
                            }
                        }
                        else
                        {
                            buttonsList.Remove(button);
                        }
                    }
                    createButtons();
                }
            }
        }