Stock from Github repo
- WPF Client (empty) - MVVM code base (limited) - Images, Sprites, and other Rss
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace SeriusSoft.Frameworks.MVVM.ViewModels
|
||||
{
|
||||
public abstract class BaseViewModel : INotifyPropertyChanged, IBackedByModel
|
||||
{
|
||||
public virtual bool IsNew { get { return true; } }
|
||||
public virtual bool IsBacked { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// if you are having trouble with the [CallerMemberName] attribute due to versioning,
|
||||
/// you can check out http://stackoverflow.com/questions/301809/workarounds-for-nameof-operator-in-c-typesafe-databinding for supplying a name to this method
|
||||
/// as well as the inner workings of new'ing up an Exception to determine how they use the call-stack to find out who called the method or which method call it is on or just finished
|
||||
///<summary>
|
||||
protected virtual void RaisePropertyChanged([CallerMemberName] string member = "")
|
||||
{
|
||||
var copy = PropertyChanged;
|
||||
if ( copy != null )
|
||||
{
|
||||
var changedEvent = new PropertyChangedEventArgs(member);
|
||||
copy(this, changedEvent);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void RaiseAllBackedPropertiesChanged();
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace SeriusSoft.Frameworks.MVVM.Exceptions
|
||||
{
|
||||
public class AlreadyInBatchModeException : Exception
|
||||
{
|
||||
public AlreadyInBatchModeException() : base() { }
|
||||
|
||||
public AlreadyInBatchModeException(string message) : base(message) { }
|
||||
|
||||
public AlreadyInBatchModeException(string message, Exception innerException) : base(message, innerException) { }
|
||||
|
||||
public AlreadyInBatchModeException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace SeriusSoft.Frameworks.MVVM.Exceptions
|
||||
{
|
||||
public class NotInBatchModeException : Exception
|
||||
{
|
||||
public NotInBatchModeException() : base() { }
|
||||
|
||||
public NotInBatchModeException(string message) : base(message) { }
|
||||
|
||||
public NotInBatchModeException(string message, Exception innerException) : base(message, innerException) { }
|
||||
|
||||
public NotInBatchModeException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace SeriusSoft.Frameworks.MVVM.ViewModels
|
||||
{
|
||||
public interface IBackedByModel
|
||||
{
|
||||
bool IsNew { get; }
|
||||
bool IsBacked { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace SeriusSoft.Frameworks.MVVM.Core
|
||||
{
|
||||
public interface IBatchable
|
||||
{
|
||||
bool IsInBatchMode { get; set; }
|
||||
void Begin_ViewModelUpdates();
|
||||
void End_ViewModelUpdates();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using SeriusSoft.Frameworks.MVVM.Core;
|
||||
using SeriusSoft.Frameworks.MVVM.Exceptions;
|
||||
|
||||
namespace SeriusSoft.Frameworks.MVVM.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Note that this is almost the same as the BaseViewModel.</para>
|
||||
/// <para>The difference is that if you use the Begin_ViewModelUpdates() and End_ViewModelUpdates() methods, calls to RaisePropertyChanged will be ignored so long as:</para>
|
||||
/// <para> - this.IsInBatchMode is false</para>
|
||||
/// <para> - OR this.OverrideBatchModeLock is true</para>
|
||||
/// <para> - Note that this means that the RaiseAllBackedPropertiesChanged will essentially do nothing even when overridden because you will be unable to trigger the PropertyChanged events w/o overriding the RaisePropertyChanged method.</para>
|
||||
/// </summary>
|
||||
public abstract class BatchableBaseViewModel : BaseViewModel, IBatchable, INotifyPropertyChanged, IBackedByModel
|
||||
{
|
||||
public bool IsInBatchMode { get; set; }
|
||||
public bool OverrideBatchModeLock { get; set; }
|
||||
|
||||
public void Begin_ViewModelUpdates()
|
||||
{
|
||||
if ( this.IsInBatchMode )
|
||||
throw new AlreadyInBatchModeException(this.GetType().FullName);
|
||||
|
||||
this.IsInBatchMode = true;
|
||||
}
|
||||
|
||||
public void End_ViewModelUpdates()
|
||||
{
|
||||
if (!this.IsInBatchMode)
|
||||
throw new NotInBatchModeException(this.GetType().FullName);
|
||||
|
||||
this.IsInBatchMode = false;
|
||||
}
|
||||
|
||||
protected override void RaisePropertyChanged([CallerMemberName] string member = "")
|
||||
{
|
||||
if ( !this.OverrideBatchModeLock && this.IsInBatchMode )
|
||||
return;
|
||||
|
||||
base.RaisePropertyChanged(member);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("MVVM")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("MVVM")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("ed5aedba-82a6-4493-b3f3-bda525c75d15")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Reference in New Issue
Block a user