Ejemplo n.º 1
0
        /// <summary>
        /// ズームを適用します。
        /// </summary>
        public void ApplyZoom()
        {
            if (!IsBrowserInitialized)
            {
                return;
            }


            double zoomRate = Configuration.ZoomRate;
            bool   fit      = Configuration.ZoomFit && StyleSheetApplied;


            double zoomFactor;

            if (fit)
            {
                double rateX = (double)SizeAdjuster.Width / KanColleSize.Width;
                double rateY = (double)SizeAdjuster.Height / KanColleSize.Height;
                zoomFactor = Math.Min(rateX, rateY);
            }
            else
            {
                if (zoomRate < 0.1)
                {
                    zoomRate = 0.1;
                }
                if (zoomRate > 10)
                {
                    zoomRate = 10;
                }

                zoomFactor = zoomRate;
            }

            Browser.GetDocShellAttribute().GetContentViewerAttribute().SetFullZoomAttribute((float)zoomFactor);


            if (StyleSheetApplied)
            {
                Browser.Size = Browser.MinimumSize = new Size(
                    (int)(KanColleSize.Width * zoomFactor),
                    (int)(KanColleSize.Height * zoomFactor)
                    );

                CenteringBrowser();
            }

            if (fit)
            {
                ToolMenu_Other_Zoom_Current.Text = "現在: ぴったり";
            }
            else
            {
                ToolMenu_Other_Zoom_Current.Text = $"現在: {zoomRate:p1}";
            }
        }