OSDN Git Service

ShipLabelから名前まわりをサブクラスNameに分離する
[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.Linq;\r
18 using System.Windows.Forms;\r
19 \r
20 namespace KancolleSniffer.View.ShipListPanel\r
21 {\r
22     public class RepairListLabels\r
23     {\r
24         private readonly ShipListPanel _shipListPanel;\r
25         private readonly List<RepairLabels> _labelList = new List<RepairLabels>();\r
26 \r
27         private class RepairLabels : ShipLabels\r
28         {\r
29             public ShipLabel Time { get; set; }\r
30             public Label PerHp { get; set; }\r
31 \r
32             public override Control[] Controls => base.Controls.Concat(new[] {Time, PerHp}).ToArray();\r
33         }\r
34 \r
35         public RepairListLabels(ShipListPanel shipListPanel)\r
36         {\r
37             _shipListPanel = shipListPanel;\r
38         }\r
39 \r
40         public void CreateLabels(int i)\r
41         {\r
42             var y = ShipListPanel.LineHeight * i + 1;\r
43             const int height = ShipListPanel.LabelHeight;\r
44             var labels = new RepairLabels\r
45             {\r
46                 Fleet = new ShipLabel {Location = new Point(1, 2), AutoSize = true},\r
47                 Name = new ShipLabel.Name(new Point(10, 2)),\r
48                 Hp = new ShipLabel.Hp(new Point(118, 0), ShipListPanel.LineHeight),\r
49                 Level = new ShipLabel\r
50                 {\r
51                     Location = new Point(116, 2),\r
52                     Size = new Size(24, height),\r
53                     TextAlign = ContentAlignment.MiddleRight\r
54                 },\r
55                 Time = new ShipLabel {Location = new Point(141, 2), AutoSize = true},\r
56                 PerHp = new Label {Location = new Point(186, 2), AutoSize = true},\r
57                 BackPanel = new Panel\r
58                 {\r
59                     Location = new Point(0, y),\r
60                     Size = new Size(ListForm.PanelWidth, ShipListPanel.LineHeight)\r
61                 }\r
62             };\r
63             _labelList.Add(labels);\r
64             labels.Arrange(_shipListPanel, CustomColors.ColumnColors.BrightFirst(i));\r
65             _shipListPanel.SetHpPercent(labels.Hp);\r
66         }\r
67 \r
68         public void SetRepairList(int i)\r
69         {\r
70             var s = _shipListPanel.GetShip(i);\r
71             if (s.Level == 1000)\r
72             {\r
73                 _shipListPanel.SetShipType(i);\r
74                 return;\r
75             }\r
76             var labels = _labelList[i];\r
77             labels.Fleet.SetFleet(s);\r
78             labels.Name.SetName(s, ShipNameWidth.RepairListFull);\r
79             labels.Hp.SetHp(s);\r
80             labels.Level.SetLevel(s);\r
81             labels.Time.SetRepairTime(s);\r
82             labels.PerHp.Text = s.RepairTimePerHp.ToString(@"mm\:ss");\r
83             labels.BackPanel.Visible = true;\r
84         }\r
85 \r
86         public void HidePanel(int i)\r
87         {\r
88             _labelList[i].BackPanel.Visible = false;\r
89         }\r
90     }\r
91 }