From ce8d680958fd4acbded63f646132abb90e655073 Mon Sep 17 00:00:00 2001 From: clown Date: Sun, 19 Jul 2020 15:08:09 +0900 Subject: [PATCH] Remove Sync method. --- .../Presenters/Insert/InsertViewModel.cs | 16 +++++----- .../Presenters/Main/MainViewModelBase.cs | 14 ++++----- .../Presenters/Main/RibbonViewModel.cs | 29 ++++++++++--------- .../Main/Sources/Presenters/ViewModelBase.cs | 11 ------- 4 files changed, 30 insertions(+), 40 deletions(-) diff --git a/Applications/Editor/Main/Sources/Presenters/Insert/InsertViewModel.cs b/Applications/Editor/Main/Sources/Presenters/Insert/InsertViewModel.cs index ed3a2b270..a22e16ea9 100644 --- a/Applications/Editor/Main/Sources/Presenters/Insert/InsertViewModel.cs +++ b/Applications/Editor/Main/Sources/Presenters/Insert/InsertViewModel.cs @@ -120,7 +120,7 @@ SynchronizationContext context public IElement Preview => Get(() => new BindableElement( () => Properties.Resources.MenuPreview, GetInvoker(false) - ) { Command = IsSelected(() => Track(() => Facade.Preview())) }); + ) { Command = IsSelected(() => Track(Facade.Preview)) }); /* ----------------------------------------------------------------- */ /// @@ -138,7 +138,7 @@ SynchronizationContext context public IElement Add => Get(() => new BindableElement( () => Properties.Resources.MenuAdd, GetInvoker(false) - ) { Command = new DelegateCommand(() => SendOpen()) }); + ) { Command = new DelegateCommand(SendOpen) }); /* ----------------------------------------------------------------- */ /// @@ -152,7 +152,7 @@ SynchronizationContext context public IElement Remove => Get(() => new BindableElement( () => Properties.Resources.MenuRemove, GetInvoker(false) - ) { Command = IsSelected(() => Sync(() => Facade.Remove())) }); + ) { Command = IsSelected(() => Track(Facade.Remove, true)) }); /* ----------------------------------------------------------------- */ /// @@ -166,7 +166,7 @@ SynchronizationContext context public IElement Clear => Get(() => new BindableElement( () => Properties.Resources.MenuClear, GetInvoker(false) - ) { Command = new DelegateCommand(() => Sync(Facade.Clear)) }); + ) { Command = new DelegateCommand(() => Track(Facade.Clear, true)) }); /* ----------------------------------------------------------------- */ /// @@ -180,7 +180,7 @@ SynchronizationContext context public IElement Up => Get(() => new BindableElement( () => Properties.Resources.MenuUp, GetInvoker(false) - ) { Command = IsSelected(() => Sync(() => Facade.Move(-1))) }); + ) { Command = IsSelected(() => Track(() => Facade.Move(-1), true)) }); /* ----------------------------------------------------------------- */ /// @@ -194,7 +194,7 @@ SynchronizationContext context public IElement Down => Get(() => new BindableElement( () => Properties.Resources.MenuDown, GetInvoker(false) - ) { Command = IsSelected(() => Sync(() => Facade.Move(1))) }); + ) { Command = IsSelected(() => Track(() => Facade.Move(1), true)) }); /* ----------------------------------------------------------------- */ /// @@ -266,7 +266,7 @@ SynchronizationContext context /// /* ----------------------------------------------------------------- */ public ICommand DragAdd => Get(() => - new DelegateCommand(e => Sync(() => Facade.Add(e))) + new DelegateCommand(e => Track(() => Facade.Add(e), true)) ); /* ----------------------------------------------------------------- */ @@ -279,7 +279,7 @@ SynchronizationContext context /// /* ----------------------------------------------------------------- */ public ICommand SelectClear => Get(() => - new DelegateCommand(() => Sync(Facade.SelectClear)) + new DelegateCommand(() => Track(Facade.SelectClear, true)) ); #endregion diff --git a/Applications/Editor/Main/Sources/Presenters/Main/MainViewModelBase.cs b/Applications/Editor/Main/Sources/Presenters/Main/MainViewModelBase.cs index de40f7ed1..d09278d1e 100644 --- a/Applications/Editor/Main/Sources/Presenters/Main/MainViewModelBase.cs +++ b/Applications/Editor/Main/Sources/Presenters/Main/MainViewModelBase.cs @@ -16,17 +16,17 @@ // along with this program. If not, see . // /* ------------------------------------------------------------------------- */ -using Cube.FileSystem; -using Cube.Mixin.Generics; -using Cube.Mixin.Observing; -using Cube.Mixin.Pdf; -using Cube.Xui; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Threading; using System.Windows.Input; +using Cube.FileSystem; +using Cube.Mixin.Generics; +using Cube.Mixin.Observing; +using Cube.Mixin.Pdf; +using Cube.Xui; namespace Cube.Pdf.Editor { @@ -95,7 +95,7 @@ SynchronizationContext context /* ----------------------------------------------------------------- */ protected ICommand GetCloseCommand() => new DelegateCommand( e => { - if (!Facade.Value.Modified) Sync(() => Facade.Close(false)); + if (!Facade.Value.Modified) Track(() => Facade.Close(false), true); else SendClose(e); }, e => Facade.Value.Source != null && (e != null || !Facade.Value.Busy) @@ -219,7 +219,7 @@ protected void SendClose(CancelEventArgs src) if (e.Cancel) return; void close() => Facade.Close(m.Value == DialogStatus.Yes); - if (src != null) Sync(close); + if (src != null) Track(close, true); else Track(close); } diff --git a/Applications/Editor/Main/Sources/Presenters/Main/RibbonViewModel.cs b/Applications/Editor/Main/Sources/Presenters/Main/RibbonViewModel.cs index d28066384..7ea22fcdf 100644 --- a/Applications/Editor/Main/Sources/Presenters/Main/RibbonViewModel.cs +++ b/Applications/Editor/Main/Sources/Presenters/Main/RibbonViewModel.cs @@ -18,6 +18,7 @@ /* ------------------------------------------------------------------------- */ using Cube.Mixin.Observing; using Cube.Xui; +using System; using System.Threading; namespace Cube.Pdf.Editor @@ -212,7 +213,7 @@ SynchronizationContext context nameof(Undo), () => Properties.Resources.MenuUndo, GetInvoker(false) - ) { Command = IsUndoable(() => Sync(Facade.Undo)) }); + ) { Command = IsUndoable(() => Track(Facade.Undo, true)) }); /* ----------------------------------------------------------------- */ /// @@ -227,7 +228,7 @@ SynchronizationContext context nameof(Redo), () => Properties.Resources.MenuRedo, GetInvoker(false) - ) { Command = IsRedoable(() => Sync(Facade.Redo)) }); + ) { Command = IsRedoable(() => Track(Facade.Redo, true)) }); /* ----------------------------------------------------------------- */ /// @@ -242,7 +243,7 @@ SynchronizationContext context nameof(Select), () => Properties.Resources.MenuSelect, GetInvoker(false) - ) { Command = IsOpen(() => Sync(Facade.Select)) }); + ) { Command = IsOpen(() => Track(Facade.Select, true)) }); /* ----------------------------------------------------------------- */ /// @@ -257,7 +258,7 @@ SynchronizationContext context nameof(Select), () => Properties.Resources.MenuSelectAll, GetInvoker(false) - ) { Command = IsOpen(() => Sync(() => Facade.Select(true))) }); + ) { Command = IsOpen(() => Track(() => Facade.Select(true), true)) }); /* ----------------------------------------------------------------- */ /// @@ -272,7 +273,7 @@ SynchronizationContext context nameof(Select), () => Properties.Resources.MenuSelectFlip, GetInvoker(false) - ) { Command = IsOpen(() => Sync(Facade.Flip)) }); + ) { Command = IsOpen(() => Track(Facade.Flip, true)) }); /* ----------------------------------------------------------------- */ /// @@ -287,7 +288,7 @@ SynchronizationContext context nameof(Select), () => Properties.Resources.MenuSelectClear, GetInvoker(false) - ) { Command = IsOpen(() => Sync(() => Facade.Select(false))) }); + ) { Command = IsOpen(() => Track(() => Facade.Select(false), true)) }); /* ----------------------------------------------------------------- */ /// @@ -403,7 +404,7 @@ SynchronizationContext context () => !Facade.Value.Busy, GetInvoker(false) ) { - Command = IsSelected(() => Sync(Facade.Remove)) + Command = IsSelected(() => Track(Facade.Remove, true)) }.Associate(Facade.Value, nameof(MainBindable.Busy), nameof(MainBindable.Source))); /* ----------------------------------------------------------------- */ @@ -434,7 +435,7 @@ SynchronizationContext context nameof(MoveNext), () => Properties.Resources.MenuMoveNext, GetInvoker(false) - ) { Command = IsSelected(() => Sync(() => Facade.Move(1))) }); + ) { Command = IsSelected(() => Track(() => Facade.Move(1), true)) }); /* ----------------------------------------------------------------- */ /// @@ -449,7 +450,7 @@ SynchronizationContext context nameof(MovePrevious), () => Properties.Resources.MenuMovePrevious, GetInvoker(false) - ) { Command = IsSelected(() => Sync(() => Facade.Move(-1))) }); + ) { Command = IsSelected(() => Track(() => Facade.Move(-1), true)) }); /* ----------------------------------------------------------------- */ /// @@ -464,7 +465,7 @@ SynchronizationContext context nameof(RotateLeft), () => Properties.Resources.MenuRotateLeft, GetInvoker(false) - ) { Command = IsSelected(() => Sync(() => Facade.Rotate(-90))) }); + ) { Command = IsSelected(() => Track(() => Facade.Rotate(-90), true)) }); /* ----------------------------------------------------------------- */ /// @@ -479,7 +480,7 @@ SynchronizationContext context nameof(RotateRight), () => Properties.Resources.MenuRotateRight, GetInvoker(false) - ) { Command = IsSelected(() => Sync(() => Facade.Rotate(90))) }); + ) { Command = IsSelected(() => Track(() => Facade.Rotate(90), true)) }); /* ----------------------------------------------------------------- */ /// @@ -525,7 +526,7 @@ SynchronizationContext context nameof(Redraw), () => Properties.Resources.MenuRedraw, GetInvoker(false) - ) { Command = IsOpen(() => Sync(Facade.Redraw)) }); + ) { Command = IsOpen(() => Track(Facade.Redraw, true)) }); /* ----------------------------------------------------------------- */ /// @@ -540,7 +541,7 @@ SynchronizationContext context nameof(ZoomIn), () => Properties.Resources.MenuZoomIn, GetInvoker(false) - ) { Command = GetCommand(() => Sync(() => Facade.Zoom(1))) }); + ) { Command = GetCommand(() => Track(() => Facade.Zoom(1), true)) }); /* ----------------------------------------------------------------- */ /// @@ -555,7 +556,7 @@ SynchronizationContext context nameof(ZoomOut), () => Properties.Resources.MenuZoomOut, GetInvoker(false) - ) { Command = GetCommand(() => Sync(() => Facade.Zoom(-1))) }); + ) { Command = GetCommand(() => Track(() => Facade.Zoom(-1), true)) }); /* ----------------------------------------------------------------- */ /// diff --git a/Applications/Editor/Main/Sources/Presenters/ViewModelBase.cs b/Applications/Editor/Main/Sources/Presenters/ViewModelBase.cs index 320dec158..74c4e92c7 100644 --- a/Applications/Editor/Main/Sources/Presenters/ViewModelBase.cs +++ b/Applications/Editor/Main/Sources/Presenters/ViewModelBase.cs @@ -61,17 +61,6 @@ protected ViewModelBase(TModel model, Aggregator aggregator, SynchronizationCont #region Methods - /* ----------------------------------------------------------------- */ - /// - /// Sync - /// - /// - /// Executes the specified action as a synchronous method. - /// - /// - /* ----------------------------------------------------------------- */ - protected void Sync(Action action) => Track(action, true); - /* ----------------------------------------------------------------- */ /// /// Dispose