OSDN Git Service

一覧の要修復一覧の表示をRepairListLabelsに分離する
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Thu, 16 May 2019 08:22:36 +0000 (17:22 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Fri, 17 May 2019 06:47:16 +0000 (15:47 +0900)
KancolleSniffer/KancolleSniffer.csproj
KancolleSniffer/View/RepairListLabels.cs [new file with mode: 0644]
KancolleSniffer/View/ShipListPanel.cs

index 2ea5801..f3cfba8 100644 (file)
     <Compile Include="Properties\AssemblyInfo.cs" />\r
     <Compile Include="Model\QuestInfo.cs" />\r
     <Compile Include="Model\ConditionTimer.cs" />\r
+    <Compile Include="View\RepairListLabels.cs" />\r
     <Compile Include="View\RepairShipCount.cs" />\r
     <Compile Include="View\ResizableToolTip.cs">\r
       <SubType>Component</SubType>\r
diff --git a/KancolleSniffer/View/RepairListLabels.cs b/KancolleSniffer/View/RepairListLabels.cs
new file mode 100644 (file)
index 0000000..e0b4aa7
--- /dev/null
@@ -0,0 +1,104 @@
+// Copyright (C) 2019 Kazuhiro Fujieda <fujieda@users.osdn.me>\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//    http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+\r
+using System.Collections.Generic;\r
+using System.Drawing;\r
+using System.Windows.Forms;\r
+\r
+namespace KancolleSniffer.View\r
+{\r
+    public class RepairListLabels\r
+    {\r
+        private readonly ShipListPanel _shipListPanel;\r
+        private readonly List<ShipLabel[]> _labelList = new List<ShipLabel[]>();\r
+        private readonly List<Panel> _panelList = new List<Panel>();\r
+\r
+        public RepairListLabels(ShipListPanel shipListPanel)\r
+        {\r
+            _shipListPanel = shipListPanel;\r
+        }\r
+\r
+        public void CreateLabels(int i)\r
+        {\r
+            var y = ShipListPanel.LineHeight * i + 1;\r
+            const int height = ShipListPanel.LabelHeight;\r
+            var panel = new Panel\r
+            {\r
+                Location = new Point(0, y),\r
+                Size = new Size(ListForm.PanelWidth, ShipListPanel.LineHeight),\r
+                BackColor = ShipLabel.ColumnColors[(i + 1) % 2]\r
+            };\r
+            Scaler.Scale(panel);\r
+            panel.Tag = panel.Location.Y;\r
+            var labels = new[]\r
+            {\r
+                new ShipLabel\r
+                {\r
+                    Location = new Point(118, 0),\r
+                    AutoSize = true,\r
+                    AnchorRight = true,\r
+                    MinimumSize = new Size(0, ShipListPanel.LineHeight),\r
+                    TextAlign = ContentAlignment.MiddleLeft,\r
+                    Cursor = Cursors.Hand\r
+                },\r
+                new ShipLabel\r
+                {\r
+                    Location = new Point(116, 2),\r
+                    Size = new Size(24, height),\r
+                    TextAlign = ContentAlignment.MiddleRight\r
+                },\r
+                new ShipLabel {Location = new Point(141, 2), AutoSize = true},\r
+                new ShipLabel {Location = new Point(186, 2), AutoSize = true},\r
+                new ShipLabel {Location = new Point(10, 2), AutoSize = true},\r
+                new ShipLabel {Location = new Point(1, 2), AutoSize = true}\r
+            };\r
+            _labelList.Add(labels);\r
+            _panelList.Add(panel);\r
+            // ReSharper disable once CoVariantArrayConversion\r
+            panel.Controls.AddRange(labels);\r
+            _shipListPanel.Controls.Add(panel);\r
+            var unused = panel.Handle; // create handle\r
+            foreach (var label in labels)\r
+            {\r
+                Scaler.Scale(label);\r
+                label.PresetColor =\r
+                    label.BackColor = ShipLabel.ColumnColors[(i + 1) % 2];\r
+            }\r
+            _shipListPanel.SetHpPercent(labels[0]);\r
+        }\r
+\r
+        public void SetRepairList(int i)\r
+        {\r
+            var s = _shipListPanel.GetShip(i);\r
+            if (s.Level == 1000)\r
+            {\r
+                _shipListPanel.SetShipType(i);\r
+                return;\r
+            }\r
+            var labels = _labelList[i];\r
+            labels[0].SetHp(s);\r
+            labels[1].SetLevel(s);\r
+            labels[2].SetRepairTime(s);\r
+            labels[3].Text = s.RepairTimePerHp.ToString(@"mm\:ss");\r
+            labels[4].SetName(s, ShipNameWidth.RepairListFull);\r
+            labels[5].SetFleet(s);\r
+            _panelList[i].Visible = true;\r
+        }\r
+\r
+        public void HidePanel(int i)\r
+        {\r
+            _panelList[i].Visible = false;\r
+        }\r
+    }\r
+}
\ No newline at end of file
index 3b6f7cb..fa928f2 100644 (file)
@@ -30,10 +30,9 @@ namespace KancolleSniffer.View
         private ShipStatus[] _shipList;\r
         private readonly List<ShipLabel[]> _labelList = new List<ShipLabel[]>();\r
         private readonly List<Panel> _labelPanelList = new List<Panel>();\r
-        private readonly List<ShipLabel[]> _repairLabelList = new List<ShipLabel[]>();\r
-        private readonly List<Panel> _repairPanelList = new List<Panel>();\r
         private readonly List<ShipLabel> _hpLabels = new List<ShipLabel>();\r
         private readonly GroupConfigLabels _groupConfigLabels;\r
+        private readonly RepairListLabels _repairListLabels;\r
         private string _mode;\r
         private bool _hpPercent;\r
 \r
@@ -58,6 +57,7 @@ namespace KancolleSniffer.View
             ScrollBar.ValueChanged += ScrollBarOnValueChanged;\r
             Controls.Add(ScrollBar);\r
             _groupConfigLabels = new GroupConfigLabels(this);\r
+            _repairListLabels = new RepairListLabels(this);\r
         }\r
 \r
         private void ScrollBarOnValueChanged(object sender, EventArgs eventArgs)\r
@@ -273,7 +273,7 @@ namespace KancolleSniffer.View
             for (var i = _labelList.Count; i * LineHeight < Height; i++)\r
             {\r
                 _groupConfigLabels.CreateComponents(i);\r
-                CreateRepairLabels(i);\r
+                _repairListLabels.CreateLabels(i);\r
                 CreateShipLabels(i);\r
             }\r
             SetupScrollBar();\r
@@ -298,58 +298,6 @@ namespace KancolleSniffer.View
             ScrollBar.Value = Min(ScrollBar.Value, max);\r
         }\r
 \r
-        private void CreateRepairLabels(int i)\r
-        {\r
-            var y = LineHeight * i + 1;\r
-            const int height = LabelHeight;\r
-            var panel = new Panel\r
-            {\r
-                Location = new Point(0, y),\r
-                Size = new Size(ListForm.PanelWidth, LineHeight),\r
-                BackColor = ShipLabel.ColumnColors[(i + 1) % 2]\r
-            };\r
-            Scaler.Scale(panel);\r
-            panel.Tag = panel.Location.Y;\r
-            var labels = new[]\r
-            {\r
-                new ShipLabel\r
-                {\r
-                    Location = new Point(118, 0),\r
-                    AutoSize = true,\r
-                    AnchorRight = true,\r
-                    MinimumSize = new Size(0, LineHeight),\r
-                    TextAlign = ContentAlignment.MiddleLeft,\r
-                    Cursor = Cursors.Hand\r
-                },\r
-                new ShipLabel\r
-                {\r
-                    Location = new Point(116, 2),\r
-                    Size = new Size(24, height),\r
-                    TextAlign = ContentAlignment.MiddleRight\r
-                },\r
-                new ShipLabel {Location = new Point(141, 2), AutoSize = true},\r
-                new ShipLabel {Location = new Point(186, 2), AutoSize = true},\r
-                new ShipLabel {Location = new Point(10, 2), AutoSize = true},\r
-                new ShipLabel {Location = new Point(1, 2), AutoSize = true}\r
-            };\r
-            _repairLabelList.Add(labels);\r
-            _repairPanelList.Add(panel);\r
-            // ReSharper disable once CoVariantArrayConversion\r
-            panel.Controls.AddRange(labels);\r
-            Controls.Add(panel);\r
-            var unused = panel.Handle; // create handle\r
-            foreach (var label in labels)\r
-            {\r
-                Scaler.Scale(label);\r
-                label.PresetColor =\r
-                    label.BackColor = ShipLabel.ColumnColors[(i + 1) % 2];\r
-            }\r
-            if (_hpPercent)\r
-                labels[0].ToggleHpPercent();\r
-            _hpLabels.Add(labels[0]);\r
-            labels[0].DoubleClick += HpLabelClickHandler;\r
-        }\r
-\r
         private void CreateShipLabels(int i)\r
         {\r
             var y = LineHeight * i + 1;\r
@@ -405,10 +353,15 @@ namespace KancolleSniffer.View
                 label.PresetColor =\r
                     label.BackColor = ShipLabel.ColumnColors[(i + 1) % 2];\r
             }\r
+            SetHpPercent(labels[0]);\r
+        }\r
+\r
+        public void SetHpPercent(ShipLabel label)\r
+        {\r
             if (_hpPercent)\r
-                labels[0].ToggleHpPercent();\r
-            _hpLabels.Add(labels[0]);\r
-            labels[0].DoubleClick += HpLabelClickHandler;\r
+                label.ToggleHpPercent();\r
+            _hpLabels.Add(label);\r
+            label.DoubleClick += HpLabelClickHandler;\r
         }\r
 \r
         private void SetShipLabels()\r
@@ -423,13 +376,14 @@ namespace KancolleSniffer.View
                 if (_mode == "分類")\r
                     _groupConfigLabels.SetGrouping(i);\r
                 if (_mode == "修復")\r
-                    SetRepairList(i);\r
+                    _repairListLabels.SetRepairList(i);\r
             }\r
         }\r
 \r
         private void HidePanels(int i)\r
         {\r
-            _labelPanelList[i].Visible = _repairPanelList[i].Visible = false;\r
+            _labelPanelList[i].Visible = false;\r
+            _repairListLabels.HidePanel(i);\r
             _groupConfigLabels.HidePanel(i);\r
         }\r
 \r
@@ -467,24 +421,6 @@ namespace KancolleSniffer.View
             _labelPanelList[i].Visible = true;\r
         }\r
 \r
-        private void SetRepairList(int i)\r
-        {\r
-            var s = _shipList[i + ScrollBar.Value];\r
-            if (s.Level == 1000)\r
-            {\r
-                SetShipType(i);\r
-                return;\r
-            }\r
-            var labels = _repairLabelList[i];\r
-            labels[0].SetHp(s);\r
-            labels[1].SetLevel(s);\r
-            labels[2].SetRepairTime(s);\r
-            labels[3].Text = s.RepairTimePerHp.ToString(@"mm\:ss");\r
-            labels[4].SetName(s, ShipNameWidth.RepairListFull);\r
-            labels[5].SetFleet(s);\r
-            _repairPanelList[i].Visible = true;\r
-        }\r
-\r
         public event Action HpLabelClick;\r
 \r
         private void HpLabelClickHandler(object sender, EventArgs ev)\r