diff --git a/MetaMorpheus/GUI/MainWindow.xaml b/MetaMorpheus/GUI/MainWindow.xaml index 7c33fd33b..0b3e10473 100644 --- a/MetaMorpheus/GUI/MainWindow.xaml +++ b/MetaMorpheus/GUI/MainWindow.xaml @@ -463,15 +463,15 @@ \ No newline at end of file diff --git a/MetaMorpheus/GUI/TaskWindows/GlycoSearchTaskWindow.xaml.cs b/MetaMorpheus/GUI/TaskWindows/GlycoSearchTaskWindow.xaml.cs index b3d7847e3..4b9aa9217 100644 --- a/MetaMorpheus/GUI/TaskWindows/GlycoSearchTaskWindow.xaml.cs +++ b/MetaMorpheus/GUI/TaskWindows/GlycoSearchTaskWindow.xaml.cs @@ -29,7 +29,7 @@ public partial class GlycoSearchTaskWindow : Window private readonly ObservableCollection FixedModTypeForTreeViewObservableCollection = new ObservableCollection(); private readonly ObservableCollection VariableModTypeForTreeViewObservableCollection = new ObservableCollection(); private CustomFragmentationWindow CustomFragmentationWindow; - + private TaskSettingViewModel TaskSettingViewModel; public GlycoSearchTaskWindow() : this(null) { } @@ -39,7 +39,13 @@ public GlycoSearchTaskWindow(GlycoSearchTask task) InitializeComponent(); PopulateChoices(); TheTask = task ?? new GlycoSearchTask(); - UpdateFieldsFromTask(TheTask); + + + var updateFieldsFromNewTaskAction = (MetaMorpheusTask task) => UpdateFieldsFromTask(task as GlycoSearchTask); + TaskSettingViewModel = new(TheTask, updateFieldsFromNewTaskAction, GetTaskFromGui); + TaskSettingsCtrl.DataContext = TaskSettingViewModel; + setDefaultbutton.DataContext = TaskSettingViewModel; + if (task == null) { @@ -242,15 +248,25 @@ private void CancelButton_Click(object sender, RoutedEventArgs e) } private void SaveButton_Click(object sender, RoutedEventArgs e) + { + GlycoSearchTask task = GetTaskFromGui(); + if (task is null) + return; + + TheTask = task; + DialogResult = true; + } + + private GlycoSearchTask GetTaskFromGui() { string fieldNotUsed = "1"; if (!GlobalGuiSettings.CheckTaskSettingsValidity(PrecusorMsTlTextBox.Text, productMassToleranceTextBox.Text, missedCleavagesTextBox.Text, maxModificationIsoformsTextBox.Text, MinPeptideLengthTextBox.Text, MaxPeptideLengthTextBox.Text, maxThreadsTextBox.Text, minScoreAllowed.Text, - fieldNotUsed, fieldNotUsed, fieldNotUsed, TopNPeaksTextBox.Text, MinRatioTextBox.Text, null, null, numberOfDatabaseSearchesTextBox.Text, TxtBoxMaxModPerPep.Text, + fieldNotUsed, fieldNotUsed, fieldNotUsed, TopNPeaksTextBox.Text, MinRatioTextBox.Text, null, null, numberOfDatabaseSearchesTextBox.Text, TxtBoxMaxModPerPep.Text, fieldNotUsed, null, null, null)) { - return; + return null; } DissociationType dissociationType = GlobalVariables.AllSupportedDissociationTypes[DissociationTypeComboBox.SelectedItem.ToString()]; @@ -393,8 +409,7 @@ private void SaveButton_Click(object sender, RoutedEventArgs e) assumeOrphanPeaksAreZ1Fragments: protease.Name != "top-down"); TheTask.CommonParameters = commonParamsToSave; - - DialogResult = true; + return TheTask; } private void ApmdExpander_Collapsed(object sender, RoutedEventArgs e) @@ -478,7 +493,7 @@ private void OnClosing(object sender, CancelEventArgs e) // remove event handler from timer // keeping it will trigger an exception because the closed window stops existing - CustomFragmentationWindow.Close(); + CustomFragmentationWindow?.Close(); } private void NonSpecificUpdate(object sender, SelectionChangedEventArgs e) diff --git a/MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml b/MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml index 12a517324..d21f2748a 100644 --- a/MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml +++ b/MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml @@ -16,7 +16,7 @@ - + - + + + + + @@ -562,7 +574,7 @@ - + @@ -578,9 +590,8 @@ - - + @@ -603,10 +614,10 @@ - + - - + + @@ -1196,10 +1207,11 @@ - +