//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn protected void Selection_Network_SelectionChanged(object sender, EventArgs e) /// /// \brief Event handler. Called by Selection_Network for selection changed events. /// /// \par Description. /// Change the Selection_Files control to hold the files of the network or a default file if /// the network is new /// /// \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_Network_SelectionChanged(object sender, EventArgs e) { if (!inInit) { string subject = Selection_Subject.TextBox_Selected.Text; string algorithm = Selection_Algorithm.TextBox_Selected.Text; string network = Selection_Network.TextBox_Selected.Text; List <string> files; // If the network is new it is not found in the config so we have to create a new file // for it. The name of the file is the same as the network try { files = ListFiles(Config.Instance[Config.Keys.Subjects][subject][algorithm][Config.AlgorithmKeys.Networks][network][filesKey]); } catch { files = new List <string> { network }; } data[(int)Data.File].options = files; data[(int)Data.File].enableItems = null; data[(int)Data.File].initiallySelected = new List <int> { 0 }; Selection_File.Init(data[(int)Data.File]); } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn private void Selection_Network_NewItemSelected(object sender, EventArgs e) /// /// \brief Event handler. Called by Selection_Network for new item selected events. /// /// \par Description. /// When a new item was created in the network control (a network that does not exist) /// Create a file name the same as the network and insert it to the Selection_File control /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 29/11/2017 /// /// \param sender (object) - Source of the event. /// \param e (EventArgs) - Event information. //////////////////////////////////////////////////////////////////////////////////////////////////// private void Selection_Network_NewItemSelected(object sender, EventArgs e) { string text = Selection_Network.TextBox_Selected.Text; List <string> files = new List <string> { text }; data[(int)Data.File].options = files; data[(int)Data.File].enableItems = null; data[(int)Data.File].initiallySelected = new List <int> { 0 }; Selection_File.Init(data[(int)Data.File]); }
public DocsSelect(SelectSource selectSource, string message, string subject, string algorithm) { InitializeComponent(); this.selectSource = selectSource; this.subject = subject; this.algorithm = algorithm; data = new List <SelectControlData>(); switch (selectSource) { case SelectSource.Processed: pathKey = Config.AlgorithmKeys.DocProcessedPath; filesKey = Config.AlgorithmKeys.DocProcessedFiles; break; } // Header Message Label_Message.Content = message; // Create the data for the subjects control List <string> subjects = ListStr(Config.Instance[Config.Keys.Subjects].Keys); 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); List <int> selectedAlgorithmIdx = new List <int> { algorithms.IndexOf(algorithm) }; data.Add(new SelectControlData { options = algorithms, initiallySelected = selectedAlgorithmIdx }); // Create the data for the Type control List <string> documentType = new List <string> { TypesUtility.GetKeyToString(selectSource) }; List <int> selectedTypeIdx = new List <int> { 0 }; data.Add(new SelectControlData { options = documentType, initiallySelected = selectedTypeIdx }); // Create the data for the files control List <string> files = ListFiles(Config.Instance[Config.Keys.Subjects][subject][algorithm][filesKey]); if (files.Count == 0) { files.Add(algorithm); } List <int> selectedFileIdx = new List <int> { 0 }; data.Add(new SelectControlData { options = files, initiallySelected = selectedFileIdx }); Selection_File.Init(data[(int)Data.File]); Selection_Type.Init(data[(int)Data.Type]); Selection_Algorithm.Init(data[(int)Data.Algorithm]); Selection_Subject.Init(data[(int)Data.Subject]); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \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; }