Skip to content

Commit 409388a

Browse files
committed
feedbacks addressed
1 parent a64b7c8 commit 409388a

File tree

3 files changed

+24
-31
lines changed

3 files changed

+24
-31
lines changed
Loading

Annotations/AddStandardStampsinToolBar/MainWindow.xaml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,6 @@
88
mc:Ignorable="d"
99
Title="MainWindow" Height="450" Width="800">
1010
<Grid>
11-
<Grid.RowDefinitions>
12-
<RowDefinition Height="50" />
13-
<RowDefinition Height="*" />
14-
</Grid.RowDefinitions>
15-
<StackPanel Grid.Row="0" Orientation="Horizontal">
16-
<Button x:Name="addStamp"
17-
Height="30"
18-
Width="100"
19-
Click="addStamp_Click"
20-
Margin="10">
21-
AddStamp
22-
</Button>
23-
</StackPanel>
24-
<PdfViewer:PdfViewerControl Grid.Row="1" Name="pdfViewer"/>
11+
<PdfViewer:PdfViewerControl Name="pdfViewer"/>
2512
</Grid>
2613
</Window>

Annotations/AddStandardStampsinToolBar/MainWindow.xaml.cs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,29 @@ public MainWindow()
3333
path = "../../../Data/";
3434
#endif
3535
pdfViewer.Load(System.IO.Path.Combine(path, "F#.pdf"));
36+
pdfViewer.DocumentLoaded += PdfViewer_DocumentLoaded;
3637
}
37-
/// <summary>
38-
/// A button click event that creates a stamp from a local image and adds the standard stamp to the toolbar.
39-
/// </summary>
40-
/// <param name="sender">The source of the event.</param>
41-
/// <param name="e">Event data associated with the click event.</param>
42-
private void addStamp_Click(object sender, RoutedEventArgs e)
43-
{
44-
// Clear the existing standard stamps if it is not needed.
45-
pdfViewer.ToolbarSettings.StampAnnotations.Clear();
46-
//Load the custom image from the local disk.
47-
System.Windows.Controls.Image image = new System.Windows.Controls.Image();
48-
image.Source = new BitmapImage(new Uri(System.IO.Path.Combine(path,"Adventure_Cycle.jpg"), UriKind.RelativeOrAbsolute));
49-
//Create a new standard stamp from the image.
50-
PdfStampAnnotation newStandardStamp = new PdfStampAnnotation(image);
51-
//Add the custom stamp in the toolbar.
52-
pdfViewer.ToolbarSettings.StampAnnotations.Add(newStandardStamp);
53-
}
38+
39+
/// <summary>
40+
/// Document loaded event that handles the creation of stamps from the local images and adds the standard stamps to the toolbar.
41+
/// </summary>
42+
/// <param name="sender">Source of the event</param>
43+
/// <param name="args">Event arguments</param>
44+
private void PdfViewer_DocumentLoaded(object sender, EventArgs args)
45+
{
46+
// Clear the existing standard stamps if it is not needed.
47+
pdfViewer.ToolbarSettings.StampAnnotations.Clear();
48+
//Load the custom image from the local disk.
49+
System.Windows.Controls.Image image1 = new System.Windows.Controls.Image();
50+
image1.Source = new BitmapImage(new Uri(System.IO.Path.Combine(path, "Adventure_Cycle.jpg"), UriKind.RelativeOrAbsolute));
51+
System.Windows.Controls.Image image2 = new System.Windows.Controls.Image();
52+
image2.Source = new BitmapImage(new Uri(System.IO.Path.Combine(path, "Confidential.png"), UriKind.RelativeOrAbsolute));
53+
//Create a new standard stamp from the image.
54+
PdfStampAnnotation newStandardStamp1 = new PdfStampAnnotation(image1);
55+
PdfStampAnnotation newStandardStamp2 = new PdfStampAnnotation(image2);
56+
//Add the custom stamp in the toolbar.
57+
pdfViewer.ToolbarSettings.StampAnnotations.Add(newStandardStamp1);
58+
pdfViewer.ToolbarSettings.StampAnnotations.Add(newStandardStamp2 );
59+
}
5460
}
5561
}

0 commit comments

Comments
 (0)