OSDN Git Service

建造欄をKDockPanelに分離する
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Sun, 29 Mar 2020 12:04:38 +0000 (21:04 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Sun, 30 Aug 2020 05:58:20 +0000 (14:58 +0900)
KancolleSniffer/KancolleSniffer.csproj
KancolleSniffer/MainForm.Designer.cs
KancolleSniffer/MainForm.cs
KancolleSniffer/View/KDockPanel.cs [new file with mode: 0644]

index 6d60fc0..b47448d 100644 (file)
     <Compile Include="Util\HttpUtility.cs" />\r
     <Compile Include="View\FleetSpec.cs" />\r
     <Compile Include="View\GrowLeftLabel.cs" />\r
+    <Compile Include="View\KDockPanel.cs">\r
+      <SubType>Component</SubType>\r
+    </Compile>\r
     <Compile Include="View\NDockPanel.cs">\r
       <SubType>Component</SubType>\r
     </Compile>\r
index e111f01..2e26588 100644 (file)
@@ -82,15 +82,6 @@ namespace KancolleSniffer
             this.label35 = new System.Windows.Forms.Label();\r
             this.labelFuelHistory = new System.Windows.Forms.Label();\r
             this.labelNDock = new System.Windows.Forms.Label();\r
-            this.panel1 = new System.Windows.Forms.Panel();\r
-            this.labelConstruct3 = new System.Windows.Forms.Label();\r
-            this.label12 = new System.Windows.Forms.Label();\r
-            this.labelConstruct4 = new System.Windows.Forms.Label();\r
-            this.label11 = new System.Windows.Forms.Label();\r
-            this.labelConstruct2 = new System.Windows.Forms.Label();\r
-            this.label10 = new System.Windows.Forms.Label();\r
-            this.labelConstruct1 = new System.Windows.Forms.Label();\r
-            this.label9 = new System.Windows.Forms.Label();\r
             this.labelConstruct = new System.Windows.Forms.Label();\r
             this.labelQuest = new System.Windows.Forms.Label();\r
             this.labelMission = new System.Windows.Forms.Label();\r
@@ -135,11 +126,11 @@ namespace KancolleSniffer
             this.ndockPanel = new KancolleSniffer.View.NDockPanel();\r
             this.missionPanel = new KancolleSniffer.View.MissionPanel();\r
             this.questPanel = new KancolleSniffer.View.QuestPanel();\r
+            this.kdockPanel = new KancolleSniffer.View.KDockPanel();\r
             this.panelHeadquarters.SuspendLayout();\r
             this.panelShipInfo.SuspendLayout();\r
             this.panelBattleInfo.SuspendLayout();\r
             this.panelMaterialHistory.SuspendLayout();\r
-            this.panel1.SuspendLayout();\r
             this.contextMenuStripNotifyIcon.SuspendLayout();\r
             this.contextMenuStripMain.SuspendLayout();\r
             this.SuspendLayout();\r
@@ -497,91 +488,6 @@ namespace KancolleSniffer
             this.labelNDock.Text = "入渠";\r
             this.labelNDock.Click += new System.EventHandler(this.labelNDock_Click);\r
             // \r
-            // panel1\r
-            // \r
-            this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r
-            this.panel1.Controls.Add(this.labelConstruct3);\r
-            this.panel1.Controls.Add(this.label12);\r
-            this.panel1.Controls.Add(this.labelConstruct4);\r
-            this.panel1.Controls.Add(this.label11);\r
-            this.panel1.Controls.Add(this.labelConstruct2);\r
-            this.panel1.Controls.Add(this.label10);\r
-            this.panel1.Controls.Add(this.labelConstruct1);\r
-            this.panel1.Controls.Add(this.label9);\r
-            this.panel1.Location = new System.Drawing.Point(149, 209);\r
-            this.panel1.Name = "panel1";\r
-            this.panel1.Size = new System.Drawing.Size(77, 64);\r
-            this.panel1.TabIndex = 7;\r
-            // \r
-            // labelConstruct3\r
-            // \r
-            this.labelConstruct3.BackColor = System.Drawing.Color.Transparent;\r
-            this.labelConstruct3.Location = new System.Drawing.Point(28, 33);\r
-            this.labelConstruct3.Name = "labelConstruct3";\r
-            this.labelConstruct3.Size = new System.Drawing.Size(47, 12);\r
-            this.labelConstruct3.TabIndex = 6;\r
-            this.labelConstruct3.TextAlign = System.Drawing.ContentAlignment.TopRight;\r
-            // \r
-            // label12\r
-            // \r
-            this.label12.AutoSize = true;\r
-            this.label12.Location = new System.Drawing.Point(2, 48);\r
-            this.label12.Name = "label12";\r
-            this.label12.Size = new System.Drawing.Size(29, 12);\r
-            this.label12.TabIndex = 3;\r
-            this.label12.Text = "第四";\r
-            // \r
-            // labelConstruct4\r
-            // \r
-            this.labelConstruct4.Location = new System.Drawing.Point(28, 48);\r
-            this.labelConstruct4.Name = "labelConstruct4";\r
-            this.labelConstruct4.Size = new System.Drawing.Size(47, 12);\r
-            this.labelConstruct4.TabIndex = 7;\r
-            this.labelConstruct4.TextAlign = System.Drawing.ContentAlignment.TopRight;\r
-            // \r
-            // label11\r
-            // \r
-            this.label11.AutoSize = true;\r
-            this.label11.Location = new System.Drawing.Point(2, 33);\r
-            this.label11.Name = "label11";\r
-            this.label11.Size = new System.Drawing.Size(29, 12);\r
-            this.label11.TabIndex = 2;\r
-            this.label11.Text = "第三";\r
-            // \r
-            // labelConstruct2\r
-            // \r
-            this.labelConstruct2.Location = new System.Drawing.Point(28, 18);\r
-            this.labelConstruct2.Name = "labelConstruct2";\r
-            this.labelConstruct2.Size = new System.Drawing.Size(47, 12);\r
-            this.labelConstruct2.TabIndex = 5;\r
-            this.labelConstruct2.TextAlign = System.Drawing.ContentAlignment.TopRight;\r
-            // \r
-            // label10\r
-            // \r
-            this.label10.AutoSize = true;\r
-            this.label10.Location = new System.Drawing.Point(2, 18);\r
-            this.label10.Name = "label10";\r
-            this.label10.Size = new System.Drawing.Size(29, 12);\r
-            this.label10.TabIndex = 1;\r
-            this.label10.Text = "第二";\r
-            // \r
-            // labelConstruct1\r
-            // \r
-            this.labelConstruct1.Location = new System.Drawing.Point(28, 3);\r
-            this.labelConstruct1.Name = "labelConstruct1";\r
-            this.labelConstruct1.Size = new System.Drawing.Size(47, 12);\r
-            this.labelConstruct1.TabIndex = 4;\r
-            this.labelConstruct1.TextAlign = System.Drawing.ContentAlignment.TopRight;\r
-            // \r
-            // label9\r
-            // \r
-            this.label9.AutoSize = true;\r
-            this.label9.Location = new System.Drawing.Point(2, 3);\r
-            this.label9.Name = "label9";\r
-            this.label9.Size = new System.Drawing.Size(29, 12);\r
-            this.label9.TabIndex = 0;\r
-            this.label9.Text = "第一";\r
-            // \r
             // labelConstruct\r
             // \r
             this.labelConstruct.AutoSize = true;\r
@@ -968,6 +874,7 @@ namespace KancolleSniffer
             // \r
             // missionPanel\r
             // \r
+            this.missionPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r
             this.missionPanel.Location = new System.Drawing.Point(6, 290);\r
             this.missionPanel.Name = "missionPanel";\r
             this.missionPanel.Size = new System.Drawing.Size(220, 49);\r
@@ -981,12 +888,21 @@ namespace KancolleSniffer
             this.questPanel.Size = new System.Drawing.Size(220, 94);\r
             this.questPanel.TabIndex = 56;\r
             // \r
+            // kdockPanel\r
+            // \r
+            this.kdockPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r
+            this.kdockPanel.Location = new System.Drawing.Point(149, 209);\r
+            this.kdockPanel.Name = "kdockPanel";\r
+            this.kdockPanel.Size = new System.Drawing.Size(77, 64);\r
+            this.kdockPanel.TabIndex = 60;\r
+            // \r
             // MainForm\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(232, 456);\r
             this.ContextMenuStrip = this.contextMenuStripMain;\r
+            this.Controls.Add(this.kdockPanel);\r
             this.Controls.Add(this.panelRepairList);\r
             this.Controls.Add(this.ndockPanel);\r
             this.Controls.Add(this.missionPanel);\r
@@ -1018,7 +934,6 @@ namespace KancolleSniffer
             this.Controls.Add(this.labelCheckFleet1);\r
             this.Controls.Add(this.labelMission);\r
             this.Controls.Add(this.labelQuest);\r
-            this.Controls.Add(this.panel1);\r
             this.Controls.Add(this.labelConstruct);\r
             this.Controls.Add(this.labelNDock);\r
             this.Controls.Add(this.panelShipInfo);\r
@@ -1042,8 +957,6 @@ namespace KancolleSniffer
             this.panelBattleInfo.PerformLayout();\r
             this.panelMaterialHistory.ResumeLayout(false);\r
             this.panelMaterialHistory.PerformLayout();\r
-            this.panel1.ResumeLayout(false);\r
-            this.panel1.PerformLayout();\r
             this.contextMenuStripNotifyIcon.ResumeLayout(false);\r
             this.contextMenuStripMain.ResumeLayout(false);\r
             this.ResumeLayout(false);\r
@@ -1062,16 +975,7 @@ namespace KancolleSniffer
         private System.Windows.Forms.Label label1;\r
         private System.Windows.Forms.Panel panelShipInfo;\r
         private System.Windows.Forms.Label labelNDock;\r
-        private System.Windows.Forms.Panel panel1;\r
         private System.Windows.Forms.Label labelConstruct;\r
-        private System.Windows.Forms.Label labelConstruct3;\r
-        private System.Windows.Forms.Label label12;\r
-        private System.Windows.Forms.Label labelConstruct4;\r
-        private System.Windows.Forms.Label label11;\r
-        private System.Windows.Forms.Label labelConstruct2;\r
-        private System.Windows.Forms.Label label10;\r
-        private System.Windows.Forms.Label labelConstruct1;\r
-        private System.Windows.Forms.Label label9;\r
         private System.Windows.Forms.Label labelQuest;\r
         private System.Windows.Forms.Label labelMission;\r
         private System.Windows.Forms.Timer timerMain;\r
@@ -1142,6 +1046,7 @@ namespace KancolleSniffer
         private System.Windows.Forms.Label labelQuestCount;\r
         private MissionPanel missionPanel;\r
         private NDockPanel ndockPanel;\r
+        private KDockPanel kdockPanel;\r
     }\r
 }\r
 \r
index 72f0dd7..817bdbf 100644 (file)
@@ -942,13 +942,7 @@ namespace KancolleSniffer
         {\r
             missionPanel.UpdateTimers(Sniffer, _now, (Config.ShowEndTime & TimerKind.Mission) != 0);\r
             ndockPanel.UpdateTimers(Sniffer, _now, (Config.ShowEndTime & TimerKind.NDock) != 0);\r
-            var kdock = new[] {labelConstruct1, labelConstruct2, labelConstruct3, labelConstruct4};\r
-            for (var i = 0; i < kdock.Length; i++)\r
-            {\r
-                var timer = Sniffer.KDock[i];\r
-                SetTimerColor(kdock[i], timer, _now);\r
-                kdock[i].Text = timer.ToString(_now);\r
-            }\r
+            kdockPanel.UpdateTimers(Sniffer, _now);\r
             UpdateCondTimers();\r
             UpdateAkashiTimer();\r
             _timerEnabled = true;\r
diff --git a/KancolleSniffer/View/KDockPanel.cs b/KancolleSniffer/View/KDockPanel.cs
new file mode 100644 (file)
index 0000000..bf23d96
--- /dev/null
@@ -0,0 +1,77 @@
+// Copyright (C) 2020 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 KancolleSniffer.Model;\r
+\r
+namespace KancolleSniffer.View\r
+{\r
+    public class KDockPanel : Panel\r
+    {\r
+        private const int TopMargin = 3;\r
+        private const int LeftMargin = 2;\r
+        private const int LabelHeight = 12;\r
+        private const int LineHeight = 15;\r
+        private readonly KDockLabels[] _labels = new KDockLabels[DockInfo.DockCount];\r
+\r
+        private class KDockLabels\r
+        {\r
+            public Label Number { get; set; }\r
+            public Label Timer { get; set; }\r
+        }\r
+\r
+        public KDockPanel()\r
+        {\r
+            BorderStyle = BorderStyle.FixedSingle;\r
+            for (var i = 0; i < _labels.Length; i++)\r
+            {\r
+                var y = TopMargin + i * LineHeight;\r
+                _labels[i] = new KDockLabels\r
+                {\r
+                    Number = new Label\r
+                    {\r
+                        Location = new Point(LeftMargin, y),\r
+                        AutoSize = true,\r
+                        Text = "第" + new[] {"一", "二", "三", "四"}[i]\r
+                    },\r
+                    Timer = new Label\r
+                    {\r
+                        Location = new Point(LeftMargin + 26, y),\r
+                        Size = new Size(47, LabelHeight),\r
+                        TextAlign = ContentAlignment.MiddleRight\r
+                    }\r
+                };\r
+            }\r
+            Controls.AddRange(_labels.SelectMany(l => new Control[] {l.Number, l.Timer}).ToArray());\r
+        }\r
+\r
+        public void UpdateTimers(Sniffer sniffer, DateTime now)\r
+        {\r
+            foreach (var entry in _labels.Zip(sniffer.KDock,\r
+                (label, kdock) => new {label = label.Timer, timer = kdock}))\r
+            {\r
+                SetTimerColor(entry.label, entry.timer, now);\r
+                entry.label.Text = entry.timer.ToString(now);\r
+            }\r
+        }\r
+\r
+        private void SetTimerColor(Label label, AlarmTimer timer, DateTime now)\r
+        {\r
+            label.ForeColor = timer.IsFinished(now) ? CUDColors.Red : Color.Black;\r
+        }\r
+    }\r
+}
\ No newline at end of file