public RLVConfigurationPanel(IRLVProgressionChartPanel chartControl, IRLVSelectedDetailsPanel detailsControl) { InitializeComponent(); this.chartControl = chartControl; this.detailsControl = detailsControl; chartConfig.PopulateControls(this.chartControl); detailsConfig.PopulateControls(this.detailsControl); }
public virtual void SetupVisualizer(IEnumerable <IRLVPanel> panels, IRLVOutputVisualizer visualizer = null) { if (panels != null) { // iterate through panels and register each event/handler pair this.panels = panels; foreach (var panel in panels) { if (panel is IRLVProgressionChartPanel) { IRLVProgressionChartPanel progPanel = panel as IRLVProgressionChartPanel; progPanel.SelectedCaseChangedEvent += IRLVProgressionChartPanel_SelectedCaseChangedHandler; progPanel.SelectedCaseScaleChangedEvent += IRLVProgressionChartPanel_SelectedCaseScaleChangedHandler; SelectedUniqueInputSetChangedResultsEvent += progPanel.IRLVCore_SelectedUniqueInputSetChangedResultsHandler; ScaleChangedResultsEvent += progPanel.IRLVCore_ScaleChangedResultsHandler; NextPrevCaseChangedResultsEvent += progPanel.IRLVCore_NextPrevCaseChangedResultsHandler; RealTimeUpdateEvent += progPanel.IRLVCore_RealTimeUpdateHandler; SelectedCaseScaleChangedResultsEvent += progPanel.IRLVCore_SelectedCaseScaleChangedResultsHandler; progPanel.SelectChartDataPointEvent += IRLVProgressionChartPantl_SelectChartDataPointHandler; } if (panel is IRLVSelectedDetailsPanel) { IRLVSelectedDetailsPanel detailsPanel = panel as IRLVSelectedDetailsPanel; detailsPanel.LearningComparisonEvent += IRLVSelectedDetailsPanel_LearningComparisonHandler; detailsPanel.NextPrevCaseChangedEvent += IRLVSelectedDetailsPanel_NextPrevCaseChangedHandler; detailsPanel.SessionBreakdownClickEvent += IRLVSelectedDetailsPanel_SessionBreakdownClickHandler; SessionBreakdownClickResultsEvent += detailsPanel.IRLVCore_SessionBreakdownClickResultsHandler; SelectedCaseDetailResultsEvent += detailsPanel.IRLVCore_SelectedCaseDetailResultsHandler; detailsPanel.OutputVisualizer = visualizer; } if (panel is IRLVScaleSelectionPanel) { IRLVScaleSelectionPanel scalePanel = panel as IRLVScaleSelectionPanel; scalePanel.ScaleChangedEvent += IRLVScaleSelectionPanel_ScaleChangedHandler; currentScale = ((RLVScaleSelectionVM)scalePanel.ViewModel).DefaultScale; } } } // register the event/handler pair for the external app this.visualizer = visualizer; if (visualizer != null) { visualizer.ComparisonModeClosedEvent += IRLVOutputVisualizer_ComparisonModeClosedHandler; visualizer.SelectedUniqueInputSetChangedEvent += IRLVOutputVisualizer_SelectedUniqueInputSetChangedHandler; LearningComparisonResultsEvent += visualizer.IRLVCore_LearningComparisonResultsHandler; DataNotAvailableEvent += visualizer.IRLVCore_DataNotAvailableHandler; } }
public void PopulateControls(IRLVSelectedDetailsPanel detailsControl) { // *** The following will create a mapping of elements from the RLVSelectedDetailsPanel to be defined by the user. *** // == Mapping for the Labels/Text displayed in RLVSelectedDetailsPanel. == double gridHorizontalGap = 43; // Gap between each child elements. foreach (var element in ((RLVSelectedDetailVM)detailsControl.ViewModel).Labels) { // The grid that will contain the following elements, need this to align them side by side. Grid grid = new Grid(); grid.Margin = new Thickness(10, gridHorizontalGap, 10, 0); TextBlock lbl = new TextBlock(); // The default text. TextBox txtVal = new TextBox(); // The custom text that will be specified by the user. CheckBox chk = new CheckBox(); // To set the visibility of the element from the RLVSelectedDetailsPanel // Configure the positioning of the the above elements. // For the default text. lbl.TextAlignment = TextAlignment.Right; lbl.HorizontalAlignment = HorizontalAlignment.Left; lbl.Margin = new Thickness(0, 4, 0, 0); lbl.VerticalAlignment = VerticalAlignment.Top; lbl.RenderTransformOrigin = new Point(0.433, -0.385); lbl.Width = 133; // For the user defined text. txtVal.HorizontalAlignment = HorizontalAlignment.Left; txtVal.Height = 23; txtVal.Margin = new Thickness(138, 0, 0, 0); txtVal.VerticalAlignment = VerticalAlignment.Top; txtVal.Width = 155; // For the checkbox that sets the visibility of the element in RLVSelectedDetailsPanel. chk.HorizontalAlignment = HorizontalAlignment.Left; chk.Margin = new Thickness(298, 4, 0, 0); chk.VerticalAlignment = VerticalAlignment.Top; chk.ToolTip = "Hide this control"; // Element bindings Binding lblBinding = new Binding() { Source = element, Path = new PropertyPath("Value"), Mode = BindingMode.OneTime }; Binding valueBinding = new Binding() { Source = element, Path = new PropertyPath("Value"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; Binding checkBinding = new Binding() { Source = element, Path = new PropertyPath("Visibility"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; checkBinding.Converter = new CheckConverter(); BindingOperations.SetBinding(lbl, TextBlock.TextProperty, lblBinding); BindingOperations.SetBinding(txtVal, TextBox.TextProperty, valueBinding); BindingOperations.SetBinding(chk, CheckBox.IsCheckedProperty, checkBinding); // Add the elements to its container grid. grid.Children.Add(txtVal); grid.Children.Add(lbl); grid.Children.Add(chk); // Add them to the parent grid labelsGrid.Children.Add(grid); gridHorizontalGap += 31; // Increase gap between grid after each iteration. } // == Mapping for the Values displayed in RLVSelectedDetailsPanel. == gridHorizontalGap = 43; // Reset the gap between element grid container for the new set. foreach (var ctrl in ((RLVSelectedDetailVM)detailsControl.ViewModel).Values) { // The grid that will contain the following elements. Grid grid = new Grid(); grid.Margin = new Thickness(10, gridHorizontalGap, 10, 0); TextBlock lbl = new TextBlock(); // The description of the values. ComboBox formatterDropDown = new ComboBox(); // The list of formatters to be defined by the user // to set the format of the selected element value // in RLVSelectedDetailsPanel CheckBox chk = new CheckBox(); // To set the visibility of the element. // Positioning of elements. // For the description text. lbl.TextAlignment = TextAlignment.Right; lbl.HorizontalAlignment = HorizontalAlignment.Left; lbl.Margin = new Thickness(0, 4, 0, 0); lbl.VerticalAlignment = VerticalAlignment.Top; lbl.RenderTransformOrigin = new Point(0.433, -0.385); lbl.Width = 133; // For the list of available formats. formatterDropDown.HorizontalAlignment = HorizontalAlignment.Left; formatterDropDown.Height = 23; formatterDropDown.Margin = new Thickness(138, 0, 0, 0); formatterDropDown.VerticalAlignment = VerticalAlignment.Top; formatterDropDown.Width = 155; formatterDropDown.ToolTip = "Configure formatting for this value."; formatterDropDown.Text = "Select Format"; formatterDropDown.ItemsSource = Enum.GetValues(typeof(RLVFormatters)); formatterDropDown.SelectedIndex = 0; // An event to get the choosen format. IValueConverter converter = null; formatterDropDown.SelectionChanged += (a, b) => { var selected = (RLVFormatters)b.AddedItems[0]; switch (selected) { case RLVFormatters.Text: converter = null; break; case RLVFormatters.Numeric_General: converter = new RLVNumberConverter(selected); break; case RLVFormatters.Numeric_Currency: converter = new RLVNumberConverter(selected); break; case RLVFormatters.Numeric_FixedPoint: converter = new RLVNumberConverter(selected); break; case RLVFormatters.Numeric_Number: converter = new RLVNumberConverter(selected); break; case RLVFormatters.Numeric_Percent: converter = new RLVNumberConverter(selected); break; case RLVFormatters.Time_Days: converter = new RLVTimeConverter(selected); break; case RLVFormatters.Time_Hours: converter = new RLVTimeConverter(selected); break; case RLVFormatters.Time_Minutes: converter = new RLVTimeConverter(selected); break; case RLVFormatters.Time_Seconds: converter = new RLVTimeConverter(selected); break; case RLVFormatters.Time_Milliseconds: converter = new RLVTimeConverter(selected); break; } ctrl.Converter = converter; detailsControl.UpdateBindings(ctrl); // Call this to apply the formatting. }; // For the checkbox that sets the visibility of the element in the RLVSelectedDetailsPanel. chk.HorizontalAlignment = HorizontalAlignment.Left; chk.Margin = new Thickness(298, 4, 0, 0); chk.VerticalAlignment = VerticalAlignment.Top; chk.ToolTip = "Hide this control"; // The bindings Binding lblBinding = new Binding() { Source = ctrl, Path = new PropertyPath("Description"), Mode = BindingMode.OneTime }; Binding checkBinding = new Binding() { Source = ctrl, Path = new PropertyPath("Visibility"), Mode = BindingMode.TwoWay }; checkBinding.Converter = new CheckConverter(); BindingOperations.SetBinding(lbl, TextBlock.TextProperty, lblBinding); BindingOperations.SetBinding(chk, CheckBox.IsCheckedProperty, checkBinding); // Add to its container grid. grid.Children.Add(formatterDropDown); grid.Children.Add(lbl); grid.Children.Add(chk); // Add to the parent container grid. valuesGrid.Children.Add(grid); gridHorizontalGap += 31; // Increase gap between grid after each iteration. } }