Esempio n. 1
0
 public AddProcessWindow(ProcessToMonitor processToEdit, ProcessToMonitor[] allProcesses)
     : this(allProcesses)
 {
     this.Title               = Wsapm.Resources.Wsapm.AddProcessWindow_TitleEdit;
     this.editProcessCopy     = processToEdit;
     this.textBoxProcess.Text = processToEdit.ProcessName;
 }
Esempio n. 2
0
        private void buttonOK_Click(object sender, RoutedEventArgs e)
        {
            var processStr = this.textBoxProcess.Text.Trim();

            if (string.IsNullOrEmpty(processStr))
            {
                MessageBox.Show(String.Format(Wsapm.Resources.Wsapm.AddProcessWindow_NoInfoError, Environment.NewLine), Wsapm.Resources.Wsapm.General_MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            // Avoid to add a element twice.
            if (this.editProcessCopy == null)
            {
                // Add new mode.
                if (this.allProcesses != null)
                {
                    for (int i = 0; i < this.allProcesses.Length; i++)
                    {
                        if (this.allProcesses[i].ProcessName == processStr)
                        {
                            MessageBox.Show(String.Format(Wsapm.Resources.Wsapm.AddProcessWindow_ProcessAlreadyAdded, processStr), Wsapm.Resources.Wsapm.General_MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }
                    }
                }
            }
            else
            {
                // Edit mode.
                if (processStr == this.editProcessCopy.ProcessName)
                {
                    // Element was not changed.
                    this.DialogResult = false;
                    this.Close();
                    return;
                }
                else
                {
                    // Element was changed.
                    if (this.allProcesses != null)
                    {
                        for (int i = 0; i < this.allProcesses.Length; i++)
                        {
                            if (this.allProcesses[i].ProcessName == processStr)
                            {
                                MessageBox.Show(String.Format(Wsapm.Resources.Wsapm.AddProcessWindow_ProcessAlreadyAdded, processStr), Wsapm.Resources.Wsapm.General_MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error);
                                return;
                            }
                        }
                    }
                }
            }

            this.process      = new ProcessToMonitor(processStr);
            this.DialogResult = true;
            this.Close();
        }