From f005e6c43866d5cefeeead66e559b460f6fc0cea Mon Sep 17 00:00:00 2001 From: Kazuhiro Fujieda Date: Sun, 29 Mar 2020 21:04:38 +0900 Subject: [PATCH] =?utf8?q?=E5=BB=BA=E9=80=A0=E6=AC=84=E3=82=92KDockPanel?= =?utf8?q?=E3=81=AB=E5=88=86=E9=9B=A2=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- KancolleSniffer/KancolleSniffer.csproj | 3 + KancolleSniffer/MainForm.Designer.cs | 119 ++++----------------------------- KancolleSniffer/MainForm.cs | 8 +-- KancolleSniffer/View/KDockPanel.cs | 77 +++++++++++++++++++++ 4 files changed, 93 insertions(+), 114 deletions(-) create mode 100644 KancolleSniffer/View/KDockPanel.cs diff --git a/KancolleSniffer/KancolleSniffer.csproj b/KancolleSniffer/KancolleSniffer.csproj index 6d60fc0..b47448d 100644 --- a/KancolleSniffer/KancolleSniffer.csproj +++ b/KancolleSniffer/KancolleSniffer.csproj @@ -127,6 +127,9 @@ + + Component + Component diff --git a/KancolleSniffer/MainForm.Designer.cs b/KancolleSniffer/MainForm.Designer.cs index e111f01..2e26588 100644 --- a/KancolleSniffer/MainForm.Designer.cs +++ b/KancolleSniffer/MainForm.Designer.cs @@ -82,15 +82,6 @@ namespace KancolleSniffer this.label35 = new System.Windows.Forms.Label(); this.labelFuelHistory = new System.Windows.Forms.Label(); this.labelNDock = new System.Windows.Forms.Label(); - this.panel1 = new System.Windows.Forms.Panel(); - this.labelConstruct3 = new System.Windows.Forms.Label(); - this.label12 = new System.Windows.Forms.Label(); - this.labelConstruct4 = new System.Windows.Forms.Label(); - this.label11 = new System.Windows.Forms.Label(); - this.labelConstruct2 = new System.Windows.Forms.Label(); - this.label10 = new System.Windows.Forms.Label(); - this.labelConstruct1 = new System.Windows.Forms.Label(); - this.label9 = new System.Windows.Forms.Label(); this.labelConstruct = new System.Windows.Forms.Label(); this.labelQuest = new System.Windows.Forms.Label(); this.labelMission = new System.Windows.Forms.Label(); @@ -135,11 +126,11 @@ namespace KancolleSniffer this.ndockPanel = new KancolleSniffer.View.NDockPanel(); this.missionPanel = new KancolleSniffer.View.MissionPanel(); this.questPanel = new KancolleSniffer.View.QuestPanel(); + this.kdockPanel = new KancolleSniffer.View.KDockPanel(); this.panelHeadquarters.SuspendLayout(); this.panelShipInfo.SuspendLayout(); this.panelBattleInfo.SuspendLayout(); this.panelMaterialHistory.SuspendLayout(); - this.panel1.SuspendLayout(); this.contextMenuStripNotifyIcon.SuspendLayout(); this.contextMenuStripMain.SuspendLayout(); this.SuspendLayout(); @@ -497,91 +488,6 @@ namespace KancolleSniffer this.labelNDock.Text = "入渠"; this.labelNDock.Click += new System.EventHandler(this.labelNDock_Click); // - // panel1 - // - this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panel1.Controls.Add(this.labelConstruct3); - this.panel1.Controls.Add(this.label12); - this.panel1.Controls.Add(this.labelConstruct4); - this.panel1.Controls.Add(this.label11); - this.panel1.Controls.Add(this.labelConstruct2); - this.panel1.Controls.Add(this.label10); - this.panel1.Controls.Add(this.labelConstruct1); - this.panel1.Controls.Add(this.label9); - this.panel1.Location = new System.Drawing.Point(149, 209); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(77, 64); - this.panel1.TabIndex = 7; - // - // labelConstruct3 - // - this.labelConstruct3.BackColor = System.Drawing.Color.Transparent; - this.labelConstruct3.Location = new System.Drawing.Point(28, 33); - this.labelConstruct3.Name = "labelConstruct3"; - this.labelConstruct3.Size = new System.Drawing.Size(47, 12); - this.labelConstruct3.TabIndex = 6; - this.labelConstruct3.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // label12 - // - this.label12.AutoSize = true; - this.label12.Location = new System.Drawing.Point(2, 48); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(29, 12); - this.label12.TabIndex = 3; - this.label12.Text = "第四"; - // - // labelConstruct4 - // - this.labelConstruct4.Location = new System.Drawing.Point(28, 48); - this.labelConstruct4.Name = "labelConstruct4"; - this.labelConstruct4.Size = new System.Drawing.Size(47, 12); - this.labelConstruct4.TabIndex = 7; - this.labelConstruct4.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // label11 - // - this.label11.AutoSize = true; - this.label11.Location = new System.Drawing.Point(2, 33); - this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(29, 12); - this.label11.TabIndex = 2; - this.label11.Text = "第三"; - // - // labelConstruct2 - // - this.labelConstruct2.Location = new System.Drawing.Point(28, 18); - this.labelConstruct2.Name = "labelConstruct2"; - this.labelConstruct2.Size = new System.Drawing.Size(47, 12); - this.labelConstruct2.TabIndex = 5; - this.labelConstruct2.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // label10 - // - this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(2, 18); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(29, 12); - this.label10.TabIndex = 1; - this.label10.Text = "第二"; - // - // labelConstruct1 - // - this.labelConstruct1.Location = new System.Drawing.Point(28, 3); - this.labelConstruct1.Name = "labelConstruct1"; - this.labelConstruct1.Size = new System.Drawing.Size(47, 12); - this.labelConstruct1.TabIndex = 4; - this.labelConstruct1.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // label9 - // - this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(2, 3); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(29, 12); - this.label9.TabIndex = 0; - this.label9.Text = "第一"; - // // labelConstruct // this.labelConstruct.AutoSize = true; @@ -968,6 +874,7 @@ namespace KancolleSniffer // // missionPanel // + this.missionPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.missionPanel.Location = new System.Drawing.Point(6, 290); this.missionPanel.Name = "missionPanel"; this.missionPanel.Size = new System.Drawing.Size(220, 49); @@ -981,12 +888,21 @@ namespace KancolleSniffer this.questPanel.Size = new System.Drawing.Size(220, 94); this.questPanel.TabIndex = 56; // + // kdockPanel + // + this.kdockPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.kdockPanel.Location = new System.Drawing.Point(149, 209); + this.kdockPanel.Name = "kdockPanel"; + this.kdockPanel.Size = new System.Drawing.Size(77, 64); + this.kdockPanel.TabIndex = 60; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(232, 456); this.ContextMenuStrip = this.contextMenuStripMain; + this.Controls.Add(this.kdockPanel); this.Controls.Add(this.panelRepairList); this.Controls.Add(this.ndockPanel); this.Controls.Add(this.missionPanel); @@ -1018,7 +934,6 @@ namespace KancolleSniffer this.Controls.Add(this.labelCheckFleet1); this.Controls.Add(this.labelMission); this.Controls.Add(this.labelQuest); - this.Controls.Add(this.panel1); this.Controls.Add(this.labelConstruct); this.Controls.Add(this.labelNDock); this.Controls.Add(this.panelShipInfo); @@ -1042,8 +957,6 @@ namespace KancolleSniffer this.panelBattleInfo.PerformLayout(); this.panelMaterialHistory.ResumeLayout(false); this.panelMaterialHistory.PerformLayout(); - this.panel1.ResumeLayout(false); - this.panel1.PerformLayout(); this.contextMenuStripNotifyIcon.ResumeLayout(false); this.contextMenuStripMain.ResumeLayout(false); this.ResumeLayout(false); @@ -1062,16 +975,7 @@ namespace KancolleSniffer private System.Windows.Forms.Label label1; private System.Windows.Forms.Panel panelShipInfo; private System.Windows.Forms.Label labelNDock; - private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Label labelConstruct; - private System.Windows.Forms.Label labelConstruct3; - private System.Windows.Forms.Label label12; - private System.Windows.Forms.Label labelConstruct4; - private System.Windows.Forms.Label label11; - private System.Windows.Forms.Label labelConstruct2; - private System.Windows.Forms.Label label10; - private System.Windows.Forms.Label labelConstruct1; - private System.Windows.Forms.Label label9; private System.Windows.Forms.Label labelQuest; private System.Windows.Forms.Label labelMission; private System.Windows.Forms.Timer timerMain; @@ -1142,6 +1046,7 @@ namespace KancolleSniffer private System.Windows.Forms.Label labelQuestCount; private MissionPanel missionPanel; private NDockPanel ndockPanel; + private KDockPanel kdockPanel; } } diff --git a/KancolleSniffer/MainForm.cs b/KancolleSniffer/MainForm.cs index 72f0dd7..817bdbf 100644 --- a/KancolleSniffer/MainForm.cs +++ b/KancolleSniffer/MainForm.cs @@ -942,13 +942,7 @@ namespace KancolleSniffer { missionPanel.UpdateTimers(Sniffer, _now, (Config.ShowEndTime & TimerKind.Mission) != 0); ndockPanel.UpdateTimers(Sniffer, _now, (Config.ShowEndTime & TimerKind.NDock) != 0); - var kdock = new[] {labelConstruct1, labelConstruct2, labelConstruct3, labelConstruct4}; - for (var i = 0; i < kdock.Length; i++) - { - var timer = Sniffer.KDock[i]; - SetTimerColor(kdock[i], timer, _now); - kdock[i].Text = timer.ToString(_now); - } + kdockPanel.UpdateTimers(Sniffer, _now); UpdateCondTimers(); UpdateAkashiTimer(); _timerEnabled = true; diff --git a/KancolleSniffer/View/KDockPanel.cs b/KancolleSniffer/View/KDockPanel.cs new file mode 100644 index 0000000..bf23d96 --- /dev/null +++ b/KancolleSniffer/View/KDockPanel.cs @@ -0,0 +1,77 @@ +// Copyright (C) 2020 Kazuhiro Fujieda +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Drawing; +using System.Linq; +using System.Windows.Forms; +using KancolleSniffer.Model; + +namespace KancolleSniffer.View +{ + public class KDockPanel : Panel + { + private const int TopMargin = 3; + private const int LeftMargin = 2; + private const int LabelHeight = 12; + private const int LineHeight = 15; + private readonly KDockLabels[] _labels = new KDockLabels[DockInfo.DockCount]; + + private class KDockLabels + { + public Label Number { get; set; } + public Label Timer { get; set; } + } + + public KDockPanel() + { + BorderStyle = BorderStyle.FixedSingle; + for (var i = 0; i < _labels.Length; i++) + { + var y = TopMargin + i * LineHeight; + _labels[i] = new KDockLabels + { + Number = new Label + { + Location = new Point(LeftMargin, y), + AutoSize = true, + Text = "第" + new[] {"一", "二", "三", "四"}[i] + }, + Timer = new Label + { + Location = new Point(LeftMargin + 26, y), + Size = new Size(47, LabelHeight), + TextAlign = ContentAlignment.MiddleRight + } + }; + } + Controls.AddRange(_labels.SelectMany(l => new Control[] {l.Number, l.Timer}).ToArray()); + } + + public void UpdateTimers(Sniffer sniffer, DateTime now) + { + foreach (var entry in _labels.Zip(sniffer.KDock, + (label, kdock) => new {label = label.Timer, timer = kdock})) + { + SetTimerColor(entry.label, entry.timer, now); + entry.label.Text = entry.timer.ToString(now); + } + } + + private void SetTimerColor(Label label, AlarmTimer timer, DateTime now) + { + label.ForeColor = timer.IsFinished(now) ? CUDColors.Red : Color.Black; + } + } +} \ No newline at end of file -- 2.11.0