OSDN Git Service

インデントを修正する
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer / View / RepairListLabels.cs
1 // Copyright (C) 2019 Kazuhiro Fujieda <fujieda@users.osdn.me>\r
2 //\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
6 //\r
7 //    http://www.apache.org/licenses/LICENSE-2.0\r
8 //\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
14 \r
15 using System.Collections.Generic;\r
16 using System.Drawing;\r
17 using System.Windows.Forms;\r
18 \r
19 namespace KancolleSniffer.View\r
20 {\r
21     public class RepairListLabels\r
22     {\r
23         private readonly ShipListPanel _shipListPanel;\r
24         private readonly List<ShipLabel[]> _labelList = new List<ShipLabel[]>();\r
25         private readonly List<Panel> _panelList = new List<Panel>();\r
26 \r
27         public RepairListLabels(ShipListPanel shipListPanel)\r
28         {\r
29             _shipListPanel = shipListPanel;\r
30         }\r
31 \r
32         public void CreateLabels(int i)\r
33         {\r
34             var y = ShipListPanel.LineHeight * i + 1;\r
35             const int height = ShipListPanel.LabelHeight;\r
36             var panel = new Panel\r
37             {\r
38                 Location = new Point(0, y),\r
39                 Size = new Size(ListForm.PanelWidth, ShipListPanel.LineHeight),\r
40                 BackColor = ShipLabel.ColumnColors[(i + 1) % 2]\r
41             };\r
42             Scaler.Scale(panel);\r
43             panel.Tag = panel.Location.Y;\r
44             var labels = new[]\r
45             {\r
46                 new ShipLabel\r
47                 {\r
48                     Location = new Point(118, 0),\r
49                     AutoSize = true,\r
50                     AnchorRight = true,\r
51                     MinimumSize = new Size(0, ShipListPanel.LineHeight),\r
52                     TextAlign = ContentAlignment.MiddleLeft,\r
53                     Cursor = Cursors.Hand\r
54                 },\r
55                 new ShipLabel\r
56                 {\r
57                     Location = new Point(116, 2),\r
58                     Size = new Size(24, height),\r
59                     TextAlign = ContentAlignment.MiddleRight\r
60                 },\r
61                 new ShipLabel {Location = new Point(141, 2), AutoSize = true},\r
62                 new ShipLabel {Location = new Point(186, 2), AutoSize = true},\r
63                 new ShipLabel {Location = new Point(10, 2), AutoSize = true},\r
64                 new ShipLabel {Location = new Point(1, 2), AutoSize = true}\r
65             };\r
66             _labelList.Add(labels);\r
67             _panelList.Add(panel);\r
68             // ReSharper disable once CoVariantArrayConversion\r
69             panel.Controls.AddRange(labels);\r
70             _shipListPanel.Controls.Add(panel);\r
71             var unused = panel.Handle; // create handle\r
72             foreach (var label in labels)\r
73             {\r
74                 Scaler.Scale(label);\r
75                 label.PresetColor =\r
76                     label.BackColor = ShipLabel.ColumnColors[(i + 1) % 2];\r
77             }\r
78             _shipListPanel.SetHpPercent(labels[0]);\r
79         }\r
80 \r
81         public void SetRepairList(int i)\r
82         {\r
83             var s = _shipListPanel.GetShip(i);\r
84             if (s.Level == 1000)\r
85             {\r
86                 _shipListPanel.SetShipType(i);\r
87                 return;\r
88             }\r
89             var labels = _labelList[i];\r
90             labels[0].SetHp(s);\r
91             labels[1].SetLevel(s);\r
92             labels[2].SetRepairTime(s);\r
93             labels[3].Text = s.RepairTimePerHp.ToString(@"mm\:ss");\r
94             labels[4].SetName(s, ShipNameWidth.RepairListFull);\r
95             labels[5].SetFleet(s);\r
96             _panelList[i].Visible = true;\r
97         }\r
98 \r
99         public void HidePanel(int i)\r
100         {\r
101             _panelList[i].Visible = false;\r
102         }\r
103     }\r
104 }