Beispiel #1
0
        private RadDocument LoadDocumentToInsert()
        {
            RadDocument document = null;

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Word Documents (*.docx)|*.docx|All Files (*.*)|*.*";

            if (ofd.ShowDialog() == true)
            {
                string extension;
#if SILVERLIGHT
                extension = ofd.File.Extension.ToLower();
#else
                extension = Path.GetExtension(ofd.SafeFileName).ToLower();
#endif

                IDocumentFormatProvider provider = DocumentFormatProvidersManager.GetProviderByExtension(extension);

                Stream stream;
#if SILVERLIGHT
                stream = ofd.File.OpenRead();
#else
                stream = ofd.OpenFile();
#endif
                using (stream)
                {
                    document = provider.Import(stream);
                }
            }

            return(document);
        }
        private void ExportButton_Click(object sender, RoutedEventArgs e)
        {
            IDocumentFormatProvider provider = this.provider;
            SaveFileDialog          dialog   = new SaveFileDialog();

            if ((provider as DocxFormatProvider) != null)
            {
                dialog.DefaultExt = "docx";
                dialog.Filter     = "Word document (docx) | *.docx |All Files (*.*) | *.*";
            }
            else if ((provider as PdfFormatProvider) != null)
            {
                dialog.DefaultExt = "pdf";
                dialog.Filter     = "Pdf document (pdf) | *.pdf |All Files (*.*) | *.*";
            }
            else if ((provider as HtmlFormatProvider) != null)
            {
                dialog.DefaultExt = "html";
                dialog.Filter     = "Html document (html) | *.html |All Files (*.*) | *.*";
            }
            else
            {
                MessageBox.Show("Unknown output format!");
                return;
            }

            SaveFile(dialog, provider, document);
            (this.Parent as RadWindow).Close();
        }
Beispiel #3
0
        private void OpenDocument()
        {
            using (OpenFileDialog openDialog = new OpenFileDialog())
            {
                openDialog.Filter = "Word Documents (*.docx)|*.docx|Web Pages (*.htm,*.html)|*.htm;*.html|Rich Text Format (*.rtf)|*.rtf|Text Files (*.txt)|*.txt|XAML Files (*.xaml)|*.xaml";

                if (openDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string extension = Path.GetExtension(openDialog.SafeFileName).ToLower();

                    IDocumentFormatProvider provider = GetProviderByExtension(extension);

                    if (provider == null)
                    {
                        RadMessageBox.Show("Unable to find format provider for extension " + extension, "Error");
                        return;
                    }

                    using (Stream stream = openDialog.OpenFile())
                    {
                        RadDocument document = provider.Import(stream);
                        this.DetachDocument(this.radRichTextBox1.Document);
                        this.radRichTextBox1.Document = document;
                        this.AttachDocument(document);
                        document.LayoutMode = DocumentLayoutMode.Paged;
                    }
                }

                this.radRichTextBox1.Focus();
            }
        }
        public PrintPreview(RadDocument document, IDocumentFormatProvider provider)
        {
            InitializeComponent();
            this.document = document;
            this.provider = provider;

            this.RichTextBox.Document = this.document;
        }
Beispiel #5
0
 private void LoadDocument()
 {
     using (Stream stream = Application.GetResourceStream(GetResourceUri(SampleDocumentPath)).Stream)
     {
         IDocumentFormatProvider xamlProvider = DocumentFormatProvidersManager.GetProviderByExtension(".xaml");
         this.radRichTextBox.Document = xamlProvider.Import(stream);
     }
 }
        public PrintPreview(RadDocument document, IDocumentFormatProvider provider)
        {
            InitializeComponent();
            this.document = document;
            this.provider = provider;

            this.RichTextBox.Document = this.document;
        }
Beispiel #7
0
 private string GetFilter(IDocumentFormatProvider formatProvider)
 {
     return
         (formatProvider.FilesDescription +
          " (" +
          string.Join(", ", formatProvider.SupportedExtensions.Select(ext => "*" + ext).ToArray()) +
          ")|" +
          string.Join(";", formatProvider.SupportedExtensions.Select(ext => "*" + ext).ToArray()));
 }
        private void ExecuteButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(this.fromPathTextBox.Text))
            {
                System.Windows.MessageBox.Show("From path is not specified.");
                return;
            }

            if (string.IsNullOrEmpty(this.toPathTextBox.Text))
            {
                System.Windows.MessageBox.Show("To path is not specified.");
                return;
            }

            if (this.toFormatProviderComboBox.SelectedItem == null)
            {
                System.Windows.MessageBox.Show("Please specify desired format provider.");
                return;
            }

            this.toPath = this.toPathTextBox.Text;

            IDocumentFormatProvider fromFormatProvider = (this.fromFormatProviderComboBox.SelectedItem as FormatProviderPair).FormatProvider;
            IDocumentFormatProvider toFormatProvider   = (this.toFormatProviderComboBox.SelectedItem as FormatProviderPair).FormatProvider;

            DirectoryInfo directoryInfo = new DirectoryInfo(this.fromPathTextBox.Text);

            FileInfo[] fileInfoArray = directoryInfo.GetFiles();

            LinkedList <Task> tasks = new LinkedList <Task>();

            foreach (FileInfo fileInfo in fileInfoArray)
            {
                if (fromFormatProvider != null && !fromFormatProvider.SupportedExtensions.Contains(fileInfo.Extension))
                {
                    continue;
                }

                Action <object>  action           = new Action <object>(this.ConvertFiles);
                ThreadParameters threadParameters = new ThreadParameters(fileInfo, fromFormatProvider, toFormatProvider);

                Task task = new Task(action, threadParameters);
                tasks.AddLast(task);
                task.Start();
            }

            try
            {
                Task.WaitAll(tasks.ToArray());

                System.Windows.MessageBox.Show("All files are converted.");
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Exception occur during convertion of file: " + ex.Message);
            }
        }
 void radRichTextBox_CommandExecuted(object sender, CommandExecutedEventArgs e)
 {
     if (e.Command is NewDocumentCommand)
     {
         // When a new document is opened the values of the path and the provider should be cleared.
         this.path = null;
         this.provider = null;
     }
 }
Beispiel #10
0
 void radRichTextBox_CommandExecuted(object sender, CommandExecutedEventArgs e)
 {
     if (e.Command is NewDocumentCommand)
     {
         // When a new document is opened the values of the path and the provider should be cleared.
         this.path     = null;
         this.provider = null;
     }
 }
Beispiel #11
0
        private void OpenFile(object parameter)
        {
            RadOpenFileDialog ofd = new RadOpenFileDialog();

            string stringParameter = parameter as string;

            if (stringParameter != null && stringParameter.Contains("|"))
            {
                ofd.Filter = stringParameter;
            }
            else
            {
                string filter = string.Join("|", DocumentFormatProvidersManager.FormatProviders.Where(fp => fp.CanImport)
                                            .OrderBy(fp => fp.Name)
                                            .Select(fp => FileHelper.GetFilter(fp))
                                            .ToArray()) + "|All Files|*.*";
                ofd.Filter = filter;
            }

            if (ofd.ShowDialog() == true)
            {
                string extension;
                extension = Path.GetExtension(ofd.FileName).ToLower();

                IDocumentFormatProvider provider =
                    DocumentFormatProvidersManager.GetProviderByExtension(extension);

                if (provider == null)
                {
                    MessageBox.Show(LocalizationManager.GetString("Documents_OpenDocumentCommand_UnsupportedFileFormat"));
                    return;
                }

                try
                {
                    Stream stream;
                    stream = ofd.OpenFile();
                    using (stream)
                    {
                        RadDocument document = provider.Import(stream);
                        this.radRichTextBox.Document = document;
                        this.SetDocumentName(ofd.FileName);
                    }
                }
                catch (IOException)
                {
                    MessageBox.Show(LocalizationManager.GetString("Documents_OpenDocumentCommand_TheFileIsLocked"));
                }
                catch (Exception)
                {
                    MessageBox.Show(LocalizationManager.GetString("Documents_OpenDocumentCommand_TheFileCannotBeOpened"));
                }
            }
        }
Beispiel #12
0
        private void AutoSave(object sender, EventArgs e)
        {
            IDocumentFormatProvider provider = GetProviderByExtension(".html");

            using (Stream output = new FileStream(path, FileMode.Create))
            {
                provider.Export(this.radRichTextBox1.Document, output);
            }
            ParentControl.Update();
            this.radRichTextBox1.Focus();
        }
Beispiel #13
0
        private void SaveDocument(string format)
        {
            using (SaveFileDialog saveDialog = new SaveFileDialog())
            {
                if (format == "docx")
                {
                    saveDialog.Filter = "Word Document (*.docx)|*.docx";
                }
                else if (format == "rtf")
                {
                    saveDialog.Filter = "Rich Text Format (*.rtf)|*.rtf";
                }
                else if (format == "html")
                {
                    saveDialog.Filter = "Web Page (*.html)|*.html";
                }
                else if (format == "xaml")
                {
                    saveDialog.Filter = "XAML File (*.xaml)|*.xaml";
                }
                else if (format == "txt")
                {
                    saveDialog.Filter = "Text File (*.txt)|*.txt";
                }
                else if (format == "pdf")
                {
                    saveDialog.Filter = "PDF File (*.pdf)|*.pdf";
                }
                else
                {
                    saveDialog.Filter = "Word Document (*.docx)|*.docx|PDF File (*.pdf)|*.pdf|Web Page (*.html)|*.html|Rich Text Format (*.rtf)|*.rtf|Text File (*.txt)|*.txt|XAML File (*.xaml)|*.xaml";
                }

                if (saveDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string extension = System.IO.Path.GetExtension(saveDialog.FileName);

                    IDocumentFormatProvider provider = GetProviderByExtension(extension);

                    if (provider == null)
                    {
                        RadMessageBox.Show("Unable to find format provider for extension " + extension, "Error");
                        return;
                    }

                    using (Stream output = saveDialog.OpenFile())
                    {
                        provider.Export(this.radRichTextBox1.Document, output);
                    }
                }

                this.radRichTextBox1.Focus();
            }
        }
Beispiel #14
0
        private void GetProvider(string extension)
        {
            this.provider = DocumentFormatProvidersManager.GetProviderByExtension(extension);

            if (this.provider == null)
            {
                MessageBox.Show(LocalizationManager.GetString("Documents_SaveCommand_UnsupportedFileFormat"));
            }

            if (this.provider is IConfigurablePdfFormatProvider)
            {
                IConfigurablePdfFormatProvider pdfFormatProvider = (IConfigurablePdfFormatProvider)this.provider;
                pdfFormatProvider.ExportSettings.CommentsExportMode =
                    this.radRichTextBox.ShowComments ? PdfCommentsExportMode.NativePdfAnnotations : PdfCommentsExportMode.None;
            }
        }
Beispiel #15
0
        private static void ShowPrintPreviewDialog(RadDocument document, IDocumentFormatProvider provider)
        {
            PrintPreview printPreview = new PrintPreview(document, provider);

            RadWindow window = new RadWindow();

            window.Content = printPreview;
            window.Header  = "Print Preview";
            window.Height  = 400;
            window.Width   = 500;
#if SILVERLIGHT
            window.WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterScreen;
#else
            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
#endif
            window.Show();
        }
Beispiel #16
0
        private void OpenButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd    = new OpenFileDialog();
            string         filter = string.Join("|", DocumentFormatProvidersManager.FormatProviders
                                                .Where(fp => fp.CanImport)
                                                .OrderBy(fp => fp.Name)
                                                .Select(fp => this.GetFilter(fp))
                                                .ToArray()) + "|All Files|*.*";

            ofd.Filter = filter;

            if (ofd.ShowDialog() == true)
            {
                string extension = Path.GetExtension(ofd.SafeFileName).ToLower();

                this.provider = DocumentFormatProvidersManager.GetProviderByExtension(extension);

                if (this.provider == null)
                {
                    MessageBox.Show(LocalizationManager.GetString("Documents_OpenDocumentCommand_UnsupportedFileFormat"));
                    return;
                }

                try
                {
                    Stream stream;
                    stream = ofd.OpenFile();
                    using (stream)
                    {
                        RadDocument document = provider.Import(stream);
                        this.radRichTextBox.Document = document;

                        // Preserve the file name to use it when saving
                        this.path = ofd.FileName;
                    }
                }
                catch (IOException ex)
                {
                    MessageBox.Show(LocalizationManager.GetString("Documents_OpenDocumentCommand_TheFileIsLocked"));
                }
                catch (Exception ex)
                {
                    MessageBox.Show(LocalizationManager.GetString("Documents_OpenDocumentCommand_TheFileCannotBeOpened"));
                }
            }
        }
 private static void SaveFile(SaveFileDialog dialog, IDocumentFormatProvider provider, RadDocument document)
 {
     var result = dialog.ShowDialog();
     if (result == true)
     {
         try
         {
             using (var stream = dialog.OpenFile())
             {
                 provider.Export(document, stream);
             }
         }
         catch (IOException ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
        private static void SaveFile(SaveFileDialog dialog, IDocumentFormatProvider provider, RadDocument document)
        {
            var result = dialog.ShowDialog();

            if (result == true)
            {
                try
                {
                    using (var stream = dialog.OpenFile())
                    {
                        provider.Export(document, stream);
                    }
                }
                catch (IOException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
        public string ExportContent(string defaultExtension,
                                    string filter,
                                    IDocumentFormatProvider formatProvider)
        {
            var saveFileDialog = new Microsoft.Win32.SaveFileDialog
            {
                DefaultExt = defaultExtension,
                Filter     = filter
            };

            var dialogResult = saveFileDialog.ShowDialog();

            if (dialogResult == true)
            {
                using (var outputStream = saveFileDialog.OpenFile())
                {
                    formatProvider.Export(radRichTextBox.Document, outputStream);
                }
            }

            return(saveFileDialog.FileName);
        }
Beispiel #20
0
        private void SaveDocument()
        {
            SaveFileDialog saveDialog      = new SaveFileDialog();
            var            formatProviders = DocumentFormatProvidersManager.FormatProviders.Where(fp => fp.CanExport);

            saveDialog.Filter = string.Join("|", formatProviders.Select(fp => GetFilter(fp)).ToArray()) + "|All Files|*.*";

            saveDialog.FilterIndex = 3;

            bool?dialogResult = saveDialog.ShowDialog();

            if (dialogResult == true)
            {
                string extension = Path.GetExtension(saveDialog.SafeFileName);
                IDocumentFormatProvider provider = DocumentFormatProvidersManager.GetProviderByExtension(extension);

                using (Stream output = saveDialog.OpenFile())
                {
                    provider.Export(this.radRichTextBox.Document, output);
                }
            }
        }
        private void ConvertFiles(object parameter)
        {
            ThreadParameters threadParameters = parameter as ThreadParameters;

            IDocumentFormatProvider fromFormatProvider =
                (threadParameters.FromFormatProvider == null) ? DocumentFormatProvidersManager.GetProviderByExtension(threadParameters.FileInfo.Extension) :
                threadParameters.FromFormatProvider;

            RadDocument document = null;

            using (Stream readStream = threadParameters.FileInfo.OpenRead())
            {
                document = fromFormatProvider.Import(readStream);
            }

            string fileName = Path.GetFileNameWithoutExtension(threadParameters.FileInfo.Name) + threadParameters.ToFormatProvider.SupportedExtensions.First();

            using (FileStream writeStream = new FileStream(this.toPath + "\\" + fileName, FileMode.Create))
            {
                document.EnsureDocumentMeasuredAndArranged();
                threadParameters.ToFormatProvider.Export(document, writeStream);
            }
        }
Beispiel #22
0
        public void OpenFile(string parameter)
        {
            if (parameter != "")
            {
                string extension;
                extension = Path.GetExtension(parameter).ToLower();

                IDocumentFormatProvider provider =
                    DocumentFormatProvidersManager.GetProviderByExtension(extension);

                if (provider == null)
                {
                    MessageBox.Show(LocalizationManager.GetString("Documents_OpenDocumentCommand_UnsupportedFileFormat"));
                    return;
                }

                try
                {
                    Stream stream;
                    stream = File.Open(parameter, FileMode.Open);
                    using (stream)
                    {
                        RadDocument document = provider.Import(stream);
                        this.radRichTextBox.Document = document;
                        this.SetDocumentName(parameter);
                    }
                }
                catch (IOException)
                {
                    MessageBox.Show(LocalizationManager.GetString("Documents_OpenDocumentCommand_TheFileIsLocked"));
                }
                catch (Exception)
                {
                    MessageBox.Show(LocalizationManager.GetString("Documents_OpenDocumentCommand_TheFileCannotBeOpened"));
                }
            }
        }
        public static void Export(this RadGridView grid, ExportSettings settings)
        {
            var dialog = new SaveFileDialog();

            if (settings.Format == ExportFormat.Pdf)
            {
                dialog.DefaultExt = "*.pdf";
                dialog.Filter     = "Adobe PDF Document (*.pdf)|*.pdf";
            }
            else if (settings.Format == ExportFormat.Excel)
            {
                dialog.DefaultExt = "*.xlsx";
                dialog.Filter     = "Excel Workbook (*.xlsx)|*.xlsx";
            }
            else if (settings.Format == ExportFormat.Word)
            {
                dialog.DefaultExt = "*.docx";
                dialog.Filter     = "Word Document (*.docx)|*.docx";
            }
            else if (settings.Format == ExportFormat.Csv)
            {
                dialog.DefaultExt = "*.csv";
                dialog.Filter     = "CSV (Comma delimited) (*.csv)|*.csv";
            }

            if (dialog.ShowDialog() == true)
            {
                if (settings.Format == ExportFormat.Csv)
                {
                    using (var output = dialog.OpenFile())
                    {
                        grid.Export(output, new GridViewExportOptions()
                        {
                            Format            = Telerik.Windows.Controls.ExportFormat.Csv,
                            ShowColumnFooters = grid.ShowColumnFooters,
                            ShowColumnHeaders = grid.ShowColumnHeaders,
                            ShowGroupFooters  = grid.ShowGroupFooters
                        });
                    }
                }
                else
                {
                    if (settings.Format == ExportFormat.Excel)
                    {
                        var workbook = CreateWorkBook(grid, settings);

                        if (workbook != null)
                        {
                            var provider = new XlsxFormatProvider();
                            using (var output = dialog.OpenFile())
                            {
                                provider.Export(workbook, output);
                            }
                        }
                    }
                    else
                    {
                        var document = CreateDocument(grid, settings);

                        if (document != null)
                        {
                            document.LayoutMode = DocumentLayoutMode.Paged;
                            document.Measure(RadDocument.MAX_DOCUMENT_SIZE);
                            document.Arrange(new RectangleF(PointF.Empty, document.DesiredSize));

                            IDocumentFormatProvider provider = null;

                            if (settings.Format == ExportFormat.Pdf)
                            {
                                provider = new PdfFormatProvider();
                            }
                            else if (settings.Format == ExportFormat.Word)
                            {
                                provider = new DocxFormatProvider();
                            }

                            using (var output = dialog.OpenFile())
                            {
                                provider.Export(document, output);
                            }
                        }
                    }
                }
            }
        }
Beispiel #24
0
 public ThreadParameters(FileInfo fileInfo, IDocumentFormatProvider fromFormatProvider, IDocumentFormatProvider toFormatProvider)
 {
     this.FileInfo           = fileInfo;
     this.FromFormatProvider = fromFormatProvider;
     this.ToFormatProvider   = toFormatProvider;
 }
 public ThreadParameters(FileInfo fileInfo, IDocumentFormatProvider fromFormatProvider, IDocumentFormatProvider toFormatProvider)
 {
     this.FileInfo = fileInfo;
     this.FromFormatProvider = fromFormatProvider;
     this.ToFormatProvider = toFormatProvider;
 }
Beispiel #26
0
        public static IDocumentFormatProvider GetFormatProvider(string extension)
        {
            IDocumentFormatProvider formatProvider = DocumentFormatProvidersManager.GetProviderByExtension(extension);

            return(formatProvider);
        }
        private void OpenButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            string filter = string.Join("|", DocumentFormatProvidersManager.FormatProviders
                                                                           .Where(fp => fp.CanImport)
                                                                           .OrderBy(fp => fp.Name)
                                                                           .Select(fp => this.GetFilter(fp))
                                                                           .ToArray()) + "|All Files|*.*";
            ofd.Filter = filter;

            if (ofd.ShowDialog() == true)
            {
                string extension = Path.GetExtension(ofd.SafeFileName).ToLower();

                this.provider = DocumentFormatProvidersManager.GetProviderByExtension(extension);

                if (this.provider == null)
                {
                    MessageBox.Show(LocalizationManager.GetString("Documents_OpenDocumentCommand_UnsupportedFileFormat"));
                    return;
                }

                try
                {
                    Stream stream;
                    stream = ofd.OpenFile();
                    using (stream)
                    {
                        RadDocument document = provider.Import(stream);
                        this.radRichTextBox.Document = document;

                        // Preserve the file name to use it when saving
                        this.path = ofd.FileName;
                    }
                }
                catch (IOException ex)
                {
                    MessageBox.Show(LocalizationManager.GetString("Documents_OpenDocumentCommand_TheFileIsLocked"));
                }
                catch (Exception ex)
                {
                    MessageBox.Show(LocalizationManager.GetString("Documents_OpenDocumentCommand_TheFileCannotBeOpened"));
                }
            }
        }
 public FormatProviderPair(IDocumentFormatProvider formatProvider, string extention)
 {
     this.FormatProvider = formatProvider;
     this.Title = extention;
 }
        private void GetProvider(string extension)
        {
            this.provider = DocumentFormatProvidersManager.GetProviderByExtension(extension);

            if (this.provider == null)
            {
                MessageBox.Show(LocalizationManager.GetString("Documents_SaveCommand_UnsupportedFileFormat"));
            }

            if (this.provider is IConfigurablePdfFormatProvider)
            {
                IConfigurablePdfFormatProvider pdfFormatProvider = (IConfigurablePdfFormatProvider)this.provider;
                pdfFormatProvider.ExportSettings.CommentsExportMode =
                                                                     this.radRichTextBox.ShowComments ? PdfCommentsExportMode.NativePdfAnnotations : PdfCommentsExportMode.None;
            }
        }
Beispiel #30
0
        private void SaveFile(object parameter)
        {
            string            extension    = null;
            Stream            outputStream = null;
            RadSaveFileDialog saveDialog   = new RadSaveFileDialog();
            string            exportFormat = parameter as string;

            if (exportFormat != null && exportFormat.Contains("|"))
            {
                saveDialog.Filter = exportFormat;
            }
            else
            {
                var formatProviders = DocumentFormatProvidersManager.FormatProviders;

                if (!string.IsNullOrEmpty(exportFormat))
                {
                    string[] extensions = exportFormat.Split(',', ';').Select(e => e.Trim('.').ToLower()).ToArray();
                    formatProviders = formatProviders.Where(fp => fp.SupportedExtensions.Any(ext => extensions.Contains(ext.Trim('.').ToLower())));
                }

                string filter = string.Join("|", formatProviders.Where(fp => fp.CanExport)
                                            .OrderBy(fp => fp.Name)
                                            .Select(fp => FileHelper.GetFilter(fp))
                                            .ToArray());
                saveDialog.Filter = filter;
            }

            bool?dialogResult = saveDialog.ShowDialog();

            if (dialogResult == true)
            {
                extension    = System.IO.Path.GetExtension(saveDialog.FileName);
                outputStream = saveDialog.OpenFile();

                IDocumentFormatProvider provider = DocumentFormatProvidersManager.GetProviderByExtension(extension);

                if (provider == null)
                {
                    MessageBox.Show(LocalizationManager.GetString("Documents_SaveCommand_UnsupportedFileFormat"));
                    return;
                }

                if (provider is IConfigurablePdfFormatProvider)
                {
                    IConfigurablePdfFormatProvider pdfFormatProvider = (IConfigurablePdfFormatProvider)provider;
                    pdfFormatProvider.ExportSettings.CommentsExportMode =
                        this.radRichTextBox.ShowComments ? PdfCommentsExportMode.NativePdfAnnotations : PdfCommentsExportMode.None;
                }

                try
                {
                    using (outputStream)
                    {
                        provider.Export(this.radRichTextBox.Document, outputStream);
                        this.SetDocumentName(saveDialog.FileName);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show(LocalizationManager.GetString("Documents_SaveCommand_UnableToSaveFile"));
                }
            }
        }
Beispiel #31
0
        private static void ShowPrintPreviewDialog(RadDocument document, IDocumentFormatProvider provider)
        {
            PrintPreview printPreview = new PrintPreview(document, provider);

            RadWindow window = new RadWindow();
            window.Content = printPreview;
            window.Header = "Print Preview";
            window.Height = 400;
            window.Width = 500;
#if SILVERLIGHT
            window.WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterScreen;
#else
            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
#endif
            window.Show();
        }
 private string GetFilter(IDocumentFormatProvider formatProvider)
 {
     return
         formatProvider.FilesDescription +
         " (" +
         string.Join(", ", formatProvider.SupportedExtensions.Select(ext => "*" + ext).ToArray()) +
         ")|" +
         string.Join(";", formatProvider.SupportedExtensions.Select(ext => "*" + ext).ToArray());
 }
 public FormatProviderPair(IDocumentFormatProvider formatProvider, string extention)
 {
     this.FormatProvider = formatProvider;
     this.Title          = extention;
 }
        private void ShowPrintPreviewDialog(RadDocument document, IDocumentFormatProvider provider)
        {
            PrintPreview printPreview = new PrintPreview(document, provider);

            if (window != null)
            {
                window.Close();
            }

            this.window = new RadWindow();
            this.window.Content = printPreview;
            this.window.Header = "Print Preview";
            this.window.Height = 400;
            this.window.Width = 500;
#if SILVERLIGHT
            this.window.WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterScreen;
#else
            this.window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
#endif
            this.window.Show();
        }