1 // Copyright (C) 2020 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.Collections.Generic;
\r
17 using System.Drawing;
\r
19 using System.Windows.Forms;
\r
21 namespace KancolleSniffer.Forms
\r
23 public class ListFormGroup
\r
25 private readonly MainWindow _mainWindow;
\r
26 private readonly List<ListForm> _listForms = new List<ListForm>();
\r
28 public ListForm Main => _listForms[0];
\r
30 public ListFormGroup(MainWindow main)
\r
33 _listForms.Add(new ListForm(main, true));
\r
34 while (main.Config.ListFormGroup.Count > 0)
\r
35 _listForms.Add(new ListForm(main) {Owner = Main});
\r
38 public void ShowOrCreate()
\r
40 var listForm = _listForms.FirstOrDefault(f => f.WindowState == FormWindowState.Minimized || !f.Visible);
\r
41 if (listForm == null)
\r
43 listForm = new ListForm(_mainWindow) { Owner = Main, TopMost = Main.TopMost, Font = Main.Font };
\r
44 _listForms.Add(listForm);
\r
47 if (listForm.WindowState == FormWindowState.Minimized)
\r
48 listForm.WindowState = FormWindowState.Normal;
\r
51 public void UpdateList()
\r
53 InvokeAll(listForm => listForm.UpdateList());
\r
56 public void UpdateAirBattleResult()
\r
58 InvokeAll(listForm => listForm.UpdateAirBattleResult());
\r
61 public void UpdateBattleResult()
\r
63 InvokeAll(listForm => listForm.UpdateBattleResult());
\r
66 public void UpdateCellInfo()
\r
68 InvokeAll(listForm => listForm.UpdateCellInfo());
\r
73 set { InvokeAll(listFrom => { listFrom.TopMost = value; }); }
\r
78 get => _listForms[0].Font;
\r
79 set { InvokeAll(listForm => { listForm.Font = value; }); }
\r
82 public void ShowShip(int id)
\r
84 InvokeAll(listForm => listForm.ShowShip(id));
\r
89 InvokeAll(listForm => listForm.Show());
\r
94 InvokeAll(listForm => listForm.SaveConfig());
\r
95 InvokeAll(listForm => listForm.Close());
\r
98 private void InvokeAll(Action<ListForm> action)
\r
100 foreach (var listForm in _listForms)
\r