Example #1
0
        private void OnDockPositionChanged(ChartDock oldValue, ChartDock newValue)
        {
            if (LegendPosition == LegendPosition.Outside)
            {
                InternalDockPosition = DockPosition;
                if (ChartArea != null)
                {
                    ChartArea.LayoutLegends();
                    ChartArea.UpdateLegendArrangeRect();
                }
            }

            ChangeOrientation();

            if (LegendPosition == LegendPosition.Inside)
            {
                var dockPanel = Parent as ChartDockPanel;
                if (dockPanel == null)
                {
                    return;
                }
                Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                ChartArea.UpdateLegendArrangeRect();
                dockPanel.InvalidateMeasure();
            }
            else if (ChartDockPanel.GetDock(this) != InternalDockPosition)
            {
                ChartDockPanel.SetDock(this, InternalDockPosition);
            }
        }
Example #2
0
        private void OnLegendPositionChanged()
        {
            if (LegendPosition == Charts.LegendPosition.Inside)
            {
                InternalDockPosition = ChartDock.Floating;
            }
            else
            {
                InternalDockPosition = DockPosition;
            }

            ChartDockPanel.SetDock(this, InternalDockPosition);

            if (Parent != null)
            {
                ChartArea.LayoutLegends();
                ChartArea.UpdateLegendArrangeRect();
                (Parent as ChartDockPanel).InvalidateMeasure();
            }
        }
Example #3
0
        internal void LayoutLegends()
        {
            for (int i = 0; i < RowDefinitions.Count; i++)
            {
                int leftIndex = 0, rightIndex = 0, currLeftPos = 0, currRightPos = 0;
                RowDefinitions[i].Legends.Clear();

                foreach (ChartLegend item in LegendCollection)
                {
                    if (GetActualRow(item) == i && item.LegendPosition != LegendPosition.Inside)
                    {
                        if (item.DockPosition == ChartDock.Left)
                        {
                            RowDefinitions[i].Legends.Add(item);
                            if (leftIndex < currLeftPos)
                            {
                                leftIndex++;
                            }
                            item.RowColumnIndex = leftIndex;
                            currLeftPos++;
                        }
                        else if (item.DockPosition == ChartDock.Right)
                        {
                            RowDefinitions[i].Legends.Add(item);
                            if (rightIndex < currRightPos)
                            {
                                rightIndex++;
                            }
                            item.RowColumnIndex = rightIndex;
                            currRightPos++;
                        }
                        if (ChartDockPanel.GetDock(item) != item.InternalDockPosition)
                        {
                            ChartDockPanel.SetDock(item, item.InternalDockPosition);
                        }
                    }
                }
            }

            for (int i = 0; i < ColumnDefinitions.Count; i++)
            {
                int topIndex = 0, bottomIndex = 0, currTopIndex = 0, currBottomIndex = 0;
                ColumnDefinitions[i].Legends.Clear();

                foreach (ChartLegend item in LegendCollection)
                {
                    if (GetActualColumn(item) == i && item.LegendPosition != LegendPosition.Inside)
                    {
                        if (item.DockPosition == ChartDock.Top)
                        {
                            if (topIndex < currTopIndex)
                            {
                                topIndex++;
                            }
                            item.RowColumnIndex = topIndex;
                            currTopIndex++;
                            ColumnDefinitions[i].Legends.Add(item);
                        }
                        else if (item.DockPosition == ChartDock.Bottom)
                        {
                            if (bottomIndex < currBottomIndex)
                            {
                                bottomIndex++;
                            }
                            item.RowColumnIndex = bottomIndex;
                            currBottomIndex++;
                            ColumnDefinitions[i].Legends.Add(item);
                        }
                    }
                    if (ChartDockPanel.GetDock(item) != item.InternalDockPosition)
                    {
                        ChartDockPanel.SetDock(item, item.InternalDockPosition);
                    }
                }
            }
        }