コード例 #1
0
        private void FreezeAllLayout(ChartCollection <AxisAbs> axisCollection, IChartLegend legend, Canvas chartCanvas, Grid chartGrid, ScrollViewer scrollViewer, Grid chartContentGrid, LegendAddResult legendAddResult, AxisXHeightInfo axisXHeightInfo, AxisYWidthInfo axisYWidthInfo)
        {
            //添加scrollViewer
            scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            scrollViewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            scrollViewer.VerticalAlignment             = System.Windows.VerticalAlignment.Top;
            scrollViewer.HorizontalAlignment           = System.Windows.HorizontalAlignment.Left;
            scrollViewer.Content = chartContentGrid;
            chartGrid.Children.Add(scrollViewer);

            //布局legend
            var chartGridRowColumnDefinition = new ChartGridRowColumnDefinition(legendAddResult.HasLegend, legend, chartGrid);

            if (legendAddResult.HasLegend)
            {
                this.SetRowColumn(chartGrid, legend.LegendControl, chartGridRowColumnDefinition.Legend);
            }
            this.SetRowColumn(chartGrid, scrollViewer, chartGridRowColumnDefinition.Chart);


            //布局内部
            var chartGridRowColumnDefinition2 = new ChartGridRowColumnDefinition(false, null, chartContentGrid, axisYWidthInfo, axisXHeightInfo);

            if (axisCollection != null && axisCollection.Count > ChartConstant.ZERO_I)
            {
                RowColumnDefinitionItem rowColumnDefinition;
                foreach (var axis in axisCollection)
                {
                    switch (axis.DockOrientation)
                    {
                    case ChartDockOrientation.Left:
                        rowColumnDefinition = chartGridRowColumnDefinition2.LeftAxis;
                        break;

                    case ChartDockOrientation.Top:
                        rowColumnDefinition = chartGridRowColumnDefinition2.TopAxis;
                        break;

                    case ChartDockOrientation.Right:
                        rowColumnDefinition = chartGridRowColumnDefinition2.RightAxis;
                        break;

                    case ChartDockOrientation.Bottom:
                        rowColumnDefinition = chartGridRowColumnDefinition2.BottomAxis;
                        break;

                    default:
                        throw new NotImplementedException(axis.DockOrientation.ToString());
                    }

                    this.SetRowColumn(chartContentGrid, axis.AxisControl, rowColumnDefinition);
                }
            }

            this.SetRowColumn(chartContentGrid, chartCanvas, chartGridRowColumnDefinition2.Chart);
        }
コード例 #2
0
        private void NoneFreezeLayout(ChartCollection <AxisAbs> axisCollection, IChartLegend legend, Canvas chartCanvas, Grid chartGrid, ScrollViewer scrollViewer, LegendAddResult legendAddResult, AxisXHeightInfo axisXHeightInfo, AxisYWidthInfo axisYWidthInfo)
        {
            var chartGridRowColumnDefinition = new ChartGridRowColumnDefinition(legendAddResult.HasLegend, legend, chartGrid, axisYWidthInfo, axisXHeightInfo);

            if (legendAddResult.HasLegend)
            {
                this.SetRowColumn(chartGrid, legend.LegendControl, chartGridRowColumnDefinition.Legend);
            }

            if (axisCollection != null && axisCollection.Count > ChartConstant.ZERO_I)
            {
                RowColumnDefinitionItem rowColumnDefinition;
                foreach (var axis in axisCollection)
                {
                    switch (axis.DockOrientation)
                    {
                    case ChartDockOrientation.Left:
                        rowColumnDefinition = chartGridRowColumnDefinition.LeftAxis;
                        break;

                    case ChartDockOrientation.Top:
                        rowColumnDefinition = chartGridRowColumnDefinition.TopAxis;
                        break;

                    case ChartDockOrientation.Right:
                        rowColumnDefinition = chartGridRowColumnDefinition.RightAxis;
                        break;

                    case ChartDockOrientation.Bottom:
                        rowColumnDefinition = chartGridRowColumnDefinition.BottomAxis;
                        break;

                    default:
                        throw new NotImplementedException(axis.DockOrientation.ToString());
                    }

                    this.SetRowColumn(chartGrid, axis.AxisControl, rowColumnDefinition);
                }
            }

            this.SetRowColumn(chartGrid, scrollViewer, chartGridRowColumnDefinition.Chart);


            chartCanvas.MouseWheel          += ChartCanvas_MouseWheel;
            chartCanvas.MouseLeftButtonDown += ChartCanvas_MouseLeftButtonDown;
            chartCanvas.MouseMove           += ChartCanvas_MouseMove;
        }