{\r
public class ShipInfoPanel : PanelWithToolTip, IUpdateTimers\r
{\r
- private readonly Panel _combinedFleet = new Panel\r
- {\r
- Location = new Point(0, 0),\r
- Size = new Size(220, 113),\r
- Visible = false\r
- };\r
-\r
- private readonly Panel _7Ships = new Panel\r
- {\r
- Location = new Point(0, 0),\r
- Size = new Size(220, 113),\r
- Visible = false\r
- };\r
-\r
private readonly BattleInfoPanel _battleInfo = new BattleInfoPanel\r
{\r
Location = new Point(59, 116),\r
Location = new Point(186, 117)\r
};\r
\r
- private readonly MainShipLabels _mainLabels = new MainShipLabels();\r
+ private readonly ShipPanels _shipPanels;\r
\r
private UpdateContext _context;\r
\r
\r
public ShipInfoPanel()\r
{\r
- Controls.AddRange(new Control[] {Guide, _presetAkashiTimer, _combinedFleet, _7Ships});\r
+ Controls.AddRange(new Control[] {Guide, _presetAkashiTimer});\r
BorderStyle = BorderStyle.FixedSingle;\r
- _mainLabels.CreateAllShipLabels(new MainShipPanels\r
- {\r
- PanelShipInfo = this,\r
- Panel7Ships = _7Ships,\r
- PanelCombinedFleet = _combinedFleet\r
- }, ShipClickHandler);\r
+ _shipPanels = new ShipPanels(this, ShipClickHandler);\r
Controls.AddRange(new Control[]\r
{\r
_battleInfo,\r
\r
public void ToggleHpPercent()\r
{\r
- _mainLabels.ToggleHpPercent();\r
+ _shipPanels.ToggleHpPercent();\r
}\r
\r
- public bool ShowHpInPercent => _mainLabels.ShowHpInPercent;\r
+ public bool ShowHpInPercent => _shipPanels.ShowHpInPercent;\r
\r
private bool _inSortie;\r
\r
public new void Update()\r
{\r
var ships = Context.Sniffer.Fleets[CurrentFleet].ActualShips;\r
- _7Ships.Visible = ships.Count == 7;\r
- _mainLabels.SetShipLabels(ships);\r
+ _shipPanels.SetShipLabels(ships);\r
ShowCombinedFleet();\r
_presetAkashiTimer.Visible = Context.Config.UsePresetAkashi;\r
UpdateAkashiTimer();\r
{\r
if (!Context.Sniffer.IsCombinedFleet)\r
CombinedFleet = false;\r
- _combinedFleet.Visible = CombinedFleet;\r
if (CombinedFleet)\r
{\r
- _mainLabels.SetCombinedShipLabels(Context.Sniffer.Fleets[0].ActualShips,\r
+ _shipPanels.SetCombinedShipLabels(Context.Sniffer.Fleets[0].ActualShips,\r
Context.Sniffer.Fleets[1].ActualShips);\r
}\r
}\r
{\r
if (Context.Config.UsePresetAkashi)\r
UpdatePresetAkashiTimer();\r
- _mainLabels.SetAkashiTimer(Context.Sniffer.Fleets[CurrentFleet].ActualShips,\r
+ _shipPanels.SetAkashiTimer(Context.Sniffer.Fleets[CurrentFleet].ActualShips,\r
Context.Sniffer.AkashiTimer.GetTimers(CurrentFleet, Context.GetStep().Now));\r
}\r
\r
\r
namespace KancolleSniffer.View.MainWindow\r
{\r
- public class MainShipPanels\r
+ public class ShipPanels\r
{\r
- public Control PanelShipInfo { get; set; }\r
- public Control Panel7Ships { get; set; }\r
- public Control PanelCombinedFleet { get; set; }\r
- }\r
+ private const int Width = 220;\r
+\r
+ private readonly Panel _combined = new Panel\r
+ {\r
+ Location = new Point(0, 0),\r
+ Size = new Size(Width, 113),\r
+ Visible = false\r
+ };\r
+\r
+ private readonly Panel _7Ships = new Panel\r
+ {\r
+ Location = new Point(0, 0),\r
+ Size = new Size(Width, 113),\r
+ Visible = false\r
+ };\r
\r
- public class MainShipLabels\r
- {\r
private readonly ShipLabelLines _shipLines;\r
private readonly ShipLabelLines _shipLines7;\r
private readonly CombinedShipLines _combinedLines = new CombinedShipLines();\r
- private readonly HpDisplay _hpDisplay = new HpDisplay();\r
+ private readonly HpToggle _hpToggle = new HpToggle();\r
\r
- public bool ShowHpInPercent => _hpDisplay.InPercent;\r
+ public bool ShowHpInPercent => _hpToggle.InPercent;\r
\r
- public MainShipLabels()\r
+ public ShipPanels(Control parent, EventHandler onClick)\r
{\r
_shipLines = new ShipLabelLines(ShipInfo.MemberCount, 16);\r
_shipLines7 = new ShipLabelLines(7, 14);\r
- }\r
+ parent.Controls.AddRange(new Control[]{_combined, _7Ships});\r
+ _shipLines.Create(parent, _hpToggle, onClick);\r
+ _shipLines7.Create(_7Ships, _hpToggle, onClick);\r
+ _combinedLines.Create(_combined, _hpToggle, onClick);\r
\r
- public void CreateAllShipLabels(MainShipPanels panels, EventHandler onClick)\r
- {\r
- _shipLines.Create(panels.PanelShipInfo, _hpDisplay, onClick);\r
- _shipLines7.Create(panels.Panel7Ships, _hpDisplay, onClick);\r
- _combinedLines.Create(panels.PanelCombinedFleet, _hpDisplay, onClick);\r
}\r
\r
public void ToggleHpPercent()\r
{\r
- _hpDisplay.ToggleHpPercent();\r
+ _hpToggle.ToggleHpPercent();\r
}\r
\r
- private class HpDisplay\r
+ private class HpToggle\r
{\r
private readonly List<ShipLabel.Hp> _labels = new List<ShipLabel.Hp>();\r
public bool InPercent { get; private set; }\r
\r
public void SetShipLabels(IReadOnlyList<ShipStatus> ships)\r
{\r
- (ships.Count == 7 ? _shipLines7 : _shipLines).Set(ships);\r
+ _combined.Visible = false;\r
+ if (ships.Count == 7)\r
+ {\r
+ _7Ships.Visible = true;\r
+ _shipLines7.Set(ships);\r
+ }\r
+ else\r
+ {\r
+ _7Ships.Visible = false;\r
+ _shipLines.Set(ships);\r
+ }\r
}\r
\r
public void SetCombinedShipLabels(IReadOnlyList<ShipStatus> first, IReadOnlyList<ShipStatus> second)\r
{\r
+ _combined.Visible = true;\r
_combinedLines.Set(first, second);\r
}\r
\r
_lineHeight = lineHeight;\r
}\r
\r
- public void Create(Control parent, HpDisplay hpDisplay, EventHandler onClick)\r
+ public void Create(Control parent, HpToggle hpToggle, EventHandler onClick)\r
{\r
parent.SuspendLayout();\r
_akashiTimerLabels.Create(parent);\r
- CreateHeader(parent, hpDisplay);\r
+ CreateHeader(parent, hpToggle);\r
for (var i = 0; i < _shipLines.Length; i++)\r
{\r
\r
labels.Arrange(parent, CustomColors.ColumnColors.DarkFirst(i));\r
labels.SetClickHandler(onClick);\r
labels.SetTag(i);\r
- hpDisplay.AddHpLabel(labels.Hp);\r
+ hpToggle.AddHpLabel(labels.Hp);\r
}\r
parent.ResumeLayout();\r
}\r
\r
- private void CreateHeader(Control parent, HpDisplay hpDisplay)\r
+ private void CreateHeader(Control parent, HpToggle hpToggle)\r
{\r
var headings = new Control[]\r
{\r
control.BackColor = CustomColors.ColumnColors.Bright;\r
}\r
headings[0].Cursor = Cursors.Hand;\r
- hpDisplay.SetClickHandler(headings[0]);\r
+ hpToggle.SetClickHandler(headings[0]);\r
}\r
\r
public void Set(IReadOnlyList<ShipStatus> ships)\r
private const int LineHeight = 16;\r
private const int ParentWidth = 220; // parent.Widthを使うとDPIスケーリング時に計算がくるうので\r
\r
- public void Create(Control parent, HpDisplay hpDisplay, EventHandler onClick)\r
+ public void Create(Control parent, HpToggle hpToggle, EventHandler onClick)\r
{\r
parent.SuspendLayout();\r
- CreateHeader(parent, hpDisplay);\r
+ CreateHeader(parent, hpToggle);\r
for (var i = 0; i < _combinedLines.Length; i++)\r
{\r
var x = ParentWidth / 2 * (i / ShipInfo.MemberCount);\r
labels.SetClickHandler(onClick);\r
labels.SetTag(i);\r
var hpLabel = _combinedLines[i].Hp;\r
- hpDisplay.AddHpLabel(hpLabel);\r
+ hpToggle.AddHpLabel(hpLabel);\r
}\r
parent.ResumeLayout();\r
}\r
\r
- private void CreateHeader(Control parent, HpDisplay hpDisplay)\r
+ private void CreateHeader(Control parent, HpToggle hpToggle)\r
{\r
var headings = new Control[]\r
{\r
control.BackColor = CustomColors.ColumnColors.Bright;\r
}\r
headings[0].Cursor = headings[2].Cursor = Cursors.Hand;\r
- hpDisplay.SetClickHandler(headings[0]);\r
- hpDisplay.SetClickHandler(headings[2]);\r
+ hpToggle.SetClickHandler(headings[0]);\r
+ hpToggle.SetClickHandler(headings[2]);\r
}\r
\r
public void Set(IReadOnlyList<ShipStatus> first, IReadOnlyList<ShipStatus> second)\r