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 RepairListLabels
\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 RepairListLabels(ShipListPanel shipListPanel)
\r
29 _shipListPanel = shipListPanel;
\r
32 public void CreateLabels(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 = CustomColors.ColumnColors.BrightFirst(i)
\r
42 Scaler.Scale(panel);
\r
43 panel.Tag = panel.Location.Y;
\r
48 Location = new Point(118, 0),
\r
51 MinimumSize = new Size(0, ShipListPanel.LineHeight),
\r
52 TextAlign = ContentAlignment.MiddleLeft,
\r
53 Cursor = Cursors.Hand
\r
57 Location = new Point(116, 2),
\r
58 Size = new Size(24, height),
\r
59 TextAlign = ContentAlignment.MiddleRight
\r
61 new ShipLabel {Location = new Point(141, 2), AutoSize = true},
\r
62 new ShipLabel {Location = new Point(186, 2), AutoSize = true},
\r
63 new ShipLabel {Location = new Point(10, 2), AutoSize = true},
\r
64 new ShipLabel {Location = new Point(1, 2), AutoSize = true}
\r
66 _labelList.Add(labels);
\r
67 _panelList.Add(panel);
\r
68 // ReSharper disable once CoVariantArrayConversion
\r
69 panel.Controls.AddRange(labels);
\r
70 _shipListPanel.Controls.Add(panel);
\r
71 var unused = panel.Handle; // create handle
\r
72 foreach (var label in labels)
\r
74 Scaler.Scale(label);
\r
75 label.BackColor = CustomColors.ColumnColors.BrightFirst(i);
\r
77 _shipListPanel.SetHpPercent(labels[0]);
\r
80 public void SetRepairList(int i)
\r
82 var s = _shipListPanel.GetShip(i);
\r
83 if (s.Level == 1000)
\r
85 _shipListPanel.SetShipType(i);
\r
88 var labels = _labelList[i];
\r
90 labels[1].SetLevel(s);
\r
91 labels[2].SetRepairTime(s);
\r
92 labels[3].Text = s.RepairTimePerHp.ToString(@"mm\:ss");
\r
93 labels[4].SetName(s, ShipNameWidth.RepairListFull);
\r
94 labels[5].SetFleet(s);
\r
95 _panelList[i].Visible = true;
\r
98 public void HidePanel(int i)
\r
100 _panelList[i].Visible = false;
\r