Undo-Redo

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
Khyati
Posts: 34
Joined: 08 Feb 2011, 08:55

Undo-Redo

Post by Khyati » 10 Feb 2011, 07:14

Thanks for reply of my earlier posts.

My mainform has four buttons: Draw, Modify, Undo, Redo

i draw an image with one ellipse and two lines.
Code of drawing the ellipse and one line is written in method of a button(draw) click.
In second button(modify) click method, i've moved ellipse to upward and drawn another line.

For Undo button,
either i write
cadEditorControl1.UndoChangeEntity();
or
cadEditorControl1.Image.Undo();

it is not working properly.
It(the picture box) should be blank on pressing Undo button more times, till undo buffer gets empty.
But it is not happening like that.

1) Would you please explain the reason?
2) How undo-redo works for CADImport?

I am putting code snippet for your reference:

Code: Select all

namespace CadEx_ABV;

interface

uses
  System.Drawing,
  System.Collections,
  System.Collections.Generic,
  System.Windows.Forms,
  System.ComponentModel,
  System.Data,
System.Globalization,
System.Drawing.Imaging,
System.Drawing.Drawing2D,
System.Runtime.Serialization,
System.Runtime.Serialization.Formatters.Binary,
  CADImport,
 CADImport.CADImportForms,
 CADImport.FaceModule,
 CADImport.RasterImage,
 CADImport.Professional,
 CADImport.HPGL2,
 CADImport.Export.DirectCADtoDXF;

type
  /// <summary>
  /// Summary description for MainForm.
  /// </summary>
  MainForm = partial class(System.Windows.Forms.Form)
  private
    method button1_Click(sender: System.Object; e: System.EventArgs);
    method MainForm_Load(sender: System.Object; e: System.EventArgs);
    method button3_Click(sender: System.Object; e: System.EventArgs);
    method button4_Click(sender: System.Object; e: System.EventArgs);
    method button2_Click(sender: System.Object; e: System.EventArgs);
  protected
    method Dispose(disposing: Boolean); override;
  public
    entEllipse : CADImport.CADEllipse;
    entLine, entLine1 : CADImport.CADLine;
    
    constructor;
  end;


    

implementation

{$REGION Construction and Disposition}
constructor MainForm;
begin
  //
  // Required for Windows Form Designer support
  //
  InitializeComponent();

  //
  // TODO: Add any constructor code after InitializeComponent call
  //
end;

method MainForm.Dispose(disposing: Boolean);
begin
  if disposing then begin
    if assigned(components) then
      components.Dispose();

    //
    // TODO: Add custom disposition code here
    //
  end;
  inherited Dispose(disposing);
end;
{$ENDREGION}

method MainForm.button1_Click(sender: System.Object; e: System.EventArgs);      //// DRAW BUTTON

   
begin

    cadEditorControl1.CreateNewImage();
    cadEditorControl1.Image.InitialNewImage();

    //// DRAW a ELLIPSE
    entEllipse := new CADImport.CADEllipse();

    entEllipse.Point := new CADImport.DPoint(10, 10, 0);
    entEllipse.Radius := 50;
    entEllipse.Ratio := 0.7;
    entEllipse.RadPt := new CADImport.DPoint(12, 20, 0);
    entEllipse.Color := Color.Aqua;

    entEllipse.Loaded(cadEditorControl1.Image.Converter);
    cadEditorControl1.Image.Converter.OnCreate(entEllipse);
    cadEditorControl1.Image.CurrentLayout.AddEntity(entEllipse);

    cadEditorControl1.Invalidate();

    //// DRAW a LINE
    entLine := new CADImport.CADLine();

    entLine.Point := new CADImport.DPoint(10, 10, 0);
    entLine.Point1 := new CADImport.DPoint(10, 20, 0);
    entLine.Color := Color.Aqua;

    entLine.Loaded(cadEditorControl1.Image.Converter);
    cadEditorControl1.Image.Converter.OnCreate(entLine);
    cadEditorControl1.Image.CurrentLayout.AddEntity(entLine);

    cadEditorControl1.Invalidate();


end;

method MainForm.MainForm_Load(sender: System.Object; e: System.EventArgs);
begin
    cadEditorControl1.EntityPropertyGridVisible := false;
    //cadEditorControl1.EntityTreeVisible := false;
    cadEditorControl1.ToolsPanelVisible := false;
    cadEditorControl1.BackColor := Color.Brown;
end;

method MainForm.button3_Click(sender: System.Object; e: System.EventArgs);    //// UNDO BUTTON
begin
    
  cadEditorControl1.UndoChangeEntity();
    //cadEditorControl1.Image.Undo();

end;

method MainForm.button4_Click(sender: System.Object; e: System.EventArgs);    //// REDO BUTTON
begin
  cadEditorControl1.RedoChangeEntity();
end;

method MainForm.button2_Click(sender: System.Object; e: System.EventArgs);    //// MODIFY BUTTON: Ellipse is selected before pressing this button

begin
  
    
    //// move the selection (ellipse)
    cadEditorControl1.MoveEntity(50, 50, 30, 30);

    //// DRAW another LINE
    entLine := new CADImport.CADLine();

    entLine.Point := new CADImport.DPoint(10, 10, 0);
    entLine.Point1 := new CADImport.DPoint(50, 10, 0);
    entLine.Color := Color.Aqua;

    entLine.Loaded(cadEditorControl1.Image.Converter);
    cadEditorControl1.Image.Converter.OnCreate(entLine);
    cadEditorControl1.Image.CurrentLayout.AddEntity(entLine);

    cadEditorControl1.Invalidate();
       

end;

end.

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Undo-Redo

Post by support » 10 Feb 2011, 11:26

Hello.
Undo/Redo functionality is the part of CAD Import .NET Professional version. It affect visual entities creating, modifying or deleting. You can test the functionality with EntitiesCreator class or correspond tools from CADEditorControl. For example you can affect your ellipse visually - all visual actions can be undone or redone.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Khyati
Posts: 34
Joined: 08 Feb 2011, 08:55

Re: Undo-Redo

Post by Khyati » 11 Feb 2011, 03:51

Thanks.

Does it mean if I buy the professional version, I would be able to undo-redo the way i described in my last post?

Please do reply after relook on my last post. I've already sent an enquiry email to sales team. This question very much affects our application.

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Undo-Redo

Post by support » 11 Feb 2011, 12:17

Hello Khyati.
The Professional version doesn't allow use undo/redo library functionality with creating or affecting entities programmatically. Such functionality provided for visual entities creation or modification (that is the part of Professional version).
For example ellipse created programmatically can't be undone (deleted). However if you move this ellipse by mouse then such action can be undone. Entity created visually (using EntitiesCreator class) can be undone (deleted). But if you move it programmatically then such action can't be undone.

If you need create and affect entities programmatically with undo/redo possibility then you can create own redo/undo functionality. In this case Standard version will be enough for your task.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply