--- /dev/null
+// Copyright (C) 2015 Kazuhiro Fujieda <fujieda@users.sourceforge.jp>\r
+//\r
+// This program is part of KancolleSniffer.\r
+//\r
+// KancolleSniffer is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU General Public License as published by\r
+// the Free Software Foundation, either version 3 of the License, or\r
+// (at your option) any later version.\r
+//\r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+// GNU General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, see <http://www.gnu.org/licenses/>.\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Drawing;\r
+using System.Linq;\r
+using System.Windows.Forms;\r
+\r
+namespace KancolleSniffer\r
+{\r
+ public class EquipPanel : Panel\r
+ {\r
+ private const int LineHeight = 14;\r
+ private const int LabelHeight = 12;\r
+ private EquipColumn[] _equipList;\r
+ private readonly List<ShipLabel[]> _labelList = new List<ShipLabel[]>();\r
+ private readonly List<Panel> _panelList = new List<Panel>();\r
+\r
+ private class EquipColumn\r
+ {\r
+ public string Fleet { get; set; }\r
+ public string Ship { get; set; }\r
+ public int Id { get; set; }\r
+ public string Equip { get; set; }\r
+ public Color Color { get; set; }\r
+\r
+ public EquipColumn()\r
+ {\r
+ Fleet = Ship = Equip = "";\r
+ Color = DefaultBackColor;\r
+ }\r
+ }\r
+\r
+ public void UpdateEquip(Sniffer sniffer)\r
+ {\r
+ CreateEquipList(sniffer);\r
+ SuspendLayout();\r
+ CreateEquipLabels();\r
+ SetEquipLabels();\r
+ ResumeLayout();\r
+ }\r
+\r
+ private void CreateEquipList(Sniffer sniffer)\r
+ {\r
+ var list = new List<EquipColumn>();\r
+ var fleet = new[] { "第一艦隊", "第二艦隊", "第三艦隊", "第四艦隊" };\r
+ for (var i = 0; i < fleet.Length; i++)\r
+ {\r
+ list.Add(new EquipColumn { Fleet = fleet[i] });\r
+ foreach (var s in sniffer.GetShipStatuses(i))\r
+ {\r
+ list.Add(new EquipColumn { Ship = s.Name, Id = s.Id });\r
+ list.AddRange(\r
+ (from e in Enumerable.Range(0, s.Slot.Length)\r
+ let slot = s.Slot[e]\r
+ let onslot = s.OnSlot[e]\r
+ let max = s.Spec.MaxEq[e]\r
+ where slot != -1\r
+ let item = sniffer.Item.ItemDict[slot]\r
+ select\r
+ new EquipColumn\r
+ {\r
+ Equip = item.Spec.Name + (item.Level == 0 ? "" : "★" + item.Level) +\r
+ (!item.Spec.IsAircraft ? "" : " " + onslot + "/" + max),\r
+ Color = item.Spec.Color\r
+ })\r
+ .DefaultIfEmpty(new EquipColumn { Equip = "なし" }));\r
+ }\r
+ }\r
+ _equipList = list.ToArray();\r
+ }\r
+\r
+ private void CreateEquipLabels()\r
+ {\r
+ for (var i = _labelList.Count; i < _equipList.Length; i++)\r
+ CreateEquipLabels(i);\r
+ }\r
+\r
+ private void CreateEquipLabels(int i)\r
+ {\r
+ var y = 1 + LineHeight * i;\r
+ var lbp = new Panel\r
+ {\r
+ Location = new Point(0, y),\r
+ Size = new Size(ShipListForm.PanelWidth, LineHeight),\r
+ BackColor = ShipLabels.ColumnColors[(i + 1) % 2],\r
+ Visible = false\r
+ };\r
+ lbp.Scale(ShipLabel.ScaleFactor);\r
+ lbp.Tag = lbp.Location.Y;\r
+ var labels = new[]\r
+ {\r
+ new ShipLabel {Location = new Point(1, 2), AutoSize = true},\r
+ new ShipLabel {Location = new Point(10, 2), AutoSize = true},\r
+ new ShipLabel {Location = new Point(40, 2), AutoSize = true},\r
+ new ShipLabel {Location = new Point(37, 2), Size = new Size(4, LabelHeight - 2)}\r
+ };\r
+ _labelList.Add(labels);\r
+ _panelList.Add(lbp);\r
+ // ReSharper disable once CoVariantArrayConversion\r
+ lbp.Controls.AddRange(labels);\r
+ Controls.Add(lbp);\r
+ foreach (var label in labels)\r
+ {\r
+ label.Scale();\r
+ label.PresetColor =\r
+ label.BackColor = ShipLabels.ColumnColors[(i + 1) % 2];\r
+ }\r
+ }\r
+\r
+ private void SetEquipLabels()\r
+ {\r
+ for (var i = 0; i < _equipList.Length; i++)\r
+ SetEquip(i);\r
+ for (var i = _equipList.Length; i < _labelList.Count; i++)\r
+ _panelList[i].Visible = false;\r
+ }\r
+\r
+ private void SetEquip(int i)\r
+ {\r
+ var lbp = _panelList[i];\r
+ if (!lbp.Visible)\r
+ lbp.Location = new Point(lbp.Left, (int)lbp.Tag + AutoScrollPosition.Y);\r
+ var e = _equipList[i];\r
+ var labels = _labelList[i];\r
+ labels[0].Text = e.Fleet;\r
+ labels[1].SetName(e.Ship);\r
+ labels[2].Text = e.Equip;\r
+ labels[3].Visible = e.Equip != "";\r
+ labels[3].BackColor = e.Color;\r
+ lbp.Visible = true;\r
+ }\r
+\r
+ public void ShowShip(int id)\r
+ {\r
+ var i = Array.FindIndex(_equipList, e => e.Id == id);\r
+ if (i == -1)\r
+ return;\r
+ var y = (int)Math.Round(ShipLabel.ScaleFactor.Height * LineHeight * i);\r
+ AutoScrollPosition = new Point(0, y);\r
+ }\r
+ }\r
+}
\ No newline at end of file
this.label10 = new System.Windows.Forms.Label();\r
this.label11 = new System.Windows.Forms.Label();\r
this.panelItemHeader = new System.Windows.Forms.Panel();\r
+ this.equipPanel = new KancolleSniffer.EquipPanel();\r
this.itemTreeView = new KancolleSniffer.ItemTreeView();\r
this.panelShipList.SuspendLayout();\r
this.panelGroupHeader.SuspendLayout();\r
| System.Windows.Forms.AnchorStyles.Left)));\r
this.panelShipList.AutoScroll = true;\r
this.panelShipList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r
+ this.panelShipList.Controls.Add(this.equipPanel);\r
this.panelShipList.Controls.Add(this.itemTreeView);\r
this.panelShipList.Location = new System.Drawing.Point(6, 23);\r
this.panelShipList.Name = "panelShipList";\r
this.comboBoxGroup.Size = new System.Drawing.Size(48, 20);\r
this.comboBoxGroup.TabIndex = 1;\r
this.comboBoxGroup.SelectedIndexChanged += new System.EventHandler(this.comboBoxGroup_SelectedIndexChanged);\r
- this.comboBoxGroup.DropDownClosed += new System.EventHandler(this.comboBoxGroup_DropDownClosed);\r
// \r
// label12\r
// \r
this.panelItemHeader.Size = new System.Drawing.Size(166, 19);\r
this.panelItemHeader.TabIndex = 0;\r
// \r
+ // equipPanel\r
+ // \r
+ this.equipPanel.AutoScroll = true;\r
+ this.equipPanel.Dock = System.Windows.Forms.DockStyle.Fill;\r
+ this.equipPanel.Location = new System.Drawing.Point(0, 0);\r
+ this.equipPanel.Name = "equipPanel";\r
+ this.equipPanel.Size = new System.Drawing.Size(236, 261);\r
+ this.equipPanel.TabIndex = 1;\r
+ // \r
// itemTreeView\r
// \r
this.itemTreeView.Dock = System.Windows.Forms.DockStyle.Fill;\r
private System.Windows.Forms.Label label5;\r
private System.Windows.Forms.Label label11;\r
private System.Windows.Forms.Panel panelItemHeader;\r
+ private EquipPanel equipPanel;\r
private ItemTreeView itemTreeView;\r
}\r
}
\ No newline at end of file
private readonly Config _config;\r
private const int LabelHeight = 12;\r
private const int LineHeight = 16;\r
- private const int PanelWidth = 217;\r
+ public const int PanelWidth = 217;\r
private ShipStatus[] _shipList;\r
private readonly List<ShipLabel[]> _labelList = new List<ShipLabel[]>();\r
private readonly List<Panel> _labelPanelList = new List<Panel>();\r
private readonly List<Panel> _checkBoxPanelList = new List<Panel>();\r
private readonly List<ShipLabel[]> _repairLabelList = new List<ShipLabel[]>();\r
private readonly List<Panel> _repairPanelList = new List<Panel>();\r
- private readonly List<ShipLabel[]> _equipLabelList = new List<ShipLabel[]>();\r
- private readonly List<Panel> _equipPanelList = new List<Panel>();\r
public const int GroupCount = 4;\r
private readonly HashSet<int>[] _groupSettings = new HashSet<int>[GroupCount];\r
- private EquipColumn[] _equipList;\r
\r
public ShipListForm(Sniffer sniffer, Config config)\r
{\r
\r
public void UpdateList()\r
{\r
- panelItemHeader.Visible = InItemList();\r
+ panelItemHeader.Visible = InItemList() || InEquip();\r
itemTreeView.Visible = InItemList();\r
+ equipPanel.Visible = InEquip();\r
if (InItemList())\r
{\r
HideShipLabels();\r
- HideEquipLabels();\r
itemTreeView.SetNodes(_sniffer.ItemList);\r
}\r
else if (InEquip())\r
{\r
HideShipLabels();\r
- CreateEquip();\r
- CreateEquipLabels();\r
- SetEquipLabels();\r
+ equipPanel.UpdateEquip(_sniffer);\r
}\r
else\r
{\r
- HideEquipLabels();\r
CreateShipList();\r
CreateListLabels();\r
SetShipLabels();\r
_shipList = ships.Concat(types).OrderBy(s => s, new CompareShip(true, InRepairList())).ToArray();\r
}\r
\r
- private class EquipColumn\r
- {\r
- public string Fleet { get; set; }\r
- public string Ship { get; set; }\r
- public int Id { get; set; }\r
- public string Equip { get; set; }\r
- public Color Color { get; set; }\r
-\r
- public EquipColumn()\r
- {\r
- Fleet = Ship = Equip = "";\r
- Color = DefaultBackColor;\r
- }\r
- }\r
-\r
- private void CreateEquip()\r
- {\r
- var list = new List<EquipColumn>();\r
- var fleet = new[] {"第一艦隊", "第二艦隊", "第三艦隊", "第四艦隊"};\r
- for (var i = 0; i < fleet.Length; i++)\r
- {\r
- list.Add(new EquipColumn {Fleet = fleet[i]});\r
- foreach (var s in _sniffer.GetShipStatuses(i))\r
- {\r
- s.Fleet = -1;\r
- list.Add(new EquipColumn {Ship = s.Name, Id = s.Id});\r
- list.AddRange(\r
- (from e in Enumerable.Range(0, s.Slot.Length)\r
- let slot = s.Slot[e]\r
- let onslot = s.OnSlot[e]\r
- let max = s.Spec.MaxEq[e]\r
- where slot != -1\r
- let item = _sniffer.Item.ItemDict[slot]\r
- select\r
- new EquipColumn\r
- {\r
- Equip = item.Spec.Name + (item.Level == 0 ? "" : "★" + item.Level) +\r
- (!item.Spec.IsAircraft ? "" : " " + onslot + "/" + max),\r
- Color = item.Spec.Color\r
- })\r
- .DefaultIfEmpty(new EquipColumn {Equip = "なし"}));\r
- }\r
- }\r
- _equipList = list.ToArray();\r
- }\r
-\r
private IEnumerable<ShipStatus> FilterByGroup(IEnumerable<ShipStatus> ships)\r
{\r
var g = Array.FindIndex(new[] {"A", "B", "C", "D"}, x => x == comboBoxGroup.Text);\r
panelShipList.ResumeLayout();\r
}\r
\r
- private void CreateEquipLabels()\r
- {\r
- panelShipList.SuspendLayout();\r
- for (var i = _equipLabelList.Count; i < _equipList.Length; i++)\r
- CreateEquipLabels(i);\r
- panelShipList.ResumeLayout();\r
- }\r
-\r
private void CreateConfigComponents(int i)\r
{\r
var y = 3 + LineHeight * i;\r
}\r
}\r
\r
- private void CreateEquipLabels(int i)\r
- {\r
- var y = 3 + (LineHeight - 2) * i;\r
- var lbp = new Panel\r
- {\r
- Location = new Point(0, y - 2),\r
- Size = new Size(PanelWidth, LineHeight - 2),\r
- BackColor = ShipLabels.ColumnColors[(i + 1) % 2],\r
- Visible = false\r
- };\r
- lbp.Scale(ShipLabel.ScaleFactor);\r
- lbp.Tag = lbp.Location.Y;\r
- var labels = new[]\r
- {\r
- new ShipLabel {Location = new Point(1, 2), AutoSize = true},\r
- new ShipLabel {Location = new Point(10, 2), AutoSize = true},\r
- new ShipLabel {Location = new Point(40, 2), AutoSize = true},\r
- new ShipLabel {Location = new Point(37, 2), Size = new Size(4, LabelHeight - 2)}\r
- };\r
- _equipLabelList.Add(labels);\r
- _equipPanelList.Add(lbp);\r
- // ReSharper disable once CoVariantArrayConversion\r
- lbp.Controls.AddRange(labels);\r
- panelShipList.Controls.Add(lbp);\r
- foreach (var label in labels)\r
- {\r
- label.Scale();\r
- label.PresetColor =\r
- label.BackColor = ShipLabels.ColumnColors[(i + 1) % 2];\r
- }\r
- }\r
-\r
private void SetShipLabels()\r
{\r
panelGroupHeader.Visible = InGroupConfig();\r
lbp.Visible = true;\r
}\r
\r
- private void SetEquipLabels()\r
- {\r
- panelItemHeader.Visible = true;\r
- panelShipList.SuspendLayout();\r
- for (var i = 0; i < _equipList.Length; i++)\r
- SetEquip(i);\r
- for (var i = _equipList.Length; i < _equipLabelList.Count; i++)\r
- _equipPanelList[i].Visible = false;\r
- panelShipList.ResumeLayout();\r
- }\r
-\r
- private void SetEquip(int i)\r
- {\r
- var lbp = _equipPanelList[i];\r
- if (!lbp.Visible)\r
- lbp.Location = new Point(lbp.Left, (int)lbp.Tag + panelShipList.AutoScrollPosition.Y);\r
- var e = _equipList[i];\r
- var labels = _equipLabelList[i];\r
- labels[0].Text = e.Fleet;\r
- labels[1].SetName(e.Ship);\r
- labels[2].Text = e.Equip;\r
- labels[3].Visible = e.Equip != "";\r
- labels[3].BackColor = e.Color;\r
- lbp.Visible = true;\r
- }\r
-\r
private void SetGroupConfig(int i)\r
{\r
var cbp = _checkBoxPanelList[i];\r
panelShipList.ResumeLayout();\r
}\r
\r
- private void HideEquipLabels()\r
- {\r
- panelShipList.SuspendLayout();\r
- foreach (var e in _equipPanelList)\r
- e.Visible = false;\r
- panelShipList.ResumeLayout();\r
- }\r
-\r
private bool InShipStatus()\r
{\r
return Array.Exists(new[] {"全員", "A", "B", "C", "D"}, x => comboBoxGroup.Text == x);\r
\r
public void ShowShip(int id)\r
{\r
- var y = 0;\r
if (InShipStatus())\r
{\r
var i = Array.FindIndex(_shipList, s => s.Id == id);\r
if (i == -1)\r
return;\r
- y = (int)Math.Round(ShipLabel.ScaleFactor.Height * LineHeight * i);\r
+ var y = (int)Math.Round(ShipLabel.ScaleFactor.Height * LineHeight * i);\r
+ panelShipList.AutoScrollPosition = new Point(0, y);\r
}\r
else if (InEquip())\r
{\r
- var i = Array.FindIndex(_equipList, e => e.Id == id);\r
- if (i == -1)\r
- return;\r
- y = (int)Math.Round(ShipLabel.ScaleFactor.Height * (LineHeight - 2) * i);\r
+ equipPanel.ShowShip(id);\r
}\r
- panelShipList.AutoScrollPosition = new Point(0, y);\r
}\r
\r
private void checkBoxShipType_CheckedChanged(object sender, EventArgs e)\r
private void comboBoxGroup_SelectedIndexChanged(object sender, EventArgs e)\r
{\r
UpdateList();\r
- }\r
-\r
- private void comboBoxGroup_DropDownClosed(object sender, EventArgs e)\r
- {\r
SetActiveControl();\r
}\r
\r
if (g == -1)\r
return;\r
comboBoxGroup.SelectedIndex = g;\r
- SetActiveControl();\r
e.Handled = true;\r
}\r
\r
// マウスホイールでスクロールするためにコントロールにフォーカスを合わせる。\r
private void SetActiveControl()\r
{\r
- ActiveControl = InItemList() ? (Control)itemTreeView : panelShipList;\r
+ if (InItemList())\r
+ ActiveControl = itemTreeView;\r
+ else if (InEquip())\r
+ ActiveControl = equipPanel;\r
+ else\r
+ ActiveControl = panelShipList;\r
}\r
}\r
}
\ No newline at end of file