Example #1
0
 public AddApplicationForm(IEnumerable <string> groups, IEnumerable <string> sets, Application application)
 {
     InitializeComponent();
     _groups     = groups;
     _sets       = sets;
     Application = application;
 }
Example #2
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxName.Text))
            {
                MessageBox.Show("Application name is empty.", "Add Application", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(textBoxPath.Text))
            {
                MessageBox.Show("Application path is empty.", "Add Application", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string group = (comboBoxGroups.SelectedItem != null && string.IsNullOrEmpty((string)comboBoxGroups.SelectedItem) ? null : (string)comboBoxGroups.SelectedItem);

            if (Edit)
            {
                Application.Name      = textBoxName.Text;
                Application.Path      = textBoxPath.Text;
                Application.Arguments = textBoxArguments.Text;
                Application.Group     = group;
            }
            else
            {
                Application = new Application(textBoxName.Text, textBoxPath.Text, textBoxArguments.Text, group);
            }
            Application.Sets.Clear();
            foreach (string set in listViewSets.SelectedItems.Cast <ListViewItem>().Select(item => item.Text))
            {
                Application.Sets.Add(set);
            }
            DialogResult = DialogResult.OK;
        }