OSDN Git Service

ReSharperの警告を消す
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer / View / ShipListPanel / 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 using KancolleSniffer.Forms;\r
19 using KancolleSniffer.Model;\r
20 \r
21 namespace KancolleSniffer.View.ShipListPanel\r
22 {\r
23     public class RepairListLabels\r
24     {\r
25         private readonly ShipListPanel _shipListPanel;\r
26         private readonly List<RepairLabels> _labelList = new List<RepairLabels>();\r
27 \r
28         private class RepairLabels : ShipLabels\r
29         {\r
30             public ShipLabel.RepairTime Time { get; set; }\r
31             public Label PerHp { get; set; }\r
32 \r
33             protected override Control[] AddedControls => new Control[] {Time, PerHp};\r
34 \r
35             public override void Set(ShipStatus status)\r
36             {\r
37                 base.Set(status);\r
38                 Time.Set(status);\r
39             }\r
40         }\r
41 \r
42         public RepairListLabels(ShipListPanel shipListPanel)\r
43         {\r
44             _shipListPanel = shipListPanel;\r
45         }\r
46 \r
47         public void CreateLabels(int i)\r
48         {\r
49             var y = ShipListPanel.LineHeight * i + 1;\r
50             const int height = ShipListPanel.LabelHeight;\r
51             var labels = new RepairLabels\r
52             {\r
53                 Fleet = new ShipLabel.Fleet(new Point(1, 2)),\r
54                 Name = new ShipLabel.Name(new Point(10, 2), ShipNameWidth.RepairListFull),\r
55                 Hp = new ShipLabel.Hp(new Point(118, 0), ShipListPanel.LineHeight),\r
56                 Level = new ShipLabel.Level(new Point(116, 2), height),\r
57                 Time = new ShipLabel.RepairTime(new Point(141, 2)),\r
58                 PerHp = new Label {Location = new Point(186, 2), AutoSize = true},\r
59                 BackPanel = new Panel\r
60                 {\r
61                     Location = new Point(0, y),\r
62                     Size = new Size(ListForm.PanelWidth, ShipListPanel.LineHeight)\r
63                 }\r
64             };\r
65             _labelList.Add(labels);\r
66             labels.Arrange(_shipListPanel, CustomColors.ColumnColors.BrightFirst(i));\r
67             _shipListPanel.SetHpPercent(labels.Hp);\r
68         }\r
69 \r
70         public void SetRepairList(int i)\r
71         {\r
72             var s = _shipListPanel.GetShip(i);\r
73             if (s.Level == 1000)\r
74             {\r
75                 _shipListPanel.SetShipType(i);\r
76                 return;\r
77             }\r
78             var labels = _labelList[i];\r
79             labels.Set(s);\r
80             labels.PerHp.Text = s.RepairTimePerHp.ToString(@"mm\:ss");\r
81             labels.BackPanel.Visible = true;\r
82         }\r
83 \r
84         public void HidePanel(int i)\r
85         {\r
86             _labelList[i].BackPanel.Visible = false;\r
87         }\r
88     }\r
89 }