示例#1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool isURL = IsURL(txbItem.Text);

            Item = new StartupItem(0, txbItem.Text, (int)numOffset.Value,
                                   isURL ? "" : txbWorkingDirectory.Text,
                                   isURL ? "" : txbArguments.Text,
                                   stateChoices[cmbState.SelectedIndex]);
        }
示例#2
0
        public void EditStartupItem(StartupItem oldItem, StartupItem newItem)
        {
            if (!items.Contains(oldItem))
            {
                Debug.WriteLine("Manager items does not contain " + oldItem.ToString());
                return;
            }

            items.Remove(oldItem);
            items.Add(newItem);

            SortItems();

            IsSaveRequired = true;
        }
示例#3
0
        private void Remove()
        {
            if (listViewItems.SelectedIndices.Count == 0)
            {
                return;
            }

            // Get the selected index - first is fine as multi-select is off
            int index = listViewItems.SelectedIndices[0];

            StartupItem item = manager.GetItems().ElementAt(index);

            manager.RemoveStartupItem(item);

            PopulateListView(new List <StartupItem>(manager.GetItems()));
            UpdateUI();
        }
示例#4
0
        private void SetupDialog(StartupItem item)
        {
            try
            {
                numOffset.Maximum = Convert.ToInt32(ConfigurationManager.AppSettings["UpperTimeLimit"]);
            }
            catch (FormatException)
            {
                numOffset.Maximum = DefaultUpperTimeLimit;
            }

            foreach (ProcessWindowStyle style in stateChoices)
            {
                cmbState.Items.Add(style.ToString());
            }

            // Populate Fields
            txbItem.Text             = item.Item;
            numOffset.Value          = item.Offset;
            txbWorkingDirectory.Text = item.WorkingDirectory;
            txbArguments.Text        = item.Arguments;
            cmbState.SelectedIndex   = stateChoices.IndexOf(item.WindowState);

            // Validate input and update UI appropriately
            bool isURL = IsURL(txbItem.Text);

            btnChooseWorkingDir.Enabled = !isURL;
            ckbParentDir.Enabled        = !isURL;
            txbArguments.Enabled        = !isURL;

            Height -= grpAdvanced.Height;
            grpAdvanced.Visible = false;

            if (txbItem.Text == "")
            {
                ckbParentDir.Enabled = false;
            }

            txbItem.Focus();
        }
示例#5
0
        private void Edit()
        {
            if (listViewItems.SelectedIndices.Count == 0)
            {
                return;
            }

            // Get the selected index - first is fine as multi-select is off
            int index = listViewItems.SelectedIndices[0];

            StartupItem item = manager.GetItems().ElementAt(index);

            using (ItemDialog dialog = new ItemDialog(item))
            {
                DialogResult result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    manager.EditStartupItem(item, dialog.Item);
                    PopulateListView(new List <StartupItem>(manager.GetItems()));
                    UpdateUI();
                }
            }
        }
示例#6
0
        public void RemoveStartupItem(StartupItem item)
        {
            items.Remove(item);

            IsSaveRequired = true;
        }
示例#7
0
 public void AddStartupItem(StartupItem item)
 {
     items.Add(item);
     SortItems();
     IsSaveRequired = true;
 }
示例#8
0
        public int CompareTo(object obj)
        {
            StartupItem other = obj as StartupItem;

            return(Offset.CompareTo(other.Offset));
        }
示例#9
0
 public ItemDialog(StartupItem item = null)
 {
     InitializeComponent();
     Item = item == null ? new StartupItem(0, "", 0, "", "") : item;
     SetupDialog(Item);
 }