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); } }
/// <summary> /// Called when alignment is changed. /// </summary> /// <param name="dpObj">The dependency object.</param> /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param> private static void OnAlignmentChanged(DependencyObject dpObj, DependencyPropertyChangedEventArgs e) { ChartDockPanel dockPanel = VisualTreeHelper.GetParent(dpObj) as ChartDockPanel; if (dockPanel != null) { dockPanel.InvalidateMeasure(); } }
/// <summary> /// Called when root element is changed. /// </summary> /// <param name="dpObj">The dependency object.</param> /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param> private static void OnRootElementChanged(DependencyObject dpObj, DependencyPropertyChangedEventArgs e) { ChartDockPanel dockPanel = dpObj as ChartDockPanel; if (dockPanel != null) { if (e.OldValue != null) { dockPanel.Children.Remove(e.OldValue as UIElement); dockPanel.m_rootElement = null; } if (e.NewValue != null) { dockPanel.m_rootElement = e.NewValue as UIElement; dockPanel.Children.Add(e.NewValue as UIElement); } } }
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(); } }
/// <summary> /// DockProperty property changed handler. /// </summary> /// <param name="d">UIElement that changed its ChartDock.</param> /// <param name="e">Event arguments.</param> private static void OnDockPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (e.NewValue.Equals(e.OldValue)) { return; } // Ignore the change if requested if (_ignorePropertyChange) { _ignorePropertyChange = false; return; } UIElement element = (UIElement)d; // Cause the DockPanel to update its layout when a child changes ChartDockPanel panel = VisualTreeHelper.GetParent(element) as ChartDockPanel; if (panel != null) { panel.InvalidateMeasure(); } }
/// <summary> /// LastChildFillProperty property changed handler. /// </summary> /// <param name="d">DockPanel that changed its LastChildFill.</param> /// <param name="e">Event arguments.</param> private static void OnLastChildFillPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ChartDockPanel source = d as ChartDockPanel; source.InvalidateArrange(); }
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); } } } }