private void SortOrCompare_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ClearErrors();

                if (RowIdentifierSelectedList.Items.Count == 0)
                {
                    ErrorLabel.Content = "Please selected at least one column to use as an identifier.";
                    return;
                }

                DisableButtons();

                var rowIdentifierColumns = RowIdentifierSelectedList.Items.Cast <string>().ToList();

                if (UtilityMode == UtilityModes.Sort)
                {
                    if (SortWindow == null)
                    {
                        SortWindow = new SortingResultsWindow(this);
                    }

                    SortWindow.SetSettings(File1TextBox.Text, rowIdentifierColumns);
                    SortWindow.Show();
                    SortWindow.CreateResults();
                }
                if (UtilityMode == UtilityModes.Compare)
                {
                    var inclusionColumns = ExtraOutputSelectedList.Items.Cast <string>().ToList();
                    var exclusionColumns = CompareExcludeSelectedList.Items.Cast <string>().ToList();
                    var ignoreCase       = CaseInsensitiveCheckBox.IsChecked ?? false;
                    var alreadySorted    = SkipSortCheckBox.IsChecked ?? false;

                    if (ComparisonWindow == null)
                    {
                        ComparisonWindow = new ComparisonResultsWindow(this);
                    }

                    ComparisonWindow.SetSettings(File1TextBox.Text, File2TextBox.Text, rowIdentifierColumns, exclusionColumns, inclusionColumns, ignoreCase, alreadySorted);
                    ComparisonWindow.Show();
                    ComparisonWindow.CreateResults();
                }

                EnableButtons();
                Hide();
            }
            catch (ArgumentException ex) when(ex.Message == "An item with the same key has already been added.")
            {
                ErrorLabel.Content = "The identifier columns are not unique enough. Repeats founds between rows.";
                EnableButtons();
            }
            catch (Exception ex)
            {
                ErrorLabel.Content = $"Error: {ex.Message}{Environment.NewLine} Stack Trace: {ex.StackTrace}";
                EnableButtons();
            }
        }
Пример #2
0
        private void createSortWindow(object parameter)
        {
            SortWindow sortWindow = new SortWindow(Tasks);

            sortWindow.Show();
        }