All Projects → wieslawsoltes → Reactivehistory

wieslawsoltes / Reactivehistory

Licence: mit
Reactive undo/redo framework for .NET.

Projects that are alternatives of or similar to Reactivehistory

Mvvmvalidation
Lightweight library that helps reduce boilerplate when implementing validation in XAML MVVM applications
Stars: ✭ 141 (+71.95%)
Mutual labels:  mvvm, wpf, xaml
Avaloniabehaviors
Port of Windows UWP Xaml Behaviors for Avalonia Xaml.
Stars: ✭ 96 (+17.07%)
Mutual labels:  multi-platform, mvvm, xaml
Steamtools
🛠「Steam++」是一个开源跨平台的多功能Steam工具箱。
Stars: ✭ 4,458 (+5336.59%)
Mutual labels:  mvvm, wpf, xaml
Xaml Code Experiences
A collection of the experiences I have collected during days of Xamarin and Wpf, while following the MVVM design pattern.
Stars: ✭ 114 (+39.02%)
Mutual labels:  mvvm, wpf, xaml
Handycontrols
Contains some simple and commonly used WPF controls based on HandyControl
Stars: ✭ 347 (+323.17%)
Mutual labels:  mvvm, wpf, xaml
WpfExtensions
Some syntactic sugar for Wpf development.
Stars: ✭ 128 (+56.1%)
Mutual labels:  xaml, reactive, wpf
Wpfbindingerrors
💥 Turn WPF Binding errors into exception
Stars: ✭ 73 (-10.98%)
Mutual labels:  mvvm, wpf, xaml
Core2d
A multi-platform data driven 2D diagram editor.
Stars: ✭ 475 (+479.27%)
Mutual labels:  multi-platform, wpf, xaml
WPF-Keyboard-Control
WPF Keyboard Control
Stars: ✭ 53 (-35.37%)
Mutual labels:  xaml, wpf, mvvm
YouTube-Downloader
An easy-to-use, YouTube video downloader, without pesky ads or malware.
Stars: ✭ 22 (-73.17%)
Mutual labels:  xaml, wpf, mvvm
Windowscommunitytoolkit
The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building UWP and .NET apps for Windows 10. The toolkit is part of the .NET Foundation.
Stars: ✭ 4,654 (+5575.61%)
Mutual labels:  mvvm, wpf, xaml
Reactiveproperty
ReactiveProperty provides MVVM and asynchronous support features under Reactive Extensions. Target framework is .NET Standard 2.0.
Stars: ✭ 603 (+635.37%)
Mutual labels:  mvvm, wpf, xaml
Tumblthree
A Tumblr Blog Backup Application
Stars: ✭ 923 (+1025.61%)
Mutual labels:  mvvm, wpf
Visualstudiorevittemplate
Visual Studio project template for Revit add-in development. (using WPF and MVVM)
Stars: ✭ 22 (-73.17%)
Mutual labels:  mvvm, wpf
Neutronium
🚀 Build .NET desktop applications using HTML, CSS and javascript.
Stars: ✭ 1,190 (+1351.22%)
Mutual labels:  mvvm, wpf
Adonis Ui
Lightweight UI toolkit for WPF applications offering classic but enhanced windows visuals
Stars: ✭ 878 (+970.73%)
Mutual labels:  wpf, xaml
Csgo Demos Manager
Stars: ✭ 782 (+853.66%)
Mutual labels:  mvvm, wpf
Formswpflive
Live XAML development for Xamarin Forms Apps using WPF Backend.
Stars: ✭ 14 (-82.93%)
Mutual labels:  wpf, xaml
Dmskin
DMSkin WPF 样式 UI 框架 | WPF Borderless Window | Custom Controls & Styles | MVVM Support
Stars: ✭ 1,189 (+1350%)
Mutual labels:  mvvm, wpf
Adaptivecards
A new way for developers to exchange card content in a common and consistent way.
Stars: ✭ 950 (+1058.54%)
Mutual labels:  wpf, xaml

ReactiveHistory

Gitter

Build status

NuGet NuGet MyGet

ReactiveHistory is an undo/redo framework for .NET.

About

The main design principle for ReactiveHistory is to provide easy to use undo functionality inside your view models and allow separation from data models when following the MVVM pattern for creation of modern and portable GUI applications.

The ReactiveHistory framework enables easy implementation of undo history for observable properties and collections. To enable quick conversion from standard .NET properties and collection helper extension methods are provided. For example the ObserveWithHistory extension method is intended to be used for IObservable<T> properties and the DeleteWithHistory for IList<T> collections.

Example Usage

For examples of ReactiveHistory usage please check the samples folder. Currently there are available samples for WPF and Avalonia frameworks. The samples follow MVVM pattern, the view models use ReactiveProperty framework to implement observable properties and commands. There are also available unit tests located in tests folder with all tests for each of the use cases.

MVVM

Model

public class Layer : BaseObject
{
    private ObservableCollection<LineShape> _shapes;

    public ObservableCollection<LineShape> Shapes
    {
        get { return _shapes; }
        set { Update(ref _shapes, value); }
    }

    public Layer(object owner = null, string name = null)
    {
        this.Owner = owner;
        this.Name = name;
        this.Shapes = new ObservableCollection<LineShape>();
    }
}

ViewModel

public class LayerViewModel : IDisposable
{
    private CompositeDisposable Disposable { get; set; }
    public ReactiveProperty<string> Name { get; set; }
    public ReadOnlyReactiveCollection<LineShapeViewModel> Shapes { get; set; }
    public ReactiveCommand UndoCommand { get; set; }
    public ReactiveCommand RedoCommand { get; set; }
    public ReactiveCommand ClearCommand { get; set; }

    public LayerViewModel(Layer layer, IHistory history)
    {
        Disposable = new CompositeDisposable();

        this.Name = layer.ToReactivePropertyAsSynchronized(l => l.Name)
            .SetValidateNotifyError(name => string.IsNullOrWhiteSpace(name) ? "Name can not be null or whitespace." : null)
            .AddTo(this.Disposable);

        this.Shapes = layer.Shapes
            .ToReadOnlyReactiveCollection(x => new LineShapeViewModel(x, history))
            .AddTo(this.Disposable);

        this.Name.ObserveWithHistory(name => layer.Name = name, layer.Name, history).AddTo(this.Disposable);
        
        UndoCommand = new ReactiveCommand(history.CanUndo, false);
        UndoCommand.Subscribe(_ => history.Undo()).AddTo(this.Disposable);

        RedoCommand = new ReactiveCommand(history.CanRedo, false);
        RedoCommand.Subscribe(_ => history.Redo()).AddTo(this.Disposable);

        ClearCommand = new ReactiveCommand(history.CanClear, false);
        ClearCommand.Subscribe(_ => history.Clear()).AddTo(this.Disposable);
    }

    public void Dispose()
    {
        this.Disposable.Dispose();
    }
}

Initialization

var layer1 = new Layer("layer1");

var line1 = new LineShape(layer1, "line1");
line1.Start = new PointShape(100, 100, line1, "start11");
line1.End = new PointShape(200, 100, line1, "end11");

var line2 = new LineShape(layer1, "line2");
line2.Start = new PointShape(100, 200, line2, "start21");
line2.End = new PointShape(200, 200, line2, "end21");

layer1.Shapes.Add(line1);
layer1.Shapes.Add(line2);

var history = new StackHistory();
var layerViewModel = new LayerViewModel(layer1, history).AddTo(disposable);

Building ReactiveHistory

First, clone the repository or download the latest zip.

git clone https://github.com/wieslawsoltes/ReactiveHistory.git
git submodule update --init --recursive

NuGet

ReactiveHistory is delivered as a NuGet package.

You can find the packages here NuGet or by using nightly build feed:

  • Add https://www.myget.org/F/reactivehistory-nightly/api/v2 to your package sources
  • Alternative nightly build feed https://pkgs.dev.azure.com/wieslawsoltes/GitHub/_packaging/Nightly/nuget/v3/index.json
  • Update your package using ReactiveHistory feed

You can install the package like this:

Install-Package ReactiveHistory -Pre

Package Sources

License

ReactiveHistory is licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].