public override bool Equals(object o) { bool result = false; if (o is ZoomboxView) { ZoomboxView other = (ZoomboxView)o; if (ViewKind == other.ViewKind) { switch (ViewKind) { case ZoomboxViewKind.Absolute: result = (DoubleHelper.AreVirtuallyEqual(_scaleWidth, other._scaleWidth)) && (DoubleHelper.AreVirtuallyEqual(Position, other.Position)); break; case ZoomboxViewKind.Region: result = DoubleHelper.AreVirtuallyEqual(Region, other.Region); break; default: result = true; break; } } } return(result); }
public void SetHorizontalOffset(double offset) { offset = this.ValidateInputOffset(offset, "HorizontalOffset"); offset = Math.Min(offset, this.ExtentWidth - this.ViewportWidth); if (!DoubleHelper.AreVirtuallyEqual(offset, _offset.X)) { _offset.X = offset; base.InvalidateMeasure(); } }
public void SetVerticalOffset(double offset) { offset = this.ValidateInputOffset(offset, "VerticalOffset"); offset = Math.Min(offset, this.ExtentHeight - this.ViewportHeight); if (!DoubleHelper.AreVirtuallyEqual(offset, _offset.Y)) { _offset.Y = offset; base.InvalidateMeasure(); } }
private void SetScrollingData(Size viewport, Size extent, Vector offset) { _offset = offset; if (DoubleHelper.AreVirtuallyEqual(viewport, _viewport) == false || DoubleHelper.AreVirtuallyEqual(extent, _extent) == false || DoubleHelper.AreVirtuallyEqual(offset, _computedOffset) == false) { _viewport = viewport; _extent = extent; _computedOffset = offset; this.OnScrollChange(); } }
public static bool operator <(AnimationRate t1, AnimationRate t2) { if (t1.HasDuration && t2.HasDuration) { return(t1._duration < t2._duration); } if (t1.HasSpeed && t2.HasSpeed) { return((t1._speed < t2._speed) && !DoubleHelper.AreVirtuallyEqual(t1._speed, t2._speed)); } // arbitrary: assume a Speed is greater than a Duration return(t1.HasDuration); }
private void UpdateSizeFromRadius() { if (this.FrameType == Toolkit.FrameType.Circle) { double newSize = Radius * 2; if (!DoubleHelper.AreVirtuallyEqual(Width, newSize)) { Width = newSize; } if (!DoubleHelper.AreVirtuallyEqual(Height, newSize)) { Height = newSize; } } }
private static object CoerceSliceValue(DependencyObject d, object value) { // keep Slice in sync with EndAngle, StartAngle, and SweepDirection Pie pie = ( Pie )d; if (pie.IsUpdatingEndAngle || pie.IsUpdatingStartAngle || pie.IsUpdatingSweepDirection) { double slice = Math.Max(-360.0, Math.Min(360.0, (pie.EndAngle - pie.StartAngle))) / ((pie.SweepDirection == SweepDirection.Clockwise) ? 360.0 : -360.0); double newValue = DoubleHelper.AreVirtuallyEqual(slice, 0) ? 0 : (slice < 0) ? slice + 1 : slice; if (!DoubleHelper.AreVirtuallyEqual(( double )value, newValue)) { value = newValue; } } return(value); }
private static object CoerceEndAngleValue(DependencyObject d, object value) { // keep EndAngle in sync with Slice and SweepDirection Pie pie = ( Pie )d; if (pie.IsUpdatingSlice || pie.IsUpdatingSweepDirection || (pie.IsUpdatingStartAngle && pie.Mode == PieMode.Slice)) { double newValue = pie.StartAngle + ((pie.SweepDirection == SweepDirection.Clockwise) ? 1.0 : -1.0) * pie.Slice * 360; if (!DoubleHelper.AreVirtuallyEqual(( double )value, newValue)) { value = newValue; } } return(value); }
public static bool ScrollLeastAmount(Rect physViewRect, Rect itemRect, out Vector newPhysOffset) { bool scrollNeeded = false; newPhysOffset = new Vector(); if (physViewRect.Contains(itemRect) == false) { // Check if child is inside the view horizontially. if (itemRect.Left > physViewRect.Left && itemRect.Right < physViewRect.Right || DoubleHelper.AreVirtuallyEqual(itemRect.Left, physViewRect.Left) == true) { newPhysOffset.X = itemRect.Left; } // Child is to the left of the view or is it bigger than the view else if (itemRect.Left < physViewRect.Left || itemRect.Width > physViewRect.Width) { newPhysOffset.X = itemRect.Left; } // Child is to the right of the view else { newPhysOffset.X = Math.Max(0, physViewRect.Left + (itemRect.Right - physViewRect.Right)); } // Check if child is inside the view vertically. if (itemRect.Top > physViewRect.Top && itemRect.Bottom < physViewRect.Bottom || DoubleHelper.AreVirtuallyEqual(itemRect.Top, physViewRect.Top) == true) { newPhysOffset.Y = itemRect.Top; } // Child is the above the view or is it bigger than the view else if (itemRect.Top < physViewRect.Top || itemRect.Height > physViewRect.Height) { newPhysOffset.Y = itemRect.Top; } // Child is below the view else { newPhysOffset.Y = Math.Max(0, physViewRect.Top + (itemRect.Bottom - physViewRect.Bottom)); } scrollNeeded = true; } return(scrollNeeded); }
private static object CoerceSweepDirectionValue(DependencyObject d, object value) { // keep SweepDirection in sync with EndAngle and StartAngle Pie pie = ( Pie )d; if (pie.IsUpdatingEndAngle || pie.IsUpdatingStartAngle || pie.IsUpdatingMode) { if (DoubleHelper.AreVirtuallyEqual(pie.StartAngle, pie.EndAngle)) { // if the values are equal, use previously coerced value value = pie.SweepDirection; } else { value = (pie.EndAngle < pie.StartAngle) ? SweepDirection.Counterclockwise : SweepDirection.Clockwise; } } return(value); }