using System; namespace WarframeClock { public interface IOverlayItemViewModel { void Refresh(); } public class PlainsTimeOverlayItemViewModel : BindableBase, IOverlayItemViewModel { public string Remaining { get; private set; } public double EEDelay { get; private set; } public void Refresh() { var currentTime = DateTimeOffset.UtcNow; const double bountiesLen = 8998.8748, plainsNightLen = bountiesLen * 1 / 3; string FormatPlainsText(DateTimeOffset cetusEnd) { var plainsDayEnd = cetusEnd.AddSeconds(-plainsNightLen); string sign; TimeSpan time; if (currentTime < plainsDayEnd) { sign = "☀"; time = plainsDayEnd.Subtract(currentTime); } else { sign = "🌙"; time = cetusEnd.Subtract(currentTime); } if (time.TotalHours >= 1) return $"{sign} {time:h'h'mm'm'ss's'}"; else return $"{sign} {time:mm'm'ss's'}"; } var wsReset = App.AppData.NextBountiesResetByWorldState; wsReset = wsReset.AddSeconds( (Math.Floor(currentTime.Subtract(wsReset).TotalSeconds / bountiesLen) + 1) * bountiesLen); var eeDelay = 0.0; if (App.AppData.NextBountiesReset > currentTime) { var eeReset = App.AppData.NextBountiesReset.Value; eeDelay = eeReset.Subtract(wsReset).TotalSeconds; if (eeDelay > bountiesLen / 2) eeDelay -= bountiesLen; else if (eeDelay < -bountiesLen / 2) eeDelay += bountiesLen; } var remaining = FormatPlainsText(wsReset); if (Remaining != remaining) { Remaining = remaining; NotifyPropertyChanged(nameof(Remaining)); } if (EEDelay != eeDelay) { EEDelay = eeDelay; NotifyPropertyChanged(nameof(EEDelay)); } } } public class ArbitrationOverlayItemViewModel : BindableBase, IOverlayItemViewModel { public WfcdWorldStateData.SolNode SolNode { get; private set; } public void Refresh() { WfcdWorldStateData.SolNode solNode = null; if (Settings.ShowArbitration) { var now = DateTimeOffset.UtcNow; var hourlyMissionNextUpdate = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, 0, 0, TimeSpan.Zero).AddHours(1); if (hourlyMissionNextUpdate - App.AppData.ArbitrationSolNodeUpdated <= TimeSpan.FromHours(1)) solNode = App.AppData.ArbitrationSolNode; } if (SolNode != solNode) { SolNode = solNode; NotifyPropertyChanged(nameof(SolNode)); } } } public class KuvaFloodOverlayItemViewModel : BindableBase, IOverlayItemViewModel { public WfcdWorldStateData.SolNode SolNode { get; private set; } public void Refresh() { WfcdWorldStateData.SolNode solNode = null; if (Settings.ShowKuvaFlood) { var now = DateTimeOffset.UtcNow; var hourlyMissionNextUpdate = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, 0, 0, TimeSpan.Zero).AddHours(1); if (hourlyMissionNextUpdate - App.AppData.KuvaFloodSolNodeUpdated <= TimeSpan.FromHours(1)) solNode = App.AppData.KuvaFloodSolNode; } if (SolNode != solNode) { SolNode = solNode; NotifyPropertyChanged(nameof(SolNode)); } } } }