public HomeNavPresenter( HomeNavUi ui, ShellUi shell, MethodRunner runner) : base(ui, shell) { this.ui = ui; this.runner = runner; }
public SetupHomeNavCommand( HomeNavUi ui, ShellUi shell, NavLogicReader navReader, MethodWeb web) { this.ui = ui; this.shell = shell; this.navReader = navReader; this.web = web; }
public virtual void Handle( TimestampEditUi ui, HomeNavUi hnUi, HomeUi homeUi) { var r = this.runner; r?.Run <UiReaderWriter>(uiRW => { r.Run <TimestampReader>(reader => { var allColl = reader.ReadAll(); var ll = allColl as XLinkedList <DateTime> ?? XLinkedList <DateTime> .Create(allColl); const byte one = 1; if (ll.Count < one) { return; } var lastTimestamp = ll .Tail; uiRW.Write( ui, () => { ui.EditedTimestamp = lastTimestamp; }); }); r.Run <SettingsHolder>(settings => { settings.LastVisitedKeyLabel = uiRW.Read( hnUi, () => hnUi.ActiveKeyLabel); uiRW.Write( hnUi, () => { hnUi.ActiveKeyLabel = null; }); }); uiRW.Write( homeUi, () => { homeUi.Editing = true; }); }); }
void UiReader.ReadHomeNav( out HomeNavUi ui) { var nav = this.runner?.Run <Navigator>(); if (nav == null) { ui = null; return; } ui = nav.GetUi <HomeNavPresenter, HomeNavUi>(); }
public virtual void Handle( TimestampsUi ui, HomeNavUi homeNavUi, StatisticsUi statsUi) { var r = this.runner; r?.Run <StartHandler>(handler => { handler.Handle( ui, homeNavUi, statsUi); }); }
public virtual void Handle( TimestampsUi ui, HomeNavUi homeNavUi, StatisticsUi statsUi) { var r = this.runner; r?.Run <SettingsHolder>(settings => { settings.ShowCurrent = true; }); r?.Run <StartHandler>(handler => { handler.Handle( ui, homeNavUi, statsUi); }); }
public virtual void Handle( TimestampsUi ui, HomeNavUi homeNavUi, StatisticsUi statsUi, bool shouldShow) { var r = this.runner; r?.Run <SettingsHolder>(settings => { settings.ShowDurations = shouldShow; }); r?.Run <StartHandler>(handler => { handler.Handle( ui, homeNavUi, statsUi); }); }
public virtual void Handle( StatisticsUi ui, HomeNavUi hnUi) { var r = this.runner; r?.Run <UiReaderWriter>(uiRW => { uiRW.Write( hnUi, () => { hnUi.ActiveKeyLabel = NavKeyLabels.Statistics; }); }); r?.Run <TimerHandler>(handler => { handler.Handle( ui); }); r?.Run <xofz.Framework.Timer, GlobalSettingsHolder>( (t, settings) => { var interval = settings.TimerIntervalSeconds; if (interval < 1) { interval = 1; } t.Start(interval * 1000); }, DependencyNames.Timer); }
protected virtual void onBootstrap() { var s = this.mainShell; if (s == null) { return; } var m = this.newMessenger?.Invoke(); if (m != null) { m.Subscriber = s; } var e = this.executor; e?.Execute(new SetupMethodWebCommand( new MethodWebV2(), m, this.newConfigSaver, this.newSettingsProvider)); var w = e?.Get <SetupMethodWebCommand>()?.W; w?.Run <EventSubscriber>(sub => { var cd = AppDomain.CurrentDomain; UnhandledExceptionEventHandler handler = this.handleException; sub.Subscribe( cd, nameof(cd.UnhandledException), handler); }); w?.RegisterDependency(s); HomeUi homeUi = null; HomeNavUi homeNavUi = null; StatisticsUi statsUi = null; TimestampsUi timestampsUi = null; TimestampEditUi editUi = null; DailyUi dailyUi = null; ConfigUi configUi = null; LicenseUi licenseUi = null; w?.Run <UiReaderWriter, Lotter>( (uiRW, lotter) => { uiRW.WriteSync( s, () => { homeUi = this.newHomeUi?.Invoke(); homeNavUi = this.newHomeNavUi?.Invoke(lotter); statsUi = this.newStatsUi?.Invoke(); timestampsUi = this.newTimestampsUi?.Invoke(lotter); editUi = this.newEditUi?.Invoke(); dailyUi = this.newDailyUi?.Invoke(lotter); configUi = this.newConfigUi?.Invoke(); licenseUi = this.newLicenseUi?.Invoke(s); }); }); var homeFinished = new ManualResetEvent(false); var homeNavFinished = new ManualResetEvent(false); var statsFinished = new ManualResetEvent(false); var editFinished = new ManualResetEvent(false); var timestampsFinished = new ManualResetEvent(false); var dailyFinished = new ManualResetEvent(false); var mainFinished = new ManualResetEvent(false); var shutdownFinished = new ManualResetEvent(false); var licenseFinished = new ManualResetEvent(false); var configFinished = new ManualResetEvent(false); w?.Run <Do <Do> >(invoker => { invoker.Invoke( () => { e?.Execute( new SetupHomeCommand( homeUi, s, this.newReaderWriter, this.newDataWatcher, w)); homeFinished.Set(); }); invoker.Invoke( () => { e?.Execute( new SetupHomeNavCommand( homeNavUi, s.NavUi, new NavigatorNavLogicReader(w), w)); homeNavFinished.Set(); }); invoker.Invoke( () => { e?.Execute( new SetupStatisticsCommand( statsUi, homeUi, w)); statsFinished.Set(); }); invoker.Invoke( () => { e?.Execute( new SetupTimestampEditCommand( editUi, homeUi, w)); editFinished.Set(); }); invoker.Invoke( () => { e?.Execute( new SetupMainCommand( s, w, new SettingsHolder())); mainFinished.Set(); }); invoker.Invoke( () => { e?.Execute( new SetupShutdownCommand( w)); shutdownFinished.Set(); }); invoker.Invoke( () => { e?.Execute( new SetupLicenseCommand( licenseUi, w)); licenseFinished.Set(); }); homeFinished.WaitOne(); invoker.Invoke( () => { e?.Execute( new SetupTimestampsCommand( timestampsUi, homeUi, w)); timestampsFinished.Set(); }); invoker.Invoke( () => { e?.Execute( new SetupDailyCommand( dailyUi, homeUi, new NavigatorUiReader(w), w)); dailyFinished.Set(); }); }); // update to single-file format w?.Run <FileTimestampManager>(manager => { manager.ConvertToSingleFile(); }); w?.Run <DataWatcher>(watcher => { watcher.Start(); }); w?.Run <Navigator>( nav => { nav.Present <HomePresenter>(); w.Run <Do <Do> >(invoker => { homeNavFinished.WaitOne(); }); nav.PresentFluidly <HomeNavPresenter>(); w.Run <Do <Do> >(invoker => { timestampsFinished.WaitOne(); }); nav.PresentFluidly <TimestampsPresenter>(); }); w?.Run <Do <Do> >(invoker => { dailyFinished.WaitOne(); invoker.Invoke(() => { e?.Execute( new SetupConfigCommand( configUi, homeUi, w)); configFinished.Set(); }); statsFinished.WaitOne(); editFinished.WaitOne(); mainFinished.WaitOne(); shutdownFinished.WaitOne(); licenseFinished.WaitOne(); configFinished.WaitOne(); }); }
public virtual void Handle( TimestampsUi ui, HomeNavUi homeNavUi, StatisticsUi statsUi) { var r = this.runner; const byte one = 1; r?.Run <UiReaderWriter>(uiRW => { uiRW.Write( homeNavUi, () => { homeNavUi.ActiveKeyLabel = NavKeyLabels.Timestamps; }); }); var showCurrent = true; r?.Run <SettingsHolder>(settings => { showCurrent = settings.ShowCurrent; }); var now = DateTime.Now; var start = DateTime.Today; r?.Run <TimeProvider>(provider => { now = provider.Now(); start = now.Date; }); var end = start.AddDays(one); if (showCurrent) { r?.Run <DateCalculator>( calc => { start = calc.StartOfWeek(); end = calc.EndOfWeek().AddDays(one); }); goto findAndSetTimesInRange; } r?.Run <UiReaderWriter>(uiRW => { start = uiRW.Read( statsUi, () => statsUi.StartDate); end = uiRW.Read( statsUi, () => statsUi.EndDate) .AddDays(1); }); findAndSetTimesInRange: r?.Run < TimestampReader, Lotter, EnumerableSplitter, UiReaderWriter>( (reader, lotter, splitter, uiRW) => { var allTimes = reader.ReadAll(); var timesInRange = new XLinkedList <DateTime>(); foreach (var time in allTimes) { if (time < start) { continue; } if (time > end) { continue; } timesInRange.AddTail(time); } bool firstIn, lastIn; if (timesInRange.Count < one) { firstIn = false; lastIn = false; goto checkAdd; } firstIn = this.isInTime( timesInRange.Head); lastIn = this.isInTime( timesInRange.Tail); checkAdd: var inNow = allTimes.Count % two == one; var oddTimesInRange = timesInRange.Count % two == one; if (oddTimesInRange) { if (inNow && firstIn) { if (now > end.AddDays(one)) { // was clocked in at end of range timesInRange.AddTail(end); } // clocked in currently, do nothing goto afterCheckClockedIn; } if (firstIn) { // clocked in at end of week timesInRange.AddTail(end.Date); goto afterCheckClockedIn; } // clocked out now but was clocked in at start of week timesInRange.AddHead(start.Date); goto afterCheckClockedIn; } if (timesInRange.Count > zero) { if (!firstIn) { timesInRange.AddHead(start.Date); } if (lastIn && end < now) { timesInRange.AddTail(end.Date); } } afterCheckClockedIn: var splitTimesThisWeek = splitter.Split( timesInRange, two); var inTimes = splitTimesThisWeek[zero]; var uiTimesIn = lotter.Materialize( EnumerableHelpers.Select( inTimes, this.formatTimestamp)); uiRW.Write( ui, () => { ui.InTimes = uiTimesIn; }); var outTimes = splitTimesThisWeek[one]; var uiTimesOut = lotter.Materialize( EnumerableHelpers.Select( outTimes, this.formatTimestamp)); uiRW.Write( ui, () => { ui.OutTimes = uiTimesOut; }); r.Run <EnumerableSplicer>( splicer => { var splicedTimes = splicer.Splice( new[] { inTimes, outTimes }); short indexer = zero; DateTime currentInTime = default,