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 using KancolleSniffer.Forms;\r
19 \r
20 namespace KancolleSniffer.View.ShipListPanel\r
21 {\r
22     public class ShipListLabels\r
23     {\r
24         private readonly ShipListPanel _shipListPanel;\r
25         private readonly List<ShipLabels> _labelList = new List<ShipLabels>();\r
26 \r
27         public ShipListLabels(ShipListPanel shipListPanel)\r
28         {\r
29             _shipListPanel = shipListPanel;\r
30         }\r
31 \r
32         public void CreateShipLabels(int i)\r
33         {\r
34             var y = ShipListPanel.LineHeight * i + 1;\r
35             const int height = ShipListPanel.LabelHeight;\r
36             var labels = new ShipLabels\r
37             {\r
38                 Fleet = new ShipLabel.Fleet(new Point(1, 2)),\r
39                 Name = new ShipLabel.Name(new Point(10, 2), ShipNameWidth.ShipList),\r
40                 Hp = new ShipLabel.Hp(new Point(126, 0), ShipListPanel.LineHeight),\r
41                 Cond = new ShipLabel.Cond(new Point(127, 0), ShipListPanel.LineHeight),\r
42                 Level = new ShipLabel.Level(new Point(152, 2), height),\r
43                 Exp = new ShipLabel.Exp(new Point(174, 2), height),\r
44                 BackPanel =  new Panel\r
45                 {\r
46                     Location = new Point(0, y),\r
47                     Size = new Size(ListForm.PanelWidth, ShipListPanel.LineHeight),\r
48                     Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top\r
49                 }\r
50             };\r
51             SetAnchorRight(labels.Hp, labels.Cond, labels.Level, labels.Exp);\r
52             _labelList.Add(labels);\r
53             labels.Arrange(_shipListPanel, CustomColors.ColumnColors.BrightFirst(i));\r
54             labels.Scale();\r
55             _shipListPanel.SetHpPercent(labels.Hp);\r
56         }\r
57 \r
58         private void SetAnchorRight(params Control[] controls)\r
59         {\r
60             foreach (var control in controls)\r
61                 control.Anchor = AnchorStyles.Top | AnchorStyles.Right;\r
62         }\r
63 \r
64         public void Resize(int i, int width)\r
65         {\r
66             var labels = _labelList[i];\r
67             labels.BackPanel.Width = width;\r
68             labels.Hp.AdjustLocation();\r
69             labels.Name.AdjustWidth(Scaler.DownWidth(width) - ListForm.PanelWidth);\r
70         }\r
71 \r
72         public void SetShipStatus(int i)\r
73         {\r
74             var s = _shipListPanel.GetShip(i);\r
75             var labels = _labelList[i];\r
76             if (s.Level == 1000) // 艦種の表示\r
77             {\r
78                 SetShipType(i);\r
79                 return;\r
80             }\r
81             labels.Set(s, _shipListPanel.ToolTip);\r
82             labels.BackPanel.Visible = true;\r
83         }\r
84 \r
85         public void SetShipType(int i)\r
86         {\r
87             var s = _shipListPanel.GetShip(i);\r
88             var labels = _labelList[i];\r
89             labels.Reset();\r
90             labels.Fleet.Text = s.Name;\r
91             labels.BackPanel.Visible = true;\r
92         }\r
93 \r
94         public void HidePanel(int i)\r
95         {\r
96             _labelList[i].BackPanel.Visible = false;\r
97         }\r
98     }\r
99 }