Starts editing the given AnnObject.
public virtual void StartEditing(
Leadtools.Annotations.AnnObject annObject,
bool group
)
Public Overridable Sub StartEditing( _
ByVal annObject As Leadtools.Annotations.AnnObject, _
ByVal group As Boolean _
)
public:
virtual void StartEditing(
Leadtools.Annotations.AnnObject^ annObject,
bool group
)
annObject
An existing AnnObject to edit.
This method is called by the AnnAutomation object in design user mode whenever an object is "selected" (by clicking it with the mouse usually). You can manually start the editing process of an object by calling this method.
If you have object(s) that are currently being edited in this AnnAutomation and you want to either create a new group or add an
Calling StartEditing with group set to true might create a temporary group if more than one object will be selected, this will cause objects to be removed from the container and added into this temporary group. For example, you have a container with 3 objects (a line, a rectangle and an ellipse) and currently nothing is selected in the automation. Now you make the following call:
automation.StartEditing(lineObject, true);
Since this is the first object to be selected, its edit designer will start. If you check automation.Container.Objects.Count it will still be 3. Next you make the following call:
automation.StartEditing(rectangleObject, true);
This will instruct the automation object to add the rectangle to the current selection. The automation will create a temporary group object, add it to the container and them remove the line and ellipse objects from the container and adds them to this new group. If you check automation.Container.Objects.Count it will be 2, the group and the ellipse object. Next you make the following call:
automation.StartEditing(ellipseObject, true);
This will instruct the automation object to add the ellipse to the current selection. The automation will remove the ellipse from the container and adds it to the group. If you check automation.Container.Objects.Count it will be 1, the group
With this information in mind, to select objects in an automation, you can either use SelectAll or use StartEditing with group set to true. However, you should not write code liks this:
foreach(AnnObject obj in automation.Container.Objects)
automation.StartEditing(obj, true);
As noted before, StartEditing might cause objects to be added or removed into the Objects collection. And you should never iterate a collection that will change like that. Instead, to select all (or a group) of objects manually, first get the references to these objects into an array or collection and then iterate through that collection:
// Get a list of the objects to select, in this example, all of them
AnnObject[] toSelectObjects = new AnnObject[automation.Container.Objects.Count];
automation.Container.Objects.CopyTo(toSelectObjects, 0);
// Call StartEditing on all these objects
foreach (AnnObject obj in toSelectObjects)
automation.StartEditing(obj, true);
This example will add a new rectangle object to the active automation of an automation manager. It will then "select" this object and make it ready for editing.
using Leadtools;
using Leadtools.Annotations;
using Leadtools.WinForms;
using Leadtools.Drawing;
public void AnnAutomation_StartEditing(AnnAutomationManager manager)
{
// find the active automation
AnnAutomation automation = null;
for (int index = 0; index < manager.Automations.Count && automation == null; index++)
{
if (manager.Automations[index].Active)
automation = manager.Automations[index];
}
if (automation != null)
{
// add a new rectangle object to this automation
AnnRectangleObject rectObj = new AnnRectangleObject();
rectObj.Bounds = new AnnRectangle(100, 100, 200, 200, AnnUnit.Pixel);
rectObj.Pen = new AnnPen(Color.Blue, new AnnLength(2, AnnUnit.Pixel));
rectObj.Brush = new AnnSolidBrush(Color.Yellow);
// surround the changes to the automation by an undo
automation.BeginUndo();
automation.Container.Objects.Add(rectObj);
// "select" this rectangle and make it ready for editing
automation.StartEditing(rectObj, false);
automation.EndUndo();
}
}
Imports Leadtools
Imports Leadtools.Annotations
Imports Leadtools.WinForms
Imports Leadtools.Drawing
Public Sub AnnAutomation_StartEditing(ByVal manager As AnnAutomationManager)
' find the active automation
Dim automation As AnnAutomation = Nothing
Dim index As Integer = 0
Do While index < manager.Automations.Count AndAlso automation Is Nothing
If manager.Automations(index).Active Then
automation = manager.Automations(index)
End If
index += 1
Loop
If Not automation Is Nothing Then
' add a new rectangle object to this automation
Dim rectObj As AnnRectangleObject = New AnnRectangleObject()
rectObj.Bounds = New AnnRectangle(100, 100, 200, 200, AnnUnit.Pixel)
rectObj.Pen = New AnnPen(Color.Blue, New AnnLength(2, AnnUnit.Pixel))
rectObj.Brush = New AnnSolidBrush(Color.Yellow)
' surround the changes to the automation by an undo
automation.BeginUndo()
automation.Container.Objects.Add(rectObj)
' "select" this rectangle and make it ready for editing
automation.StartEditing(rectObj, False)
automation.EndUndo()
End If
End Sub
Products |
Support |
Feedback: StartEditing Method - Leadtools.Annotations |
Introduction |
Help Version 19.0.2017.6.20
|
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.