1 // Copyright (C) 2019 Kazuhiro Fujieda <fujieda@users.osdn.me>
\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
7 // http://www.apache.org/licenses/LICENSE-2.0
\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
15 using System.Collections.Generic;
\r
16 using System.Drawing;
\r
17 using System.Windows.Forms;
\r
19 namespace KancolleSniffer.View.ShipListPanel
\r
21 public class ShipListLabels
\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
27 public ShipListLabels(ShipListPanel shipListPanel)
\r
29 _shipListPanel = shipListPanel;
\r
32 public void CreateShipLabels(int i)
\r
34 var y = ShipListPanel.LineHeight * i + 1;
\r
35 const int height = ShipListPanel.LabelHeight;
\r
36 var panel = new Panel
\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
42 Scaler.Scale(panel);
\r
47 Location = new Point(126, 0),
\r
50 MinimumSize = new Size(0, ShipListPanel.LineHeight),
\r
51 TextAlign = ContentAlignment.MiddleLeft,
\r
52 Cursor = Cursors.Hand
\r
56 Location = new Point(128, 0),
\r
57 Size = new Size(24, ShipListPanel.LineHeight),
\r
58 TextAlign = ContentAlignment.MiddleRight
\r
62 Location = new Point(154, 2),
\r
63 Size = new Size(24, height),
\r
64 TextAlign = ContentAlignment.MiddleRight
\r
68 Location = new Point(175, 2),
\r
69 Size = new Size(42, height),
\r
70 TextAlign = ContentAlignment.MiddleRight
\r
72 new ShipLabel {Location = new Point(10, 2), AutoSize = true},
\r
73 new ShipLabel {Location = new Point(1, 2), AutoSize = true}
\r
75 _labelList.Add(labels);
\r
76 _panelList.Add(panel);
\r
77 // ReSharper disable once CoVariantArrayConversion
\r
78 panel.Controls.AddRange(labels);
\r
79 _shipListPanel.Controls.Add(panel);
\r
80 var unused = panel.Handle; // create handle
\r
81 foreach (var label in labels)
\r
83 Scaler.Scale(label);
\r
84 label.BackColor = ShipLabel.ColumnColors[(i + 1) % 2];
\r
86 _shipListPanel.SetHpPercent(labels[0]);
\r
89 public void SetShipStatus(int i)
\r
91 var s = _shipListPanel.GetShip(i);
\r
92 var labels = _labelList[i];
\r
93 if (s.Level == 1000) // 艦種の表示
\r
99 labels[1].SetCond(s);
\r
100 labels[2].SetLevel(s);
\r
101 labels[3].SetExpToNext(s);
\r
102 labels[4].SetName(s, ShipNameWidth.ShipList);
\r
103 labels[5].SetFleet(s);
\r
104 _panelList[i].Visible = true;
\r
107 public void SetShipType(int i)
\r
109 var s = _shipListPanel.GetShip(i);
\r
110 var labels = _labelList[i];
\r
111 labels[0].SetHp(null);
\r
112 labels[1].SetCond(null);
\r
113 labels[2].SetLevel(null);
\r
114 labels[3].SetExpToNext(null);
\r
115 labels[4].SetName(null);
\r
116 labels[5].SetFleet(null);
\r
117 labels[5].Text = s.Name;
\r
118 _panelList[i].Visible = true;
\r
121 public void HidePanel(int i)
\r
123 _panelList[i].Visible = false;
\r