Exemplo n.º 1
0
 /// <summary>
 /// Initializes static members of the <see cref="MainWindow"/> class.
 /// </summary>
 static MainWindow()
 {
     WpfDemoHelperMethods.PopulateDecoders(RegisteredDecoders.Decoders);
 }
Exemplo n.º 2
0
        private void FileCmdExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            RoutedCommand rc = e.Command as RoutedCommand;

            if (rc == null)
            {
                return;
            }

            switch (rc.Name)
            {
            case "Open":
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = WpfDemoHelperMethods.CreateDialogFilter(true);

                if (dlg.ShowDialog().Value)
                {
                    this.AnnotationViewer.Open(dlg.FileName, 0, null);
                }

                break;

            case "SaveAs":
                SaveFileDialog save = new SaveFileDialog();
                save.Filter = "JPEG (*.jpg)|*.jpg|TIFF (*.tif)|*.tif|PDF (*.pdf)|*.pdf";
                if (save.ShowDialog().Value)
                {
                    if (save.FilterIndex == 1)
                    {
                        SaveImage(save.FileName, new JpegEncoder());
                    }
                    else if (save.FilterIndex == 2)
                    {
                        SaveImage(save.FileName, new TiffEncoder());
                    }
                    else
                    {
                        if (AtalaImage.Edition == LicenseEdition.Document)
                        {
                            SaveImage(save.FileName, new PdfEncoder());
                            SavePdfAnnotations(save.FileName);
                        }
                        else
                        {
                            MessageBox.Show("A 'DotImage Document Imaging' license is required to save as PDF.", "License Required", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                    }
                }

                break;

            case "Print":
                PrintDialog pdlg = new PrintDialog();
                if (pdlg.ShowDialog().Value)
                {
                    PageMediaSize sz = pdlg.PrintTicket.PageMediaSize;
                    pdlg.PrintVisual(this.AnnotationViewer.CreateVisual(new Size(sz.Width.HasValue ? sz.Width.Value : 0, sz.Height.HasValue ? sz.Height.Value : 0), _printScaleMode, new Thickness(10)), "WPF Annotation Printing");
                }

                break;
            }
        }