public virtual void Handle( TimestampEditUi ui) { var r = this.runner; r.Run <UiReaderWriter>( uiRW => { var currentTime = DateTime.Now; r.Run <TimeProvider>(provider => { currentTime = provider.Now(); }); uiRW.WriteSync( ui, () => { ui.EditedTimestamp = currentTime; }); r.Run <SaveKeyTappedHandler>(handler => { handler.Handle(ui); }); }); }
public TimestampEditPresenter( TimestampEditUi ui, ShellUi shell, MethodRunner runner) : base(ui, shell) { this.ui = ui; this.runner = runner; }
public SetupTimestampEditCommand( TimestampEditUi ui, ShellUi shell, MethodWeb web) { this.ui = ui; this.shell = shell; 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; }); }); }
public virtual void Handle( TimestampEditUi ui) { var r = this.runner; r?.Run <GlobalSettingsHolder, UiReaderWriter>( (settings, uiRW) => { var format = settings.EditTimestampFormat; uiRW.Write( ui, () => { ui.TimestampFormat = format; }); }); }
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( TimestampEditUi ui) { var r = this.runner; var accepted = true; r?.Run <UiReaderWriter, GlobalSettingsHolder, Messenger>( (uiRW, settings, m) => { if (settings.Prompt) { var response = uiRW.Read( m.Subscriber, () => m.Question(@"Save edit?")); accepted = response == Response.Yes; } }); if (!accepted) { return; } r?.Run < TimestampReader, UiReaderWriter>( (reader, uiRW) => { var newTimestamp = uiRW.Read( ui, () => ui.EditedTimestamp); var allColl = reader.ReadAll(); var allLL = allColl as XLinkedList <DateTime> ?? XLinkedList <DateTime> .Create(allColl); const byte two = 2; if (allLL.Count < two) { goto checkNow; } var previousTimestamp = allLL .TailN ?.Previous ?.O; if (newTimestamp < previousTimestamp) { r.Run <Messenger>(m => { uiRW.Write( m.Subscriber, () => { m.GiveError( ErrorMessages.TooEarly); }); }); return; } checkNow: var now = DateTime.Now; r.Run <TimeProvider>(provider => { now = provider.Now(); }); if (newTimestamp > now) { r.Run <Messenger>(m => { uiRW.Write( m.Subscriber, () => { m.GiveError( ErrorMessages.TooLate); }); }); return; } r.Run <DataWatcher, TimestampWriter>( (watcher, writer) => { watcher.Stop(); writer.EditLastTimestamp(newTimestamp); watcher.Start(); }); r.Run <HomeUi, Framework.Home.TimerHandler>( (homeUi, handler) => { handler.Handle( homeUi); }); r.Run <UiReader, Framework.Statistics.TimerHandler>( (uiReader, handler) => { uiReader.ReadStatistics( out var statsUi); handler.Handle( statsUi); }); r.Run <SettingsHolder, NavLogicReader>( (settings, navReader) => { switch (settings.LastVisitedKeyLabel) { case NavKeyLabels.Timestamps: navReader.ReadTimestamps( out var navToTimestamps); navToTimestamps?.Invoke(); break; case NavKeyLabels.Statistics: navReader.ReadStatistics( out var navToStats); navToStats?.Invoke(); break; case NavKeyLabels.Daily: navReader.ReadDaily( out var navToDaily); navToDaily?.Invoke(); break; case NavKeyLabels.Config: navReader.ReadConfig( out var navToConfig); navToConfig?.Invoke(); break; default: navReader.ReadTimestamps( out var defaultNav); defaultNav?.Invoke(); break; } }); }); }