//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn protected void Selection_Algorithm_SelectionChanged(object sender, EventArgs e) /// /// \brief Event handler. Called by Selection_Algorithm for selection changed events. /// /// \par Description. /// Change the Selection_Network control to hold the networks of the selected algorithm /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 29/11/2017 /// /// \param sender (object) - Source of the event. /// \param e (EventArgs) - Event information. //////////////////////////////////////////////////////////////////////////////////////////////////// protected void Selection_Algorithm_SelectionChanged(object sender, EventArgs e) { if (!inInit) { string subject = Selection_Subject.TextBox_Selected.Text; string algorithm = Selection_Algorithm.TextBox_Selected.Text; data[(int)Data.Network].options = ListStr(Config.Instance[Config.Keys.Subjects][subject][algorithm][Config.AlgorithmKeys.Networks].Keys); data[(int)Data.Network].enableItems = null; data[(int)Data.Network].initiallySelected = new List <int> { 0 }; Selection_Network.Init(data[(int)Data.Network]); } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn private void Button_Select_Click(object sender, RoutedEventArgs e) /// /// \brief Event handler. Called by Button_Select for click events. /// /// \par Description. /// - This method gets the results from the controls and /// - According to the SelectSource call a method to determine on the action to perform /// - According to the action to perform determine: /// - If to update the config /// - If to exit or continue with the dialog /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 29/08/2017 /// /// \param sender (object) - Source of the event. /// \param e (RoutedEventArgs) - Routed event information. //////////////////////////////////////////////////////////////////////////////////////////////////// private void Button_Select_Click(object sender, RoutedEventArgs e) { string subject = Selection_Subject.GetSelection().selectionText; string algorithm = Selection_Algorithm.GetSelection().selectionText; string network = Selection_Network.GetSelection().selectionText; string file = Selection_File.GetSelection().selectionText + fileExtension; // If the network is new the dictionary of the network is not found in the config // so we generate default path string path; try { path = Config.Instance[Config.Keys.Subjects][subject][algorithm][Config.AlgorithmKeys.Networks][network][pathKey]; } catch { path = Config.Instance.GenerateDataFilePath(subject, algorithm, network); } string absPath = System.IO.Path.GetFullPath(path); switch (selectSource) { case SelectSource.New: result = EndSelectionForNew(absPath, file); break; case SelectSource.Open: result = EndSelectionForOpen(absPath, file); break; case SelectSource.SaveAs: result = EndSelectionForSaveAs(absPath, file); break; case SelectSource.SaveDebug: result = EndSelectionForSaveAs(absPath, file); break; case SelectSource.Debug: result = EndSelectionForDebug(absPath, file); break; case SelectSource.Log: result = SelectResult.Log; break; default: result = SelectResult.Quit; break; } switch (result) { case SelectResult.Quit: Close(); break; case SelectResult.Cancel: break; case SelectResult.Debug: Config.Instance.UpdateSelectedDebugFileChanged(subject, algorithm, network, file, path); Close(); break; case SelectResult.Log: Config.Instance[Config.Keys.SelectedLogFileName] = file; Close(); break; default: if (selectSource == SelectSource.SaveDebug) { Config.Instance.UpdateSelectedDebugFileChanged(subject, algorithm, network, file, path); } else { Config.Instance.UpdateSelectedDataFileChanged(subject, algorithm, network, file, path); } Close(); break; } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public SourceTargetAlgorithmsSelect() /// /// \brief Default constructor. /// /// \par Description. /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 29/08/2017 //////////////////////////////////////////////////////////////////////////////////////////////////// public FileSelect(SelectSource selectSource, string message) { inInit = true; InitializeComponent(); this.selectSource = selectSource; data = new List <SelectControlData>(); switch (selectSource) { // Setting the locals if the call is for start debug case SelectSource.Debug: fileExtension = ".debug"; pathKey = Config.NetworkKeys.DebugFilePath; filesKey = Config.NetworkKeys.DebugFiles; selectedFileKey = Config.Keys.SelectedDebugFileName; break; // Setting the locals if the call is for save during debug // (only the file name can be selected) case SelectSource.SaveDebug: fileExtension = ".debug"; pathKey = Config.NetworkKeys.DebugFilePath; filesKey = Config.NetworkKeys.DebugFiles; Selection_Algorithm.DisableSelection = true; Selection_Subject.DisableSelection = true; Selection_Network.DisableSelection = true; selectedFileKey = Config.Keys.SelectedDebugFileName; break; // Setting the locals if the call is for selecting log file // (only the file name can be selected) case SelectSource.Log: fileExtension = ".log"; pathKey = Config.NetworkKeys.LogFilePath; filesKey = Config.NetworkKeys.LogFiles; Selection_Algorithm.DisableSelection = true; Selection_Subject.DisableSelection = true; Selection_Network.DisableSelection = true; selectedFileKey = Config.Keys.SelectedLogFileName; break; // Setting the locals if the call is for selecting file to save // (The network and file name can be selected) case SelectSource.SaveAs: fileExtension = ".data"; pathKey = Config.NetworkKeys.DataFilePath; filesKey = Config.NetworkKeys.DataFiles; Selection_Algorithm.DisableSelection = true; Selection_Subject.DisableSelection = true; selectedFileKey = Config.Keys.SelectedDataFileName; break; // Setting the parameters for Open and New operations default: fileExtension = ".data"; pathKey = Config.NetworkKeys.DataFilePath; filesKey = Config.NetworkKeys.DataFiles; selectedFileKey = Config.Keys.SelectedDataFileName; break; } // Header Message Label_Message.Content = message; // Create the data for the subjects control List <string> subjects = ListStr(Config.Instance[Config.Keys.Subjects].Keys); string subject = Config.Instance[Config.Keys.SelectedSubject]; List <int> selectedSubjectIdx = new List <int> { subjects.IndexOf(subject) }; data.Add(new SelectControlData() { options = subjects, initiallySelected = selectedSubjectIdx }); // Create the data for the algorithm control List <string> algorithms = ListStr(Config.Instance[Config.Keys.Subjects][subject].Keys); string algorithm = Config.Instance[Config.Keys.SelectedAlgorithm]; List <int> selectedAlgorithmIdx = new List <int> { algorithms.IndexOf(algorithm) }; data.Add(new SelectControlData { options = algorithms, initiallySelected = selectedAlgorithmIdx }); // Create the data for the algorithm control List <string> networks = ListStr(Config.Instance[Config.Keys.Subjects][subject][algorithm][Config.AlgorithmKeys.Networks].Keys); string network = Config.Instance[Config.Keys.SelectedNetwork]; List <int> selectedNetworkIdx = new List <int> { networks.IndexOf(network) }; data.Add(new SelectControlData { options = networks, initiallySelected = selectedNetworkIdx }); // Create the data for the algorithm control List <string> files = ListFiles(Config.Instance[Config.Keys.Subjects][subject][algorithm][Config.AlgorithmKeys.Networks][network][filesKey]); string file = Config.Instance[selectedFileKey].Replace(fileExtension, ""); List <int> selectedFileIdx = new List <int> { files.IndexOf(file) }; data.Add(new SelectControlData { options = files, initiallySelected = selectedFileIdx }); Selection_File.Init(data[(int)Data.File]); Selection_Network.Init(data[(int)Data.Network]); Selection_Algorithm.Init(data[(int)Data.Algorithm]); Selection_Subject.Init(data[(int)Data.Subject]); inInit = false; }