Leadtools.Annotations Requires Document/Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.10.31
GetDefaultPicture Method
See Also  Example
Leadtools.Annotations Namespace > AnnRubberStampObject Class : GetDefaultPicture Method




type
An AnnRubberStampType value that represents the type of the rubber stamp.
Gets the default picture for an AnnRubberStampObject type.

Syntax

Visual Basic (Declaration) 
Public Shared Function GetDefaultPicture( _
   ByVal type As AnnRubberStampType _
) As AnnPicture
Visual Basic (Usage)Copy Code
Dim type As AnnRubberStampType
Dim value As AnnPicture
 
value = AnnRubberStampObject.GetDefaultPicture(type)
C# 
public static AnnPicture GetDefaultPicture( 
   AnnRubberStampType type
)
Managed Extensions for C++ 
public: static AnnPicture* GetDefaultPicture( 
   AnnRubberStampType type
) 
C++/CLI 
public:
static AnnPicture^ GetDefaultPicture( 
   AnnRubberStampType type
) 

Parameters

type
An AnnRubberStampType value that represents the type of the rubber stamp.

Return Value

An AnnPicture class that defines the picture for the AnnRubberStampType specified by type.

Example

This sample does the following: <list type="number"> <item><description>displays the default rubberstamp picture (old style)</description></item> <item><description>displays the default rubberstamp picture and displays it</description></item> <item><description>restores original rubberstamp picture and displays</description></item> <item><description>changes to new style and displays</description></item> </list>

Visual BasicCopy Code
Public Sub AnnRubberStampObject_GetDefaultPicture(ByVal graphics As Graphics, ByVal filenameNewPicture As String)
   Dim useNewPicture As Boolean = AnnRubberStampObject.GetUseNewPicture(AnnRubberStampType.Important)
   Dim type As AnnRubberStampType = AnnRubberStampType.Important
   ' first draw the original picture for the Important rubber stamp
   Dim rc As Rectangle = New Rectangle(0, 0, 240, 120)
   DrawRubberStampPicture(graphics, rc, type)
   ' now change the picture to one of our own and redraw it
   Dim img As Image = Image.FromFile(filenameNewPicture)
   Dim picture As AnnPicture = New AnnPicture(img)
   picture.TransparentMode = AnnPictureTransparentMode.None
   AnnRubberStampObject.SetDefaultPicture(type, picture)

   ' at this point, all new AnnRubberStampObject with Type = Important will use this new picture
   rc.Offset(0, rc.Height + 10)
   DrawRubberStampPicture(graphics, rc, type)

   ' finally, set the picture back to the original value and redraw it
   AnnRubberStampObject.SetUseOriginalPicture(type, True)
   rc.Offset(0, rc.Height + 10)
   DrawRubberStampPicture(graphics, rc, type)

   '
   AnnRubberStampObject.SetUseNewPicture(AnnRubberStampType.Important, (Not useNewPicture))
   rc.Offset(0, rc.Height + 10)
   DrawRubberStampPicture(graphics, rc, type)
End Sub

Private Sub DrawRubberStampPicture(ByVal graphics As Graphics, ByVal rc As Rectangle, ByVal type As AnnRubberStampType)
   ' get the default picture for the rubber stamp
   Dim pic As AnnPicture = AnnRubberStampObject.GetDefaultPicture(type)

   ' draw it
   If Not pic.Image Is Nothing Then
      Dim ia As ImageAttributes = pic.ImageAttributes
      If Not ia Is Nothing Then
         graphics.DrawImage(pic.Image, rc, 0, 0, pic.Image.Width, pic.Image.Height, GraphicsUnit.Pixel, ia)
         ia.Dispose()
      Else
         If rc.Width > 1 AndAlso rc.Height > 1 Then
            graphics.DrawImage(pic.Image, rc)
         End If
      End If
   End If
End Sub
C#Copy Code
public void AnnRubberStampObject_GetDefaultPicture(Graphics graphics, string filenameNewPicture) 

   bool useNewPicture = AnnRubberStampObject.GetUseNewPicture(AnnRubberStampType.Important); 
   AnnRubberStampType type = AnnRubberStampType.Important; 
   // first draw the original picture for the Important rubber stamp 
   Rectangle rc = new Rectangle(0, 0, 240, 120); 
   DrawRubberStampPicture(graphics, rc, type); 
   // now change the picture to one of our own and redraw it 
   Image img = Image.FromFile(filenameNewPicture); 
   AnnPicture picture = new AnnPicture(img); 
   picture.TransparentMode = AnnPictureTransparentMode.None; 
   AnnRubberStampObject.SetDefaultPicture(type, picture); 
 
   // at this point, all new AnnRubberStampObject with Type = Important will use this new picture 
   rc.Offset(0, rc.Height + 10); 
   DrawRubberStampPicture(graphics, rc, type); 
 
   // finally, set the picture back to the original value and redraw it 
   AnnRubberStampObject.SetUseOriginalPicture(type, true); 
   rc.Offset(0, rc.Height + 10); 
   DrawRubberStampPicture(graphics, rc, type); 
 
   // 
   AnnRubberStampObject.SetUseNewPicture(AnnRubberStampType.Important, !useNewPicture); 
   rc.Offset(0, rc.Height + 10); 
   DrawRubberStampPicture(graphics, rc, type); 

 
private void DrawRubberStampPicture(Graphics graphics, Rectangle rc, AnnRubberStampType type) 

   // get the default picture for the rubber stamp 
   AnnPicture pic = AnnRubberStampObject.GetDefaultPicture(type); 
 
   // draw it 
   if(pic.Image != null) 
   { 
      ImageAttributes ia = pic.ImageAttributes; 
      if(ia != null) 
      { 
         graphics.DrawImage(pic.Image, rc, 0, 0, pic.Image.Width, pic.Image.Height, GraphicsUnit.Pixel, ia); 
         ia.Dispose(); 
      } 
      else 
      { 
         if(rc.Width > 1 && rc.Height >1) 
            graphics.DrawImage(pic.Image, rc); 
      } 
   } 
}

Remarks

Use the SetDefaultPicture method to change the default picture used by the AnnRubberStampObject objects. Use the GetUseOriginalPicture and SetUseOriginalPicture methods to control whether an AnnRubberStampObject will use the default or original picture for a certain type.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Leadtools.Annotations requires a Document or Medical toolkit license and unlock key. For more information, refer to: Raster Pro/Document/Medical Features