public TickInfo[] GetTicks(double start, double stop, int ticksCount) { if (Coeffs == null || Coeffs.Length == 0 || Scale == null || ticksCount == 0) { return(null); } DebugTraceLog.WriteLine("MinorTick --> GetTicks() : ticksCount=" + ticksCount.ToString()); double step = (stop - start) / (ticksCount + 1); List <TickInfo> res = new List <TickInfo>(); int diff = Coeffs.Length - ticksCount; int startIndex = diff / 2; for (int i = 0; i < ticksCount && startIndex < Coeffs.Length; i++) { var val = start + step * (i + 1); if (ValidMinorRange(val)) { res.Add(new TickInfo(val, Scale.ToPixels(val), false, Coeffs[startIndex] * mayorTickLength)); } startIndex++; } return(res.ToArray()); }
public void InitTicks(TickInfo[] ticks) { if (ticks == null || ticks.Length == 0 || (!(ticks.First().Value is double))) { return; } shouldRound = true; try { double start = (double)ticks[0].Value; double finish = (double)ticks[ticks.Length - 1].Value; if (start == finish) { shouldRound = false; DebugTraceLog.WriteLine("shouldRound = false;"); return; } double delta = finish - start; rounding = (int)Math.Round(Math.Log10(delta)); double newStart = RoundHelper.Round(start, rounding); double newFinish = RoundHelper.Round(finish, rounding); if (newStart == newFinish) { rounding--; } } catch { } }
public void RangeSelectorContainer_Unloaded(object sender, RoutedEventArgs e) { DebugTraceLog.WriteLine("RangeSelectorContainer_Unloaded"); var adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null && adorner != null) { if (adorner.AdornerContol != null) { adorner.AdornerContol.DataContext = null; } adornerLayer.Remove(adorner); } adorner = null; }
private void RangeSelectorContainer_Loaded(object sender, RoutedEventArgs e) { DebugTraceLog.WriteLine("RangeSelectorContainer_Loaded"); var adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { if (adorner == null) { adorner = new RangeSelectorAdorner(this); adornerLayer.Add(adorner); } adorner.AdornerContol.DataContext = this; } }
private Line CreateLine(double x1, double y1, double x2, double y2, Pen linePen) { DebugTraceLog.WriteLine(string.Format("x1={0},y1={1},x2={2},y2={3}", x1, y1, x2, y2)); linePen = linePen != null ? linePen : new Pen(Brushes.Red, 1); return(new Line { Y1 = y1, Y2 = y2, X1 = x1, X2 = x2, Stroke = linePen.Brush, StrokeThickness = linePen.Thickness, StrokeDashCap = linePen.DashCap, StrokeDashArray = linePen.DashStyle != null ? linePen.DashStyle.Dashes : null, SnapsToDevicePixels = true, }); }