{\r
AircraftSpec = "",\r
Color = SystemColors.Control,\r
- Equip = "",\r
+ Equip = new FleetData.EquipRecord(""),\r
Fleet = "",\r
Fleet2 = null,\r
Id = 756,\r
continue;\r
return false;\r
}\r
- if (aVal.Equals(bVal))\r
+ if (aVal.ToString() == bVal.ToString())\r
continue;\r
return false;\r
}\r
Name = "大発動艇(八九式中戦車&陸戦隊)"\r
}\r
};\r
- Assert.AreEqual(item.Spec.Name, FleetData.Record.CreateItemRecord(item, 7, 7).Equip);\r
+ Assert.AreEqual(item.Spec.Name, FleetData.Record.CreateItemRecord(item, 7, 7).Equip.ToString(0));\r
item.Level = 10;\r
- Assert.AreEqual("大発動艇(八九式中戦車&陸戦★10", FleetData.Record.CreateItemRecord(item, 7, 7).Equip);\r
+ Assert.AreEqual("大発動艇(八九式中戦車&陸戦★10", FleetData.Record.CreateItemRecord(item, 7, 7).Equip.ToString(0));\r
\r
var aircraft = new ItemStatus\r
{\r
Type = 6\r
}\r
};\r
- Assert.AreEqual(aircraft.Spec.Name, FleetData.Record.CreateItemRecord(aircraft, 7, 7).Equip);\r
+ Assert.AreEqual(aircraft.Spec.Name, FleetData.Record.CreateItemRecord(aircraft, 7, 7).Equip.ToString(0));\r
aircraft.Level = 10;\r
- Assert.AreEqual("零式艦戦53型(岩本★10", FleetData.Record.CreateItemRecord(aircraft, 7, 7).Equip);\r
+ Assert.AreEqual("零式艦戦53型(岩本★10", FleetData.Record.CreateItemRecord(aircraft, 7, 7).Equip.ToString(0));\r
}\r
}\r
}
\ No newline at end of file
this.checkBoxSTypeHeavyCruiser = new System.Windows.Forms.CheckBox();\r
this.checkBoxSTypeAircraftCarrier = new System.Windows.Forms.CheckBox();\r
this.checkBoxSTypeBattleShip = new System.Windows.Forms.CheckBox();\r
- this.dropDownButtonSType = new KancolleSniffer.View.DropDownButton();\r
this.labelSType = new System.Windows.Forms.Label();\r
- this.airBattleResultPanel = new AirBattleResultPanel();\r
- this.battleResultPanel = new BattleResultPanel();\r
- this.antiAirPanel = new AntiAirPanel();\r
- this.fleetPanel = new FleetDataPanel();\r
- this.itemTreeView = new ItemTreeView();\r
- this.shipListPanel = new KancolleSniffer.View.ShipListPanel.ShipListPanel();\r
this.panelShipHeader = new System.Windows.Forms.Panel();\r
+ this.airBattleResultPanel = new KancolleSniffer.View.ListWindow.AirBattleResultPanel();\r
+ this.battleResultPanel = new KancolleSniffer.View.ListWindow.BattleResultPanel();\r
+ this.antiAirPanel = new KancolleSniffer.View.ListWindow.AntiAirPanel();\r
+ this.dropDownButtonSType = new KancolleSniffer.View.DropDownButton();\r
+ this.fleetPanel = new KancolleSniffer.View.ListWindow.FleetDataPanel();\r
+ this.itemTreeView = new KancolleSniffer.View.ListWindow.ItemTreeView();\r
+ this.shipListPanel = new KancolleSniffer.View.ShipListPanel.ShipListPanel();\r
this.contextMenuStripShipList.SuspendLayout();\r
this.contextMenuStripItemList.SuspendLayout();\r
this.panelGroupHeader.SuspendLayout();\r
// \r
this.labelHeaderCond.AutoSize = true;\r
this.labelHeaderCond.Cursor = System.Windows.Forms.Cursors.Hand;\r
- this.labelHeaderCond.Location = new System.Drawing.Point(19, 5);\r
+ this.labelHeaderCond.Location = new System.Drawing.Point(20, 5);\r
this.labelHeaderCond.Name = "labelHeaderCond";\r
this.labelHeaderCond.Size = new System.Drawing.Size(29, 12);\r
this.labelHeaderCond.TabIndex = 13;\r
// \r
this.labelHeaderExp.AutoSize = true;\r
this.labelHeaderExp.Cursor = System.Windows.Forms.Cursors.Hand;\r
- this.labelHeaderExp.Location = new System.Drawing.Point(88, 5);\r
+ this.labelHeaderExp.Location = new System.Drawing.Point(86, 5);\r
this.labelHeaderExp.Name = "labelHeaderExp";\r
this.labelHeaderExp.Size = new System.Drawing.Size(24, 12);\r
this.labelHeaderExp.TabIndex = 14;\r
// labelHeaderLv\r
// \r
this.labelHeaderLv.AutoSize = true;\r
- this.labelHeaderLv.Location = new System.Drawing.Point(56, 5);\r
+ this.labelHeaderLv.Location = new System.Drawing.Point(55, 5);\r
this.labelHeaderLv.Name = "labelHeaderLv";\r
this.labelHeaderLv.Size = new System.Drawing.Size(17, 12);\r
this.labelHeaderLv.TabIndex = 13;\r
// \r
// panelGroupHeader\r
// \r
+ this.panelGroupHeader.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\r
this.panelGroupHeader.Controls.Add(this.label5);\r
this.panelGroupHeader.Controls.Add(this.label9);\r
this.panelGroupHeader.Controls.Add(this.label8);\r
this.panelGroupHeader.Controls.Add(this.label7);\r
this.panelGroupHeader.Controls.Add(this.label6);\r
- this.panelGroupHeader.Location = new System.Drawing.Point(103, 3);\r
+ this.panelGroupHeader.Location = new System.Drawing.Point(101, 3);\r
this.panelGroupHeader.Name = "panelGroupHeader";\r
- this.panelGroupHeader.Size = new System.Drawing.Size(125, 19);\r
+ this.panelGroupHeader.Size = new System.Drawing.Size(112, 19);\r
this.panelGroupHeader.TabIndex = 16;\r
// \r
// label5\r
// \r
// panelRepairHeader\r
// \r
+ this.panelRepairHeader.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\r
this.panelRepairHeader.Controls.Add(this.label10);\r
this.panelRepairHeader.Controls.Add(this.label12);\r
this.panelRepairHeader.Controls.Add(this.label13);\r
this.panelRepairHeader.Controls.Add(this.label1RepairHp);\r
this.panelRepairHeader.Location = new System.Drawing.Point(104, 3);\r
this.panelRepairHeader.Name = "panelRepairHeader";\r
- this.panelRepairHeader.Size = new System.Drawing.Size(121, 19);\r
+ this.panelRepairHeader.Size = new System.Drawing.Size(118, 19);\r
this.panelRepairHeader.TabIndex = 2;\r
// \r
// label10\r
// \r
// panelEmptyHeader\r
// \r
- this.panelEmptyHeader.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\r
- this.panelEmptyHeader.Location = new System.Drawing.Point(58, 3);\r
+ this.panelEmptyHeader.Location = new System.Drawing.Point(56, 3);\r
this.panelEmptyHeader.Name = "panelEmptyHeader";\r
this.panelEmptyHeader.Size = new System.Drawing.Size(167, 19);\r
this.panelEmptyHeader.TabIndex = 0;\r
this.richTextBoxMiscText.Location = new System.Drawing.Point(6, 23);\r
this.richTextBoxMiscText.Name = "richTextBoxMiscText";\r
this.richTextBoxMiscText.ReadOnly = true;\r
- this.richTextBoxMiscText.Size = new System.Drawing.Size(238, 263);\r
+ this.richTextBoxMiscText.Size = new System.Drawing.Size(236, 263);\r
this.richTextBoxMiscText.TabIndex = 0;\r
this.richTextBoxMiscText.Text = "";\r
// \r
// \r
// panelFleetHeader\r
// \r
+ this.panelFleetHeader.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\r
this.panelFleetHeader.Controls.Add(this.labelFleet4);\r
this.panelFleetHeader.Controls.Add(this.label1Fleet3);\r
this.panelFleetHeader.Controls.Add(this.labelFleet2);\r
this.panelFleetHeader.Controls.Add(this.labelFleet1);\r
- this.panelFleetHeader.Location = new System.Drawing.Point(58, 3);\r
+ this.panelFleetHeader.Location = new System.Drawing.Point(56, 3);\r
this.panelFleetHeader.Name = "panelFleetHeader";\r
this.panelFleetHeader.Size = new System.Drawing.Size(167, 19);\r
this.panelFleetHeader.TabIndex = 0;\r
this.labelSType.Text = "艦種";\r
this.labelSType.Click += new System.EventHandler(this.labelSTypeButton_Click);\r
// \r
+ // panelShipHeader\r
+ // \r
+ this.panelShipHeader.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\r
+ this.panelShipHeader.Controls.Add(this.labelHeaderHp);\r
+ this.panelShipHeader.Controls.Add(this.labelHeaderCond);\r
+ this.panelShipHeader.Controls.Add(this.labelHeaderLv);\r
+ this.panelShipHeader.Controls.Add(this.labelHeaderExp);\r
+ this.panelShipHeader.Location = new System.Drawing.Point(113, 3);\r
+ this.panelShipHeader.Name = "panelShipHeader";\r
+ this.panelShipHeader.Size = new System.Drawing.Size(113, 19);\r
+ this.panelShipHeader.TabIndex = 21;\r
+ // \r
// airBattleResultPanel\r
// \r
this.airBattleResultPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \r
this.airBattleResultPanel.Location = new System.Drawing.Point(6, 23);\r
this.airBattleResultPanel.Name = "airBattleResultPanel";\r
this.airBattleResultPanel.ShowResultAutomatic = false;\r
- this.airBattleResultPanel.Size = new System.Drawing.Size(238, 51);\r
+ this.airBattleResultPanel.Size = new System.Drawing.Size(236, 51);\r
this.airBattleResultPanel.TabIndex = 18;\r
// \r
// battleResultPanel\r
this.battleResultPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r
this.battleResultPanel.Location = new System.Drawing.Point(6, 73);\r
this.battleResultPanel.Name = "battleResultPanel";\r
- this.battleResultPanel.Size = new System.Drawing.Size(238, 213);\r
+ this.battleResultPanel.Size = new System.Drawing.Size(236, 213);\r
this.battleResultPanel.TabIndex = 0;\r
// \r
// antiAirPanel\r
this.antiAirPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r
this.antiAirPanel.Location = new System.Drawing.Point(6, 23);\r
this.antiAirPanel.Name = "antiAirPanel";\r
- this.antiAirPanel.Size = new System.Drawing.Size(238, 263);\r
+ this.antiAirPanel.Size = new System.Drawing.Size(236, 263);\r
this.antiAirPanel.TabIndex = 17;\r
// \r
// dropDownButtonSType\r
this.fleetPanel.ContextMenuStrip = this.contextMenuStripFleetData;\r
this.fleetPanel.Location = new System.Drawing.Point(6, 23);\r
this.fleetPanel.Name = "fleetPanel";\r
- this.fleetPanel.Size = new System.Drawing.Size(238, 263);\r
+ this.fleetPanel.Size = new System.Drawing.Size(236, 263);\r
this.fleetPanel.TabIndex = 1;\r
// \r
// itemTreeView\r
this.itemTreeView.ContextMenuStrip = this.contextMenuStripItemList;\r
this.itemTreeView.Location = new System.Drawing.Point(6, 23);\r
this.itemTreeView.Name = "itemTreeView";\r
- this.itemTreeView.Size = new System.Drawing.Size(238, 263);\r
+ this.itemTreeView.Size = new System.Drawing.Size(236, 263);\r
this.itemTreeView.TabIndex = 0;\r
// \r
// shipListPanel\r
this.shipListPanel.GroupUpdated = false;\r
this.shipListPanel.Location = new System.Drawing.Point(6, 23);\r
this.shipListPanel.Name = "shipListPanel";\r
- this.shipListPanel.Size = new System.Drawing.Size(238, 263);\r
+ this.shipListPanel.Size = new System.Drawing.Size(236, 263);\r
this.shipListPanel.TabIndex = 0;\r
// \r
- // panelShipHeader\r
- // \r
- this.panelShipHeader.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\r
- this.panelShipHeader.Controls.Add(this.labelHeaderHp);\r
- this.panelShipHeader.Controls.Add(this.labelHeaderCond);\r
- this.panelShipHeader.Controls.Add(this.labelHeaderLv);\r
- this.panelShipHeader.Controls.Add(this.labelHeaderExp);\r
- this.panelShipHeader.Location = new System.Drawing.Point(114, 3);\r
- this.panelShipHeader.Name = "panelShipHeader";\r
- this.panelShipHeader.Size = new System.Drawing.Size(113, 19);\r
- this.panelShipHeader.TabIndex = 21;\r
- // \r
// ListForm\r
// \r
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);\r
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
- this.ClientSize = new System.Drawing.Size(250, 292);\r
+ this.ClientSize = new System.Drawing.Size(248, 292);\r
this.Controls.Add(this.panelSType);\r
this.Controls.Add(this.panelFleetHeader);\r
this.Controls.Add(this.airBattleResultPanel);\r
this.Activated += new System.EventHandler(this.ListForm_Activated);\r
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ListForm_FormClosing);\r
this.Load += new System.EventHandler(this.ListForm_Load);\r
+ this.ResizeEnd += new System.EventHandler(this.ListForm_ResizeEnd);\r
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.ListForm_KeyPress);\r
this.contextMenuStripShipList.ResumeLayout(false);\r
this.contextMenuStripItemList.ResumeLayout(false);\r
using System.Windows.Forms;\r
using KancolleSniffer.Model;\r
using KancolleSniffer.View;\r
+using KancolleSniffer.View.ListWindow;\r
using KancolleSniffer.View.ShipListPanel;\r
using Clipboard = KancolleSniffer.Util.Clipboard;\r
\r
private readonly CheckBox[] _shipTypeCheckBoxes;\r
private bool _isMaster;\r
private Settings _settings;\r
- public const int PanelWidth = 217;\r
+ public const int PanelWidth = 215;\r
\r
public class Settings\r
{\r
\r
private void ListForm_Load(object sender, EventArgs e)\r
{\r
- /* DPIではなくズームしたときにパネルは大きくなるがScrollBarはそのままなので隙間ができる。\r
- そこでScrollBarの幅に合わせて全体の横幅を設定し直す。*/\r
- Width = Scaler.ScaleWidth(PanelWidth + 12 /* PanelとFrameの内側 */) +\r
- SystemInformation.VerticalScrollBarWidth + 2 /* 縁の幅 */ + Width - ClientSize.Width;\r
- MinimumSize = new Size(Width, 0);\r
- MaximumSize = new Size(Width, int.MaxValue);\r
+ AdjustHeader();\r
+ SetMinimumSize();\r
var config = GetConfig();\r
_settings = Settings.FromShipListConfig(config);\r
if (_settings.ShowHpInPercent)\r
var bounds = new Rectangle(config.Location, config.Size);\r
if (MainWindow.IsTitleBarOnAnyScreen(bounds.Location))\r
Location = bounds.Location;\r
- Height = bounds.Height;\r
+ Size = bounds.Size;\r
+ }\r
+\r
+ private void AdjustHeader()\r
+ {\r
+ if (_config.Zoom == 100)\r
+ return;\r
+ foreach (var header in new[]\r
+ {\r
+ panelShipHeader, panelGroupHeader, panelRepairHeader\r
+ })\r
+ {\r
+ header.Left += SystemInformation.VerticalScrollBarWidth * (_config.Zoom - 100) / 100;\r
+ }\r
+ }\r
+\r
+ private void SetMinimumSize()\r
+ {\r
+ MinimumSize = new Size(Width - Scaler.ScaleWidth(24) - SystemInformation.VerticalScrollBarWidth * (_config.Zoom - 100) / 100, 0);\r
}\r
\r
private ShipListConfig GetConfig()\r
UpdateList();\r
SetActiveControl();\r
}\r
+\r
+ private void ListForm_ResizeEnd(object sender, EventArgs e)\r
+ {\r
+ foreach (var panel in new IPanelResize[] {shipListPanel, antiAirPanel, airBattleResultPanel, battleResultPanel, fleetPanel})\r
+ {\r
+ if (panel.Visible)\r
+ panel.ApplyResize();\r
+ }\r
+ }\r
}\r
}
\ No newline at end of file
<Compile Include="Util\Clipboard.cs" />\r
<Compile Include="Util\SoundPlayer.cs" />\r
<Compile Include="Util\TimeStep.cs" />\r
+ <Compile Include="View\ListWindow\IPanelResize.cs" />\r
<Compile Include="View\MainWindow\BattleInfoPanel.cs">\r
<SubType>Component</SubType>\r
</Compile>\r
AdjustLocation();\r
}\r
\r
- private void AdjustLocation()\r
+ public void AdjustLocation()\r
{\r
if (!GrowLeft)\r
return;\r
namespace KancolleSniffer.View.ListWindow\r
{\r
[DesignerCategory("Code")]\r
- public class AirBattleResultPanel : PanelWithToolTip\r
+ public class AirBattleResultPanel : PanelWithToolTip, IPanelResize\r
{\r
private readonly Label _phaseName;\r
private readonly Label _stage1;\r
private int _resultIndex;\r
private readonly ShipLabel.Name _ciShipName;\r
private readonly Label _ciKind;\r
+ private const int InitWidth = 236;\r
\r
public bool ShowResultAutomatic { get; set; }\r
\r
_phaseName.Click += PhaseNameOnClick;\r
}\r
\r
+ public void ApplyResize()\r
+ {\r
+ _ciShipName.AdjustWidth(Scaler.DownWidth(Width) - InitWidth, true);\r
+ }\r
+\r
public void SetResult(Sniffer sniffer)\r
{\r
var battleResult = sniffer.Battle.AirBattleResult;\r
\r
namespace KancolleSniffer.View.ListWindow\r
{\r
- public class AntiAirPanel : Panel\r
+ public class AntiAirPanel : Panel, IPanelResize\r
{\r
private const int LineHeight = 16;\r
private readonly List<AntiAirLabels> _labelList = new List<AntiAirLabels>();\r
BackPanel = new Panel\r
{\r
Location = new Point(0, y),\r
- Size = new Size(ListForm.PanelWidth, LineHeight)\r
+ Size = new Size(ListForm.PanelWidth, LineHeight),\r
}\r
};\r
_labelList.Add(labels);\r
labels.Move(AutoScrollPosition);\r
}\r
\r
+ public void ApplyResize()\r
+ {\r
+ var width = Width - SystemInformation.VerticalScrollBarWidth - 2;\r
+ SuspendLayout();\r
+ foreach (var labels in _labelList)\r
+ labels.BackPanel.Width = width;\r
+ ResumeLayout();\r
+ }\r
+\r
private void SetRecords()\r
{\r
for (var i = 0; i < _table.Count; i++)\r
\r
namespace KancolleSniffer.View.ListWindow\r
{\r
- public class BattleResultPanel : PanelWithToolTip\r
+ public class BattleResultPanel : PanelWithToolTip, IPanelResize\r
{\r
private readonly List<ShipLabels> _friendLabels = new List<ShipLabels>();\r
private readonly List<ShipLabels> _enemyLabels = new List<ShipLabels>();\r
var lines = Max(Ships(result.Friend).Length, Ships(result.Enemy).Length);\r
SetPanelVisible(lines);\r
ResumeLayout(); // スクロールバーの有無を決定する\r
- AdjustPanelWidth(lines);\r
+ AdjustPanelWidth();\r
}\r
\r
private void SetEachResult(IReadOnlyList<ShipLabels> labelsList, BattleInfo.BattleResult.Combined fleet)\r
{\r
labels.Hp.Set(ship);\r
labels.Name.SetName(ShortenName(ship.Name));\r
+ labels.Name.Left = CalcEnemyNameLeft(labels.Hp.Width);\r
}\r
else\r
{\r
private const int LabelHeight = 12;\r
private const int LabelMargin = (LineHeight - LabelHeight) / 2;\r
private const int TopMargin = 4;\r
+ private const int EnemyNameLeft = 164;\r
+\r
+ private int _adjust;\r
\r
private void CreateLabels()\r
{\r
friend.Hp.Click += HpLabelClickHandler;\r
var enemy = new ShipLabels\r
{\r
- Name = new ShipLabel.Name(new Point(164, LabelMargin), ShipNameWidth.Max),\r
+ Name = new ShipLabel.Name(new Point(EnemyNameLeft, LabelMargin), ShipNameWidth.Max),\r
Hp = new ShipLabel.Hp\r
{\r
Location = new Point(119, 0),\r
_friendLabels[i].BackPanel.Visible = i < showPanels;\r
}\r
\r
- private void AdjustPanelWidth(int lines)\r
+ private int _gap;\r
+\r
+ private void AdjustPanelWidth()\r
{\r
+ var labelMax = _enemyLabels[0].Name.Location.X + _enemyLabels.Max(labels => labels.Name.Size.Width) - 1;\r
var panelWidth = Max(ClientSize.Width, // スクロールバーの有無を反映した横幅\r
- _enemyLabels[0].Name.Location.X + _enemyLabels.Max(labels => labels.Name.Size.Width) - 1); // 敵の名前の右端\r
- for (var i = 0; i < lines; i++)\r
- _friendLabels[i].BackPanel.Width = panelWidth;\r
+ labelMax); // 敵の名前の右端\r
+ foreach (var panel in from labels in _friendLabels where labels.BackPanel.Visible select labels.BackPanel)\r
+ panel.Width = panelWidth;\r
+ _gap = (ClientSize.Width - labelMax) * 2 / 3;\r
+ }\r
+\r
+ public void ApplyResize()\r
+ {\r
+ AdjustPanelWidth();\r
+ var prev = _adjust;\r
+ _adjust = Max(0, Min(Scaler.ScaleWidth(24), _adjust + _gap));\r
+ if (_adjust == prev)\r
+ return;\r
+ var diff = _adjust - prev;\r
+ foreach (var labels in _enemyLabels)\r
+ {\r
+ labels.Hp.Left += diff;\r
+ labels.Name.Left = CalcEnemyNameLeft(labels.Hp.Width);\r
+ }\r
+ foreach (var labels in _friendLabels)\r
+ {\r
+ labels.Hp.Left += diff;\r
+ labels.Hp.AdjustLocation();\r
+ labels.Name.AdjustWidth(Scaler.DownWidth(_adjust), true);\r
+ }\r
+ }\r
+\r
+ private int CalcEnemyNameLeft(int hpWidth)\r
+ {\r
+ var nameSpace = _adjust / 2;\r
+ var hpAdjust = Scaler.ScaleWidth(12);\r
+ var wideHp = hpWidth > Scaler.ScaleWidth(47);\r
+ return Scaler.ScaleWidth(EnemyNameLeft) + _adjust + (wideHp && nameSpace < hpAdjust ? hpAdjust : nameSpace);\r
}\r
\r
protected override void OnMouseWheel(MouseEventArgs e)\r
return items.Concat(new[] {Record.CreateItemRecord(ship.SlotEx, 0, 0)});\r
}\r
\r
+ public class EquipRecord\r
+ {\r
+ private readonly ItemStatus _item;\r
+ private readonly string _text;\r
+\r
+ public EquipRecord(ItemStatus item)\r
+ {\r
+ _item = new ItemStatus{Alv = item.Alv, Level = item.Level, Spec = item.Spec};\r
+ }\r
+\r
+ public EquipRecord(string text = "")\r
+ {\r
+ _text = text;\r
+ }\r
+\r
+ public string ToString(int adjust)\r
+ {\r
+ if (_text != null)\r
+ return _text;\r
+ var level = _item.Level == 0 ? "" : "★" + _item.Level;\r
+ return StringTruncator.Truncate(_item.Spec.Name, level, adjust + (_item.Spec.IsAircraft ? 132 : 180)) + level;\r
+ }\r
+\r
+ public override string ToString()\r
+ {\r
+ return _text;\r
+ }\r
+ }\r
+\r
public class Record\r
{\r
public string Fleet { get; set; }\r
public string Ship { get; set; }\r
public string Ship2 { get; set; }\r
public int Id { get; set; }\r
- public string Equip { get; set; }\r
+ public EquipRecord Equip { get; set; }\r
public Color Color { get; set; }\r
public string Spec { get; set; }\r
public string Spec2 { get; set; }\r
public Record()\r
{\r
Color = Control.DefaultBackColor;\r
- Fleet = Ship = Equip = AircraftSpec = "";\r
+ Fleet = Ship = AircraftSpec = "";\r
+ Equip = new EquipRecord();\r
}\r
\r
public static Record CreateShipRecord(ShipStatus ship)\r
{\r
public ItemRecord(ItemStatus item, int onSlot, int maxEq)\r
{\r
- Equip = GenEquipString(item);\r
+ Equip = new EquipRecord(item);\r
Spec = item.Spec.IsAircraft ? $"+{item.Alv} {onSlot}/{maxEq}" : "";\r
AircraftSpec = GetAircraftSpec(item, onSlot);\r
Color = item.Spec.Color;\r
}\r
}\r
\r
- private static string GenEquipString(ItemStatus item)\r
- {\r
- var level = item.Level == 0 ? "" : "★" + item.Level;\r
- return StringTruncator.Truncate(item.Spec.Name, level, item.Spec.IsAircraft ? 132 : 180) + level;\r
- }\r
-\r
public static Record CreateFleetRecord(IReadOnlyList<Fleet> fleets, int number)\r
{\r
return new FleetRecord(fleets, number);\r
public CorpsPlaneRecord(AirBase.PlaneInfo plane)\r
{\r
var planeFp = plane.FighterPower;\r
- Equip = plane.State != 1 ? plane.StateName : GenEquipString(plane.Slot);\r
+ Equip = plane.State != 1 ? new EquipRecord(plane.StateName) : new EquipRecord(plane.Slot);\r
Spec = plane.State != 1 ? "" : $"+{plane.Slot.Alv} {plane.Count}/{plane.MaxCount}";\r
AircraftSpec =\r
$"距離:{plane.Slot.Spec.Distance} 制空:{RangeString(planeFp.AirCombat)}" +\r
\r
namespace KancolleSniffer.View.ListWindow\r
{\r
- public class FleetDataPanel : PanelWithToolTip\r
+ public class FleetDataPanel : PanelWithToolTip, IPanelResize\r
{\r
private const int LineHeight = 14;\r
private const int LabelHeight = 12;\r
public ShipLabel.Name Name { get; set; }\r
public Label Equip { get; set; }\r
public Label EquipColor { get; set; }\r
- public Label Spec { get; set; }\r
+ public GrowLeftLabel Spec { get; set; }\r
\r
public override Control[] Controls => new Control[] {Fleet, Name, Equip, EquipColor, Spec};\r
}\r
{\r
Fleet = new Label {Location = new Point(1, 2), AutoSize = true},\r
Name = new ShipLabel.Name(new Point(10, 2), ShipNameWidth.Max),\r
- Equip = new Label {Location = new Point(38, 2), AutoSize = true},\r
+ Equip = new Label {Location = new Point(38, 2), AutoSize = true, Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top},\r
EquipColor = new Label {Location = new Point(35, 2), Size = new Size(4, LabelHeight - 2)},\r
- Spec = new GrowLeftLabel {Location = new Point(217, 2), GrowLeft = true},\r
+ Spec = new GrowLeftLabel {Location = new Point(217, 2), GrowLeft = true, Anchor = AnchorStyles.Right | AnchorStyles.Top},\r
BackPanel = new Panel\r
{\r
Location = new Point(0, y),\r
labels.Move(AutoScrollPosition);\r
}\r
\r
+ public void ApplyResize()\r
+ {\r
+ var width = Width - SystemInformation.VerticalScrollBarWidth - 2;\r
+ SuspendLayout();\r
+ foreach (var labels in _labelList)\r
+ {\r
+ labels.BackPanel.Width = width;\r
+ labels.Spec.AdjustLocation();\r
+ }\r
+ SetRecords();\r
+ ResumeLayout();\r
+ }\r
+\r
private void SetRecords()\r
{\r
for (var i = 0; i < _data.Length; i++)\r
labels.Name.SetName(e.Ship);\r
if (e.Ship2 != "")\r
ToolTip.SetToolTip(labels.Name, e.Ship2);\r
- labels.Equip.Text = e.Equip;\r
- labels.EquipColor.Visible = e.Equip != "";\r
+ labels.Equip.Text = e.Equip.ToString(Scaler.DownWidth(labels.BackPanel.Width) - ListForm.PanelWidth);\r
+ labels.EquipColor.Visible = e.Equip.ToString() != "";\r
labels.EquipColor.BackColor = e.Color;\r
labels.Spec.Text = e.Spec;\r
if (e.Fleet != "" && e.Fleet2 != "")\r
--- /dev/null
+namespace KancolleSniffer.View.ListWindow\r
+{\r
+ public interface IPanelResize\r
+ {\r
+ bool Visible { get; }\r
+ void ApplyResize();\r
+ }\r
+}
\ No newline at end of file
{\r
public static class Scaler\r
{\r
- public static SizeF Factor { private get; set; }\r
+ public static SizeF Factor { private get; set; } = new SizeF(1, 1);\r
\r
public static void Scale(Control control)\r
{\r
{\r
return new Point(x + ScaleWidth(width), y + ScaleHeight(height));\r
}\r
+\r
+ public static int DownWidth(int width)\r
+ {\r
+ return (int)(width / Factor.Width);\r
+ }\r
}\r
}
\ No newline at end of file
public new sealed class Name : ShipLabel\r
{\r
private SlotStatus _slotStatus, _prevSlotStatus;\r
- private readonly ShipNameWidth _defaultWidth;\r
+ private ShipStatus _status;\r
\r
public static Font LatinFont { get; set; }\r
public static Font BaseFont { get; set; }\r
+ private readonly ShipNameWidth _defaultWidth;\r
+ private int _nameWidth;\r
+\r
+ public void AdjustWidth(int adjust, bool update = false)\r
+ {\r
+ _nameWidth = (int)_defaultWidth + Max(-24, adjust);\r
+ if (update && _status != null)\r
+ Set(_status);\r
+ }\r
\r
- public Name(Point location, ShipNameWidth defaultWidth)\r
+ public Name(Point location, ShipNameWidth nameWidth)\r
{\r
- _defaultWidth = defaultWidth;\r
+ _defaultWidth = nameWidth;\r
+ _nameWidth = (int)nameWidth;\r
Location = location;\r
AutoSize = true;\r
}\r
\r
public override void Set(ShipStatus status)\r
{\r
- SetName(status, _defaultWidth);\r
+ SetName(status, _nameWidth);\r
}\r
\r
public override void Reset()\r
\r
public void SetName(ShipStatus status, ShipNameWidth width)\r
{\r
+ SetName(status, (int)width);\r
+ }\r
+\r
+ private void SetName(ShipStatus status, int width)\r
+ {\r
+ _status = status;\r
var slotStatus = GetSlotStatus(status);\r
var dcName = DameConName(status);\r
var sp = SpecialAttack(status);\r
\r
public void SetName(string name)\r
{\r
- SetName(name, _defaultWidth);\r
- }\r
-\r
- private void SetName(string name, ShipNameWidth width)\r
- {\r
- SetName("", name, SlotStatus.Equipped, width);\r
+ Set(new ShipStatus{Spec = new ShipSpec{Name = name}});\r
}\r
\r
- private void SetName(string prefix, string name, SlotStatus slotStatus, ShipNameWidth width)\r
+ private void SetName(string prefix, string name, SlotStatus slotStatus, int width)\r
{\r
_slotStatus = slotStatus;\r
ChangeFont(name);\r
- var realWidth = width == ShipNameWidth.Max ? (int)width : Scaler.ScaleWidth((int)width);\r
+ var realWidth = width == int.MaxValue ? width : Scaler.ScaleWidth(width);\r
Text = prefix + StringTruncator.Truncate(name, "", realWidth, Font);\r
if (_prevSlotStatus != _slotStatus)\r
Invalidate(); // OnPaintを実行させるため\r
{\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
var cb = new CheckBox[GroupCount];\r
Scaler.Scale(cb[j]);\r
cb[j].CheckedChanged += checkboxGroup_CheckedChanged;\r
}\r
+ SetAnchorRight(cb.Concat(new Control[] {labels.Level}).ToArray());\r
_labelList.Add(labels);\r
_checkBoxesList.Add(cb);\r
labels.Arrange(_shipListPanel, CustomColors.ColumnColors.BrightFirst(i));\r
labels.BackPanel.Controls.AddRange(cb);\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.Name.AdjustWidth(Scaler.DownWidth(width) - ListForm.PanelWidth);\r
+ }\r
+\r
private void checkboxGroup_CheckedChanged(object sender, EventArgs e)\r
{\r
var cb = (CheckBox)sender;\r
Hp = new ShipLabel.Hp(new Point(118, 0), ShipListPanel.LineHeight),\r
Level = new ShipLabel.Level(new Point(116, 2), height),\r
Time = new ShipLabel.RepairTime(new Point(141, 2)),\r
- PerHp = new Label {Location = new Point(186, 2), AutoSize = true},\r
+ PerHp = new Label {Location = new Point(185, 2), AutoSize = true},\r
BackPanel = new Panel\r
{\r
Location = new Point(0, y),\r
- Size = new Size(ListForm.PanelWidth, ShipListPanel.LineHeight)\r
+ Size = new Size(ListForm.PanelWidth, ShipListPanel.LineHeight),\r
+ Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top\r
}\r
};\r
+ SetAnchorRight(labels.Hp, labels.Level, labels.Time, labels.PerHp);\r
_labelList.Add(labels);\r
labels.Arrange(_shipListPanel, CustomColors.ColumnColors.BrightFirst(i));\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 SetRepairList(int i)\r
{\r
var s = _shipListPanel.GetShip(i);\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(128, 0), ShipListPanel.LineHeight),\r
- Level = new ShipLabel.Level(new Point(154, 2), height),\r
- Exp = new ShipLabel.Exp(new Point(175, 2), height),\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(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
labels.Arrange(_shipListPanel, CustomColors.ColumnColors.BrightFirst(i));\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
{\r
var s = _shipListPanel.GetShip(i);\r
using System.Windows.Forms;\r
using KancolleSniffer.Forms;\r
using KancolleSniffer.Model;\r
+using KancolleSniffer.View.ListWindow;\r
using static System.Math;\r
\r
namespace KancolleSniffer.View.ShipListPanel\r
{\r
- public class ShipListPanel : Panel\r
+ public class ShipListPanel : Panel, IPanelResize\r
{\r
public const int LabelHeight = 12;\r
public const int LineHeight = 16;\r
ResumeDrawing();\r
}\r
\r
- protected override void OnResize(EventArgs ev)\r
+ public void ApplyResize()\r
{\r
- base.OnResize(ev);\r
if (_shipList == null || _shipList.Length == 0 || !Visible)\r
return;\r
SuspendDrawing();\r
SetupLabels();\r
+ ResizeLabels();\r
SetShipLabels();\r
ResumeDrawing();\r
}\r
CreateShipList(sniffer, settings);\r
SuspendDrawing();\r
SetupLabels();\r
+ ResizeLabels();\r
SetShipLabels();\r
ResumeDrawing();\r
}\r
ScrollBar.Value = Min(ScrollBar.Value, max);\r
}\r
\r
+ private void ResizeLabels()\r
+ {\r
+ var width = Width - SystemInformation.VerticalScrollBarWidth - 2;\r
+ for (var i = 0; i < _labelCount; i++)\r
+ {\r
+ _shipListLabels.Resize(i, width);\r
+ _groupConfigLabels.Resize(i, width);\r
+ _repairListLabels.Resize(i, width);\r
+ }\r
+ }\r
+\r
public void SetHpPercent(ShipLabel.Hp label)\r
{\r
if (_hpPercent)\r