public NumericAxisPart(double min, double max) { this.min = min; this.max = max; Control = new AxisPartControl <double>(); }
public bool ShouldRemoveFromScreen(AxisPartControl <double> part, Range <double> range) { if ((part.Range.Max.CompareTo(range.Max) < 0 || part.Range.Min.CompareTo(range.Min) > 0)) { return(true); } else { return(false); } }
public void UpdateUIRepresentation() { if (updateUIRfrozen || ConvertToDouble == null || Transform == null || PartsProvider == null || LabelProvider == null || TicksProvider == null) { return; } if (DesiredSize.Height == 0 && DesiredSize.Width == 0) { return; } double NewAxesLength = Math.Abs(GetCoordinate(CreateDataPoint(ConvertToDouble(Range.Min)).DataToScreen(Transform)) - GetCoordinate(CreateDataPoint(ConvertToDouble(Range.Max)).DataToScreen(Transform))); if (Math.Abs(axeslength - NewAxesLength) > (axeslength / 1000)) { axeslength = NewAxesLength; CleanPartsCach(); } //has the scale changed? if (Math.Abs(activeScale - (ConvertToDouble(Range.Max) - ConvertToDouble(Range.Min))) > (activeScale / 100)) { activeScale = ConvertToDouble(Range.Max) - ConvertToDouble(Range.Min); CleanPartsCach(); } Range <T>[] partsSizes = PartsProvider.GetPartsSizes(Range); builder = new StringBuilder(); //Let's calculate what parts do we need, and position them foreach (Range <T> r in partsSizes) { double left = GetCoordinate(CreateDataPoint(ConvertToDouble(r.Min)).DataToScreen(Transform)); double right = GetCoordinate(CreateDataPoint(ConvertToDouble(r.Max)).DataToScreen(Transform)); AxisPartControl <T> part = PartsProvider.GetPart(r); //shall we add the part if (!partsPresentOnScreen.Contains(part)) { layoutStackCanvas.Children.Add(part); switch (Placement) { case AxisPlacement.Left: case AxisPlacement.Right: part.Height = Math.Abs(right - left); part.Clip = new RectangleGeometry() { Rect = new Rect(new Point(), new Size(100, part.Height)) }; break; case AxisPlacement.Top: case AxisPlacement.Bottom: part.Width = Math.Abs(right - left); part.Clip = new RectangleGeometry() { Rect = new Rect(new Point(), new Size(part.Width, 100)) }; break; } partsPresentOnScreen.Add(part); part.SizeChanged += new SizeChangedEventHandler(part_SizeChanged); RaiseLoadedPartsChanged(); } //just move the part switch (Placement) { case AxisPlacement.Left: case AxisPlacement.Right: StackCanvas.SetCoordinate(part, right); break; case AxisPlacement.Bottom: case AxisPlacement.Top: StackCanvas.SetCoordinate(part, left); break; } builder.AppendLine(Placement + ":" + r.ToString());// + " converted: (" + left + "," + right + ")"); //" act size: ("+part.ActualWidth+", "+part.ActualHeight+") "+ //"rand size: ("+part.DesiredSize+")"); } //Parts to be removed from the screen List <AxisPartControl <T> > toRemove = new List <AxisPartControl <T> >(); //if we have unnessesery parts, remove them foreach (AxisPartControl <T> part in partsPresentOnScreen) { if (partsProvider.ShouldRemoveFromScreen(part, Range)) { toRemove.Add(part); } } foreach (AxisPartControl <T> p in toRemove) { partsPresentOnScreen.Remove(p); layoutStackCanvas.Children.Remove(p); p.SizeChanged -= part_SizeChanged; } if (toRemove.Count > 0) { RaiseLoadedPartsChanged(); } if (!isMinorTicksSyned) { CheckPartsMinorTicksCount(); } #if DEBUG DebugString = "Axis rander size: " + DesiredSize + "\nAvl size: " + availableSize + "\n" + builder.ToString(); #endif }
public DateTimeAxisPart(DateTime Min, DateTime Max) { min = Min; max = Max; control = new AxisPartControl <DateTime>(); }