예제 #1
0
        private void addNewProfileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            listBox1.BackColor = Color.White;

            //Prompt for profile name.
            string[] promptValues = NewProfilePrompt.ShowDialog(string.Empty, string.Empty, string.Empty, "Add new profile");

            if (string.IsNullOrWhiteSpace(promptValues[0]))
            {
                AddLog("Error: can't use empty profile name. Cancelled.");
                return;
            }

            //Check if it already exists.
            for (int i = 0; i < comboBox1.Items.Count; i++)
            {
                string comboboxText = (comboBox1.Items[i]).ToString();

                if (string.Compare(comboboxText, promptValues[0], StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    listBox1.BackColor = Color.Pink;
                    AddLog(string.Format("Error: profile '{0}' already exists.", promptValues[0]));
                    return;
                }
            }

            ProjectProfile newProfile = new ProjectProfile();

            newProfile.profilename = promptValues[0];

            int appIDvalue = 0;

            if (int.TryParse(promptValues[1], out appIDvalue))
            {
                toolStripStatusLabel_appid.Text = promptValues[1];
                newProfile.appid = appIDvalue;
            }
            else
            {
                AddLog(string.Format("ERROR: ignoring invalid appid '{0}'", promptValues[1]));
            }

            toolStripStatusLabel_description.Text = promptValues[2];
            newProfile.description = promptValues[2];

            //newProfile.description
            profiles.Add(newProfile);

            comboBox1.Items.Add(promptValues[0]);
            comboBox1.SelectedIndex = comboBox1.FindStringExact(promptValues[0]);

            AddLog(string.Empty);
            AddLog(string.Format("Added new profile: {0}", promptValues[0]));
            listBox1.BackColor = Color.White;
            SetButtonsEnabled(true);
        }
예제 #2
0
        private void configureThisProfileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Modify existing profile.

            listBox1.BackColor = Color.White;

            if (comboBox1.SelectedIndex < 0)
            {
                listBox1.BackColor = Color.Pink;
                AddLog("Error: no profile selected.");
                return;
            }

            string curProfilename = profiles[comboBox1.SelectedIndex].profilename;
            string curAppid       = profiles[comboBox1.SelectedIndex].appid.ToString();
            string curDesc        = profiles[comboBox1.SelectedIndex].description;



            string[] promptValues = NewProfilePrompt.ShowDialog(curProfilename, curAppid, curDesc, "Modify current profile");

            bool modified = ((curProfilename != promptValues[0]) ||
                             (curAppid.ToString() != promptValues[1]) ||
                             (curDesc != promptValues[2]));

            //Set appid.
            int appIDvalue = 0;

            if (int.TryParse(promptValues[1], out appIDvalue))
            {
                toolStripStatusLabel_appid.Text         = promptValues[1];
                profiles[comboBox1.SelectedIndex].appid = appIDvalue;
            }
            else
            {
                AddLog(string.Format("ERROR: ignoring invalid appid '{0}'", promptValues[1]));
            }

            //Set description.
            toolStripStatusLabel_description.Text         = promptValues[2];
            profiles[comboBox1.SelectedIndex].description = promptValues[2];


            //Set profilename. Check if it already exists.
            if (string.IsNullOrWhiteSpace(promptValues[0]))
            {
                AddLog("Error: profile name can't be empty.");
                return;
            }

            for (int i = 0; i < comboBox1.Items.Count; i++)
            {
                string comboboxText = (comboBox1.Items[i]).ToString();

                if (string.Compare(comboboxText, promptValues[0], StringComparison.InvariantCultureIgnoreCase) == 0 && comboBox1.SelectedIndex != i)
                {
                    listBox1.BackColor = Color.Pink;
                    AddLog(string.Format("Error: profile '{0}' already exists.", promptValues[0]));
                    return;
                }
            }

            profiles[comboBox1.SelectedIndex].profilename = promptValues[0];
            comboBox1.Items[comboBox1.SelectedIndex]      = promptValues[0];

            if (modified)
            {
                AddLog("Profile settings have been updated.");
            }
        }