Octgn.Play.PlayWindow.ShowCardPicture C# (CSharp) Method

ShowCardPicture() private method

private ShowCardPicture ( Card card, System.Windows.Media.Imaging.BitmapSource img ) : double
card Card
img System.Windows.Media.Imaging.BitmapSource
return double
        private double ShowCardPicture(Card card, BitmapSource img)
        {
            //var maxWidth = this.ActualWidth*0.20;
            cardViewer.Height = img.PixelHeight;
            cardViewer.Width = img.PixelWidth;
            //cardViewer.Width = img.PixelWidth > maxWidth ? maxWidth : img.PixelWidth;
            cardViewer.Dispatcher.Invoke(DispatcherPriority.Render, new Action(() => { }));
            cardViewer.Source = img;

            _fadeIn.Begin(outerCardViewer, HandoffBehavior.SnapshotAndReplace);

            double height = Math.Min(cardViewer.MaxHeight, cardViewer.Height);
            double width = cardViewer.Width * height / cardViewer.Height;
            if (img.PixelWidth > img.PixelHeight)
            {
                width = Math.Min(cardViewer.MaxWidth, cardViewer.Width);
                height = cardViewer.Height * width / cardViewer.Width;
            }

            if (cardViewer.Clip == null) return width;

            var clipRect = ((RectangleGeometry)cardViewer.Clip);
            clipRect.Rect = new Rect(new Size(width, height));

            if (card == null)
                clipRect.RadiusX = clipRect.RadiusY = Program.GameEngine.Definition.CardSize.CornerRadius * height / Program.GameEngine.Definition.CardSize.Height;
            else
            {
                clipRect.RadiusX = clipRect.RadiusY = card.RealCornerRadius*height/card.RealHeight;
            }

            return width;
        }