Beispiel #1
0
        protected override Size MeasureOverride(Size availableSize)
        {
            var progress = this.Progress;

            if (progress != null)
            {
                if (!Double.IsInfinity(availableSize.Width))
                {
                    progress.Width = Math.Min(96, Math.Max(8, availableSize.Width * 0.5));
                }
                if (!Double.IsInfinity(availableSize.Height))
                {
                    progress.Height = Math.Min(96, Math.Max(8, availableSize.Height * 0.5));
                }
                base.MeasureOverride(availableSize);
                _currentSize = NormalizeSize(availableSize);
                return(_currentSize);
            }

            var newSize = new Size(Math.Min(Int16.MaxValue, availableSize.Width), Math.Min(Int16.MaxValue, availableSize.Height));

            if (_isHttpSource && BitmapCache.GetSizeLevel(_currentSize) != BitmapCache.GetSizeLevel(newSize))
            {
                _currentSize = newSize;
                RefreshSourceUri(_currentUri);
            }
            return(base.MeasureOverride(availableSize));
        }
Beispiel #2
0
        private void OnSizeChanged(object sender, SizeChangedEventArgs e)
        {
            var imageSize = _image.DesiredSize;

            if (imageSize.Width > 0 && imageSize.Height > 0)
            {
                if (_isHttpSource && BitmapCache.GetSizeLevel(_currentSize) != BitmapCache.GetSizeLevel(imageSize))
                {
                    _currentSize = imageSize;
                    RefreshImage();
                }
            }
        }