using System; using System.Linq; using System.Windows; using System.Windows.Media; using System.Windows.Shapes; using System.Windows.Threading; using SciChart.Charting.Visuals; using SciChart.Charting.Visuals.Axes; namespace FinSysPlatform.Common.Charts.Behavior { public class GridLineStyleBehavior { private static ChartGridType _chartGridType; private static SolidColorBrush _singleGridStrock; private static Visibility _singleGridVisibility; private static Thickness _singleGridStrockThickness; #region DP SingleGridStrock /// /// SingleGridStrock /// public static readonly DependencyProperty SingleGridStrockProperty = DependencyProperty.RegisterAttached( "SingleGridStrock", typeof(SolidColorBrush), typeof(GridLineStyleBehavior), new PropertyMetadata(Brushes.Black, OnSingleGridStrockChanged)); private static void OnSingleGridStrockChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (!(d is AxisBase axisBase)) { throw new ArgumentException(@"unexpected object", nameof(d)); } if (e.NewValue is SolidColorBrush color) { Style newStyle = new Style(typeof(Line)); newStyle.Setters.Add(new Setter(Line.StrokeProperty, e.NewValue)); newStyle.Setters.Add(new Setter(Line.StrokeThicknessProperty, 5)); newStyle.Setters.Add(new Setter(Line.StrokeDashArrayProperty, "1 0")); axisBase.MajorGridLineStyle = newStyle; } } public static void SetSingleGridStrock(DependencyObject element, SolidColorBrush value) { element.SetValue(SingleGridStrockProperty, value); } public static SolidColorBrush GetSingleGridStrock(DependencyObject element) { return (SolidColorBrush) element.GetValue(SingleGridStrockProperty); } #endregion } }