OSDN Git Service

File.Moveがエラーになることがあるのを直す
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer / AirBattleResultPanel.cs
index 0b4bbb5..7212d05 100644 (file)
@@ -14,6 +14,7 @@
 \r
 using System;\r
 using System.Collections.Generic;\r
+using System.ComponentModel;\r
 using System.Drawing;\r
 using System.Windows.Forms;\r
 \r
@@ -31,30 +32,43 @@ namespace KancolleSniffer
             public int EnemyLost { get; set; }\r
         }\r
 \r
+        public class AirFireResult\r
+        {\r
+            public string ShipName { get; set; }\r
+            public int Kind { get; set; }\r
+            public string[] Items { get; set; }\r
+        }\r
+\r
         public string PhaseName { get; set; }\r
         public int AirControlLevel { get; set; }\r
-        public StageResult Stage1 { get; set; } = new StageResult();\r
-        public StageResult Stage2 { get; set; } = new StageResult();\r
+        public StageResult Stage1 { get; set;  }\r
+        public StageResult Stage2 { get; set;  }\r
+        public AirFireResult AirFire { get; set; }\r
     }\r
 \r
+    [DesignerCategory("Code")]\r
     public class AirBattleResultPanel : Panel\r
     {\r
         private readonly Label _phaseName;\r
         private readonly Label _stage1;\r
         private readonly Label[][][] _resultLabels = new Label[2][][];\r
-        private List<AirBattleResult> _resultList;\r
+        private AirBattleResult[] _resultList;\r
         private int _resultIndex;\r
+        private readonly ShipLabel _ciShipName;\r
+        private readonly Label _ciKind;\r
+        private readonly ResizableToolTip _toolTip = new ResizableToolTip{ShowAlways = true};\r
 \r
         public bool ShowResultAutomatic { get; set; }\r
 \r
         private bool ResultRemained\r
         {\r
-            set { _phaseName.BorderStyle = value ? BorderStyle.FixedSingle : BorderStyle.None; }\r
+            set => _phaseName.BorderStyle = value ? BorderStyle.FixedSingle : BorderStyle.None;\r
         }\r
 \r
         public AirBattleResultPanel()\r
         {\r
             const int top = 20;\r
+            const int ci = 168;\r
             var labels = new[]\r
             {\r
                 _phaseName =\r
@@ -68,10 +82,12 @@ namespace KancolleSniffer
                 _stage1 = new Label {Text = "stage1", Location = new Point(8, top), AutoSize = true},\r
                 new Label {Text = "stage2", Location = new Point(8, top + 14), AutoSize = true},\r
                 new Label {Text = "自軍", Location = new Point(67, 6), AutoSize = true},\r
-                new Label {Text = "敵軍", Location = new Point(124, 6), AutoSize = true}\r
+                new Label {Text = "敵軍", Location = new Point(122, 6), AutoSize = true},\r
+                new Label {Text = "CI", Location = new Point(ci, 4), AutoSize = true}\r
             };\r
             Controls.AddRange(labels);\r
-            const int left = 54;\r
+            const int left = 53;\r
+            const int space = 55;\r
             for (var stage = 0; stage < 2; stage++)\r
             {\r
                 _resultLabels[stage] = new Label[2][];\r
@@ -80,37 +96,47 @@ namespace KancolleSniffer
                     _resultLabels[stage][fe] = new Label[2];\r
                     Controls.Add(_resultLabels[stage][fe][1] = new Label\r
                     {\r
-                        Location = new Point(left + 32 + 57 * fe, top + 14 * stage),\r
-                        Size = new Size(23, 12),\r
+                        Location = new Point(left + 34 + space * fe, top + 14 * stage),\r
+                        Size = new Size(24, 12),\r
                         TextAlign = ContentAlignment.TopLeft\r
                     });\r
                     Controls.Add(new Label\r
                     {\r
-                        Location = new Point(left + 20 + 57 * fe, top + 14 * stage),\r
+                        Location = new Point(left + 21 + space * fe, top + 14 * stage),\r
                         Text = "→",\r
                         AutoSize = true\r
                     });\r
                     Controls.Add(_resultLabels[stage][fe][0] = new Label\r
                     {\r
-                        Location = new Point(left + 57 * fe, top + 14 * stage),\r
-                        Size = new Size(23, 12),\r
+                        Location = new Point(left + space * fe, top + 14 * stage),\r
+                        Size = new Size(24, 12),\r
                         TextAlign = ContentAlignment.TopRight\r
                     });\r
                 }\r
             }\r
+            Controls.Add(_ciShipName = new ShipLabel\r
+            {\r
+                Location = new Point(ci, top),\r
+                Size = new Size((int)ShipNameWidth.CiShipName, 12)\r
+            });\r
+            Controls.Add(_ciKind = new Label\r
+            {\r
+                Location = new Point(ci, top + 14),\r
+                Size = new Size(24, 12)\r
+            });\r
             _phaseName.Click += PhaseNameOnClick;\r
         }\r
 \r
         public void SetResult(List<AirBattleResult> resultList)\r
         {\r
-            _resultList = resultList;\r
-            if (_resultList.Count == 0)\r
+            _resultList = resultList.ToArray();\r
+            if (_resultList.Length == 0)\r
             {\r
                 ResultRemained = false;\r
                 ClearResult();\r
                 return;\r
             }\r
-            _resultIndex = _resultList.Count - 1;\r
+            _resultIndex = _resultList.Length - 1;\r
             if (!ShowResultAutomatic)\r
             {\r
                 ResultRemained = true;\r
@@ -118,23 +144,23 @@ namespace KancolleSniffer
                 return;\r
             }\r
             ShowResult();\r
-            ResultRemained = _resultList.Count > 1;\r
+            ResultRemained = _resultList.Length > 1;\r
             _resultIndex = 0;\r
         }\r
 \r
         private void PhaseNameOnClick(object sender, EventArgs eventArgs)\r
         {\r
-            if (_resultList == null || _resultList.Count == 0)\r
+            if (_resultList == null || _resultList.Length == 0)\r
                 return;\r
             ShowResult();\r
-            if (_resultList.Count == 1)\r
+            if (_resultList.Length == 1)\r
                 ResultRemained = false;\r
-            _resultIndex = (_resultIndex + 1) % _resultList.Count;\r
+            _resultIndex = (_resultIndex + 1) % _resultList.Length;\r
         }\r
 \r
         private void ShowResult()\r
         {\r
-            if (_resultIndex >= _resultList.Count)\r
+            if (_resultIndex >= _resultList.Length)\r
                 return;\r
             var result = _resultList[_resultIndex];\r
             _phaseName.Text = result.PhaseName;\r
@@ -150,6 +176,24 @@ namespace KancolleSniffer
                 labels[1][0].Text = $"{stage.EnemyCount}";\r
                 labels[1][1].Text = $"{stage.EnemyCount - stage.EnemyLost}";\r
             }\r
+            ShowAirFireResult();\r
+        }\r
+\r
+        private void ShowAirFireResult()\r
+        {\r
+            var result = _resultList[_resultIndex];\r
+            if (result.AirFire == null)\r
+            {\r
+                _ciShipName.SetName(null);\r
+                _ciKind.Text = "";\r
+                _toolTip.SetToolTip(_ciKind, "");\r
+            }\r
+            else\r
+            {\r
+                _ciShipName.SetName(result.AirFire.ShipName, ShipNameWidth.CiShipName);\r
+                _ciKind.Text = result.AirFire.Kind.ToString();\r
+                _toolTip.SetToolTip(_ciKind, string.Join("\r\n", result.AirFire.Items));\r
+            }\r
         }\r
 \r
         private void ClearResult()\r
@@ -166,6 +210,16 @@ namespace KancolleSniffer
                     }\r
                 }\r
             }\r
+            _ciShipName.SetName(null);\r
+            _ciKind.Text = "";\r
+            _toolTip.SetToolTip(_ciKind, "");\r
+        }\r
+\r
+        protected override void ScaleControl(SizeF factor, BoundsSpecified specified)\r
+        {\r
+            base.ScaleControl(factor, specified);\r
+            if (factor.Height > 1)\r
+                _toolTip.Font = new Font(_toolTip.Font.FontFamily, _toolTip.Font.Size * factor.Height);\r
         }\r
     }\r
 }
\ No newline at end of file