示例#1
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Do you want to overwrite the existing file?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                ProcessConfigurationFile processFile = GetProcessFileFromCurrentUiState();

                _processRepo.SaveProcessConfigurationFile(processFile);

                RefreshProcessListBox(processFile);
            }
        }
示例#2
0
        private void RefreshProcessListBox(ProcessConfigurationFile selectedProcessFile = null)
        {
            Processes = _processRepo.Configs?.OrderBy(c => c.Priority)?.ToList();
            ConfigsListBox.ItemsSource = Processes;
            ConfigsListBox.Items.Refresh();

            if (selectedProcessFile != null)
            {
                SelectedProcessFile         = Processes.FirstOrDefault(p => p.Id == selectedProcessFile.Id);
                ConfigsListBox.SelectedItem = SelectedProcessFile;
            }
        }
示例#3
0
        private void CreateProcessButton_Click(object sender, RoutedEventArgs e)
        {
            var id = NewProcessTextBox.Text;

            if (string.IsNullOrEmpty(id))
            {
                MessageBox.Show("You must enter a ID for the new process.");
                return;
            }

            if (!_processRepo.IsSafeId(id))
            {
                MessageBox.Show("A process with this ID already exists");
                return;
            }

            var newFile = new ProcessConfigurationFile
            {
                Id       = id,
                Filename = _processRepo.GetSafeFilename(id),
                Steps    = new List <ProcessStepConfiguration>()
            };

            if (CreateCopyCheckBox.IsChecked == true)
            {
                var selected = SelectedProcessFile;

                newFile.Steps         = selected.Steps;
                newFile.MatchProperty = selected.MatchProperty;
                newFile.MatchValue    = selected.MatchValue;
            }

            if (ChooseExampleImageCheckBox.IsChecked == true && MatchCategoryAndValueComboBox.SelectedItem != null)
            {
                var selected = (KeyValuePair <string, string>)MatchCategoryAndValueComboBox.SelectedItem;

                newFile.MatchProperty = selected.Key;
                newFile.MatchValue    = selected.Value;
            }

            _processRepo.CreateProcessConfigurationFile(newFile);
            RefreshProcessListBox(newFile);

            NewProcessTextBox.Text = string.Empty;
            EnableEditing();
        }