1 // Copyright (C) 2019 Kazuhiro Fujieda <fujieda@users.osdn.me>
\r
3 // Licensed under the Apache License, Version 2.0 (the "License");
\r
4 // you may not use this file except in compliance with the License.
\r
5 // You may obtain a copy of the License at
\r
7 // http://www.apache.org/licenses/LICENSE-2.0
\r
9 // Unless required by applicable law or agreed to in writing, software
\r
10 // distributed under the License is distributed on an "AS IS" BASIS,
\r
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 // See the License for the specific language governing permissions and
\r
13 // limitations under the License.
\r
16 using System.Drawing;
\r
17 using System.Windows.Forms;
\r
19 namespace KancolleSniffer.View
\r
21 public abstract class ControlsArranger
\r
23 public abstract Control[] Controls { get; }
\r
25 public Panel BackPanel;
\r
27 public void Arrange(Control parent)
\r
33 public void Arrange(Control parent, Color color)
\r
35 if (BackPanel != null)
\r
37 ArrangeBackPanel(parent, color);
\r
41 SetBackColor(color);
\r
44 private void ArrangeBackPanel(Control parent, Color color)
\r
46 parent.Controls.Add(BackPanel);
\r
47 BackPanel.BackColor = color;
\r
48 Scaler.Scale(BackPanel);
\r
51 private void SetParent(Control parent)
\r
53 parent.Controls.AddRange(Controls);
\r
56 private void Scale()
\r
58 foreach (var control in Controls)
\r
59 Scaler.Scale(control);
\r
62 private void SetBackColor(Color color)
\r
64 foreach (var control in Controls)
\r
65 control.BackColor = color;
\r
68 public void SetClickHandler(EventHandler onClick)
\r
70 foreach (var control in Controls)
\r
71 control.Click += onClick;
\r
74 public void SetTag(int index)
\r
76 foreach (var control in Controls)
\r
77 control.Tag = index;
\r
80 public void Move(Point offset)
\r
82 if (BackPanel == null)
\r
84 var pos = BackPanel.Location;
\r
86 // 単にLocation.Offsetではだめで代入する必要がある
\r
87 BackPanel.Location = pos;
\r