+ public readonly string Origin;\r
+ public readonly string Result;\r
+\r
+ public Pair()\r
+ {\r
+ Origin = "";\r
+ Result = "";\r
+ }\r
+\r
+ public Pair(string origin, string result)\r
+ {\r
+ Origin = origin;\r
+ Result = result;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// 文字数制限がない\r
+ /// </summary>\r
+ [TestMethod]\r
+ public void Unlimited()\r
+ {\r
+ var label = new ShipLabel.Name(Point.Empty, ShipNameWidth.Max){Parent = new Panel()};\r
+ var str = "一二三四五六七八九〇一二三四五六七八九〇一二三四五六七八九〇";\r
+ label.SetName(str);\r
+ Assert.AreEqual(str, label.Text);\r
+ }\r
+\r
+ /// <summary>\r
+ /// 明石タイマー表示中の艦娘の名前を縮める\r
+ /// </summary>\r
+ [TestMethod]\r
+ public void ForAkashiTimer()\r
+ {\r
+ var data = new TestData\r
+ {\r
+ {\r
+ 100,\r
+ new[]\r
+ {\r
+ new Pair("夕立改二", "夕立改二"),\r
+ new Pair("千代田航改", "千代田航"),\r
+ new Pair("千代田航改二", "千代田航"),\r
+ new Pair("Bismarck改", "Bismarck"),\r
+ new Pair("Bismarck zwei", "Bismarck"),\r
+ new Pair("Bismarck drei", "Bismarck"),\r
+ new Pair("Prinz Eugen", "Prinz Eug"),\r
+ new Pair("Prinz Eugen改", "Prinz Eug"),\r
+ new Pair("Graf Zeppelin", "Graf Zep"),\r
+ new Pair("Graf Zeppelin改", "Graf Zep"),\r
+ new Pair("Libeccio改", "Libeccio")\r
+ }\r
+ },\r
+ {\r
+ 125,\r
+ new[]\r
+ {\r
+ new Pair(),\r
+ new Pair(),\r
+ new Pair(),\r
+ new Pair(),\r
+ new Pair(),\r
+ new Pair(),\r
+ new Pair(),\r
+ new Pair(),\r
+ new Pair("Graf Zeppelin", "Graf Zepp"),\r
+ new Pair("Graf Zeppelin改", "Graf Zepp"),\r
+ new Pair("Libeccio改", "Libeccio改")\r
+ }\r
+ }\r
+ };\r
+ TestTruncate(data, ShipNameWidth.AkashiTimer);\r
+ }\r
+\r
+ /// <summary>\r
+ /// 入渠中の艦娘名の名前を縮める\r
+ /// </summary>\r
+ [TestMethod]\r
+ public void ForNDock()\r
+ {\r
+ var data = new TestData\r
+ {\r
+ {\r
+ 100, new[]\r
+ {\r
+ new Pair("千歳航改二", "千歳航改二"),\r
+ new Pair("千代田航改二", "千代田航改"),\r
+ new Pair("Graf Zeppelin", "Graf Zeppeli"),\r
+ new Pair("Graf Zeppelin改", "Graf Zeppeli")\r
+ }\r
+ },\r
+ {\r
+ 125, new[]\r
+ {\r
+ new Pair(),\r
+ new Pair(),\r
+ new Pair("Graf Zeppelin", "Graf Zeppelin"),\r
+ new Pair("Graf Zeppelin改", "Graf Zeppelin")\r
+ }\r
+ }\r
+ };\r
+ TestTruncate(data, ShipNameWidth.NDock);\r
+ }\r
+\r
+ /// <summary>\r
+ /// 一覧ウィンドウの要修復一覧の艦娘の名前を縮める\r
+ /// </summary>\r
+ [TestMethod]\r
+ public void ForRepairListFull()\r
+ {\r
+ var data = new TestData\r
+ {\r
+ {\r
+ 100,\r
+ new[]\r
+ {\r
+ new Pair("Graf Zeppelin", "Graf Zeppelin"),\r
+ new Pair("Graf Zeppelin改", "Graf Zeppelin"),\r
+ new Pair("千代田航改二", "千代田航改")\r
+ }\r
+ },\r
+ {\r
+ 125,\r
+ new[]\r
+ {\r
+ new Pair(),\r
+ new Pair(),\r
+ new Pair("千代田航改二", "千代田航改二")\r
+ }\r
+ }\r
+ };\r
+ TestTruncate(data, ShipNameWidth.RepairListFull);\r
+ }\r
+\r
+ /// <summary>\r
+ /// メインパネルの艦娘の名前を縮める\r
+ /// </summary>\r
+ [TestMethod]\r
+ public void ForMainPanel()\r
+ {\r
+ var data = new TestData\r
+ {\r
+ {\r
+ 100,\r
+ new[]\r
+ {\r
+ new Pair("Commandant Teste", "Commandant Tes")\r
+ }\r
+ },\r
+ {\r
+ 125,\r
+ new[]\r
+ {\r
+ new Pair("Commandant Teste", "Commandant Test")\r
+ }\r
+ }\r
+ };\r
+ TestTruncate(data, ShipNameWidth.MainPanel);\r
+ }\r
+\r
+ /// <summary>\r
+ /// 一覧ウィンドウの艦娘一覧の名前を縮める\r
+ /// </summary>\r
+ [TestMethod]\r
+ public void ForShipList()\r
+ {\r
+ var data = new TestData\r
+ {\r
+ {\r
+ 100,\r
+ new[]\r
+ {\r
+ new Pair("Commandant Teste", "Commandant T"),\r
+ new Pair("Graf Zeppelin改", "Graf Zeppelin")\r
+ }\r
+ },\r
+ {\r
+ 125,\r
+ new[]\r
+ {\r
+ new Pair(),\r
+ new Pair("Graf Zeppelin改", "Graf Zeppelin改")\r
+ }\r
+ }\r
+ };\r
+ TestTruncate(data, ShipNameWidth.ShipList);\r
+ }\r
+\r
+ private static void TestTruncate(TestData data, ShipNameWidth width)\r
+ {\r
+ foreach (var zoom in data.Keys)\r
+ {\r
+ SetScaleFactor(zoom);\r
+ var label = new ShipLabel.Name(Point.Empty, width) {Font = ShipLabel.Name.BaseFont};\r
+ for (var i = 0; i < data[zoom].Length; i++)\r
+ {\r
+ var entry = data[zoom][i];\r
+ if (string.IsNullOrEmpty(entry.Origin))\r
+ entry = data[100][i];\r
+ label.SetName(entry.Origin);\r
+ Assert.AreEqual(entry.Result, label.Text, $"{entry.Origin}: scale {zoom}");\r
+ }\r
+ }\r
+ }\r
+\r
+ private static void SetScaleFactor(int zoom)\r
+ {\r
+ var form = new Form {AutoScaleMode = AutoScaleMode.Font};\r
+ if (zoom == 100)\r
+ {\r
+ Scaler.Factor = new SizeF(1, 1);\r
+ ShipLabel.Name.BaseFont = form.Font;\r
+ ShipLabel.Name.LatinFont = LatinFont(100);\r
+ return;\r
+ }\r
+ var prev = form.CurrentAutoScaleDimensions;\r
+ form.Font = new Font(form.Font.FontFamily, form.Font.Size * zoom / 100);\r
+ ShipLabel.Name.BaseFont = form.Font;\r
+ ShipLabel.Name.LatinFont = LatinFont(zoom);\r
+ var cur = form.CurrentAutoScaleDimensions;\r
+ Scaler.Factor = new SizeF(cur.Width / prev.Width, cur.Height / prev.Height);\r
+ }\r
+\r
+ private static Font LatinFont(int zoom)\r
+ {\r
+ return new Font("Tahoma", 8f * zoom / 100);\r