Esempio n. 1
0
        private void SaveText(ref FlowDocumentReader fdr)
        {
            string         mask = "Rich Text Format (*.rtf)|*.rtf|" + app.Language.TextDocument + " (*.txt)|*.txt|" + app.Language.AllFiles + " (*.*)|*.*";
            SaveFileDialog Save = CreateSaveDialog(mask, app.Language.Save);

            if (Save.ShowDialog(this).GetValueOrDefault())
            {
                FileStream file = SafeFileMethods.CreateFile(Save.FileName);
                if (file == null)
                {
                    ShowNotification(app.Language.SaveTextError, Title, System.Windows.Forms.ToolTipIcon.Error);
                    return;
                }
                TextRange tr = new TextRange(fdr.Document.ContentStart, fdr.Document.ContentEnd);
                tr.Select(fdr.Document.ContentStart, fdr.Document.ContentEnd);
                if (Save.FilterIndex > 1)
                {
                    tr.Save(file, DataFormats.Text);
                }
                else
                {
                    tr.Save(file, DataFormats.Rtf);
                }
                tr.Select(fdr.Document.ContentStart, fdr.Document.ContentStart);
                file.Close();
            }
        }
Esempio n. 2
0
        private void SaveImage(ref FlowDocumentReader fdr)
        {
            string         mask = app.Language.BitmapImage + " (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|Portable Network Graphics (*.png)|*.png|Graphics Interchange Format (*.gif)|*.gif|Tagged Image File Format (*.tiff)|*.tiff";
            SaveFileDialog Save = CreateSaveDialog(mask, app.Language.Save);

            if (Save.ShowDialog(this).GetValueOrDefault())
            {
                FileStream file = SafeFileMethods.CreateFile(Save.FileName);
                if (file == null)
                {
                    ShowNotification(app.Language.SaveImageError, Title, System.Windows.Forms.ToolTipIcon.Error);
                    return;
                }
                FlowDocumentReader FlowDocReader = ActiveTab.Content as FlowDocumentReader;
                object             obj           = GetParagraphImage(ref FlowDocReader);
                if (obj == null)
                {
                    goto CloseStream;
                }
                BitmapFrame frame = BitmapFrame.Create(obj as BitmapSource);
                ImageType   imgtype;
                switch (Save.FilterIndex)
                {
                case 1: imgtype = ImageType.Bmp; break;

                case 2: imgtype = ImageType.Jpg; break;

                case 3: imgtype = ImageType.Png; break;

                case 4: imgtype = ImageType.Gif; break;

                case 5: imgtype = ImageType.Tiff; break;

                default: imgtype = ImageType.Bmp; break;
                }
                CreateImageFile(file, frame, imgtype);
                CloseStream : file.Close();
            }
        }