GithubHelp home page GithubHelp logo

urd's Introduction

URD

#undo redo pattern for C# applications

this is a basic undo pattern for .NET applications. developed for use in GS subtitle project (not published) in this pattern when you want a undo / redo able action you will need to warp that action with using statement. as a example if you going to change a property you can do this

using (new PropertyChange(Object, "Property", "Property changed "))
{
  Object.Property="new value";
}

now the change you made to the "Property" property of the "Object" object is added to the drop out stack and it can undo or redo any time you want.

if you want a undoAble list change you can do it using same syntax

private void AddNewItem(<string>List list,string item,bool undoAble)
{
	using (undoAble?new ListChangeAddElement(list,item,"add new string to the string list"):null) //you can use a condition then you can minimize code
	{
		list.Add(item);
	}
}

Removing a Item

private void RemoveItem(list,item,bool undoAble)
{
	using(undoAble?new ListChangeRemoveElement(list,item,list.IndexOf(item)," remove "+item+" from the string list"))
	{
		list.Remove(item);
	}
}

so on.. (check the code)

benefits of this pattern

low CPU, Memory usage
undo only what you want

if you want to implement your own operation . only thing you need to do is create a class--> extend Change class and IUndoAble interface.

urd's People

Contributors

rusith avatar tharindukaha avatar

Watchers

Abdul Kareem avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.