LEADTOOLS Annotations for WPF and Silverlight (Leadtools.Windows.Annotations assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.31
ObjectsDirty Property
See Also 
Leadtools.Windows.Annotations Namespace > AnnAutomation Class : ObjectsDirty Property



The ObjectsDirty Property supports WPF/Silverlight.

The ObjectsDirty Property is available in LEADTOOLS Document and Medical Imaging toolkits.

Gets or sets a value to determine whether one or more objects in this AnnAutomation have been changed. Supported in Silverlight, Windows Phone 7

Syntax

Visual Basic (Declaration) 
Public Overridable Property ObjectsDirty As Boolean
Visual Basic (Usage)Copy Code
Dim instance As AnnAutomation
Dim value As Boolean
 
instance.ObjectsDirty = value
 
value = instance.ObjectsDirty
C# 
public virtual bool ObjectsDirty {get; set;}
C++/CLI 
public:
virtual property bool ObjectsDirty {
   bool get();
   void set (    bool value);
}

Property Value

true if one or more objects in this AnnAutomation have been changed; otherwise false.

Example

Visual BasicCopy Code
Private Sub AnnAutomation_ObjectsDirty(ByVal automation As AnnAutomation)
   ' make sure no objects are selected and clear the object dirty flag
   automation.SelectNone()
   automation.ObjectsDirty = False
   ' test
   DirtyTest(automation)

   ' add a new object
   Dim rectObj As AnnRectangleObject = New AnnRectangleObject()
   rectObj.Rect = New Rect(100, 100, 200, 200)

   rectObj.Stroke = Colors.Blue
   rectObj.StrokeThickness = 2.0
   rectObj.Fill = Colors.Yellow
   automation.Container.Children.Add(rectObj)

   ' since we added the object manually, we need to update the ObjectsDirty property ourselves
   automation.ObjectsDirty = True

   automation.StartEditing(rectObj, False)

   ' test
   DirtyTest(automation)

   ' lock the object
   automation.Lock()

   ' test
   DirtyTest(automation)

   ' unlock
   automation.Unlock()

   ' test
   DirtyTest(automation)

   ' delete
   automation.Delete()

   ' test
   DirtyTest(automation)
End Sub

Private Sub DirtyTest(ByVal automation As AnnAutomation)
   ' see if the objects are dirty (changed)
   If automation.ObjectsDirty Then
      ' yes
      MessageBox.Show("Object(s) have been changed.  We are going to clear the flag here")
      automation.ObjectsDirty = False
   Else
      MessageBox.Show("No object has been changed")
   End If
End Sub
C#Copy Code
private void AnnAutomation_ObjectsDirty(AnnAutomation automation)
{
   // make sure no objects are selected and clear the object dirty flag
   automation.SelectNone();
   automation.ObjectsDirty = false;
   // test
   DirtyTest(automation);

   // add a new object
   AnnRectangleObject rectObj = new AnnRectangleObject();
   rectObj.Rect = new Rect(100, 100, 200, 200);
   rectObj.Stroke = Colors.Blue;
   rectObj.Fill = Colors.Yellow;

   rectObj.StrokeThickness = 2.0;
   automation.Container.Children.Add(rectObj);

   // since we added the object manually, we need to update the ObjectsDirty property ourselves
   automation.ObjectsDirty = true;

   automation.StartEditing(rectObj, false);

   // test
   DirtyTest(automation);

   // lock the object
   automation.Lock();

   // test
   DirtyTest(automation);

   // unlock
   automation.Unlock();

   // test
   DirtyTest(automation);

   // delete
   automation.Delete();

   // test
   DirtyTest(automation);
}

private void DirtyTest(AnnAutomation automation)
{
   // see if the objects are dirty (changed)
   if(automation.ObjectsDirty)
   {
      // yes
      MessageBox.Show("Object(s) have been changed.  We are going to clear the flag here");
      automation.ObjectsDirty = false;
   }
   else
      MessageBox.Show("No object has been changed");
}
SilverlightCSharpCopy Code
private void AnnAutomation_ObjectsDirty(AnnAutomation automation)
{
   // make sure no objects are selected and clear the object dirty flag
   automation.SelectNone();
   automation.ObjectsDirty = false;
   // test
   DirtyTest(automation);

   // add a new object
   AnnRectangleObject rectObj = new AnnRectangleObject();
   rectObj.Rect = new Rect(100, 100, 200, 200);
   rectObj.Stroke = Colors.Blue;
   rectObj.Fill = Colors.Yellow;

   rectObj.StrokeThickness = 2.0;
   automation.Container.Children.Add(rectObj);

   // since we added the object manually, we need to update the ObjectsDirty property ourselves
   automation.ObjectsDirty = true;

   automation.StartEditing(rectObj, false);

   // test
   DirtyTest(automation);

   // lock the object
   automation.Lock();

   // test
   DirtyTest(automation);

   // unlock
   automation.Unlock();

   // test
   DirtyTest(automation);

   // delete
   automation.Delete();

   // test
   DirtyTest(automation);
}

private void DirtyTest(AnnAutomation automation)
{
   // see if the objects are dirty (changed)
   if(automation.ObjectsDirty)
   {
      // yes
      MessageBox.Show("Object(s) have been changed.  We are going to clear the flag here");
      automation.ObjectsDirty = false;
   }
   else
      MessageBox.Show("No object has been changed");
}
SilverlightVBCopy Code
Private Sub AnnAutomation_ObjectsDirty(ByVal automation As AnnAutomation)
   ' make sure no objects are selected and clear the object dirty flag
   automation.SelectNone()
   automation.ObjectsDirty = False
   ' test
   DirtyTest(automation)

   ' add a new object
   Dim rectObj As AnnRectangleObject = New AnnRectangleObject()
   rectObj.Rect = New Rect(100, 100, 200, 200)
   rectObj.Stroke = Colors.Blue
   rectObj.Fill = Colors.Yellow

   rectObj.StrokeThickness = 2.0
   automation.Container.Children.Add(rectObj)

   ' since we added the object manually, we need to update the ObjectsDirty property ourselves
   automation.ObjectsDirty = True

   automation.StartEditing(rectObj, False)

   ' test
   DirtyTest(automation)

   ' lock the object
   automation.Lock()

   ' test
   DirtyTest(automation)

   ' unlock
   automation.Unlock()

   ' test
   DirtyTest(automation)

   ' delete
   automation.Delete()

   ' test
   DirtyTest(automation)
End Sub

Private Sub DirtyTest(ByVal automation As AnnAutomation)
   ' see if the objects are dirty (changed)
   If automation.ObjectsDirty Then
      ' yes
      MessageBox.Show("Object(s) have been changed.  We are going to clear the flag here")
      automation.ObjectsDirty = False
   Else
      MessageBox.Show("No object has been changed")
   End If
End Sub

Remarks

The objects in the automation can change in multiple ways: calling most of the methods of this AnnAutomation will usually change the objects. For example, calling the AnnAutomation.Flip or AnnAutomation.Delete methods will change this value. Adding new objects to this AnnAutomation will also set the value of this property to true as will deleting objects.

You should check the value of this property in your application and save the objects back to the annotation file if the value of this property is true. You should set the value of this property to false after you do so to indicate that the objects are up to date.

The AnnAutomation.BeforeObjectChanged event is fired before any object is about to change.

The AnnAutomation.AfterObjectChanged event is fired after any object has been changed. Internally, when the AnnAutomation sets the value of the ObjectsDirty property to true the AnnAutomation.AfterObjectChanged event fires.

The value of this property gets updated only when the objects are changed by calling one of the AnnAutomation methods or by the user interface. If you add or edit or delete objects manually through code (for example, by adding objects manually to the Container), the value of this property will not be updated. You need to set the value of the ObjectsDirty property to true manually as well in this case.

Requirements

Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)

See Also

ObjectsDirty requires a Document/Medical product license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features and Unlocking Special LEAD Features.