コード例 #1
0
        private void SetSize()
        {
            if (CurrentTileset != null && !string.IsNullOrEmpty(CurrentTileset.SpritePath))
            {
                if (LoadedImages.ContainsKey(CurrentTileset.SpritePath))
                {
                    TexData spr            = LoadedImages[CurrentTileset.SpritePath];
                    double  ratio          = (double)spr.image.Height / spr.image.Width;
                    double  adjustedHeight = ActualHeight / ratio;
                    double  maxDimension   = Math.Min(ActualWidth, adjustedHeight);
                    HwndControl.Width             = maxDimension;
                    HwndControl.Height            = maxDimension * ratio;
                    HwndControl.VerticalAlignment = VerticalAlignment.Top;

                    if (renderer != IntPtr.Zero)
                    {
                        HRESULT.Check(WindowAPI.SetSize(renderer, (int)maxDimension, (int)(maxDimension * ratio)));
                    }
                }
            }
        }