<DependentUpon>NotificationConfigDialog.cs</DependentUpon>\r
</Compile>\r
<Compile Include="PresetDeck.cs" />\r
+ <Compile Include="RepairListForMain.cs">\r
+ <SubType>Component</SubType>\r
+ </Compile>\r
<Compile Include="ShipLabels.cs" />\r
<Compile Include="ListForm.cs">\r
<SubType>Form</SubType>\r
this.labelBucketHistory = new System.Windows.Forms.Label();\r
this.label36 = new System.Windows.Forms.Label();\r
this.labelMaterialHistoryButton = new System.Windows.Forms.Label();\r
- this.panelRepairList = new System.Windows.Forms.Panel();\r
this.labelRepairListButton = new System.Windows.Forms.Label();\r
this.label31 = new System.Windows.Forms.Label();\r
this.imageListFuelSq = new System.Windows.Forms.ImageList(this.components);\r
this.labelAkashiRepair = new System.Windows.Forms.Label();\r
this.toolTipFighterPower = new System.Windows.Forms.ToolTip(this.components);\r
this.toolTipLoS = new System.Windows.Forms.ToolTip(this.components);\r
+ this.panelRepairList = new KancolleSniffer.RepairListForMain();\r
this.panelHeadquarters.SuspendLayout();\r
this.panelShipInfo.SuspendLayout();\r
this.panelBattleInfo.SuspendLayout();\r
this.labelMaterialHistoryButton.TabIndex = 10;\r
this.labelMaterialHistoryButton.Click += new System.EventHandler(this.labelMaterialHistoryButton_Click);\r
// \r
- // panelRepairList\r
- // \r
- this.panelRepairList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r
- this.panelRepairList.Location = new System.Drawing.Point(6, 207);\r
- this.panelRepairList.Name = "panelRepairList";\r
- this.panelRepairList.Size = new System.Drawing.Size(129, 19);\r
- this.panelRepairList.TabIndex = 44;\r
- this.panelRepairList.Visible = false;\r
- this.panelRepairList.Click += new System.EventHandler(this.panelRepairList_Click);\r
- // \r
// labelRepairListButton\r
// \r
this.labelRepairListButton.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r
// \r
this.toolTipLoS.ShowAlways = true;\r
// \r
+ // panelRepairList\r
+ // \r
+ this.panelRepairList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r
+ this.panelRepairList.Location = new System.Drawing.Point(6, 207);\r
+ this.panelRepairList.Name = "panelRepairList";\r
+ this.panelRepairList.Size = new System.Drawing.Size(129, 21);\r
+ this.panelRepairList.TabIndex = 4;\r
+ this.panelRepairList.Visible = false;\r
+ this.panelRepairList.Click += new System.EventHandler(this.panelRepairList_Click);\r
+ // \r
// MainForm\r
// \r
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);\r
private System.Windows.Forms.Label labelFuelHistory;\r
private System.Windows.Forms.Label label36;\r
private System.Windows.Forms.Label labelMaterialHistoryButton;\r
- private System.Windows.Forms.Panel panelRepairList;\r
private System.Windows.Forms.Label labelRepairListButton;\r
private System.Windows.Forms.Label label31;\r
private System.Windows.Forms.ContextMenuStrip contextMenuStripNotifyIcon;\r
private System.Windows.Forms.Label labelPresetAkashiTimer;\r
private System.Windows.Forms.ToolTip toolTipFighterPower;\r
private System.Windows.Forms.ToolTip toolTipLoS;\r
+ private RepairListForMain panelRepairList;\r
}\r
}\r
\r
_shipLabels.CreateAkashiTimers(panelShipInfo);\r
_shipLabels.CreateShipLabels(panelShipInfo, ShowShipOnShipList);\r
_shipLabels.CreateCombinedShipLabels(panelCombinedFleet, ShowShipOnShipList);\r
- _shipLabels.CreateRepairList(panelRepairList, panelRepairList_Click);\r
_shipLabels.CreateNDockLabels(panelDock, labelNDock_Click);\r
+ panelRepairList.CreateLabels(panelRepairList_Click);\r
labelPresetAkashiTimer.BackColor = ShipLabels.ColumnColors[1];\r
_listForm = new ListForm(_sniffer, _config) {Owner = this};\r
_noticeQueue = new NoticeQueue(Ring);\r
\r
private void UpdateRepairList()\r
{\r
- _shipLabels.SetRepairList(_sniffer.RepairList);\r
+ panelRepairList.SetRepairList(_sniffer.RepairList);\r
}\r
\r
private void UpdateQuestList()\r
--- /dev/null
+// Copyright (C) 2017 Kazuhiro Fujieda <fujieda@users.osdn.me>\r
+// \r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+\r
+using System;\r
+using System.Drawing;\r
+using System.Linq;\r
+using System.Windows.Forms;\r
+using static System.Math;\r
+\r
+namespace KancolleSniffer\r
+{\r
+ public class RepairListForMain : Panel\r
+ {\r
+ private const int PanelPadding = 5;\r
+ private const int LabelPadding = 2;\r
+ private const int LineHeight = 16;\r
+ private readonly ShipLabel[][] _repairLabels = new ShipLabel[14][];\r
+ private ShipStatus[] _repairList;\r
+ private int _repairListPosition;\r
+\r
+ public void CreateLabels(EventHandler onClick)\r
+ {\r
+ SuspendLayout();\r
+ for (var i = 0; i < _repairLabels.Length; i++)\r
+ {\r
+ var y = PanelPadding + LabelPadding + i * LineHeight;\r
+ const int height = 12;\r
+ Controls.AddRange(_repairLabels[i] = new[]\r
+ {\r
+ new ShipLabel {Location = new Point(0, y), Size = new Size(11, height)},\r
+ new ShipLabel {Location = new Point(119, y), Size = new Size(5, height - 1)},\r
+ new ShipLabel {Location = new Point(75, y), AutoSize = true},\r
+ new ShipLabel {Location = new Point(9, y), AutoSize = true},\r
+ new ShipLabel {Location = new Point(0, y - LabelPadding), Size = new Size(Width, height + LabelPadding + 1)}\r
+ });\r
+ foreach (var label in _repairLabels[i])\r
+ {\r
+ label.Scale();\r
+ label.PresetColor = label.BackColor = ShipLabels.ColumnColors[(i + 1) % 2];\r
+ label.Click += onClick;\r
+ }\r
+ }\r
+ foreach (var label in _repairLabels[0])\r
+ {\r
+ label.MouseEnter += TopRepairLabelsOnMouseEnter;\r
+ label.MouseLeave += TopRepairLabelsOnMouseLeave;\r
+ }\r
+ _topScrollRepeatTimer.Tick += TopRepairLabelsOnMouseEnter;\r
+ foreach (var label in _repairLabels.Last())\r
+ {\r
+ label.MouseEnter += BottomRepairLabelsOnMouseEnter;\r
+ label.MouseLeave += BottomRepairLabelsOnMouseLeave;\r
+ }\r
+ _bottomScrollRepeatTimer.Tick += BottomRepairLabelsOnMouseEnter;\r
+ ResumeLayout();\r
+ }\r
+\r
+ private readonly Timer _topScrollRepeatTimer = new Timer {Interval = 100};\r
+ private readonly Timer _bottomScrollRepeatTimer = new Timer {Interval = 100};\r
+\r
+ private void TopRepairLabelsOnMouseEnter(object sender, EventArgs e)\r
+ {\r
+ if (_repairListPosition == 0)\r
+ return;\r
+ _repairListPosition--;\r
+ ShowRepairList();\r
+ _topScrollRepeatTimer.Start();\r
+ }\r
+\r
+ private void TopRepairLabelsOnMouseLeave(object sender, EventArgs e)\r
+ {\r
+ _topScrollRepeatTimer.Stop();\r
+ }\r
+\r
+ private void BottomRepairLabelsOnMouseEnter(object sender, EventArgs e)\r
+ {\r
+ if (_repairListPosition + _repairLabels.Length >= _repairList.Length)\r
+ return;\r
+ _repairListPosition++;\r
+ ShowRepairList();\r
+ _bottomScrollRepeatTimer.Start();\r
+ }\r
+\r
+ private void BottomRepairLabelsOnMouseLeave(object sender, EventArgs e)\r
+ {\r
+ _bottomScrollRepeatTimer.Stop();\r
+ }\r
+\r
+ public void SetRepairList(ShipStatus[] list)\r
+ {\r
+ const int fleet = 0, name = 3, time = 2, damage = 1;\r
+ _repairList = list;\r
+ if (list.Length == 0)\r
+ {\r
+ Size = new Size(Width, (int)Round(ShipLabel.ScaleFactor.Height * (LineHeight + PanelPadding * 2)));\r
+ var labels = _repairLabels[0];\r
+ labels[fleet].Text = "";\r
+ labels[name].SetName("なし");\r
+ labels[time].Text = "";\r
+ labels[damage].BackColor = labels[damage].PresetColor;\r
+ return;\r
+ }\r
+ Size = new Size(Width,\r
+ (int)Round(ShipLabel.ScaleFactor.Height *\r
+ (Min(_repairList.Length, _repairLabels.Length) * LineHeight + PanelPadding * 2)));\r
+ _repairListPosition = Min(_repairListPosition, Max(0, _repairList.Length - _repairLabels.Length));\r
+ ShowRepairList();\r
+ }\r
+\r
+ public void ShowRepairList()\r
+ {\r
+ const int fleet = 0, name = 3, time = 2, damage = 1;\r
+ for (var i = 0; i < Min(_repairList.Length, _repairLabels.Length); i++)\r
+ {\r
+ var s = _repairList[i + _repairListPosition];\r
+ var labels = _repairLabels[i];\r
+ labels[fleet].SetFleet(s);\r
+ labels[name].SetName(s, ShipNameWidth.RepairList);\r
+ labels[time].SetRepairTime(s);\r
+ labels[damage].BackColor = ShipLabel.DamageColor(s, labels[damage].PresetColor);\r
+ }\r
+ DrawMark();\r
+ }\r
+\r
+ private void DrawMark()\r
+ {\r
+ using (var g = CreateGraphics())\r
+ {\r
+ var topBrush = _repairListPosition > 0 ? Brushes.Black : new SolidBrush(BackColor);\r
+ g.FillPolygon(topBrush,\r
+ new[]\r
+ {\r
+ new PointF(Width * 0.45f, PanelPadding), new PointF(Width * 0.55f, PanelPadding),\r
+ new PointF(Width * 0.5f, 0), new PointF(Width * 0.45f, PanelPadding)\r
+ });\r
+ var bottomBrush = _repairLabels.Length + _repairListPosition < _repairList.Length\r
+ ? Brushes.Black\r
+ : new SolidBrush(BackColor);\r
+ g.FillPolygon(bottomBrush,\r
+ new[]\r
+ {\r
+ new PointF(Width * 0.45f, Height - PanelPadding - 2), new PointF(Width * 0.55f, Height - PanelPadding - 2),\r
+ new PointF(Width * 0.5f, Height - 2), new PointF(Width * 0.45f, Height - PanelPadding - 2)\r
+ });\r
+\r
+ }\r
+ }\r
+\r
+ protected override void OnPaint(PaintEventArgs e)\r
+ {\r
+ base.OnPaint(e);\r
+ DrawMark();\r
+ }\r
+ }\r
+}
\ No newline at end of file
// limitations under the License.\r
\r
using System;\r
+using System.ComponentModel;\r
using System.Drawing;\r
using System.Linq;\r
using System.Text.RegularExpressions;\r
private readonly ShipLabel[][] _labels = new ShipLabel[ShipInfo.MemberCount][];\r
private readonly ShipLabel[][] _combinedLabels = new ShipLabel[ShipInfo.MemberCount * 2][];\r
private readonly ShipLabel[] _akashiTimers = new ShipLabel[ShipInfo.MemberCount];\r
- private readonly ShipLabel[][] _repairList = new ShipLabel[16][];\r
- private Control _panelRepairList;\r
private readonly ShipLabel[][] _ndockLabels = new ShipLabel[DockInfo.DockCount][];\r
public static Color[] ColumnColors = {SystemColors.Control, Color.FromArgb(255, 250, 250, 250)};\r
\r
}\r
}\r
\r
- public void CreateRepairList(Control parent, EventHandler onClick)\r
- {\r
- parent.SuspendLayout();\r
- for (var i = 0; i < _repairList.Length; i++)\r
- {\r
- var y = 3 + i * 16;\r
- const int height = 12;\r
- parent.Controls.AddRange(_repairList[i] = new[]\r
- {\r
- new ShipLabel {Location = new Point(0, y), Size = new Size(11, height)},\r
- new ShipLabel {Location = new Point(119, y), Size = new Size(5, height - 1)},\r
- new ShipLabel {Location = new Point(75, y), AutoSize = true},\r
- new ShipLabel {Location = new Point(9, y), AutoSize = true},\r
- new ShipLabel {Location = new Point(0, y - 2), Size = new Size(parent.Width, height + 3)}\r
- });\r
- foreach (var label in _repairList[i])\r
- {\r
- label.Scale();\r
- label.PresetColor = label.BackColor = ColumnColors[(i + 1) % 2];\r
- label.Click += onClick;\r
- }\r
- }\r
- _panelRepairList = parent;\r
- parent.ResumeLayout();\r
- }\r
-\r
- public void SetRepairList(ShipStatus[] list)\r
- {\r
- const int fleet = 0, name = 3, time = 2, damage = 1;\r
- var parent = _panelRepairList;\r
- var num = Min(list.Length, _repairList.Length);\r
- if (num == 0)\r
- {\r
- parent.Size = new Size(parent.Width, (int)Round(ShipLabel.ScaleFactor.Height * 19));\r
- var labels = _repairList[0];\r
- labels[fleet].Text = "";\r
- labels[name].SetName("なし");\r
- labels[time].Text = "";\r
- labels[damage].BackColor = labels[damage].PresetColor;\r
- return;\r
- }\r
- parent.Size = new Size(parent.Width, (int)Round(ShipLabel.ScaleFactor.Height * (num * 16 + 3)));\r
- for (var i = 0; i < num; i++)\r
- {\r
- var s = list[i];\r
- var labels = _repairList[i];\r
- labels[fleet].SetFleet(s);\r
- labels[name].SetName(s, ShipNameWidth.RepairList);\r
- labels[time].SetRepairTime(s);\r
- labels[damage].BackColor = ShipLabel.DamageColor(s, labels[damage].PresetColor);\r
- }\r
- }\r
-\r
public void CreateNDockLabels(Control parent, EventHandler onClick)\r
{\r
for (var i = 0; i < _ndockLabels.Length; i++)\r
}\r
}\r
\r
- [System.ComponentModel.DesignerCategory("Code")]\r
+ [DesignerCategory("Code")]\r
public class ShipLabel : Label\r
{\r
public static SizeF ScaleFactor { get; set; }\r
? CUDColor.Yellow\r
: cond >= 30\r
? PresetColor\r
- : cond >= 20 ? CUDColor.Orange : CUDColor.Red;\r
+ : cond >= 20\r
+ ? CUDColor.Orange\r
+ : CUDColor.Red;\r
}\r
\r
public void SetLevel(ShipStatus status)\r