Esempio n. 1
0
        private void btnRenameProfile_Click(object sender, EventArgs e)
        {
            ProfileData profileToRename;

            profileToRename = (ProfileData)lstProfiles.SelectedItem;

            if (profileToRename != null)
            {
                ProfileNameDialog pnd = new ProfileNameDialog()
                {
                    ProfileName = profileToRename.Name
                };
                pnd.ShowDialog(this);

                if (pnd.DialogResult == DialogResult.OK && pnd.ProductName != "")
                {
                    profileToRename.Name = pnd.ProfileName;

                    foreach (ToolStripMenuItem tsi in NotificationMenu.Items.OfType <ToolStripMenuItem>())
                    {
                        if (tsi.Tag == profileToRename)
                        {
                            tsi.Text = profileToRename.Name;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        // ----- PROFILES UI ------
        #region Profiles

        private void BtnNewProfile_Click(object sender, EventArgs e)
        {
            ProfileNameDialog pnd = new ProfileNameDialog()
            {
                ProfileName = ""
            };

            pnd.ShowDialog(this);

            if (pnd.DialogResult == DialogResult.Cancel)
            {
                return;
            }

            if (pnd.ProfileName != "")
            {
                // Verify in the profile name already exists
                foreach (ProfileData p in _profiles.ProfileList)
                {
                    if (p.Name == pnd.ProfileName)
                    {
                        MessageBox.Show("Name already exists.");
                        return;
                    }
                }

                if (pnd.DialogResult == DialogResult.OK && pnd.ProductName != "")
                {
                    // Create the new profile
                    ProfileData newProfile = new ProfileData(pnd.ProfileName);
                    _profiles.ProfileList.Add(newProfile);

                    ToolStripMenuItem newToolStripMenuItem = new ToolStripMenuItem(newProfile.Name, null, ToolStripMenuItemProfile_click)
                    {
                        Tag = newProfile
                    };

                    NotificationMenu.Items.Add(newToolStripMenuItem);
                }
            }
        }