Esempio n. 1
0
 private void btnRemoveRule_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Delete this rule?", "Rule deletion", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
     {
         ((ComboWatcherItem)comboRules.SelectedItem).Watcher.Dispose();
         Watcher.SaveToSettings();
         comboRules.Items.Remove(comboRules.SelectedItem);
         txtFilter.Text    = string.Empty;
         txtMovePath.Text  = string.Empty;
         txtWatchPath.Text = string.Empty;
     }
 }
Esempio n. 2
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            if (comboRules.SelectedIndex != -1)
            {
                if (!Directory.Exists(txtWatchPath.Text))
                {
                    MessageBox.Show("Watch directory " + txtWatchPath.Text + " doesn't exist.", "Something is wrong...", MessageBoxButtons.OK);
                }
                else if (!Directory.Exists(txtMovePath.Text))
                {
                    MessageBox.Show("Move directory " + txtMovePath.Text + " doesn't exist.", "Something is wrong...", MessageBoxButtons.OK);
                }
                else if (txtFilter.Text == "")
                {
                    MessageBox.Show("The filter is empty. Please enter filter. You can use \"*\" and \"?\" symbols. Separate filters by \",\" or \"|\".");
                }
                else
                {
                    ((ComboWatcherItem)comboRules.SelectedItem).Watcher.WatchPath = txtWatchPath.Text;
                    ((ComboWatcherItem)comboRules.SelectedItem).Watcher.MovePath  = txtMovePath.Text;
                    ((ComboWatcherItem)comboRules.SelectedItem).Watcher.Filter    = txtFilter.Text;
                    Watcher.SaveToSettings();

                    //black magic here:
                    ((ComboWatcherItem)comboRules.SelectedItem).Text = txtWatchPath.Text;
                    typeof(ComboBox).InvokeMember("RefreshItems", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.InvokeMethod, null, comboRules, new object[] { });
                }
            }

            if (chkStartup.Checked)
            {
                rkApp.SetValue("Ejik", Application.ExecutablePath.ToString());
            }
            else
            {
                rkApp.DeleteValue("Ejik", false);
            }

            Form1.LastInstance.SetTooltip();
        }