@@ -21,29 +21,31 @@ namespace AddingStandardStampsInToolBar
21
21
/// </summary>
22
22
public partial class MainWindow : Window
23
23
{
24
+ string path ;
24
25
public MainWindow ( )
25
26
{
26
27
InitializeComponent ( ) ;
27
28
this . WindowState = WindowState . Maximized ;
28
- //Loads the Document
29
+ //Setting the path based on the framework
29
30
#if NETFRAMEWORK
30
- pdfViewer . Load ( "../../Data/F#.pdf" ) ;
31
+ path = "../../Data/" ;
31
32
#else
32
- pdfViewer . Load ( "../../../Data/F#.pdf" ) ;
33
+ path = "../../../Data/" ;
33
34
#endif
35
+ pdfViewer . Load ( System . IO . Path . Combine ( path , "F#.pdf" ) ) ;
34
36
}
35
-
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>
36
42
private void addStamp_Click ( object sender , RoutedEventArgs e )
37
43
{
38
44
// Clear the existing standard stamps if it is not needed.
39
45
pdfViewer . ToolbarSettings . StampAnnotations . Clear ( ) ;
40
46
//Load the custom image from the local disk.
41
47
System . Windows . Controls . Image image = new System . Windows . Controls . Image ( ) ;
42
- #if NETFRAMEWORK
43
- image . Source = new BitmapImage ( new Uri ( @"../../Data/Adventure_Cycle.jpg" , UriKind . RelativeOrAbsolute ) ) ;
44
- #else
45
- image . Source = new BitmapImage ( new Uri ( @"../../../Data/Adventure_Cycle.jpg" , UriKind . RelativeOrAbsolute ) ) ;
46
- #endif
48
+ image . Source = new BitmapImage ( new Uri ( System . IO . Path . Combine ( path , "Adventure_Cycle.jpg" ) , UriKind . RelativeOrAbsolute ) ) ;
47
49
//Create a new standard stamp from the image.
48
50
PdfStampAnnotation newStandardStamp = new PdfStampAnnotation ( image ) ;
49
51
//Add the custom stamp in the toolbar.
0 commit comments