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.