LEADTOOLS Annotations for WPF and Silverlight (Leadtools.Windows.Annotations assembly)
LEAD Technologies, Inc

GetDefaultPicture Method

Example 





An AnnRubberStampType value that represents the type of the rubber stamp.
Gets the default picture for an AnnRubberStampObject type. .NET support Silverlight support
Syntax
public static AnnPicture GetDefaultPicture( 
   AnnRubberStampType type
)
'Declaration
 
Public Shared Function GetDefaultPicture( _
   ByVal type As AnnRubberStampType _
) As AnnPicture
'Usage
 
Dim type As AnnRubberStampType
Dim value As AnnPicture
 
value = AnnRubberStampObject.GetDefaultPicture(type)
public static AnnPicture GetDefaultPicture( 
   AnnRubberStampType type
)
 function Leadtools.Windows.Annotations.AnnRubberStampObject.GetDefaultPicture( 
   type 
)
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.
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.
Example
Copy CodeCopy Code  
Public Sub AnnRubberStampObject_GetDefaultPicture(ByVal dc As DrawingContext, ByVal filenameNewPicture As String)
   Dim type As AnnRubberStampType = AnnRubberStampType.Important
   ' first draw the original picture for the Important rubber stamp
   Dim rc As Rect = New Rect(0, 0, 240, 120)
   DrawRubberStampPicture(dc, rc, type)
   ' now change the picture to one of our own and redraw it
   Dim img As BitmapSource = New BitmapImage(New Uri(filenameNewPicture))
   Dim picture As AnnPicture = New AnnPicture(img)
   picture.TransparentMode = AnnTransparentMode.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(dc, 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(dc, rc, type)
End Sub

Private Sub DrawRubberStampPicture(ByVal dc As DrawingContext, ByVal rc As Rect, 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
      dc.DrawImage(pic.Image, rc)
   End If
End Sub
public void AnnRubberStampObject_GetDefaultPicture(DrawingContext dc, string filenameNewPicture)
{
   AnnRubberStampType type = AnnRubberStampType.Important;
   // first draw the original picture for the Important rubber stamp
   Rect rc = new Rect(0, 0, 240, 120);
   DrawRubberStampPicture(dc, rc, type);
   // now change the picture to one of our own and redraw it
   BitmapSource img = new BitmapImage(new Uri(filenameNewPicture));
   AnnPicture picture = new AnnPicture(img);
   picture.TransparentMode = AnnTransparentMode.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(dc, 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(dc, rc, type);
}

private void DrawRubberStampPicture(DrawingContext dc, Rect rc, AnnRubberStampType type)
{
   // get the default picture for the rubber stamp
   AnnPicture pic = AnnRubberStampObject.GetDefaultPicture(type);

   // draw it
   if(pic.Image != null)
   {
      dc.DrawImage(pic.Image, rc);
   }
}
public void AnnRubberStampObject_GetDefaultPicture(WriteableBitmap wb, string filenameNewPicture)
{
   AnnRubberStampType type = AnnRubberStampType.Important;
   // first draw the original picture for the Important rubber stamp
   Rect rc = new Rect(0, 0, 240, 120);
   DrawRubberStampPicture(ref wb, rc, type);
   // now change the picture to one of our own and redraw it
   BitmapSource img = new BitmapImage(new Uri(filenameNewPicture));
   AnnPicture picture = new AnnPicture(img);
   picture.TransparentMode = AnnTransparentMode.None;
   AnnRubberStampObject.SetDefaultPicture(type, picture);

   // at this point, all new AnnRubberStampObject with Type = Important will use this new picture
   rc.Y += rc.Height + 10;
   DrawRubberStampPicture(ref wb, rc, type);

   // finally, set the picture back to the original value and redraw it
   AnnRubberStampObject.SetUseOriginalPicture(type, true);
   rc.Y += rc.Height + 10;
   DrawRubberStampPicture(ref wb, rc, type);
}

private void DrawRubberStampPicture(ref WriteableBitmap wb, Rect rc, AnnRubberStampType type)
{
   // get the default picture for the rubber stamp
   AnnPicture pic = AnnRubberStampObject.GetDefaultPicture(type);

   // draw it
   if (pic.Image != null)
   {
      Canvas cvs = new Canvas();
      cvs.RenderTransformOrigin = new Point(rc.X, rc.Y);
      cvs.Width = rc.Width;
      cvs.Height = rc.Height;

      wb = new WriteableBitmap(pic.Image);
      wb.Render(cvs, null);
   }
}
Public Sub AnnRubberStampObject_GetDefaultPicture(ByVal wb As WriteableBitmap, ByVal filenameNewPicture As String)
   Dim type As AnnRubberStampType = AnnRubberStampType.Important
   ' first draw the original picture for the Important rubber stamp
   Dim rc As Rect = New Rect(0, 0, 240, 120)
   DrawRubberStampPicture(wb, rc, type)
   ' now change the picture to one of our own and redraw it
   Dim img As BitmapSource = New BitmapImage(New Uri(filenameNewPicture))
   Dim picture As AnnPicture = New AnnPicture(img)
   picture.TransparentMode = AnnTransparentMode.None
   AnnRubberStampObject.SetDefaultPicture(type, picture)

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

   ' finally, set the picture back to the original value and redraw it
   AnnRubberStampObject.SetUseOriginalPicture(type, True)
   rc.Y += rc.Height + 10
   DrawRubberStampPicture(wb, rc, type)
End Sub

Private Sub DrawRubberStampPicture(ByRef wb As WriteableBitmap, ByVal rc As Rect, 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 cvs As Canvas = New Canvas()
      cvs.RenderTransformOrigin = New Point(rc.X, rc.Y)
      cvs.Width = rc.Width
      cvs.Height = rc.Height

      wb = New WriteableBitmap(pic.Image)
      wb.Render(cvs, Nothing)
   End If
End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

AnnRubberStampObject Class
AnnRubberStampObject Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.