//------------------------------------------------------------------- // // Private Methods // //------------------------------------------------------------------- #region Private Methods /// <summary> /// Contains the code common for MeasureOverride and ArrangeOverride. /// </summary> /// <param name="inputSize">input size is the parent-provided space that Image should use to "fit in", according to other properties.</param> /// <returns>Image's desired size.</returns> private Size MeasureArrangeHelper(Size inputSize) { ImageSource imageSource = Source; Size naturalSize = new Size(); if (imageSource == null) { return(naturalSize); } try { UpdateBaseUri(this, imageSource); naturalSize = imageSource.Size; } catch (Exception e) { SetCurrentValue(SourceProperty, null); RaiseEvent(new ExceptionRoutedEventArgs(ImageFailedEvent, this, e)); } //get computed scale factor Size scaleFactor = Viewbox.ComputeScaleFactor(inputSize, naturalSize, this.Stretch, this.StretchDirection); // Returns our minimum size & sets DesiredSize. return(new Size(naturalSize.Width * scaleFactor.Width, naturalSize.Height * scaleFactor.Height)); }
// Token: 0x060051B1 RID: 20913 RVA: 0x0016DB5C File Offset: 0x0016BD5C private Size MeasureArrangeHelper(Size inputSize) { MediaPlayer player = this._helper.Player; if (player == null) { return(default(Size)); } Size contentSize = new Size((double)player.NaturalVideoWidth, (double)player.NaturalVideoHeight); Size size = Viewbox.ComputeScaleFactor(inputSize, contentSize, this.Stretch, this.StretchDirection); return(new Size(contentSize.Width * size.Width, contentSize.Height * size.Height)); }
/// <summary>Arranges the content of a <see cref="T:System.Windows.Controls.Viewbox" /> element.</summary> /// <param name="arrangeSize">The <see cref="T:System.Windows.Size" /> this element uses to arrange its child elements.</param> /// <returns> /// <see cref="T:System.Windows.Size" /> that represents the arranged size of this <see cref="T:System.Windows.Controls.Viewbox" /> element and its child elements.</returns> protected override Size ArrangeOverride(Size arrangeSize) { UIElement internalChild = this.InternalChild; if (internalChild != null) { Size desiredSize = internalChild.DesiredSize; Size size = Viewbox.ComputeScaleFactor(arrangeSize, desiredSize, this.Stretch, this.StretchDirection); this.InternalTransform = new ScaleTransform(size.Width, size.Height); internalChild.Arrange(new Rect(default(Point), internalChild.DesiredSize)); arrangeSize.Width = size.Width * desiredSize.Width; arrangeSize.Height = size.Height * desiredSize.Height; } return(arrangeSize); }
/// <summary>Measures the child elements of a <see cref="T:System.Windows.Controls.Viewbox" /> prior to arranging them during the <see cref="M:System.Windows.Controls.WrapPanel.ArrangeOverride(System.Windows.Size)" /> pass.</summary> /// <param name="constraint">A <see cref="T:System.Windows.Size" /> limit that <see cref="T:System.Windows.Controls.Viewbox" /> cannot exceed.</param> /// <returns>The <see cref="T:System.Windows.Size" /> that represents the element size you want.</returns> protected override Size MeasureOverride(Size constraint) { UIElement internalChild = this.InternalChild; Size result = default(Size); if (internalChild != null) { Size availableSize = new Size(double.PositiveInfinity, double.PositiveInfinity); internalChild.Measure(availableSize); Size desiredSize = internalChild.DesiredSize; Size size = Viewbox.ComputeScaleFactor(constraint, desiredSize, this.Stretch, this.StretchDirection); result.Width = size.Width * desiredSize.Width; result.Height = size.Height * desiredSize.Height; } return(result); }
/// <summary> /// Contains the code common for MeasureOverride and ArrangeOverride. /// </summary> /// <param name="inputSize">input size is the parent-provided space that Video should use to "fit in", according to other properties.</param> /// <returns>MediaElement's desired size.</returns> private Size MeasureArrangeHelper(Size inputSize) { MediaPlayer mediaPlayer = _helper.Player; if (mediaPlayer == null) { return(new Size()); } Size naturalSize = new Size((double)mediaPlayer.NaturalVideoWidth, (double)mediaPlayer.NaturalVideoHeight); //get computed scale factor Size scaleFactor = Viewbox.ComputeScaleFactor(inputSize, naturalSize, this.Stretch, this.StretchDirection); // Returns our minimum size & sets DesiredSize. return(new Size(naturalSize.Width * scaleFactor.Width, naturalSize.Height * scaleFactor.Height)); }
// Token: 0x06004E77 RID: 20087 RVA: 0x00160E44 File Offset: 0x0015F044 private Size MeasureArrangeHelper(Size inputSize) { ImageSource source = this.Source; Size size = default(Size); if (source == null) { return(size); } try { Image.UpdateBaseUri(this, source); size = source.Size; } catch (Exception errorException) { base.SetCurrentValue(Image.SourceProperty, null); base.RaiseEvent(new ExceptionRoutedEventArgs(Image.ImageFailedEvent, this, errorException)); } Size size2 = Viewbox.ComputeScaleFactor(inputSize, size, this.Stretch, this.StretchDirection); return(new Size(size.Width * size2.Width, size.Height * size2.Height)); }