this.label4 = new System.Windows.Forms.Label();\r
this.label3 = new System.Windows.Forms.Label();\r
this.checkBoxShipType = new System.Windows.Forms.CheckBox();\r
+ this.panelGroupHeader = new System.Windows.Forms.Panel();\r
+ this.label9 = new System.Windows.Forms.Label();\r
+ this.label8 = new System.Windows.Forms.Label();\r
+ this.label7 = new System.Windows.Forms.Label();\r
+ this.label6 = new System.Windows.Forms.Label();\r
+ this.comboBoxGroup = new System.Windows.Forms.ComboBox();\r
+ this.panelGroupHeader.SuspendLayout();\r
this.SuspendLayout();\r
// \r
// panelShipList\r
// label1\r
// \r
this.label1.AutoSize = true;\r
- this.label1.Location = new System.Drawing.Point(104, 8);\r
+ this.label1.Location = new System.Drawing.Point(105, 8);\r
this.label1.Name = "label1";\r
this.label1.Size = new System.Drawing.Size(29, 12);\r
this.label1.TabIndex = 13;\r
// label2\r
// \r
this.label2.AutoSize = true;\r
- this.label2.Location = new System.Drawing.Point(133, 8);\r
+ this.label2.Location = new System.Drawing.Point(134, 8);\r
this.label2.Name = "label2";\r
this.label2.Size = new System.Drawing.Size(29, 12);\r
this.label2.TabIndex = 13;\r
// label4\r
// \r
this.label4.AutoSize = true;\r
- this.label4.Location = new System.Drawing.Point(198, 8);\r
+ this.label4.Location = new System.Drawing.Point(199, 8);\r
this.label4.Name = "label4";\r
this.label4.Size = new System.Drawing.Size(41, 12);\r
this.label4.TabIndex = 14;\r
// label3\r
// \r
this.label3.AutoSize = true;\r
- this.label3.Location = new System.Drawing.Point(162, 8);\r
+ this.label3.Location = new System.Drawing.Point(163, 8);\r
this.label3.Name = "label3";\r
this.label3.Size = new System.Drawing.Size(34, 12);\r
this.label3.TabIndex = 13;\r
// \r
this.checkBoxShipType.AutoSize = true;\r
this.checkBoxShipType.FlatStyle = System.Windows.Forms.FlatStyle.Flat;\r
- this.checkBoxShipType.Location = new System.Drawing.Point(10, 6);\r
+ this.checkBoxShipType.Location = new System.Drawing.Point(58, 6);\r
this.checkBoxShipType.Name = "checkBoxShipType";\r
this.checkBoxShipType.Size = new System.Drawing.Size(45, 16);\r
this.checkBoxShipType.TabIndex = 15;\r
this.checkBoxShipType.Text = "艦種";\r
this.checkBoxShipType.CheckedChanged += new System.EventHandler(this.checkBoxShipType_CheckedChanged);\r
// \r
+ // panelGroupHeader\r
+ // \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(104, 3);\r
+ this.panelGroupHeader.Name = "panelGroupHeader";\r
+ this.panelGroupHeader.Size = new System.Drawing.Size(136, 19);\r
+ this.panelGroupHeader.TabIndex = 16;\r
+ this.panelGroupHeader.Visible = false;\r
+ // \r
+ // label9\r
+ // \r
+ this.label9.AutoSize = true;\r
+ this.label9.Location = new System.Drawing.Point(103, 5);\r
+ this.label9.Name = "label9";\r
+ this.label9.Size = new System.Drawing.Size(13, 12);\r
+ this.label9.TabIndex = 4;\r
+ this.label9.Text = "D";\r
+ // \r
+ // label8\r
+ // \r
+ this.label8.AutoSize = true;\r
+ this.label8.Location = new System.Drawing.Point(73, 5);\r
+ this.label8.Name = "label8";\r
+ this.label8.Size = new System.Drawing.Size(13, 12);\r
+ this.label8.TabIndex = 3;\r
+ this.label8.Text = "C";\r
+ // \r
+ // label7\r
+ // \r
+ this.label7.AutoSize = true;\r
+ this.label7.Location = new System.Drawing.Point(43, 5);\r
+ this.label7.Name = "label7";\r
+ this.label7.Size = new System.Drawing.Size(13, 12);\r
+ this.label7.TabIndex = 2;\r
+ this.label7.Text = "B";\r
+ // \r
+ // label6\r
+ // \r
+ this.label6.AutoSize = true;\r
+ this.label6.Location = new System.Drawing.Point(13, 5);\r
+ this.label6.Name = "label6";\r
+ this.label6.Size = new System.Drawing.Size(13, 12);\r
+ this.label6.TabIndex = 1;\r
+ this.label6.Text = "A";\r
+ // \r
+ // comboBoxGroup\r
+ // \r
+ this.comboBoxGroup.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+ this.comboBoxGroup.FlatStyle = System.Windows.Forms.FlatStyle.Flat;\r
+ this.comboBoxGroup.FormattingEnabled = true;\r
+ this.comboBoxGroup.Items.AddRange(new object[] {\r
+ "全員",\r
+ "A",\r
+ "B",\r
+ "C",\r
+ "D",\r
+ "設定"});\r
+ this.comboBoxGroup.Location = new System.Drawing.Point(6, 4);\r
+ this.comboBoxGroup.Name = "comboBoxGroup";\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
// ShipListForm\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(263, 262);\r
+ this.Controls.Add(this.panelGroupHeader);\r
this.Controls.Add(this.checkBoxShipType);\r
this.Controls.Add(this.label4);\r
this.Controls.Add(this.label2);\r
this.Controls.Add(this.label3);\r
this.Controls.Add(this.label1);\r
this.Controls.Add(this.panelShipList);\r
+ this.Controls.Add(this.comboBoxGroup);\r
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));\r
this.MaximizeBox = false;\r
this.Name = "ShipListForm";\r
this.Text = "艦娘一覧";\r
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ShipListForm_FormClosing);\r
this.Load += new System.EventHandler(this.ShipListForm_Load);\r
+ this.panelGroupHeader.ResumeLayout(false);\r
+ this.panelGroupHeader.PerformLayout();\r
this.ResumeLayout(false);\r
this.PerformLayout();\r
\r
private System.Windows.Forms.Label label4;\r
private System.Windows.Forms.Label label3;\r
private System.Windows.Forms.CheckBox checkBoxShipType;\r
+ private System.Windows.Forms.Panel panelGroupHeader;\r
+ private System.Windows.Forms.Label label6;\r
+ private System.Windows.Forms.Label label9;\r
+ private System.Windows.Forms.Label label8;\r
+ private System.Windows.Forms.Label label7;\r
+ private System.Windows.Forms.ComboBox comboBoxGroup;\r
}\r
}
\ No newline at end of file
{\r
private readonly Sniffer _sniffer;\r
private readonly Config _config;\r
- private readonly List<ShipLabel[]> _labelList = new List<ShipLabel[]>();\r
+ private const int LabelHeight = 12;\r
+ private const int LineHeight = 16;\r
private const int HpLabelRight = 126;\r
- private const int PanelWidth = 235;\r
+ private const int PanelWidth = 232;\r
private ShipStatus[] _currentList;\r
+ private readonly List<ShipLabel[]> _labelList = new List<ShipLabel[]>();\r
+ private readonly List<Panel> _labelPanelList = new List<Panel>();\r
+ private readonly List<CheckBox[]> _checkBoxesList = new List<CheckBox[]>();\r
+ private readonly List<Panel> _checkBoxPanelList = new List<Panel>();\r
+ public const int GroupCount = 4;\r
+ private readonly HashSet<int>[] _groupSettings = new HashSet<int>[GroupCount];\r
\r
public ShipListForm(Sniffer sniffer, Config config)\r
{\r
\r
private void CreateList()\r
{\r
- var ships = (IEnumerable<ShipStatus>)_sniffer.ShipList;\r
+ var ships = FilterByGroup(_sniffer.ShipList).ToArray();\r
if (!_config.ShipList.ShipType)\r
{\r
_currentList = ships.OrderBy(s => s, new CompareShipByExp()).ToArray();\r
_currentList = ships.Concat(types).OrderBy(s => s, new CompareShipByType()).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
+ if (g == -1)\r
+ return ships;\r
+ return from s in ships where _groupSettings[g].Contains(s.Id) select s;\r
+ }\r
+\r
private void CreateListLabels()\r
{\r
panelShipList.SuspendLayout();\r
for (var i = _labelList.Count; i < _currentList.Length; i++)\r
{\r
- const int height = 12, lh = 16;\r
- var y = 3 + lh * i +\r
- (int)Math.Round(panelShipList.AutoScrollPosition.Y / ShipLabel.ScaleFactor.Height);\r
- var labels = new[]\r
+ CreateCheckBoxes(i);\r
+ CreateShipLabels(i);\r
+ }\r
+ panelShipList.ResumeLayout();\r
+ }\r
+\r
+ private void CreateCheckBoxes(int i)\r
+ {\r
+ var y = 3 + LineHeight * i;\r
+ var cb = new CheckBox[GroupCount];\r
+ var cbp = new Panel\r
+ {\r
+ Location = new Point(79, y),\r
+ Size = new Size(153, LabelHeight),\r
+ BackColor = ShipInfoLabels.ColumnColors[(i + 1) % 2],\r
+ Visible = false\r
+ };\r
+ cbp.Scale(ShipLabel.ScaleFactor);\r
+ cbp.Tag = cbp.Location.Y;\r
+ for (var j = 0; j < cb.Length; j++)\r
+ {\r
+ cb[j] = new CheckBox\r
{\r
- new ShipLabel {Location = new Point(HpLabelRight, y), AutoSize = true},\r
- new ShipLabel\r
- {\r
- Location = new Point(132, y),\r
- Size = new Size(23, height),\r
- TextAlign = ContentAlignment.MiddleRight\r
- },\r
- new ShipLabel\r
- {\r
- Location = new Point(166, y),\r
- Size = new Size(23, height),\r
- TextAlign = ContentAlignment.MiddleRight\r
- },\r
- new ShipLabel\r
- {\r
- Location = new Point(191, y),\r
- Size = new Size(41, height),\r
- TextAlign = ContentAlignment.MiddleRight\r
- },\r
- new ShipLabel {Location = new Point(10, y), AutoSize = true},\r
- new ShipLabel {Location = new Point(1, y), AutoSize = true},\r
- new ShipLabel {Location = new Point(0, y - 1), Size = new Size(PanelWidth - 3, lh - 1)}\r
+ Location = new Point(31 + j * 30, 0),\r
+ FlatStyle = FlatStyle.Flat,\r
+ Size = new Size(15, 14),\r
+ Tag = i * 10 + j\r
};\r
- _labelList.Add(labels);\r
- foreach (var label in labels)\r
- label.Scale(ShipLabel.ScaleFactor);\r
- // ReSharper disable once CoVariantArrayConversion\r
- panelShipList.Controls.AddRange(labels);\r
- labels[0].SizeChanged += labelHP_SizeChanged;\r
- foreach (var label in labels)\r
- {\r
- label.PresetColor =\r
- label.BackColor = ShipInfoLabels.ColumnColors[(i + 1) % 2];\r
- }\r
+ cb[j].Scale(ShipLabel.ScaleFactor);\r
+ cb[j].CheckedChanged += checkboxGroup_CheckedChanged;\r
}\r
- for (var i = _labelList.Count; i > _currentList.Length; i--)\r
+ _checkBoxesList.Add(cb);\r
+ _checkBoxPanelList.Add(cbp);\r
+// ReSharper disable once CoVariantArrayConversion\r
+ cbp.Controls.AddRange(cb);\r
+ panelShipList.Controls.Add(cbp);\r
+ }\r
+\r
+ private void CreateShipLabels(int i)\r
+ {\r
+ var y = 3 + LineHeight * i;\r
+ const int height = LabelHeight;\r
+ const int lh = LineHeight;\r
+ var lbp = new Panel\r
+ {\r
+ Location = new Point(0, y - 1),\r
+ Size = new Size(PanelWidth, lh),\r
+ BackColor = ShipInfoLabels.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
- foreach (var label in _labelList[i - 1])\r
+ new ShipLabel {Location = new Point(HpLabelRight, 1), AutoSize = true},\r
+ new ShipLabel\r
{\r
- panelShipList.Controls.Remove(label);\r
- label.Dispose();\r
- }\r
- _labelList.RemoveAt(i - 1);\r
+ Location = new Point(132, 1),\r
+ Size = new Size(23, height),\r
+ TextAlign = ContentAlignment.MiddleRight\r
+ },\r
+ new ShipLabel\r
+ {\r
+ Location = new Point(166, 1),\r
+ Size = new Size(23, height),\r
+ TextAlign = ContentAlignment.MiddleRight\r
+ },\r
+ new ShipLabel\r
+ {\r
+ Location = new Point(191, 1),\r
+ Size = new Size(41, height),\r
+ TextAlign = ContentAlignment.MiddleRight\r
+ },\r
+ new ShipLabel {Location = new Point(10, 1), AutoSize = true},\r
+ new ShipLabel {Location = new Point(1, 1), AutoSize = true},\r
+ new ShipLabel {Location = new Point(0, 0), Size = new Size(PanelWidth, lh - 1)}\r
+ };\r
+ foreach (var label in labels)\r
+ {\r
+ label.Scale(ShipLabel.ScaleFactor);\r
+ label.PresetColor =\r
+ label.BackColor = ShipInfoLabels.ColumnColors[(i + 1) % 2];\r
}\r
- panelShipList.ResumeLayout();\r
+ _labelList.Add(labels);\r
+ _labelPanelList.Add(lbp);\r
+// ReSharper disable once CoVariantArrayConversion\r
+ lbp.Controls.AddRange(labels);\r
+ panelShipList.Controls.Add(lbp);\r
+ labels[0].SizeChanged += labelHP_SizeChanged;\r
}\r
\r
private class CompareShipByExp : IComparer<ShipStatus>\r
\r
private void SetShipLabels()\r
{\r
+ panelGroupHeader.Visible = InGroupConfig();\r
+ panelShipList.SuspendLayout();\r
var fn = new[] {"", "1", "2", "3", "4"};\r
- var i = 0;\r
- foreach (var s in _currentList)\r
+ for (var i = 0; i < _currentList.Length; i++)\r
{\r
- var labels = _labelList[i++];\r
+ var lbp = _labelPanelList[i];\r
+ if (lbp.Visible == false)\r
+ {\r
+ lbp.Location = new Point(lbp.Left, (int)lbp.Tag + panelShipList.AutoScrollPosition.Y);\r
+ lbp.Visible = true;\r
+ }\r
+ var cbp = _checkBoxPanelList[i];\r
+ if (cbp.Visible == false && InGroupConfig())\r
+ {\r
+ cbp.Location = new Point(cbp.Left, (int)cbp.Tag + panelShipList.AutoScrollPosition.Y);\r
+ }\r
+ var s = _currentList[i];\r
+ var labels = _labelList[i];\r
if (s.Level == 1000)\r
{\r
+ cbp.Visible = false;\r
for (var c = 0; c < 6; c++)\r
{\r
labels[c].Text = "";\r
labels[5].Text = s.Name;\r
continue;\r
}\r
- labels[0].SetHp(s);\r
- labels[1].SetCond(s);\r
- labels[2].SetLevel(s);\r
- labels[3].SetExpToNext(s);\r
+ cbp.Visible = InGroupConfig();\r
+ if (InGroupConfig())\r
+ {\r
+ var cb = _checkBoxesList[i];\r
+ for (var j = 0; j < cb.Length; j++)\r
+ cb[j].Checked = _groupSettings[j].Contains(s.Id);\r
+ }\r
+ else\r
+ {\r
+ labels[0].SetHp(s);\r
+ labels[1].SetCond(s);\r
+ labels[2].SetLevel(s);\r
+ labels[3].SetExpToNext(s);\r
+ }\r
labels[4].SetName(s);\r
labels[5].Text = fn[s.Fleet + 1];\r
}\r
+ for (var i = _currentList.Length; i < _labelPanelList.Count; i++)\r
+ {\r
+ _labelPanelList[i].Visible = false;\r
+ _checkBoxPanelList[i].Visible = false;\r
+ }\r
+ panelShipList.ResumeLayout();\r
+ }\r
+\r
+ private bool InGroupConfig()\r
+ {\r
+ return comboBoxGroup.Text == "設定";\r
}\r
\r
private void labelHP_SizeChanged(object sender, EventArgs e)\r
\r
private void ShipListForm_Load(object sender, EventArgs e)\r
{\r
- panelShipList.Width = (int)Math.Round(PanelWidth * ShipLabel.ScaleFactor.Width) + SystemInformation.VerticalScrollBarWidth;\r
+ panelShipList.Width = (int)Math.Round(PanelWidth * ShipLabel.ScaleFactor.Width) + 3 +\r
+ SystemInformation.VerticalScrollBarWidth;\r
Width = panelShipList.Width + 12 + (Width - ClientSize.Width);\r
MinimumSize = new Size(Width, 0);\r
MaximumSize = new Size(Width, int.MaxValue);\r
var config = _config.ShipList;\r
checkBoxShipType.Checked = config.ShipType;\r
ActiveControl = panelShipList;\r
+ for (var i = 0; i < GroupCount; i++)\r
+ _groupSettings[i] = new HashSet<int>(config.ShipGroup[i]);\r
+ comboBoxGroup.SelectedIndex = 0;\r
if (config.Location.X == int.MinValue)\r
return;\r
var bounds = new Rectangle(config.Location, config.Size);\r
private void ShipListForm_FormClosing(object sender, FormClosingEventArgs e)\r
{\r
var config = _config.ShipList;\r
- var bounds = WindowState == FormWindowState.Normal ? Bounds : RestoreBounds;\r
+ var all = _sniffer.ShipList.Select(s => s.Id).ToArray();\r
+ for (var i = 0; i < GroupCount; i++)\r
+ {\r
+ if (_groupSettings[i] == null)\r
+ break;\r
+ if (all.Count() > 0)\r
+ _groupSettings[i].IntersectWith(all);\r
+ config.ShipGroup[i] = _groupSettings[i].ToList(); \r
+ }\r
e.Cancel = true;\r
if (!Visible)\r
return;\r
+ var bounds = WindowState == FormWindowState.Normal ? Bounds : RestoreBounds;\r
config.Location = bounds.Location;\r
config.Size = bounds.Size;\r
Hide();\r
UpdateList();\r
ActiveControl = panelShipList;\r
}\r
+\r
+ private void checkboxGroup_CheckedChanged(object sender, EventArgs e)\r
+ {\r
+ var cb = (CheckBox)sender;\r
+ var group = (int)cb.Tag % 10;\r
+ var idx = (int)cb.Tag / 10;\r
+ if (cb.Checked)\r
+ _groupSettings[group].Add(_currentList[idx].Id);\r
+ else\r
+ _groupSettings[group].Remove(_currentList[idx].Id);\r
+ }\r
+\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
+ ActiveControl = panelShipList;\r
+ }\r
}\r
}
\ No newline at end of file