Ejemplo n.º 1
0
        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]);
        }
Ejemplo n.º 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;
        }