public RLVConfigurationPanel(IRLVProgressionChartPanel chartControl, IRLVSelectedDetailsPanel detailsControl)
        {
            InitializeComponent();

            this.chartControl   = chartControl;
            this.detailsControl = detailsControl;

            chartConfig.PopulateControls(this.chartControl);
            detailsConfig.PopulateControls(this.detailsControl);
        }
示例#2
0
        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(IRLVProgressionChartPanel chartControl)
        {
            // *** The following will create a mapping of elements from the RLVProgressionChartPanel to be defined by the user. ***

            // Clear for repopulation of controls
            labelsGrid.Children.Clear();
            valuesGrid.Children.Clear();

            // == Mapping for the Labels/Text displayed in RLVProgressionChartPanel. ==

            double gridHorizontalGap = 10; // Gap between each child elements.

            Grid grid1 = new Grid();

            grid1.Margin = new Thickness(10, gridHorizontalGap, 10, 0);

            TextBlock panelHeaderLbl = new TextBlock();

            panelHeaderLbl.TextAlignment       = TextAlignment.Right;
            panelHeaderLbl.HorizontalAlignment = HorizontalAlignment.Left;
            panelHeaderLbl.Margin                = new Thickness(0, 4, 0, 0);
            panelHeaderLbl.VerticalAlignment     = VerticalAlignment.Top;
            panelHeaderLbl.RenderTransformOrigin = new Point(0.433, -0.385);
            panelHeaderLbl.Width = 133;

            TextBox panelHeaderTxtVal = new TextBox();

            panelHeaderTxtVal.HorizontalAlignment = HorizontalAlignment.Left;
            panelHeaderTxtVal.Height            = 23;
            panelHeaderTxtVal.Margin            = new Thickness(138, 0, 0, 0);
            panelHeaderTxtVal.VerticalAlignment = VerticalAlignment.Top;
            panelHeaderTxtVal.Width             = 155;

            Binding panelHeaderLblBinding = new Binding()
            {
                Source = "Panel Header", Mode = BindingMode.OneTime
            };
            Binding panelHeaderLblValueBinding = new Binding()
            {
                Source = ((IRLVProgressionChartVM)chartControl.ViewModel), Path = new PropertyPath("Header"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };

            BindingOperations.SetBinding(panelHeaderLbl, TextBlock.TextProperty, panelHeaderLblBinding);
            BindingOperations.SetBinding(panelHeaderTxtVal, TextBox.TextProperty, panelHeaderLblValueBinding);

            grid1.Children.Add(panelHeaderLbl);
            grid1.Children.Add(panelHeaderTxtVal);

            labelsGrid.Children.Add(grid1);

            gridHorizontalGap += 31; // Increase gap between grid after each iteration.
            foreach (var element in ((IRLVProgressionChartVM)chartControl.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 RLVProgressionChartPanel
                //ComboBox cmb = new ComboBox();

                // 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 = 10; // Reset the gap between element grid container for the new set.
            foreach (var ctrl in ((RLVProgressionChartVM)chartControl.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 RLVNumericConverter(selected);
                        ctrl.ConverterType = 0;
                        break;

                    case RLVFormatters.Numeric_Currency:
                        converter          = new RLVNumericConverter(selected);
                        ctrl.ConverterType = 0;
                        break;

                    case RLVFormatters.Numeric_FixedPoint:
                        converter          = new RLVNumericConverter(selected);
                        ctrl.ConverterType = 0;
                        break;

                    case RLVFormatters.Numeric_Number:
                        converter          = new RLVNumericConverter(selected);
                        ctrl.ConverterType = 0;
                        break;

                    case RLVFormatters.Numeric_Percent:
                        converter          = new RLVNumericConverter(selected);
                        ctrl.ConverterType = 0;
                        break;

                    case RLVFormatters.Time_Days:
                        converter          = new RLVTimeConverter(selected);
                        ctrl.ConverterType = 1;
                        break;

                    case RLVFormatters.Time_Hours:
                        converter          = new RLVTimeConverter(selected);
                        ctrl.ConverterType = 1;
                        break;

                    case RLVFormatters.Time_Minutes:
                        converter          = new RLVTimeConverter(selected);
                        ctrl.ConverterType = 1;
                        break;

                    case RLVFormatters.Time_Seconds:
                        converter          = new RLVTimeConverter(selected);
                        ctrl.ConverterType = 1;
                        break;

                    case RLVFormatters.Time_Milliseconds:
                        converter          = new RLVTimeConverter(selected);
                        ctrl.ConverterType = 1;
                        break;
                    }

                    ctrl.Converter = converter;
                    ctrl.SelectedValueFromConverter = (int)selected;
                    chartControl.UpdateBindings(ctrl); // Call this to apply the formatting.
                };

                if (ctrl.SelectedValueFromConverter != null)
                {
                    formatterDropDown.SelectedValue = (RLVFormatters)ctrl.SelectedValueFromConverter;
                }


                // 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.
            }
        }