OSDN Git Service

装備一覧の更新時の書き換えを最小限にする
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer / View / ShipListPanel / ShipListLabels.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.ShipListPanel\r
20 {\r
21     public class ShipListLabels\r
22     {\r
23         private readonly ShipListPanel _shipListPanel;\r
24         private readonly List<ShipLabels> _labelList = new List<ShipLabels>();\r
25 \r
26         public ShipListLabels(ShipListPanel shipListPanel)\r
27         {\r
28             _shipListPanel = shipListPanel;\r
29         }\r
30 \r
31         public void CreateShipLabels(int i)\r
32         {\r
33             var y = ShipListPanel.LineHeight * i + 1;\r
34             const int height = ShipListPanel.LabelHeight;\r
35             var labels = new ShipLabels\r
36             {\r
37                 Fleet = new ShipLabel.Fleet(new Point(1, 2)),\r
38                 Name = new ShipLabel.Name(new Point(10, 2), ShipNameWidth.ShipList),\r
39                 Hp = new ShipLabel.Hp(new Point(126, 0), ShipListPanel.LineHeight),\r
40                 Cond = new ShipLabel.Cond(new Point(128, 0), ShipListPanel.LineHeight),\r
41                 Level = new ShipLabel.Level(new Point(154, 2), height),\r
42                 Exp = new ShipLabel.Exp(new Point(175, 2), height),\r
43                 BackPanel =  new Panel\r
44                 {\r
45                     Location = new Point(0, y),\r
46                     Size = new Size(ListForm.PanelWidth, ShipListPanel.LineHeight),\r
47                 }\r
48             };\r
49             _labelList.Add(labels);\r
50             labels.Arrange(_shipListPanel, CustomColors.ColumnColors.BrightFirst(i));\r
51             _shipListPanel.SetHpPercent(labels.Hp);\r
52         }\r
53 \r
54         public void SetShipStatus(int i)\r
55         {\r
56             var s = _shipListPanel.GetShip(i);\r
57             var labels = _labelList[i];\r
58             if (s.Level == 1000) // 艦種の表示\r
59             {\r
60                 SetShipType(i);\r
61                 return;\r
62             }\r
63             labels.Set(s);\r
64             labels.BackPanel.Visible = true;\r
65         }\r
66 \r
67         public void SetShipType(int i)\r
68         {\r
69             var s = _shipListPanel.GetShip(i);\r
70             var labels = _labelList[i];\r
71             labels.Reset();\r
72             labels.Fleet.Text = s.Name;\r
73             labels.BackPanel.Visible = true;\r
74         }\r
75 \r
76         public void HidePanel(int i)\r
77         {\r
78             _labelList[i].BackPanel.Visible = false;\r
79         }\r
80     }\r
81 }