using System.Collections.Generic;\r
using System.Drawing;\r
using System.Windows.Forms;\r
+using KancolleSniffer.Forms;\r
\r
namespace KancolleSniffer.View.ShipListPanel\r
{\r
public class ShipListLabels\r
{\r
private readonly ShipListPanel _shipListPanel;\r
- private readonly List<ShipLabel[]> _labelList = new List<ShipLabel[]>();\r
- private readonly List<Panel> _panelList = new List<Panel>();\r
+ private readonly List<ShipLabels> _labelList = new List<ShipLabels>();\r
\r
public ShipListLabels(ShipListPanel shipListPanel)\r
{\r
{\r
var y = ShipListPanel.LineHeight * i + 1;\r
const int height = ShipListPanel.LabelHeight;\r
- var panel = new Panel\r
+ var labels = new ShipLabels\r
{\r
- Location = new Point(0, y),\r
- Size = new Size(ListForm.PanelWidth, ShipListPanel.LineHeight),\r
- BackColor = ShipLabel.ColumnColors[(i + 1) % 2]\r
- };\r
- Scaler.Scale(panel);\r
- var labels = new[]\r
- {\r
- new ShipLabel\r
- {\r
- Location = new Point(126, 0),\r
- AutoSize = true,\r
- AnchorRight = true,\r
- MinimumSize = new Size(0, ShipListPanel.LineHeight),\r
- TextAlign = ContentAlignment.MiddleLeft,\r
- Cursor = Cursors.Hand\r
- },\r
- new ShipLabel\r
- {\r
- Location = new Point(128, 0),\r
- Size = new Size(24, ShipListPanel.LineHeight),\r
- TextAlign = ContentAlignment.MiddleRight\r
- },\r
- new ShipLabel\r
+ Fleet = new ShipLabel.Fleet(new Point(1, 2)),\r
+ Name = new ShipLabel.Name(new Point(10, 2), ShipNameWidth.ShipList),\r
+ Hp = new ShipLabel.Hp(new Point(126, 0), ShipListPanel.LineHeight),\r
+ Cond = new ShipLabel.Cond(new Point(127, 0), ShipListPanel.LineHeight),\r
+ Level = new ShipLabel.Level(new Point(152, 2), height),\r
+ Exp = new ShipLabel.Exp(new Point(174, 2), height),\r
+ BackPanel = new Panel\r
{\r
- Location = new Point(154, 2),\r
- Size = new Size(24, height),\r
- TextAlign = ContentAlignment.MiddleRight\r
- },\r
- new ShipLabel\r
- {\r
- Location = new Point(175, 2),\r
- Size = new Size(42, height),\r
- TextAlign = ContentAlignment.MiddleRight\r
- },\r
- new ShipLabel {Location = new Point(10, 2), AutoSize = true},\r
- new ShipLabel {Location = new Point(1, 2), AutoSize = true}\r
+ Location = new Point(0, y),\r
+ Size = new Size(ListForm.PanelWidth, ShipListPanel.LineHeight),\r
+ Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top\r
+ }\r
};\r
+ SetAnchorRight(labels.Hp, labels.Cond, labels.Level, labels.Exp);\r
_labelList.Add(labels);\r
- _panelList.Add(panel);\r
- // ReSharper disable once CoVariantArrayConversion\r
- panel.Controls.AddRange(labels);\r
- _shipListPanel.Controls.Add(panel);\r
- var unused = panel.Handle; // create handle\r
- foreach (var label in labels)\r
- {\r
- Scaler.Scale(label);\r
- label.BackColor = ShipLabel.ColumnColors[(i + 1) % 2];\r
- }\r
- _shipListPanel.SetHpPercent(labels[0]);\r
+ labels.Arrange(_shipListPanel, CustomColors.ColumnColors.BrightFirst(i));\r
+ labels.Scale();\r
+ _shipListPanel.SetHpPercent(labels.Hp);\r
+ }\r
+\r
+ private void SetAnchorRight(params Control[] controls)\r
+ {\r
+ foreach (var control in controls)\r
+ control.Anchor = AnchorStyles.Top | AnchorStyles.Right;\r
+ }\r
+\r
+ public void Resize(int i, int width)\r
+ {\r
+ var labels = _labelList[i];\r
+ labels.BackPanel.Width = width;\r
+ labels.Hp.AdjustLocation();\r
+ labels.Name.AdjustWidth(Scaler.DownWidth(width) - ListForm.PanelWidth);\r
}\r
\r
public void SetShipStatus(int i)\r
SetShipType(i);\r
return;\r
}\r
- labels[0].SetHp(s);\r
- labels[1].SetCond(s);\r
- labels[2].SetLevel(s);\r
- labels[3].SetExpToNext(s);\r
- labels[4].SetName(s, ShipNameWidth.ShipList);\r
- labels[5].SetFleet(s);\r
- _panelList[i].Visible = true;\r
+ labels.Set(s, _shipListPanel.ToolTip);\r
+ labels.BackPanel.Visible = true;\r
}\r
\r
public void SetShipType(int i)\r
{\r
var s = _shipListPanel.GetShip(i);\r
var labels = _labelList[i];\r
- labels[0].SetHp(null);\r
- labels[1].SetCond(null);\r
- labels[2].SetLevel(null);\r
- labels[3].SetExpToNext(null);\r
- labels[4].SetName(null);\r
- labels[5].SetFleet(null);\r
- labels[5].Text = s.Name;\r
- _panelList[i].Visible = true;\r
+ labels.Reset();\r
+ labels.Fleet.Text = s.Name;\r
+ labels.BackPanel.Visible = true;\r
}\r
\r
public void HidePanel(int i)\r
{\r
- _panelList[i].Visible = false;\r
+ _labelList[i].BackPanel.Visible = false;\r
}\r
}\r
}
\ No newline at end of file