protected override Size MeasureOverride(Size availableSize)
        {
            // Note that we do not call the Measure method on any children
            // because a ViewFinderDisplay has no children.  It is merely used
            // as a surface for the view finder's VisualBrush.

            // store the available size for use by the Zoombox control
            _availableSize = availableSize;

            // Simulate size-to-content for the display panel by ensuring a width and height
            // based on the content bounds. Otherwise, the display panel may have no size, since it doesn't
            // contain content.
            double width            = DoubleHelper.IsNaN(ContentBounds.Width) ? 0 : Math.Max(0, ContentBounds.Width);
            double height           = DoubleHelper.IsNaN(ContentBounds.Height) ? 0 : Math.Max(0, ContentBounds.Height);
            Size   displayPanelSize = new Size(width, height);

            // Now ensure that the result fits within the available size while maintaining
            // the width/height ratio of the content bounds
            if (displayPanelSize.Width > availableSize.Width || displayPanelSize.Height > availableSize.Height)
            {
                double aspectX = availableSize.Width / displayPanelSize.Width;
                double aspectY = availableSize.Height / displayPanelSize.Height;
                double scale   = (aspectX < aspectY) ? aspectX : aspectY;
                displayPanelSize = new Size(displayPanelSize.Width * scale, displayPanelSize.Height * scale);
            }

            return(displayPanelSize);
        }
Beispiel #2
0
        public bool Equals(AnimationRate animationRate)
        {
            if (this.HasDuration)
            {
                if (animationRate.HasDuration)
                {
                    return(_duration == animationRate._duration);
                }

                return(false);
            }
            else // HasSpeed
            {
                if (animationRate.HasSpeed)
                {
                    if (DoubleHelper.IsNaN(_speed))
                    {
                        return(DoubleHelper.IsNaN(animationRate._speed));
                    }

                    return(_speed == animationRate._speed);
                }

                return(false);
            }
        }
        public override object ConvertTo(
            ITypeDescriptorContext typeDescriptorContext,
            CultureInfo cultureInfo,
            object value,
            Type destinationType)
        {
            object      result = null;
            ZoomboxView view   = value as ZoomboxView;

            if (view != null)
            {
                if (destinationType == typeof(string))
                {
                    result = "Empty";
                    switch (view.ViewKind)
                    {
                    case ZoomboxViewKind.Absolute:
                        if (PointHelper.IsEmpty(view.Position))
                        {
                            if (!DoubleHelper.IsNaN(view.Scale))
                            {
                                result = view.Scale.ToString();
                            }
                        }
                        else if (DoubleHelper.IsNaN(view.Scale))
                        {
                            result = view.Position.X.ToString() + "," + view.Position.Y.ToString();
                        }
                        else
                        {
                            result = view.Scale.ToString() + ","
                                     + view.Position.X.ToString() + ","
                                     + view.Position.Y.ToString();
                        }
                        break;

                    case ZoomboxViewKind.Center:
                        result = "Center";
                        break;

                    case ZoomboxViewKind.Fill:
                        result = "Fill";
                        break;

                    case ZoomboxViewKind.Fit:
                        result = "Fit";
                        break;

                    case ZoomboxViewKind.Region:
                        result = view.Region.X.ToString() + ","
                                 + view.Region.Y.ToString() + ","
                                 + view.Region.Width.ToString() + ","
                                 + view.Region.Height.ToString();
                        break;
                    }
                }
            }
            return(result == null ? base.ConvertTo(typeDescriptorContext, cultureInfo, value, destinationType) : result);
        }
Beispiel #4
0
 public AnimationRate(double speed)
 {
     if (DoubleHelper.IsNaN(speed) || speed < 0d)
     {
         throw new ArgumentException(ErrorMessages.GetMessage(ErrorMessages.NegativeSpeedNotSupported));
     }
     _duration = 0;
     _speed    = speed;
     _rateType = RateType.Speed;
 }
Beispiel #5
0
        private static bool ValidateSlice(object value)
        {
            double newValue = ( double )value;

            if (newValue < 0 || newValue > 1 || DoubleHelper.IsNaN(newValue))
            {
                throw new ArgumentException(ErrorMessages.GetMessage("SliceOOR"));
            }

            return(true);
        }
        public static void SetValueWithAnimation(this DataPoint dataPoint, DependencyProperty dp, string propertyName, double value)
        {
            double num = (double)dataPoint.GetValue(dp);

            if (num == value)
            {
                return;
            }
            Series series = dataPoint.Series;

            if (series == null || series.ChartArea == null || (DoubleHelper.IsNaN(num) || DoubleHelper.IsNaN(value)))
            {
                dataPoint.SetValue(dp, (object)value);
            }
            else
            {
                DependencyPropertyAnimationHelper.BeginAnimation(series.ChartArea, propertyName, (object)num, (object)value, (Action <object, object>)((current, next) => dataPoint.SetValue(dp, next)), dataPoint.Storyboards, series.ActualTransitionDuration, series.ActualTransitionEasingFunction);
            }
        }
Beispiel #7
0
 internal bool IsSizeEmptyOrUndefined(Size size)
 {
     return(DoubleHelper.IsNaN(size.Width) || DoubleHelper.IsNaN(size.Height) || size.IsEmpty);
 }
        private static bool IsWidthHeightValid(object value)
        {
            double num = (double)value;

            return(DoubleHelper.IsNaN(num) || ((num >= 0d) && !double.IsPositiveInfinity(num)));
        }