Example #1
0
        private void SetupArrayControl(ExpressionInfo expressionInfo)
        {
            if (_arrCtl != null && _arrCtl.Tag == expressionInfo)
            {
                return;
            }

            SetRotationOptions(_dimensions.Length);

            ArrayControl newArrCtl = ArrayControl.GetArrayControl(_dimensions.Length);

            if (newArrCtl == null)
            {
                return;
            }
            else
            {
                _arrCtl = newArrCtl;
            }

            _arrCtl.Formatter      = formatterTextBox.Text;
            _arrCtl.CaptionBuilder = GetCaptionBuilder(_arrCtl.Formatter);

            _arrCtl.CellHeight = GetCellSize(cellHeightTextBox.Text, 40);
            _arrCtl.CellWidth  = GetCellSize(cellWidthTextBox.Text, 60);

            _arrCtl.LeftBracket  = _arrayLoader.LeftBracket;
            _arrCtl.RightBracket = _arrayLoader.RightBracket;

            _arrCtl.CellClick += arrCtl_CellClick;

            _arrCtl.SetControlData(_data);

            _arrCtl.Padding = new Thickness(8);
            _arrCtl.Width  += 16;
            _arrCtl.Height += 16;

            _arrCtl.Tag = expressionInfo;
        }
Example #2
0
        private void SetupControls(ExpressionInfo expressionInfo)
        {
            if (_data == null || arraysListBox.SelectedIndex == -1)
            {
                return;
            }

            if (VisualizerTab.SelectedIndex == 0)
            {
                _displayMode = DisplayMode.Array;
            }
            else if (VisualizerTab.SelectedIndex == 1)
            {
                _displayMode = DisplayMode.Chart;
            }

            switch (_displayMode)
            {
            case DisplayMode.Array:
                SetupArrayControl(expressionInfo);
                SetupChartControl(expressionInfo);
                ShowElement(_arrCtl);
                break;

            case DisplayMode.Chart:
                SetupChartControl(expressionInfo);
                if (chartTab.IsEnabled)
                {
                    ShowElement(_chartCtl);
                }
                else
                {
                    _displayMode = DisplayMode.Array;
                    SetupControls(expressionInfo);
                }
                break;
            }
        }
Example #3
0
        private void SetupChartControl(ExpressionInfo expressionInfo)
        {
            IEnumerable <double> chartData = null;

            int dimenstionsCount = _dimensions.Length;

            try
            {
                if ((dimenstionsCount == 1 || dimenstionsCount == 2) && _data != null)
                {
                    chartData          = ConvertToDoubles(_data);
                    chartTab.IsEnabled = chartData.Any();
                }
                else
                {
                    chartTab.IsEnabled = false;
                }
            }
            finally
            {
                if (!chartTab.IsEnabled)
                {
                    if (VisualizerTab.SelectedIndex == 1)
                    {
                        dataTab.IsSelected = true;
                    }
                }
                else
                {
                    if (_chartCtl == null || _chartCtl.Tag != expressionInfo)
                    {
                        if (_chartCtl != null)
                        {
                            _chartCtl.Dispose();
                        }

                        _chartCtl = new Chart();
                        ChartArea area = new ChartArea();

                        if (dimenstionsCount == 1)
                        {
                            area.Series.Add(GetSeries(GetSelectedChartType(), chartData));
                        }
                        else //2 dims
                        {
                            double[] chartDataFlat = chartData.ToArray();
                            for (int i = 0; i < _dimensions[0]; i++)
                            {
                                area.Series.Add(GetSeries(GetSelectedChartType(), chartDataFlat.Skip(i * _dimensions[1]).Take(_dimensions[1])));
                            }
                        }
                        _chartCtl.Areas.Add(area);

                        SetChartLineStroke();
                        SetChartStackModeOptions();
                        SetGridLines();
                        _chartCtl.Tag = expressionInfo;
                    }
                }
            }
        }