private Path GetPath(Point startPoint, Point endPoint, PlacementTypes placementType, CustomAxisLabel customLabel) { Path path = new System.Windows.Shapes.Path(); path.Stroke = Charts.Chart.CalculateFontColor((Chart as Chart), ParentAxis.Background, customLabel.LineColor, false); path.StrokeThickness = (Double) customLabel.LineThickness; PathGeometry geometry = new PathGeometry(); PathFigure pathFigure = new PathFigure(); pathFigure.StartPoint = startPoint; PointCollection collection = new PointCollection(); if (placementType == PlacementTypes.Bottom) { collection.Add(new Point(startPoint.X, startPoint.Y + (LineEnabled ? LINE_HEIGHT : 0))); collection.Add(new Point(endPoint.X, endPoint.Y + (LineEnabled ? LINE_HEIGHT : 0))); collection.Add(endPoint); } else if (placementType == PlacementTypes.Left) { collection.Add(new Point(startPoint.X - (LineEnabled ? LINE_HEIGHT : 0), startPoint.Y)); collection.Add(new Point(endPoint.X - (LineEnabled ? LINE_HEIGHT : 0), endPoint.Y)); collection.Add(endPoint); } else if (placementType == PlacementTypes.Right) { collection.Add(new Point(startPoint.X + (LineEnabled ? LINE_HEIGHT : 0), startPoint.Y)); collection.Add(new Point(endPoint.X + (LineEnabled ? LINE_HEIGHT : 0), endPoint.Y)); collection.Add(endPoint); } else if (placementType == PlacementTypes.Top) { collection.Add(new Point(startPoint.X, startPoint.Y - (LineEnabled ? LINE_HEIGHT : 0))); collection.Add(new Point(endPoint.X, endPoint.Y - (LineEnabled ? LINE_HEIGHT : 0))); collection.Add(endPoint); } foreach (Point point in collection) { LineSegment segment = new LineSegment(); segment.Point = point; pathFigure.Segments.Add(segment); } geometry.Figures.Add(pathFigure); path.Data = geometry; return path; }
/// <summary> /// Apply font properties of CustomAxisLabels /// </summary> /// <param name="label">AxisLabel</param> private void ApplyAxisLabelFontProperties(AxisLabel label, CustomAxisLabel customAxisLabel) { //Set size affecting font properties label.FontSize = InternalFontSize; if(customAxisLabel != null) label.FontColor = Charts.Chart.CalculateFontColor((Chart as Chart), ParentAxis.Background, customAxisLabel.FontColor, false); label.FontFamily = InternalFontFamily; label.FontStyle = InternalFontStyle; label.FontWeight = InternalFontWeight; label.TextAlignment = TextAlignment; label.Angle = GetAngle(); }
/// <summary> /// Event handler attached with LineThickness property changed event of CustomAxisLabel element /// </summary> /// <param name="d"></param> /// <param name="e"></param> private static void OnLineThicknessPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { CustomAxisLabel customAxisLabel = d as CustomAxisLabel; customAxisLabel.UpdateVisual(VcProperties.LineThickness, e.NewValue); }
/// <summary> /// Event handler attached with From property changed event of CustomAxisLabel element /// </summary> /// <param name="d">DependencyObject</param> /// <param name="e">DependencyPropertyChangedEventArgs</param> private static void OnFromPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { CustomAxisLabel customAxisLabel = d as CustomAxisLabel; customAxisLabel.FirePropertyChanged(VcProperties.From); }
/// <summary> /// Event handler attached with FontColor property changed event of CustomAxisLabel element /// </summary> /// <param name="d"></param> /// <param name="e"></param> private static void OnFontColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { CustomAxisLabel customAxisLabel = d as CustomAxisLabel; customAxisLabel.UpdateVisual(VcProperties.FontColor, e.NewValue); }