2 using System.Drawing;
\r
3 using System.Windows.Forms;
\r
4 using KancolleSniffer.Model;
\r
5 using KancolleSniffer.Properties;
\r
7 namespace KancolleSniffer.View
\r
9 public class HqPanel : PanelWithToolTip, IUpdateable
\r
11 public Label Login { get; } = new Label
\r
13 Location = new Point(6, 2),
\r
14 Size = new Size(210, 28),
\r
15 Font = new Font("MS UI Gothic", 9.75f),
\r
16 TextAlign = ContentAlignment.MiddleLeft,
\r
17 Text = "艦これにログインしてください。\r\nログイン中ならログインし直してください。"
\r
20 public Label PlayLog { get; } = new Label
\r
22 Location = new Point(207, 3),
\r
28 private readonly Label _bucketHistoryButton = new Label
\r
30 Location = new Point(146, 15),
\r
31 Size = new Size(14, 14),
\r
32 BorderStyle = BorderStyle.FixedSingle,
\r
33 Image = Resources.arrow_virtical
\r
36 private readonly Label _achievement = new Label
\r
38 Location = new Point(166, 18),
\r
39 Size = new Size(33, 12),
\r
40 TextAlign = ContentAlignment.MiddleRight
\r
43 private readonly Label _numOfBuckets = new Label
\r
45 Location = new Point(116, 18),
\r
46 Size = new Size(30, 12),
\r
48 TextAlign = ContentAlignment.MiddleRight
\r
51 private readonly Label _numOfEquips = new Label
\r
53 Location = new Point(46, 18),
\r
54 Size = new Size(60, 12),
\r
56 TextAlign = ContentAlignment.MiddleRight
\r
59 private readonly Label _numOfShips = new Label
\r
61 Location = new Point(0, 18),
\r
62 Size = new Size(48, 12),
\r
64 TextAlign = ContentAlignment.MiddleRight
\r
67 private readonly Label _bucketHistory = new Label
\r
69 BorderStyle = BorderStyle.FixedSingle,
\r
70 Name = "labelBucketHistory",
\r
71 Size = new Size(61, 28),
\r
73 TextAlign = ContentAlignment.MiddleRight,
\r
77 private readonly Control[] _captions =
\r
81 Location = new Point(170, 3),
\r
87 Location = new Point(113, 3),
\r
93 Location = new Point(65, 3),
\r
99 Location = new Point(7, 3),
\r
105 public UpdateContext Context { private get; set; }
\r
109 BorderStyle = BorderStyle.FixedSingle;
\r
110 Controls.AddRange(new Control[]
\r
111 {Login, PlayLog, _bucketHistoryButton, _achievement, _numOfBuckets, _numOfEquips, _numOfShips});
\r
112 Controls.AddRange(_captions);
\r
113 _bucketHistoryButton.Click += BucketHistoryButtonClick;
\r
114 _numOfBuckets.Click += BucketHistoryButtonClick;
\r
115 _bucketHistory.Click += BucketHistoryButtonClick;
\r
118 protected override void OnParentChanged(EventArgs e)
\r
120 base.OnParentChanged(e);
\r
121 _bucketHistory.Location =
\r
122 new Point(Location.X + Parent.Location.X + 100, Location.Y + Parent.Location.Y + 30);
\r
123 Parent.Controls.Add(_bucketHistory);
\r
126 public new void Update()
\r
128 UpdateNumOfShips();
\r
129 UpdateNumOfEquips();
\r
130 Context.Submitter.Flash();
\r
131 UpdateNumOfBuckets();
\r
132 UpdateBucketHistory();
\r
133 UpdateAchievement();
\r
136 public void UpdateTimers()
\r
140 private void UpdateNumOfBuckets()
\r
142 _numOfBuckets.Text = Context.Sniffer.Material.MaterialHistory[(int)Material.Bucket].Now.ToString("D");
\r
145 private void UpdateAchievement()
\r
147 var ac = Context.Sniffer.Achievement.Value;
\r
150 _achievement.Text = ac >= 1000 ? ((int)ac).ToString("D") : ac.ToString("F1");
\r
151 ToolTip.SetToolTip(_achievement,
\r
152 "今月 " + Context.Sniffer.Achievement.ValueOfMonth.ToString("F1") + "\n" +
\r
153 "EO " + Context.Sniffer.ExMap.Achievement);
\r
156 private void UpdateNumOfShips()
\r
158 var ship = Context.Sniffer.ShipCounter;
\r
159 _numOfShips.Text = $"{ship.Now:D}/{ship.Max:D}";
\r
160 _numOfShips.ForeColor = ship.TooMany ? CUDColors.Red : Color.Black;
\r
163 var message = $"残り{ship.Rest:D}隻";
\r
164 Context.Submitter.Enqueue("艦娘数超過", message);
\r
165 ship.Alarm = false;
\r
169 private void UpdateNumOfEquips()
\r
171 var item = Context.Sniffer.ItemCounter;
\r
172 _numOfEquips.Text = $"{item.Now:D}/{item.Max:D}";
\r
173 _numOfEquips.ForeColor = item.TooMany ? CUDColors.Red : Color.Black;
\r
176 var message = $"残り{item.Rest:D}個";
\r
177 Context.Submitter.Enqueue("装備数超過", message);
\r
178 item.Alarm = false;
\r
182 private void UpdateBucketHistory()
\r
184 var count = Context.Sniffer.Material.MaterialHistory[(int)Material.Bucket];
\r
185 var day = CutOverflow(count.Now - count.BegOfDay, 999);
\r
186 var week = CutOverflow(count.Now - count.BegOfWeek, 999);
\r
187 _bucketHistory.Text = $"{day:+#;-#;±0} 今日\n{week:+#;-#;±0} 今週";
\r
190 private void BucketHistoryButtonClick(object sender, EventArgs e)
\r
192 if (_bucketHistory.Visible)
\r
194 _bucketHistory.Visible = false;
\r
195 _bucketHistoryButton.BackColor = DefaultBackColor;
\r
199 _bucketHistory.Visible = true;
\r
200 _bucketHistory.BringToFront();
\r
201 _bucketHistoryButton.BackColor = CustomColors.ActiveButtonColor;
\r
205 private static int CutOverflow(int value, int limit)
\r
209 if (value < -limit)
\r