1 // Copyright (C) 2019 Kazuhiro Fujieda <fujieda@users.osdn.me>
\r
3 // Licensed under the Apache License, Version 2.0 (the "License");
\r
4 // you may not use this file except in compliance with the License.
\r
5 // You may obtain a copy of the License at
\r
7 // http://www.apache.org/licenses/LICENSE-2.0
\r
9 // Unless required by applicable law or agreed to in writing, software
\r
10 // distributed under the License is distributed on an "AS IS" BASIS,
\r
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 // See the License for the specific language governing permissions and
\r
13 // limitations under the License.
\r
16 using System.Drawing;
\r
17 using System.Windows.Forms;
\r
19 namespace KancolleSniffer.View
\r
21 public static class Scaler
\r
23 public static SizeF Factor { private get; set; } = new SizeF(1, 1);
\r
25 public static void Scale(Control control)
\r
27 control.Scale(Factor);
\r
30 public static float ScaleWidth(float width)
\r
32 return width * Factor.Width;
\r
35 public static float ScaleHeight(float height)
\r
37 return height * Factor.Height;
\r
40 public static int ScaleWidth(int width)
\r
42 return (int)Math.Round(width * Factor.Width);
\r
45 public static int ScaleHeight(int height)
\r
47 return (int)Math.Round(height * Factor.Height);
\r
50 public static Size Scale(int width, int height)
\r
52 return new Size(ScaleWidth(width), ScaleHeight(height));
\r
55 public static SizeF Scale(float width, float height)
\r
57 return new SizeF(ScaleWidth(width), ScaleHeight(height));
\r
60 public static Point Move(int x, int y, int width, int height)
\r
62 return new Point(x + ScaleWidth(width), y + ScaleHeight(height));
\r
65 public static int DownWidth(int width)
\r
67 return (int)(width / Factor.Width);
\r