Table of Contents

Class ModificationHistory

Namespace
vdWebLibrary
Assembly
JsPropertiesExtractor.dll

Maintains the stack of redo and undo logs.Each entry in the undo stack represents a single property change

It is accessible by UndoHistory()

public class ModificationHistory
Inheritance
ModificationHistory
Inherited Members

Examples

var vdcanvas; // keep the vdcanvas control global for quick access inside the functions since it is the only one in the this page
function vdrawInitPageLoad() {//Intiallize theweb control inside this function.It must be called inside onload event of this page
    vdmanager.AttachCanvas("canvas"); //create a new web control andattch it to the canvas elemement
    vdcanvas = vdmanager.vdrawObject(); //return a refence to the attached web control
    vdcanvas.vdAfterOpenDocument = _vdAfterOpenDocument; //defines the function that will be fire when a web control document loaded.
    vdcanvas.vdPrompt = _onprompt; //defines the function that will be fire when a vdcanvas.Prompt is called in order to print the message on this page
    vdcanvas.vdError = _vdError; //defines the function that will be fire when an error ocured in order to print the message on this page
}

function printInfo(text) {//print messages in the 'info' element of this page
    document.getElementById("info").innerHTML = ":" + text;
}
function _vdError(sender, ErrCategoryId, statusId, info) {
    printInfo("Error status code = " + statusId.toString() + ". " + (info ? info : ""));
}
function _onprompt(sender, msg) {
    printInfo(msg);
}

function _vdAfterOpenDocument() {//fire when a web control document loaded.
    vdcanvas.Prompt("Document opened successfully");
    createTestobject();
}
function createTestobject() {
    var k = 0;
    var line;
    for (k = 0; k < 2; k++) {
        line = vdcanvas.AddLine([-5, k, 0], [5, k, 0]);
        vdcanvas.UndoHistory().store(line, "Deleted", true); //add the new line object to history
        vdcanvas.UndoHistory().store(line, "PenColor"); //add the Pencolor property to history
        line.PenColor = vdConst.createNewColor(k.toString()); //change the PenColor
    }

    vdcanvas.UndoHistory().group_start(); //start a new undo group
    //same code with previous loop but inside a group
    for (k = 2; k < 4; k++) {
        line = vdcanvas.AddLine([-5, k, 0], [5, k, 0]);
        vdcanvas.UndoHistory().store(line, "Deleted", true);
        vdcanvas.UndoHistory().store(line, "PenColor");
        line.PenColor = vdConst.createNewColor(k.toString());
    }
    vdcanvas.UndoHistory().group_end(); //end the undo group 
    vdcanvas.redraw();
}

function undo() {
    vdcanvas.UndoHistory().undo(); //make a single undo . Call it multi times until everything undone
    setTimeout(vdcanvas.redraw, 0); //send a redraw to timeout
}
function redo() {
    vdcanvas.UndoHistory().redo(); //make a single redo.Call it multi times until everything redone.
    setTimeout(vdcanvas.redraw, 0); //send a redraw to timeout
}

function test() {
    //select a new document for the web control.
    //NOTE: Always a document must be selected to the web control.Else the web control is unusable
    vdcanvas.SelectDocument("vddocument.vds");
}




First Select Test to open a new drawing and create some entities, then select Undo and Redo buttons




    Test

    Undo

    Redo



    :

Properties

Enable

Get/Set a boolean value to the enable undo stack write.

RedoStack

Returns the array of the redo records.

UndoStack

Returns the array of the undo records.

Methods

Clear()

Clear the undo and redo stack.

group_end()

End a Group of property changes.

group_start()

Begin a Group of property changes.

redo()

Redones the last item stored in the redo list.If a start group item is last then redones all items of the group.

store(object, string, object)

This method would be called by the parent object in order to store the value of a property before it changes.

undo()

Undones the last item stored in the undo list.If an end group item is last then undones all items of the group.