OSDN Git Service

ColumnColorsの抽象度を上げる
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Fri, 17 May 2019 11:21:48 +0000 (20:21 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Fri, 17 May 2019 12:00:30 +0000 (21:00 +0900)
KancolleSniffer/MainForm.cs
KancolleSniffer/View/AntiAirPanel.cs
KancolleSniffer/View/BattleResultPanel.cs
KancolleSniffer/View/CustomColors.cs
KancolleSniffer/View/FleetPanel.cs
KancolleSniffer/View/MainFormLabels.cs
KancolleSniffer/View/RepairListForMain.cs
KancolleSniffer/View/ShipLabel.cs
KancolleSniffer/View/ShipListPanel/GroupConfigLabels.cs
KancolleSniffer/View/ShipListPanel/RepairListLabels.cs
KancolleSniffer/View/ShipListPanel/ShipListLabels.cs

index 805f09c..421c3fd 100644 (file)
@@ -84,7 +84,7 @@ namespace KancolleSniffer
             SetupFleetClick();\r
             CreateMainLabels();\r
             CreateNumberAndHistory(manager);\r
-            labelPresetAkashiTimer.BackColor = ShipLabel.ColumnColors[1];\r
+            labelPresetAkashiTimer.BackColor = CustomColors.ColumnColors.Bright;\r
             SetupQuestPanel();\r
             panelRepairList.CreateLabels(panelRepairList_Click);\r
             PerformZoom();\r
index 4a7f2ac..b2e860e 100644 (file)
@@ -94,7 +94,7 @@ namespace KancolleSniffer.View
             {\r
                 Location = new Point(0, y),\r
                 Size = new Size(ListForm.PanelWidth, LineHeight),\r
-                BackColor = ShipLabel.ColumnColors[(i + 1) % 2],\r
+                BackColor = CustomColors.ColumnColors.BrightFirst(i),\r
                 Visible = false\r
             };\r
             Scaler.Scale(lbp);\r
@@ -114,7 +114,7 @@ namespace KancolleSniffer.View
             foreach (var label in labels)\r
             {\r
                 Scaler.Scale(label);\r
-                label.BackColor = ShipLabel.ColumnColors[(i + 1) % 2];\r
+                label.BackColor = CustomColors.ColumnColors.BrightFirst(i);\r
             }\r
         }\r
 \r
index 47531b1..3ad38fb 100644 (file)
@@ -336,7 +336,7 @@ namespace KancolleSniffer.View
                 {\r
                     Location = new Point(0, y),\r
                     Size = new Size(0, LineHeight),\r
-                    BackColor = ShipLabel.ColumnColors[i % 2],\r
+                    BackColor = CustomColors.ColumnColors.DarkFirst(i),\r
                     Visible = false,\r
                     Tag = y\r
                 };\r
@@ -373,7 +373,7 @@ namespace KancolleSniffer.View
                 foreach (var label in friend.Concat(enemy))\r
                 {\r
                     panel.Controls.Add(label);\r
-                    label.BackColor = ShipLabel.ColumnColors[i % 2];\r
+                    label.BackColor = CustomColors.ColumnColors.DarkFirst(i);\r
                 }\r
                 Controls.Add(panel);\r
             }\r
@@ -440,7 +440,7 @@ namespace KancolleSniffer.View
                     }\r
                 });\r
                 // ReSharper disable once VirtualMemberCallInConstructor\r
-                BackColor = ShipLabel.ColumnColors[1];\r
+                BackColor = CustomColors.ColumnColors.Bright;\r
             }\r
 \r
             public void SetInformation(BattleInfo battleInfo)\r
index f6370f1..46ceac5 100644 (file)
@@ -1,9 +1,33 @@
-using System.Drawing;\r
+// Copyright (C) 2019 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.Drawing;\r
 \r
 namespace KancolleSniffer.View\r
 {\r
     public static class CustomColors\r
     {\r
         public static Color ActiveButtonColor = Color.FromArgb(152, 179, 208);\r
+\r
+        public class ColumnColors\r
+        {\r
+            public static readonly Color Bright = Color.White;\r
+            private static readonly Color Dark = SystemColors.Control;\r
+            private static readonly Color[] Colors = {Bright, Dark};\r
+\r
+            public static Color BrightFirst(int i) => Colors[i % 2];\r
+            public static Color DarkFirst(int i) => Colors[(i + 1) % 2];\r
+        }\r
     }\r
 }
\ No newline at end of file
index 55fafd3..062f32b 100644 (file)
@@ -300,7 +300,7 @@ namespace KancolleSniffer.View
             {\r
                 Location = new Point(0, y),\r
                 Size = new Size(ListForm.PanelWidth, LineHeight),\r
-                BackColor = ShipLabel.ColumnColors[(i + 1) % 2],\r
+                BackColor = CustomColors.ColumnColors.BrightFirst(i),\r
                 Visible = false\r
             };\r
             Scaler.Scale(lbp);\r
@@ -320,7 +320,7 @@ namespace KancolleSniffer.View
             foreach (var label in labels)\r
             {\r
                 Scaler.Scale(label);\r
-                label.BackColor = ShipLabel.ColumnColors[(i + 1) % 2];\r
+                label.BackColor = CustomColors.ColumnColors.BrightFirst(i);\r
             }\r
         }\r
 \r
index ca7c8a1..03c21e2 100644 (file)
@@ -105,7 +105,7 @@ namespace KancolleSniffer.View
             foreach (var label in headings)\r
             {\r
                 Scaler.Scale(label);\r
-                label.BackColor = ShipLabel.ColumnColors[1];\r
+                label.BackColor = CustomColors.ColumnColors.Bright;\r
             }\r
             for (var i = 0; i < shipLabels.Length; i++)\r
             {\r
@@ -145,7 +145,7 @@ namespace KancolleSniffer.View
                 foreach (var label in shipLabels[i])\r
                 {\r
                     Scaler.Scale(label);\r
-                    label.BackColor = ShipLabel.ColumnColors[i % 2];\r
+                    label.BackColor = CustomColors.ColumnColors.DarkFirst(i);\r
                     label.Tag = i;\r
                     label.Click += onClick;\r
                 }\r
@@ -206,7 +206,7 @@ namespace KancolleSniffer.View
             foreach (var label in headings)\r
             {\r
                 Scaler.Scale(label);\r
-                label.BackColor = ShipLabel.ColumnColors[1];\r
+                label.BackColor = CustomColors.ColumnColors.Bright;\r
             }\r
             for (var i = 0; i < _combinedLabels.Length; i++)\r
             {\r
@@ -235,7 +235,7 @@ namespace KancolleSniffer.View
                 foreach (var label in _combinedLabels[i])\r
                 {\r
                     Scaler.Scale(label);\r
-                    label.BackColor = ShipLabel.ColumnColors[i % 2];\r
+                    label.BackColor = CustomColors.ColumnColors.DarkFirst(i);\r
                     label.Tag = i;\r
                     label.Click += onClick;\r
                 }\r
@@ -289,7 +289,7 @@ namespace KancolleSniffer.View
                             Size = new Size(31, 12),\r
                             TextAlign = ContentAlignment.TopRight\r
                         });\r
-                label.BackColor = ShipLabel.ColumnColors[i % 2];\r
+                label.BackColor = CustomColors.ColumnColors.DarkFirst(i);\r
             }\r
             foreach (var label in timerLabels)\r
                 Scaler.Scale(label);\r
index 8c50e6d..c93557a 100644 (file)
@@ -65,7 +65,7 @@ namespace KancolleSniffer.View
                 foreach (var label in _repairLabels[i].Labels)\r
                 {\r
                     Scaler.Scale(label);\r
-                    label.BackColor = ShipLabel.ColumnColors[(i + 1) % 2];\r
+                    label.BackColor = CustomColors.ColumnColors.BrightFirst(i);\r
                     label.Click += onClick;\r
                 }\r
             }\r
@@ -137,7 +137,7 @@ namespace KancolleSniffer.View
             labels.Fleet.Text = "";\r
             labels.Name.SetName("");\r
             labels.Time.Text = "";\r
-            labels.Damage.BackColor = ShipLabel.ColumnColors[(i + 1) % 2];\r
+            labels.Damage.BackColor = CustomColors.ColumnColors.BrightFirst(i);\r
         }\r
     }\r
 }
\ No newline at end of file
index b9a0f2a..66e561e 100644 (file)
@@ -26,7 +26,6 @@ namespace KancolleSniffer.View
     [DesignerCategory("Code")]\r
     public class ShipLabel : Label\r
     {\r
-        public static Color[] ColumnColors = {SystemColors.Control, Color.White};\r
         public static Font LatinFont { get; set; } = new Font("Tahoma", 8f);\r
         public bool AnchorRight { get; set; }\r
         private Color _initialBackColor;\r
index b502f12..96eadfc 100644 (file)
@@ -46,7 +46,7 @@ namespace KancolleSniffer.View.ShipListPanel
             {\r
                 Location = new Point(0, y),\r
                 Size = new Size(ListForm.PanelWidth, ShipListPanel.LineHeight),\r
-                BackColor = ShipLabel.ColumnColors[(i + 1) % 2]\r
+                BackColor = CustomColors.ColumnColors.BrightFirst(i)\r
             };\r
             Scaler.Scale(panel);\r
             panel.Tag = panel.Location.Y;\r
@@ -85,7 +85,7 @@ namespace KancolleSniffer.View.ShipListPanel
             foreach (var label in labels)\r
             {\r
                 Scaler.Scale(label);\r
-                label.BackColor = ShipLabel.ColumnColors[(i + 1) % 2];\r
+                label.BackColor = CustomColors.ColumnColors.BrightFirst(i);\r
             }\r
         }\r
 \r
index 53a6d67..092bca3 100644 (file)
@@ -37,7 +37,7 @@ namespace KancolleSniffer.View.ShipListPanel
             {\r
                 Location = new Point(0, y),\r
                 Size = new Size(ListForm.PanelWidth, ShipListPanel.LineHeight),\r
-                BackColor = ShipLabel.ColumnColors[(i + 1) % 2]\r
+                BackColor = CustomColors.ColumnColors.BrightFirst(i)\r
             };\r
             Scaler.Scale(panel);\r
             panel.Tag = panel.Location.Y;\r
@@ -72,7 +72,7 @@ namespace KancolleSniffer.View.ShipListPanel
             foreach (var label in labels)\r
             {\r
                 Scaler.Scale(label);\r
-                label.BackColor = ShipLabel.ColumnColors[(i + 1) % 2];\r
+                label.BackColor = CustomColors.ColumnColors.BrightFirst(i);\r
             }\r
             _shipListPanel.SetHpPercent(labels[0]);\r
         }\r
index 8bf004f..ce7a4e0 100644 (file)
@@ -37,7 +37,7 @@ namespace KancolleSniffer.View.ShipListPanel
             {\r
                 Location = new Point(0, y),\r
                 Size = new Size(ListForm.PanelWidth, ShipListPanel.LineHeight),\r
-                BackColor = ShipLabel.ColumnColors[(i + 1) % 2]\r
+                BackColor = CustomColors.ColumnColors.BrightFirst(i)\r
             };\r
             Scaler.Scale(panel);\r
             var labels = new[]\r
@@ -81,7 +81,7 @@ namespace KancolleSniffer.View.ShipListPanel
             foreach (var label in labels)\r
             {\r
                 Scaler.Scale(label);\r
-                label.BackColor = ShipLabel.ColumnColors[(i + 1) % 2];\r
+                label.BackColor = CustomColors.ColumnColors.BrightFirst(i);\r
             }\r
             _shipListPanel.SetHpPercent(labels[0]);\r
         }\r