1 // Copyright (C) 2016 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.ComponentModel;
\r
18 using System.Drawing;
\r
19 using System.Windows.Forms;
\r
21 // ReSharper disable CoVariantArrayConversion
\r
23 namespace KancolleSniffer
\r
25 public class AirBattleResult
\r
27 public class StageResult
\r
29 public int FriendCount { get; set; }
\r
30 public int FriendLost { get; set; }
\r
31 public int EnemyCount { get; set; }
\r
32 public int EnemyLost { get; set; }
\r
35 public class AirFireResult
\r
37 public string ShipName { get; set; }
\r
38 public int Kind { get; set; }
\r
39 public string[] Items { get; set; }
\r
42 public string PhaseName { get; set; }
\r
43 public int AirControlLevel { get; set; }
\r
44 public StageResult Stage1 { get; set; }
\r
45 public StageResult Stage2 { get; set; }
\r
46 public AirFireResult AirFire { get; set; }
\r
49 [DesignerCategory("Code")]
\r
50 public class AirBattleResultPanel : Panel
\r
52 private readonly Label _phaseName;
\r
53 private readonly Label _stage1;
\r
54 private readonly Label[][][] _resultLabels = new Label[2][][];
\r
55 private AirBattleResult[] _resultList;
\r
56 private int _resultIndex;
\r
57 private readonly ShipLabel _ciShipName;
\r
58 private readonly Label _ciKind;
\r
59 private readonly ToolTip _toolTip = new ToolTip{ShowAlways = true};
\r
61 public bool ShowResultAutomatic { get; set; }
\r
63 private bool ResultRemained
\r
65 set => _phaseName.BorderStyle = value ? BorderStyle.FixedSingle : BorderStyle.None;
\r
68 public AirBattleResultPanel()
\r
78 Location = new Point(4, 4),
\r
79 Size = new Size(49, 12),
\r
80 TextAlign = ContentAlignment.TopCenter
\r
82 _stage1 = new Label {Text = "stage1", Location = new Point(8, top), AutoSize = true},
\r
83 new Label {Text = "stage2", Location = new Point(8, top + 14), AutoSize = true},
\r
84 new Label {Text = "自軍", Location = new Point(67, 6), AutoSize = true},
\r
85 new Label {Text = "敵軍", Location = new Point(122, 6), AutoSize = true},
\r
86 new Label {Text = "CI", Location = new Point(ci, 4), AutoSize = true}
\r
88 Controls.AddRange(labels);
\r
89 const int left = 53;
\r
90 const int space = 55;
\r
91 for (var stage = 0; stage < 2; stage++)
\r
93 _resultLabels[stage] = new Label[2][];
\r
94 for (var fe = 0; fe < 2; fe++)
\r
96 _resultLabels[stage][fe] = new Label[2];
\r
97 Controls.Add(_resultLabels[stage][fe][1] = new Label
\r
99 Location = new Point(left + 34 + space * fe, top + 14 * stage),
\r
100 Size = new Size(24, 12),
\r
101 TextAlign = ContentAlignment.TopLeft
\r
103 Controls.Add(new Label
\r
105 Location = new Point(left + 21 + space * fe, top + 14 * stage),
\r
109 Controls.Add(_resultLabels[stage][fe][0] = new Label
\r
111 Location = new Point(left + space * fe, top + 14 * stage),
\r
112 Size = new Size(24, 12),
\r
113 TextAlign = ContentAlignment.TopRight
\r
117 Controls.Add(_ciShipName = new ShipLabel
\r
119 Location = new Point(ci, top),
\r
120 Size = new Size((int)ShipNameWidth.CiShipName, 12)
\r
122 Controls.Add(_ciKind = new Label
\r
124 Location = new Point(ci, top + 14),
\r
125 Size = new Size(24, 12)
\r
127 _phaseName.Click += PhaseNameOnClick;
\r
130 public void SetResult(List<AirBattleResult> resultList)
\r
132 _resultList = resultList.ToArray();
\r
133 if (_resultList.Length == 0)
\r
135 ResultRemained = false;
\r
139 _resultIndex = _resultList.Length - 1;
\r
140 if (!ShowResultAutomatic)
\r
142 ResultRemained = true;
\r
147 ResultRemained = _resultList.Length > 1;
\r
151 private void PhaseNameOnClick(object sender, EventArgs eventArgs)
\r
153 if (_resultList == null || _resultList.Length == 0)
\r
156 if (_resultList.Length == 1)
\r
157 ResultRemained = false;
\r
158 _resultIndex = (_resultIndex + 1) % _resultList.Length;
\r
161 private void ShowResult()
\r
163 if (_resultIndex >= _resultList.Length)
\r
165 var result = _resultList[_resultIndex];
\r
166 _phaseName.Text = result.PhaseName;
\r
167 var color = new[] {DefaultForeColor, CUDColor.Blue, CUDColor.Green, CUDColor.Orange, CUDColor.Red};
\r
168 _stage1.ForeColor = color[result.AirControlLevel];
\r
169 var stages = new[] {result.Stage1, result.Stage2};
\r
170 for (var i = 0; i < 2; i++)
\r
172 var stage = stages[i];
\r
173 var labels = _resultLabels[i];
\r
174 labels[0][0].Text = $"{stage.FriendCount}";
\r
175 labels[0][1].Text = $"{stage.FriendCount - stage.FriendLost}";
\r
176 labels[1][0].Text = $"{stage.EnemyCount}";
\r
177 labels[1][1].Text = $"{stage.EnemyCount - stage.EnemyLost}";
\r
179 ShowAirFireResult();
\r
182 private void ShowAirFireResult()
\r
184 var result = _resultList[_resultIndex];
\r
185 if (result.AirFire == null)
\r
187 _ciShipName.SetName(null);
\r
189 _toolTip.SetToolTip(_ciKind, "");
\r
193 _ciShipName.SetName(result.AirFire.ShipName, ShipNameWidth.CiShipName);
\r
194 _ciKind.Text = result.AirFire.Kind.ToString();
\r
195 _toolTip.SetToolTip(_ciKind, string.Join("\r\n", result.AirFire.Items));
\r
199 private void ClearResult()
\r
201 _phaseName.Text = "航空戦";
\r
202 _stage1.ForeColor = DefaultForeColor;
\r
203 for (var st = 0; st < 2; st++)
\r
205 for (var fe = 0; fe < 2; fe++)
\r
207 for (var ba = 0; ba < 2; ba++)
\r
209 _resultLabels[st][fe][ba].Text = "";
\r
213 _ciShipName.SetName(null);
\r
215 _toolTip.SetToolTip(_ciKind, "");
\r