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(this.ContentBounds.Width) ? 0 : Math.Max(0, this.ContentBounds.Width); double height = DoubleHelper.IsNaN(this.ContentBounds.Height) ? 0 : Math.Max(0, this.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); }
public static bool IsEmpty(Point point) { return(DoubleHelper.IsNaN(point.X) && DoubleHelper.IsNaN(point.Y)); }