<Compile Include="ConfirmDialog.Designer.cs">\r
<DependentUpon>ConfirmDialog.cs</DependentUpon>\r
</Compile>\r
+ <Compile Include="View\ControlsArranger.cs" />\r
<Compile Include="View\CUDColors.cs" />\r
<Compile Include="Model\DockInfo.cs" />\r
<Compile Include="Model\Fleet.cs" />\r
--- /dev/null
+// 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;\r
+using System.Drawing;\r
+using System.Windows.Forms;\r
+\r
+namespace KancolleSniffer.View\r
+{\r
+ public abstract class ControlsArranger\r
+ {\r
+ public abstract Control[] Controls { get; }\r
+\r
+ public void Arrange(Control parent)\r
+ {\r
+ SetParent(parent);\r
+ Scale();\r
+ }\r
+\r
+ public void Arrange(Control parent, Color color)\r
+ {\r
+ Arrange(parent);\r
+ SetBackColor(color);\r
+ }\r
+\r
+ private void SetParent(Control parent)\r
+ {\r
+ parent.Controls.AddRange(Controls);\r
+ }\r
+\r
+ private void SetBackColor(Color color)\r
+ {\r
+ foreach (var control in Controls)\r
+ control.BackColor = color;\r
+ }\r
+\r
+ private void Scale()\r
+ {\r
+ foreach (var control in Controls)\r
+ Scaler.Scale(control);\r
+ }\r
+\r
+ public void SetClickHandler(EventHandler onClick)\r
+ {\r
+ foreach (var control in Controls)\r
+ control.Click += onClick;\r
+ }\r
+ }\r
+}
\ No newline at end of file
// limitations under the License.\r
\r
using System;\r
-using System.Collections;\r
using System.Collections.Generic;\r
using System.Drawing;\r
using System.Linq;\r
CreateLabels(i);\r
}\r
\r
- private class FleetLabels : IEnumerable<ShipLabel>\r
+ private class FleetLabels : ControlsArranger\r
{\r
public ShipLabel Fleet { get; set; }\r
public ShipLabel Name { get; set; }\r
public ShipLabel EquipColor { get; set; }\r
public ShipLabel Spec { get; set; }\r
\r
- public IEnumerator<ShipLabel> GetEnumerator() =>\r
- ((IEnumerable<ShipLabel>)new[] {Fleet, Name, Equip, EquipColor, Spec}).GetEnumerator();\r
-\r
- IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();\r
+ public override Control[] Controls => new Control[] {Fleet, Name, Equip, EquipColor, Spec};\r
}\r
\r
private void CreateLabels(int i)\r
};\r
_labelList.Add(labels);\r
_panelList.Add(lbp);\r
- lbp.Controls.AddRange(labels.Cast<Control>().ToArray());\r
+ labels.Arrange(lbp, CustomColors.ColumnColors.BrightFirst(i));\r
Controls.Add(lbp);\r
- foreach (var label in labels)\r
- {\r
- Scaler.Scale(label);\r
- label.BackColor = CustomColors.ColumnColors.BrightFirst(i);\r
- }\r
}\r
\r
private void SetRecords()\r
\r
public event Action EndScroll;\r
\r
- public ListScroller(Panel panel, Label[] topLabels, Label[] bottomLabels)\r
+ public ListScroller(Panel panel, Control[] topLabels, Control[] bottomLabels)\r
{\r
_panel = panel;\r
panel.Paint += (obj, ev) => DrawMark();\r
SetBottomEventHandler(bottomLabels);\r
}\r
\r
- public void SetTopEventHandler(Label[] top)\r
+ public void SetTopEventHandler(Control[] top)\r
{\r
foreach (var label in top)\r
{\r
_topScrollRepeatTimer.Tick += (obj, e) => ScrollUp();\r
}\r
\r
- public void SetBottomEventHandler(Label[] bottom)\r
+ public void SetBottomEventHandler(Control[] bottom)\r
{\r
foreach (var label in bottom)\r
{\r
using System.Windows.Forms;\r
using KancolleSniffer.Model;\r
\r
-// ReSharper disable CoVariantArrayConversion\r
-\r
namespace KancolleSniffer.View\r
{\r
- public class QuestLabels\r
+ public class QuestLabels : ControlsArranger\r
{\r
public ShipLabel Color { get; set; }\r
public ShipLabel Name { get; set; }\r
public ShipLabel Count { get; set; }\r
public ShipLabel Progress { get; set; }\r
\r
- public ShipLabel[] Labels => new[] {Color, Count, Progress, Name};\r
+ public override Control[] Controls => new Control[] {Color, Count, Progress, Name};\r
}\r
\r
public class QuestPanel : PanelWithToolTip\r
}\r
};\r
_labels[i].Name.DoubleClick += onDoubleClick;\r
- Controls.AddRange(_labels[i].Labels);\r
- foreach (var label in _labels[i].Labels)\r
- Scaler.Scale(label);\r
+ _labels[i].Arrange(this);\r
}\r
ResumeLayout();\r
SetupListScroller();\r
\r
private void SetupListScroller()\r
{\r
- _listScroller = new ListScroller(this, _labels[0].Labels, _labels[_lines - 1].Labels)\r
+ _listScroller = new ListScroller(this, _labels[0].Controls, _labels[_lines - 1].Controls)\r
{\r
Lines = _lines,\r
Padding = TopMargin\r
{\r
private const int PanelPadding = 5;\r
private const int LineHeight = 15;\r
- private RepairListLabels[] _repairLabels;\r
+ private RepairLabels[] _repairLabels;\r
private ShipStatus[] _repairList = new ShipStatus[0];\r
private ListScroller _listScroller;\r
\r
- private class RepairListLabels\r
+ private class RepairLabels : ControlsArranger\r
{\r
public ShipLabel Fleet { get; set; }\r
public ShipLabel Name { get; set; }\r
public ShipLabel Damage { get; set; }\r
public ShipLabel BackGround { private get; set; }\r
\r
- public ShipLabel[] Labels => new[] {Fleet, Damage, Time, Name, BackGround};\r
+ public override Control[] Controls => new[] {Fleet, Damage, Time, Name, BackGround};\r
}\r
\r
public void CreateLabels(EventHandler onClick)\r
{\r
- _repairLabels = new RepairListLabels[Lines];\r
+ _repairLabels = new RepairLabels[Lines];\r
SuspendLayout();\r
for (var i = 0; i < _repairLabels.Length; i++)\r
{\r
var y = PanelPadding + 1 + i * LineHeight;\r
const int height = 12;\r
- _repairLabels[i] = new RepairListLabels\r
+ _repairLabels[i] = new RepairLabels\r
{\r
Fleet = new ShipLabel {Location = new Point(0, y), Size = new Size(11, height)},\r
Damage = new ShipLabel {Location = new Point(119, y), Size = new Size(5, height - 1)},\r
Size = new Size(Width, height + 2)\r
}\r
};\r
- Controls.AddRange(_repairLabels[i].Labels);\r
- foreach (var label in _repairLabels[i].Labels)\r
- {\r
- Scaler.Scale(label);\r
- label.BackColor = CustomColors.ColumnColors.BrightFirst(i);\r
- label.Click += onClick;\r
- }\r
+ _repairLabels[i].Arrange(this, CustomColors.ColumnColors.BrightFirst(i));\r
+ _repairLabels[i].SetClickHandler(onClick);\r
}\r
ResumeLayout();\r
SetupListScroller();\r
\r
private void SetupListScroller()\r
{\r
- _listScroller = new ListScroller(this, _repairLabels[0].Labels, _repairLabels.Last().Labels)\r
+ _listScroller = new ListScroller(this, _repairLabels[0].Controls, _repairLabels.Last().Controls)\r
{\r
Lines = _repairLabels.Length,\r
Padding = PanelPadding\r