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
15 using System.Drawing;
\r
16 using System.Windows.Forms;
\r
17 using KancolleSniffer.Model;
\r
19 namespace KancolleSniffer.View
\r
21 public class NumberAndHistoryLabels
\r
23 public Label FuelHistory { get; set; }
\r
24 public Label BulletHistory { get; set; }
\r
25 public Label SteelHistory { get; set; }
\r
26 public Label BauxiteHistory { get; set; }
\r
27 public ToolTip ToolTip { get; set; }
\r
30 public class NumberAndHistory
\r
32 private readonly NumberAndHistoryLabels _labels;
\r
33 private readonly Sniffer _sniffer;
\r
34 private readonly ToolTip _toolTip;
\r
35 private readonly MainForm.INotifySubmitter _submitter;
\r
37 public NumberAndHistory(NumberAndHistoryLabels labels, Sniffer sniffer, MainForm.INotifySubmitter submitter)
\r
41 _toolTip = labels.ToolTip;
\r
42 _submitter = submitter;
\r
45 public void Update()
\r
47 UpdateMaterialHistory();
\r
50 private void UpdateMaterialHistory()
\r
52 var labels = new[] {_labels.FuelHistory, _labels.BulletHistory, _labels.SteelHistory, _labels.BauxiteHistory };
\r
53 var text = new[] { "燃料", "弾薬", "鋼材", "ボーキ" };
\r
54 for (var i = 0; i < labels.Length; i++)
\r
56 var count = _sniffer.Material.MaterialHistory[i];
\r
57 var port = CutOverflow(count.Now - _sniffer.Material.PrevPort[i], 99999);
\r
58 var day = CutOverflow(count.Now - count.BegOfDay, 99999);
\r
59 var week = CutOverflow(count.Now - count.BegOfWeek, 99999);
\r
60 labels[i].Text = $"{text[i]}\n{port:+#;-#;±0}\n{day:+#;-#;±0}\n{week:+#;-#;±0}";
\r
64 private int CutOverflow(int value, int limit)
\r