Exemple #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \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]);
            }
        }
Exemple #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \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;
        }