Skip to content

Commit

Permalink
Refactor ViewModels.
Browse files Browse the repository at this point in the history
  • Loading branch information
clown committed Jul 19, 2020
1 parent e803fb1 commit fc35cc2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 36 deletions.
32 changes: 3 additions & 29 deletions Applications/Editor/Main/Sources/Presenters/DialogViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
/* ------------------------------------------------------------------------- */
using Cube.Xui;
using System;
using System.Threading;
using Cube.Xui;

namespace Cube.Pdf.Editor
{
Expand All @@ -31,7 +30,7 @@ namespace Cube.Pdf.Editor
/// </summary>
///
/* --------------------------------------------------------------------- */
public abstract class DialogViewModel<TModel> : GenericViewModel<TModel>
public abstract class DialogViewModel<TModel> : ViewModelBase<TModel>
{
#region Constructors

Expand All @@ -54,7 +53,7 @@ protected DialogViewModel(TModel model,
SynchronizationContext context
) : base(model, aggregator, context)
{
_dispose = Locale.Subscribe(e => Refresh(nameof(Title)));
Use(Locale.Subscribe(e => Refresh(nameof(Title))));
}

#endregion
Expand Down Expand Up @@ -117,31 +116,6 @@ SynchronizationContext context
/* ----------------------------------------------------------------- */
protected abstract string GetTitle();

/* ----------------------------------------------------------------- */
///
/// Dispose
///
/// <summary>
/// Releases the unmanaged resources used by the object and
/// optionally releases the managed resources.
/// </summary>
///
/// <param name="disposing">
/// true to release both managed and unmanaged resources;
/// false to release only unmanaged resources.
/// </param>
///
/* ----------------------------------------------------------------- */
protected override void Dispose(bool disposing)
{
try { if (disposing) _dispose.Dispose(); }
finally { base.Dispose(disposing); }
}

#endregion

#region Fields
private readonly IDisposable _dispose;
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Cube.Pdf.Editor
/// </summary>
///
/* --------------------------------------------------------------------- */
public sealed class PositionViewModel : GenericViewModel<InsertBindable>
public sealed class PositionViewModel : ViewModelBase<InsertBindable>
{
#region Constructors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace Cube.Pdf.Editor
/// </summary>
///
/* --------------------------------------------------------------------- */
public abstract class MainViewModelBase : GenericViewModel<MainFacade>
public abstract class MainViewModelBase : ViewModelBase<MainFacade>
{
#region Constructors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Cube.Pdf.Editor
/// </summary>
///
/* --------------------------------------------------------------------- */
public sealed class RecentViewModel : GenericViewModel<DirectoryMonitor>
public sealed class RecentViewModel : ViewModelBase<DirectoryMonitor>
{
#region Constructors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
/* ------------------------------------------------------------------------- */
using Cube.Xui;
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Windows.Input;
using Cube.Xui;

namespace Cube.Pdf.Editor
{
/* --------------------------------------------------------------------- */
///
/// GenericViewModel(TModel)
/// ViewModelBase(TModel)
///
/// <summary>
/// Represents the base class of ViewModels.
/// </summary>
///
/* --------------------------------------------------------------------- */
public abstract class GenericViewModel<TModel> : Presentable<TModel>
public abstract class ViewModelBase<TModel> : Presentable<TModel>
{
#region Constructors

Expand All @@ -54,7 +54,7 @@ public abstract class GenericViewModel<TModel> : Presentable<TModel>
/// <param name="context">Synchronization context.</param>
///
/* ----------------------------------------------------------------- */
protected GenericViewModel(TModel model, Aggregator aggregator, SynchronizationContext context) :
protected ViewModelBase(TModel model, Aggregator aggregator, SynchronizationContext context) :
base(model, aggregator, context) { }

#endregion
Expand Down

0 comments on commit fc35cc2

Please sign in to comment.