//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn protected void Selection_SourceSubject_SelectionChanged(object sender, EventArgs e) /// /// \brief Event handler. Called by Selection_SourceSubject for selection changed events. /// /// \par Description. /// - The Source algorithms control change (To present the algorithms of the subject) /// - The Target subject control change (To set the Target subject is set to the source subject /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 29/08/2017 /// /// \param sender (object) - Source of the event. /// \param e (EventArgs) - Event information. //////////////////////////////////////////////////////////////////////////////////////////////////// protected void Selection_SourceSubject_SelectionChanged(object sender, EventArgs e) { data[1].options = TypesUtility.GetAlgorithmsOfSubject(Selection_SourceSubject.TextBox_Selected.Text); data[1].enableItems = null; Selection_SourceAlgorithm.Init(data[1]); if (((ListBoxItem)Selection_TargetSubject.ListBox_Options.Items[Selection_SourceSubject.ListBox_Options.SelectedIndex]).IsEnabled) { Selection_TargetSubject.ListBox_Options.SelectedIndex = Selection_SourceSubject.ListBox_Options.SelectedIndex; } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public SourceTargetAlgorithmsSelect() /// /// \brief Default constructor. /// /// \par Description. /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 29/08/2017 //////////////////////////////////////////////////////////////////////////////////////////////////// public SourceTargetAlgorithmsSelect() { InitializeComponent(); List <SelectControlData> data = new List <SelectControlData>(); // Create a list of the subjects and an enable list for them List <string> subjects = TypesUtility.GetAlgorithmsSubjects(); var enableSubjectsSource = Enumerable.Repeat(true, subjects.Count).ToList(); // Create the data for the source subject control // For the source subject the System subject is disabled (It cannot be used as source) enableSubjectsSource[subjects.IndexOf("Base")] = false; List <int> initialySelectedSubject = new List <int> { subjects.IndexOf("Templates") }; data.Add(new SelectControlData() { options = subjects, enableItems = enableSubjectsSource, initiallySelected = initialySelectedSubject }); // Create the data for the control of the source algorithm data.Add(new SelectControlData { options = new List <string>() }); // Create the data for the control of the target subject // For the target subject the System and Templates subjects are diasabled List <string> allSubjects = subjects.Concat(Config.Instance.GetSubjects().ToList()).ToList(); allSubjects = allSubjects.Distinct().ToList(); var enableSubjectsTragets = Enumerable.Repeat(true, allSubjects.Count).ToList(); enableSubjectsTragets[allSubjects.IndexOf("Base")] = false; enableSubjectsTragets[allSubjects.IndexOf("Templates")] = false; data.Add(new SelectControlData { options = allSubjects, enableItems = enableSubjectsTragets }); // Create the data for the control of the target algorithm data.Add(new SelectControlData { options = new List <string>() }); this.data = data; // Order of changing the presentation according to selection change is as follows // Source subject change : // The Source algorithms control change (To present the algorithms of the subject) // The Target subject control change (To set the Target subject is set to the source subject // Target subject change : // The Target algorithms control change (To present the algorithms of the subject) // // There for the order of initialize of the controls is in reverse order // (So the initiation will not override the data that was set by a control that is before // in the change chain) Selection_TargetAlgorithm.Init(data[3]); Selection_TargetSubject.Init(data[2]); Selection_SourceAlgorithm.Init(data[1]); Selection_SourceSubject.Init(data[0]); }