Skip to content

Commit

Permalink
Remove Sync method.
Browse files Browse the repository at this point in the history
  • Loading branch information
clown committed Jul 19, 2020
1 parent fc35cc2 commit ce8d680
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) });

/* ----------------------------------------------------------------- */
///
Expand All @@ -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) });

/* ----------------------------------------------------------------- */
///
Expand All @@ -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)) });

/* ----------------------------------------------------------------- */
///
Expand All @@ -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)) });

/* ----------------------------------------------------------------- */
///
Expand All @@ -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)) });

/* ----------------------------------------------------------------- */
///
Expand All @@ -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)) });

/* ----------------------------------------------------------------- */
///
Expand Down Expand Up @@ -266,7 +266,7 @@ SynchronizationContext context
///
/* ----------------------------------------------------------------- */
public ICommand DragAdd => Get(() =>
new DelegateCommand<string[]>(e => Sync(() => Facade.Add(e)))
new DelegateCommand<string[]>(e => Track(() => Facade.Add(e), true))
);

/* ----------------------------------------------------------------- */
Expand All @@ -279,7 +279,7 @@ SynchronizationContext context
///
/* ----------------------------------------------------------------- */
public ICommand SelectClear => Get(() =>
new DelegateCommand(() => Sync(Facade.SelectClear))
new DelegateCommand(() => Track(Facade.SelectClear, true))
);

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
/* ------------------------------------------------------------------------- */
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
{
Expand Down Expand Up @@ -95,7 +95,7 @@ SynchronizationContext context
/* ----------------------------------------------------------------- */
protected ICommand GetCloseCommand() => new DelegateCommand<CancelEventArgs>(
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)
Expand Down Expand Up @@ -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);
}

Expand Down
29 changes: 15 additions & 14 deletions Applications/Editor/Main/Sources/Presenters/Main/RibbonViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
/* ------------------------------------------------------------------------- */
using Cube.Mixin.Observing;
using Cube.Xui;
using System;
using System.Threading;

namespace Cube.Pdf.Editor
Expand Down Expand Up @@ -212,7 +213,7 @@ SynchronizationContext context
nameof(Undo),
() => Properties.Resources.MenuUndo,
GetInvoker(false)
) { Command = IsUndoable(() => Sync(Facade.Undo)) });
) { Command = IsUndoable(() => Track(Facade.Undo, true)) });

/* ----------------------------------------------------------------- */
///
Expand All @@ -227,7 +228,7 @@ SynchronizationContext context
nameof(Redo),
() => Properties.Resources.MenuRedo,
GetInvoker(false)
) { Command = IsRedoable(() => Sync(Facade.Redo)) });
) { Command = IsRedoable(() => Track(Facade.Redo, true)) });

/* ----------------------------------------------------------------- */
///
Expand All @@ -242,7 +243,7 @@ SynchronizationContext context
nameof(Select),
() => Properties.Resources.MenuSelect,
GetInvoker(false)
) { Command = IsOpen(() => Sync(Facade.Select)) });
) { Command = IsOpen(() => Track(Facade.Select, true)) });

/* ----------------------------------------------------------------- */
///
Expand All @@ -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)) });

/* ----------------------------------------------------------------- */
///
Expand All @@ -272,7 +273,7 @@ SynchronizationContext context
nameof(Select),
() => Properties.Resources.MenuSelectFlip,
GetInvoker(false)
) { Command = IsOpen(() => Sync(Facade.Flip)) });
) { Command = IsOpen(() => Track(Facade.Flip, true)) });

/* ----------------------------------------------------------------- */
///
Expand All @@ -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)) });

/* ----------------------------------------------------------------- */
///
Expand Down Expand Up @@ -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)));

/* ----------------------------------------------------------------- */
Expand Down Expand Up @@ -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)) });

/* ----------------------------------------------------------------- */
///
Expand All @@ -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)) });

/* ----------------------------------------------------------------- */
///
Expand All @@ -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)) });

/* ----------------------------------------------------------------- */
///
Expand All @@ -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)) });

/* ----------------------------------------------------------------- */
///
Expand Down Expand Up @@ -525,7 +526,7 @@ SynchronizationContext context
nameof(Redraw),
() => Properties.Resources.MenuRedraw,
GetInvoker(false)
) { Command = IsOpen(() => Sync(Facade.Redraw)) });
) { Command = IsOpen(() => Track(Facade.Redraw, true)) });

/* ----------------------------------------------------------------- */
///
Expand All @@ -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)) });

/* ----------------------------------------------------------------- */
///
Expand All @@ -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)) });

/* ----------------------------------------------------------------- */
///
Expand Down
11 changes: 0 additions & 11 deletions Applications/Editor/Main/Sources/Presenters/ViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,6 @@ protected ViewModelBase(TModel model, Aggregator aggregator, SynchronizationCont

#region Methods

/* ----------------------------------------------------------------- */
///
/// Sync
///
/// <summary>
/// Executes the specified action as a synchronous method.
/// </summary>
///
/* ----------------------------------------------------------------- */
protected void Sync(Action action) => Track(action, true);

/* ----------------------------------------------------------------- */
///
/// Dispose
Expand Down

0 comments on commit ce8d680

Please sign in to comment.