From: Kazuhiro Fujieda Date: Sun, 5 Apr 2020 08:12:53 +0000 (+0900) Subject: IUpdatableをIUpdateContextとIUpdateTimerに分離する X-Git-Tag: v12.0~64 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c7ebe46dd5769c36eacad57420aac0c0ce2847df;hp=94cc78d80b9ee6ac1d10ab51cc3d85d0d1406756;p=kancollesniffer%2FKancolleSniffer.git IUpdatableをIUpdateContextとIUpdateTimerに分離する --- diff --git a/KancolleSniffer/MainForm.cs b/KancolleSniffer/MainForm.cs index 12930c3..c9962a9 100644 --- a/KancolleSniffer/MainForm.cs +++ b/KancolleSniffer/MainForm.cs @@ -57,7 +57,8 @@ namespace KancolleSniffer private string _debugLogFile; private IEnumerator _playLog; private DateTime _prev, _now; - private IEnumerable _updatables; + private IEnumerable _updateable; + private IEnumerable _timers; private readonly ErrorDialog _errorDialog = new ErrorDialog(); private readonly ErrorLog _errorLog; @@ -104,10 +105,11 @@ namespace KancolleSniffer private void SetupUpdateable() { - _updatables = new IUpdateable[] {hqPanel, missionPanel, kdockPanel, ndockPanel, materialHistoryPanel}; + _updateable = new IUpdateContext[] {hqPanel, missionPanel, kdockPanel, ndockPanel, materialHistoryPanel}; var context = new UpdateContext(Sniffer, Config, new NotifySubmitter(_notificationManager), () => _now); - foreach (var updateable in _updatables) + foreach (var updateable in _updateable) updateable.Context = context; + _timers = new IUpdateTimers[] {missionPanel, kdockPanel, ndockPanel}; } private void SetScaleFactorOfDpiScaling() @@ -938,8 +940,8 @@ namespace KancolleSniffer private void UpdateTimers() { - foreach (var updateable in _updatables) - updateable.UpdateTimers(); + foreach (var timer in _timers) + timer.UpdateTimers(); UpdateCondTimers(); UpdateAkashiTimer(); _timerEnabled = true; diff --git a/KancolleSniffer/View/HqPanel.cs b/KancolleSniffer/View/HqPanel.cs index 1e14e65..1cb9448 100644 --- a/KancolleSniffer/View/HqPanel.cs +++ b/KancolleSniffer/View/HqPanel.cs @@ -6,7 +6,7 @@ using KancolleSniffer.Properties; namespace KancolleSniffer.View { - public class HqPanel : PanelWithToolTip, IUpdateable + public class HqPanel : PanelWithToolTip, IUpdateContext { public Label Login { get; } = new Label { @@ -133,10 +133,6 @@ namespace KancolleSniffer.View UpdateAchievement(); } - public void UpdateTimers() - { - } - private void UpdateNumOfBuckets() { _numOfBuckets.Text = Context.Sniffer.Material.MaterialHistory[(int)Material.Bucket].Now.ToString("D"); diff --git a/KancolleSniffer/View/IUpdateable.cs b/KancolleSniffer/View/IUpdateable.cs index 632ec2d..2af3e19 100644 --- a/KancolleSniffer/View/IUpdateable.cs +++ b/KancolleSniffer/View/IUpdateable.cs @@ -1,8 +1,12 @@ namespace KancolleSniffer.View { - public interface IUpdateable + public interface IUpdateContext { UpdateContext Context { set; } + } + + public interface IUpdateTimers : IUpdateContext + { void UpdateTimers(); } } \ No newline at end of file diff --git a/KancolleSniffer/View/KDockPanel.cs b/KancolleSniffer/View/KDockPanel.cs index f71054e..8841315 100644 --- a/KancolleSniffer/View/KDockPanel.cs +++ b/KancolleSniffer/View/KDockPanel.cs @@ -20,7 +20,7 @@ using KancolleSniffer.Model; namespace KancolleSniffer.View { - public class KDockPanel : Panel, IUpdateable + public class KDockPanel : Panel, IUpdateTimers { private const int TopMargin = 3; private const int LeftMargin = 2; diff --git a/KancolleSniffer/View/MaterialHistoryPanel.cs b/KancolleSniffer/View/MaterialHistoryPanel.cs index 772f3a0..70b6299 100644 --- a/KancolleSniffer/View/MaterialHistoryPanel.cs +++ b/KancolleSniffer/View/MaterialHistoryPanel.cs @@ -4,7 +4,7 @@ using System.Windows.Forms; namespace KancolleSniffer.View { - public class MaterialHistoryPanel : Panel, IUpdateable + public class MaterialHistoryPanel : Panel, IUpdateContext { private readonly Label _bauxite = new Label { diff --git a/KancolleSniffer/View/MissionPanel.cs b/KancolleSniffer/View/MissionPanel.cs index d41ff07..7869e62 100644 --- a/KancolleSniffer/View/MissionPanel.cs +++ b/KancolleSniffer/View/MissionPanel.cs @@ -20,7 +20,7 @@ using KancolleSniffer.Model; namespace KancolleSniffer.View { - public class MissionPanel : PanelWithToolTip, IUpdateable + public class MissionPanel : PanelWithToolTip, IUpdateTimers { private const int TopMargin = 3; private const int LeftMargin = 2; diff --git a/KancolleSniffer/View/NDockPanel.cs b/KancolleSniffer/View/NDockPanel.cs index 1ef3446..9e4732c 100644 --- a/KancolleSniffer/View/NDockPanel.cs +++ b/KancolleSniffer/View/NDockPanel.cs @@ -20,7 +20,7 @@ using KancolleSniffer.Model; namespace KancolleSniffer.View { - public class NDockPanel : Panel, IUpdateable + public class NDockPanel : Panel, IUpdateTimers { private const int TopMargin = 3; private const int LeftMargin = 2;