コード例 #1
0
        public void ExportGrid(ExportType fileType)
        {
            switch (fileType)
            {
            case ExportType.XLSX:
                SaveFileDialogService.DefaultExt = "xlsx";
                SaveFileDialogService.Filter     = "Excel 2007+|*.xlsx";
                break;

            case ExportType.PDF:
                SaveFileDialogService.DefaultExt = "pdf";
                SaveFileDialogService.Filter     = "PDF|*.pdf";
                break;
            }

            if (SaveFileDialogService.ShowDialog())
            {
                var fileName = SaveFileDialogService.GetFullFileName();
                ExportService.ExportTo(fileType, fileName);
                if (MessageBoxService.ShowMessage("Would you like to open the file?", "Export finished",
                                                  MessageButton.YesNo) == MessageResult.Yes)
                {
                    Process.Start(fileName);
                }
            }
        }
        /// <summary>
        /// Export Grid
        /// </summary>
        /// <param name="fileType"></param>
        public void ExportGrid(ExportType fileType)
        {
            try
            {
                switch (fileType)
                {
                case ExportType.XLSX:
                    SaveFileDialogService.DefaultExt = "xlsx";
                    SaveFileDialogService.Filter     = "Excel 2007+|*.xlsx";
                    break;

                case ExportType.PDF:
                    SaveFileDialogService.DefaultExt = "pdf";
                    SaveFileDialogService.Filter     = "PDF|*.pdf";
                    break;
                }

                if (SaveFileDialogService.ShowDialog())
                {
                    var fileName = SaveFileDialogService.GetFullFileName();
                    ExportGridService.ExportTo(fileType, fileName);
                    if (MessageBoxService.ShowMessage("¿Desea abrir el archivo?", "Operación Exitosa", MessageButton.YesNo) == MessageResult.Yes)
                    {
                        var process = new Process();
                        process.StartInfo.UseShellExecute = true;
                        process.StartInfo.FileName        = fileName;
                        process.Start();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBoxService.ShowMessage(GetStringValue(Next.Enums.Enums.MessageError.ExportError), ex.Message);
            }
        }
コード例 #3
0
 public void Export()
 {
     SaveFileDialogService.Filter = "PDF files (*.pdf)|*.pdf";
     if (SaveFileDialogService.ShowDialog())
     {
         IsBusy = true;
         ExportToPdf(serverConnection, SaveFileDialogService.GetFullFileName(), SelectedReportObject.Id);
     }
 }
コード例 #4
0
 public void Export()
 {
     SaveFileDialogService.Filter = "PDF files (*.pdf)|*.pdf";
     if (SaveFileDialogService.ShowDialog())
     {
         IsBusy = true;
         ExportReport(new PdfExportOptions())
         .ContinueWith(ExportToPdfCompleted, TaskScheduler.FromCurrentSynchronizationContext());
     }
 }
コード例 #5
0
        public void ExportToExcel()
        {
            SaveFileDialogService.Filter = "Excel files (*.xlsx)|*.xlsx";
            if (SaveFileDialogService.ShowDialog())
            {
                IXlExporter exporter    = XlExport.CreateExporter(XlDocumentFormat.Xlsx);
                string[]    columnNames = new string[] { "Word", "Definition" };
                string      fileName    = SaveFileDialogService.GetFullFileName();

                using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite))
                {
                    using (IXlDocument document = exporter.CreateDocument(stream))
                    {
                        using (IXlSheet sheet = document.CreateSheet())
                        {
                            sheet.Name = "Dictionary";

                            using (IXlColumn column = sheet.CreateColumn())
                            {
                                column.WidthInCharacters    = 25;
                                column.Formatting           = new XlCellFormatting();
                                column.Formatting.Alignment = new XlCellAlignment();
                                column.Formatting.Alignment.VerticalAlignment = XlVerticalAlignment.Center;
                            }

                            using (IXlColumn column = sheet.CreateColumn())
                            {
                                column.WidthInCharacters             = 100;
                                column.Formatting                    = new XlCellFormatting();
                                column.Formatting.Alignment          = new XlCellAlignment();
                                column.Formatting.Alignment.WrapText = true;
                            }

                            IXlTable table;
                            using (IXlRow row = sheet.CreateRow())
                                table = row.BeginTable(columnNames, true);

                            foreach (DictionaryBookmark bookmark in DictionaryBookmarksView)
                            {
                                using (IXlRow row = sheet.CreateRow())
                                    row.BulkCells(new string[] { bookmark.Word, bookmark.Definition }, null);
                            }

                            using (IXlRow row = sheet.CreateRow())
                                row.EndTable(table, false);

                            table.Style.ShowFirstColumn = true;
                        }
                    }
                }

                Process.Start(fileName);
            }
        }
コード例 #6
0
        public void SaveImage(BitmapImage image, object item)
        {
            SaveFileDialogService.Filter          = "Image File (.jpg)|*.jpg";
            SaveFileDialogService.DefaultFileName = Regex.Replace(item.ToString(), InvalidFileNameChars, "");

            if (SaveFileDialogService.ShowDialog())
            {
                BitmapEncoder encoder = new JpegBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(image));

                using (Stream stream = SaveFileDialogService.OpenFile())
                {
                    encoder.Save(stream);
                }
            }
        }
コード例 #7
0
        public void ExportToPdf(IPrintableControl control)
        {
            PrintableControlLink link = new PrintableControlLink(control);

            link.Margins = new Margins(50, 50, 50, 50);

            if (ExportHelper.Export(ExportFormat.Pdf, link.PrintingSystem) == true)
            {
                SaveFileDialogService.Filter = "PDF File (.pdf)|*.pdf";

                if (SaveFileDialogService.ShowDialog())
                {
                    link.ExportToPdf(SaveFileDialogService.GetFullFileName());
                    OpenExternalApplication(SaveFileDialogService.GetFullFileName());
                }
            }
        }
コード例 #8
0
 public void Save()
 {
     SaveFileDialogService.DefaultExt      = DefaultExt;
     SaveFileDialogService.DefaultFileName = DefaultFileName;
     SaveFileDialogService.Filter          = Filter;
     SaveFileDialogService.FilterIndex     = FilterIndex;
     DialogResult = SaveFileDialogService.ShowDialog();
     if (!DialogResult)
     {
         ResultFileName = string.Empty;
     }
     else
     {
         using (var stream = new StreamWriter(SaveFileDialogService.OpenFile())) {
             stream.Write(FileBody);
         }
     }
 }
コード例 #9
0
        public void Export(ExportType type)
        {
            switch (type)
            {
            case ExportType.PDF:
                SaveFileDialogService.Filter = "PDF files|*.pdf";
                if (SaveFileDialogService.ShowDialog())
                {
                    ExportService.ExportToPDF(SaveFileDialogService.GetFullFileName());
                }
                break;

            case ExportType.XLSX:
                SaveFileDialogService.Filter = "Excel 207 files|*.xlsx";
                if (SaveFileDialogService.ShowDialog())
                {
                    ExportService.ExportToPDF(SaveFileDialogService.GetFullFileName());
                }
                break;
            }
        }
コード例 #10
0
        public async Task Download(Subtitle subtitle)
        {
            string path = null;

            if (!String.IsNullOrWhiteSpace(FilePath))
            {
                string folderPath = Path.GetDirectoryName(FilePath);
                if (Directory.Exists(folderPath))
                {
                    path = folderPath;
                }
            }
            else if (!String.IsNullOrWhiteSpace(LocalPath))
            {
                if (Directory.Exists(LocalPath))
                {
                    path = LocalPath;
                }
            }

            SaveFileDialogService.Filter = SubtitleFilter;
            if (SaveFileDialogService.ShowDialog(null, path, subtitle.SubtitleFileName))
            {
                try
                {
                    await SubtitleClient.DownloadSubtitleToPath(SaveFileDialogService.File.DirectoryName, subtitle, SaveFileDialogService.SafeFileName());
                }
                catch (Exception e)
                {
                    Journal.WriteError(e);

                    MessageViewModel viewModel = MessageViewModel.FromException(e);
                    Messenger.Default.Send(viewModel);
                }
            }
        }