예제 #1
0
        private string saveButton(u3tbButton button)
        {
            string buttonString = "<Button title=\"" + button.title + "\" ";

            switch (button.type)
            {
            case u3tbButtonType.ButtonCommand:
                buttonString += "type=\"command\" ";
                buttonString += "cmd=\"" + button.command + "\" ";
                if (button.param1 != "")
                {
                    buttonString += "param1=\"" + button.param1 + "\" ";
                }
                break;

            case u3tbButtonType.ButtonNotepad:
                buttonString += "type=\"notepad\" ";
                if (button.wndProperties != null)
                {
                    buttonString += button.wndProperties.XmlString();
                }
                break;
            }
            buttonString += "/>";
            return(buttonString);
        }
예제 #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            u3tbAddButtonForm addDlg = new u3tbAddButtonForm();

            if (addDlg.ShowDialogNew() == System.Windows.Forms.DialogResult.OK)
            {
                u3tbButton button = new u3tbButton();
                button.title = addDlg.textTitle.Text;
                if (addDlg.cbType.Text == "Command")
                {
                    button.type    = u3tbButtonType.ButtonCommand;
                    button.command = addDlg.textCommand.Text;
                    button.param1  = addDlg.textParam1.Text;
                }
                if (addDlg.cbType.Text == "Notepad")
                {
                    button.type = u3tbButtonType.ButtonNotepad;
                }
                if (buttonsList == null)
                {
                    buttonsList = new List <u3tbButton>();
                }
                buttonsList.Add(button);
                createButtons();
            }
        }
예제 #3
0
        public DialogResult ShowDialogEdit(u3tbButton button)
        {
            cbType.Items.Clear();
            cbType.Items.Add("Command");
            cbType.Items.Add("Notepad");

            textTitle.Text = button.title;
            switch (button.type)
            {
            case u3tbButtonType.ButtonCommand:
                cbType.SelectedIndex = cbType.FindStringExact("Command");
                textCommand.Text     = button.command;
                textParam1.Text      = button.param1;
                break;

            case u3tbButtonType.ButtonNotepad:
                cbType.SelectedIndex = cbType.FindStringExact("Notepad");
                break;
            }

            return(ShowDialog());
        }
예제 #4
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();
                    }
                }
            }
        }
예제 #5
0
        private void u3tbLoadConfig()
        {
            XmlDocument cfg = new XmlDocument();

            try
            {
                cfg.Load(u3tbUtilities.getHomePath() + "\\u3ToolboxCfg.xml");
            }
            catch
            {
                return;
            }

            // main app preferencies
            XmlNode prefposnode = cfg.SelectSingleNode("u3Toolbox/Preferences/Position");

            if (prefposnode != null)
            {
                try
                {
                    this.StartPosition = FormStartPosition.Manual;
                    this.DesktopBounds = new Rectangle(
                        Convert.ToInt32(prefposnode.Attributes["left"].InnerText),
                        Convert.ToInt32(prefposnode.Attributes["top"].InnerText),
                        Convert.ToInt32(prefposnode.Attributes["width"].InnerText),
                        Convert.ToInt32(prefposnode.Attributes["height"].InnerText));
                }
                catch
                {
                    this.StartPosition = FormStartPosition.WindowsDefaultBounds;
                }
            }
            XmlNode prefstylenode = cfg.SelectSingleNode("u3Toolbox/Preferences/Style");

            if (prefstylenode != null)
            {
                try
                {
                    string style = prefstylenode.Attributes["name"].InnerText;
                    appStyle.setCurrentStyle(appStyle.findStyleFromName(style));
                }
                catch
                {
                }
            }

            // buttons list
            buttonsList = new List <u3tbButton>();
            foreach (XmlNode node in cfg.SelectNodes("u3Toolbox/Buttons/Button"))
            {
                u3tbButton button = new u3tbButton();
                try
                {
                    button.title = node.Attributes["title"].InnerText;
                }
                catch
                {
                    continue;
                }
                string type = "";
                try
                {
                    type = node.Attributes["type"].InnerText;
                }
                catch
                {
                    type = "";
                }
                switch (type)
                {
                case "command":
                    button.type = u3tbButtonType.ButtonCommand;
                    break;

                case "notepad":
                    button.type = u3tbButtonType.ButtonNotepad;
                    break;

                default:
                    button.type = u3tbButtonType.ButtonCommand;
                    break;
                }

                switch (button.type)
                {
                case u3tbButtonType.ButtonCommand:
                    try
                    {
                        button.command = node.Attributes["cmd"].InnerText;
                    }
                    catch
                    {
                        button.command = "";
                    }
                    try
                    {
                        button.param1 = node.Attributes["param1"].InnerText;
                    }
                    catch
                    {
                        button.param1 = "";
                    }
                    break;

                case u3tbButtonType.ButtonNotepad:
                    try
                    {
                        int left   = Convert.ToInt32(node.Attributes["left"].InnerText);
                        int top    = Convert.ToInt32(node.Attributes["top"].InnerText);
                        int width  = Convert.ToInt32(node.Attributes["width"].InnerText);
                        int height = Convert.ToInt32(node.Attributes["height"].InnerText);
                        button.wndProperties = new u3tbWndProperties(left, top, width, height);
                    }
                    catch
                    {
                    }
                    break;
                }

                if (button.title != "")
                {
                    buttonsList.Add(button);
                }
            }
        }