public SilverlightSaveModelDialog() { _saveFileDialog = new SaveFileDialog { Filter = "Turtle Pictures (.tur)|*.tur", }; }
public override void Execute(object parameter) { var saveFile = new SaveFileDialog { /*TODO, In Silverlight 5: DefaultFileName = string.Format("Dump of {0}, {1}", ApplicationModel.Database.Value.Name, DateTimeOffset.Now.ToString()), */ DefaultExt = ".raven.dump", Filter = "Raven Dumps|*.raven.dump", }; if (saveFile.ShowDialog() != true) return; stream = saveFile.OpenFile(); gZipStream = new GZipStream(stream, CompressionMode.Compress); streamWriter = new StreamWriter(gZipStream); jsonWriter = new JsonTextWriter(streamWriter) { Formatting = Formatting.Indented }; output(String.Format("Exporting to {0}", saveFile.SafeFileName)); output("Begin reading indexes"); jsonWriter.WriteStartObject(); jsonWriter.WritePropertyName("Indexes"); jsonWriter.WriteStartArray(); ReadIndexes(0).Catch(exception => Infrastructure.Execute.OnTheUI(() => Finish(exception))); }
private void Button1_Click(object sender, RoutedEventArgs e) { var pageSize = this.pager.PageSize; var pageIndex = this.pager.PageIndex; this.pager.PageIndex = 0; this.pager.PageSize = 0; string extension = "xlsx"; SaveFileDialog dialog = new SaveFileDialog() { DefaultExt = extension, Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, "Excel"), FilterIndex = 1 }; if (dialog.ShowDialog() == true) { using (Stream stream = dialog.OpenFile()) { this.clubsGrid.ExportToXlsx(stream); } } this.pager.PageSize = pageSize; this.pager.PageIndex = pageIndex; }
void Download_Click(object sender, System.Windows.RoutedEventArgs e) { if (DocumentProperty.FileContents == null) return; SaveFileDialog dialog = new SaveFileDialog(); dialog.DefaultFileName = DocumentProperty.FileName; try { if(dialog.ShowDialog().Value) { using(Stream fileStream = dialog.OpenFile() ) { using(BinaryWriter writer = new BinaryWriter(fileStream)) { writer.Write(DocumentProperty.FileContents); } } } } catch(IOException ex) { this.Details.Dispatcher.BeginInvoke(() => { this.ShowMessageBox(ex.Message, "Error", MessageBoxOption.Ok); }); } }
public static void SaveImage(this UIElement uiElement) { var dialog = new SaveFileDialog { DefaultExt = ".png", Filter = "PNG | *.png | JPG | *.jpg", }; var save = dialog.ShowDialog(); if (save.HasValue && save.Value) { var saveStream = dialog.OpenFile(); var bitmap = new WriteableBitmap(uiElement, new TranslateTransform()); var image = bitmap.ToImage(); if (dialog.SafeFileName.EndsWith(".png")) { var encoder = new PngEncoder(); encoder.Encode(image, saveStream); } else if (dialog.SafeFileName.EndsWith(".jpg")) { var encoder = new JpegEncoder(); encoder.Encode(image, saveStream); } saveStream.Close(); } }
public IEnumerable<IResult> Save() { var dialog = new SaveFileDialog(); yield return Show.SaveFileDialog(dialog); yield return Show.MessageBox("You saved " + dialog.SafeFileName + ".", "File"); }
public override void Execute(object parameter) { var saveFile = new SaveFileDialog { DefaultExt = ".raven.dump", Filter = "Raven Dumps|*.raven.dump" }; var dialogResult = saveFile.ShowDialog() ?? false; if (!dialogResult) return; stream = saveFile.OpenFile(); gZipStream = new GZipStream(stream, CompressionMode.Compress); streamWriter = new StreamWriter(gZipStream); jsonWriter = new JsonTextWriter(streamWriter) { Formatting = Formatting.Indented }; output(string.Format("Exporting to {0}", saveFile.SafeFileName)); output("Begin reading indexes"); jsonWriter.WriteStartObject(); jsonWriter.WritePropertyName("Indexes"); jsonWriter.WriteStartArray(); ReadIndexes(0).Catch(exception => Deployment.Current.Dispatcher.InvokeAsync(() => Finish(exception))); }
private void SaveGraphAsImage() { //TODO: ENSURE THAT DATA IS EVEN PRESENT ON THE GRAPH //TODO: THIS SHOULD BE DECOUPLED ImageTools.IO.Encoders.AddEncoder <ImageTools.IO.Jpeg.JpegEncoder>(); ImageTools.IO.Encoders.AddEncoder <ImageTools.IO.Png.PngEncoder>(); UI.GraphViewModel graphVM = UI.ViewModelLocator.GraphDataStatic; ImageTools.ExtendedImage myImage = graphVM.GraphToImage(); System.Windows.Controls.SaveFileDialog saveFileDialog = new System.Windows.Controls.SaveFileDialog(); saveFileDialog.Filter = "JPEG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png"; saveFileDialog.FilterIndex = 1; bool?dialogResult = saveFileDialog.ShowDialog(); if (dialogResult == true) { using (Stream fs = (Stream)saveFileDialog.OpenFile()) { myImage.WriteToStream(fs, saveFileDialog.SafeFileName); } } }
/// <summary> /// Prompts the user to save the loaded Image locally /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, RoutedEventArgs e) { // Return if no image was loaded if (jpegOut == null) return; // Create an show dialog var dialog = new SaveFileDialog(); if (dialog.ShowDialog() == true) { // After the resize, we can now inspect the PPI values var ppiX = jpegOut.Image.DensityX; var ppiY = jpegOut.Image.DensityX; Debug.WriteLine("DPI: {0}, {1}", ppiX, ppiY); // We can now also update the DPI jpegOut.Image.DensityX = 72; jpegOut.Image.DensityY = 72; // Get the file using (var fileStream = dialog.OpenFile()) { new JpegEncoder(jpegOut, 100, fileStream).Encode(); } } }
public void Execute(object parameter) { if (View == null) return; try { SaveFileDialog dialog = new SaveFileDialog(); dialog.DefaultExt = ".xml"; dialog.Filter = "XML Files|*.xml|Text Files|*.txt|All Files|*.*"; if (dialog.ShowDialog() == true) { using (Stream fs = (Stream)dialog.OpenFile()) { string xml = View.GetMapConfiguration(null); byte[] fileBytes = UTF8Encoding.UTF8.GetBytes(xml.ToString()); fs.Write(fileBytes, 0, fileBytes.Length); } } } catch (Exception ex) { string err = ex.Message; MessageBoxDialog.Show("Error saving File" #if DEBUG + ": " + err #endif ); ; } }
private void btnSave_Click(object sender, RoutedEventArgs e) { SaveFileDialog dialog = new SaveFileDialog(); try { dialog.DefaultExt = ".txt"; dialog.Filter = "Text Files|*.txt"; //dialog.FilterIndex = 0; bool? dialogResult = dialog.ShowDialog(); if (dialogResult == false) return; System.IO.Stream fileStream = dialog.OpenFile(); System.IO.StreamWriter sw = new System.IO.StreamWriter(fileStream); foreach (StatusItem item in ViewModel.Current.Status.StatusItems) { sw.WriteLine(item.FormattedMesage ); } sw.Flush(); sw.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void ExportButton_Click(object sender, RoutedEventArgs e) { var data = Factory.GetDummyOrders(); SaveFileDialog d = new SaveFileDialog(); d.Filter = "PDF file format|*.pdf"; // Save the document... if (d.ShowDialog() == true) { var grid = CreateGrid(data); var document = CreateDocument(grid); if (document != null) { document.LayoutMode = DocumentLayoutMode.Paged; document.Measure(RadDocument.MAX_DOCUMENT_SIZE); document.Arrange(new RectangleF(PointF.Empty, document.DesiredSize)); IDocumentFormatProvider provider = new PdfFormatProvider(); using (var output = d.OpenFile()) { provider.Export(document, output); } } } }
private void btnSave_Click(object sender, RoutedEventArgs e) { var sfd = new SaveFileDialog(); if (sfd.ShowDialog() != true) return; using (var fs = sfd.OpenFile()) fs.Write(data, 0, data.Length); }
public void DefaultProperties () { SaveFileDialog sfd = new SaveFileDialog (); Assert.AreEqual (String.Empty, sfd.DefaultExt, "DefaultExt"); Assert.AreEqual (String.Empty, sfd.SafeFileName, "SafeFileName"); Assert.AreEqual (String.Empty, sfd.Filter, "Filter"); Assert.AreEqual (1, sfd.FilterIndex, "FilterIndex"); }
public override void Execute(object parameter) { TaskCheckBox attachmentUI = taskModel.TaskInputs.FirstOrDefault(x => x.Name == "Include Attachments") as TaskCheckBox; includeAttachments = attachmentUI != null && attachmentUI.Value; var saveFile = new SaveFileDialog { DefaultExt = ".ravendump", Filter = "Raven Dumps|*.ravendump;*.raven.dump", }; var name = ApplicationModel.Database.Value.Name; var normalizedName = new string(name.Select(ch => Path.GetInvalidPathChars().Contains(ch) ? '_' : ch).ToArray()); var defaultFileName = string.Format("Dump of {0}, {1}", normalizedName, DateTimeOffset.Now.ToString("dd MMM yyyy HH-mm", CultureInfo.InvariantCulture)); try { saveFile.DefaultFileName = defaultFileName; } catch { } if (saveFile.ShowDialog() != true) return; taskModel.CanExecute.Value = false; stream = saveFile.OpenFile(); gZipStream = new GZipStream(stream, CompressionMode.Compress); streamWriter = new StreamWriter(gZipStream); jsonWriter = new JsonTextWriter(streamWriter) { Formatting = Formatting.Indented }; taskModel.TaskStatus = TaskStatus.Started; output(String.Format("Exporting to {0}", saveFile.SafeFileName)); jsonWriter.WriteStartObject(); Action finalized = () => { jsonWriter.WriteEndObject(); Infrastructure.Execute.OnTheUI(() => Finish(null)); }; Action readAttachments = () => ReadAttachments(Guid.Empty, 0, callback: finalized); Action readDocuments = () => ReadDocuments(Guid.Empty, 0, callback: includeAttachments ? readAttachments : finalized); try { ReadIndexes(0, callback: readDocuments); } catch (Exception ex) { taskModel.ReportError(ex); Infrastructure.Execute.OnTheUI(() => Finish(ex)); } }
/// <summary> /// 保存成文件流 /// </summary> /// <param name="filter">保存格式</param> /// <returns></returns> public static Stream DowmLoadDialogStream(string filter) { //保存对话框 var dialog = new SaveFileDialog {Filter = filter}; //保存的格式 if (!(bool)dialog.ShowDialog()) return null; //获取保存的文件流 return dialog.OpenFile(); }
private void SaveSilverPdf_Click(object sender, RoutedEventArgs e) { var d = new SaveFileDialog { Filter = "Pdf files (*.pdf)|*.pdf", DefaultExt = ".pdf" }; if (true == d.ShowDialog()) { using (var s = d.OpenFile()) { OxyPlot.Pdf.PdfExporter.Export(this.plot1.ActualModel, s, this.plot1.ActualWidth, this.plot1.ActualHeight); } } }
private void SavePng_Click(object sender, RoutedEventArgs e) { var d = new SaveFileDialog { Filter = "Png files (*.png)|*.png", DefaultExt = ".png" }; if (true == d.ShowDialog()) { using (var s = d.OpenFile()) { PngExporter.Export(this.plot1.ActualModel, s, this.plot1.ActualWidth, this.plot1.ActualHeight, OxyColors.Transparent); } } }
private void SavePdf_Click(object sender, RoutedEventArgs e) { var d = new SaveFileDialog { Filter = "Pdf files (*.pdf)|*.pdf", DefaultExt = ".pdf" }; if (d.ShowDialog().Value) { using (var s = d.OpenFile()) { PdfExporter.Export(Plot1.ActualModel, s, Plot1.ActualWidth, Plot1.ActualHeight); } } }
/// <summary> /// 保存成文件流 /// </summary> /// <param name="filter">保存格式</param> /// <returns></returns> public static Stream DownloadDialogStream(string filter) { //保存对话框 var dialog = new SaveFileDialog {Filter = filter}; var showDialog = dialog.ShowDialog(); if (showDialog != null && !(bool)showDialog) return null; //获取保存的文件流 return dialog.OpenFile(); }
private void Export_Excel_Click(object sender, RoutedEventArgs e) { SaveFileDialog dialog = new SaveFileDialog(); dialog.DefaultExt = "*.xlsx"; dialog.Filter = "Files(*.xlsx)|*.xlsx"; if (!(bool)dialog.ShowDialog()) return; Stream fileStream = dialog.OpenFile(); radChart.ExportToExcelML(fileStream); fileStream.Close(); }
private void button2_Click(object sender, RoutedEventArgs e) { this.StopRecord(); SaveFileDialog dialog = new SaveFileDialog(); if (dialog.ShowDialog() == true) { this.WriteToStream(dialog.OpenFile()); } this.start_button.IsEnabled = true; this.stop_button.IsEnabled = false; }
public CustGroupPage() { InitializeComponent(); this.Title = "Abone Grupları"; //service = new OSYSWcfServiceClient(); //service.getCustomerGroupCompleted += new EventHandler<getCustomerGroupCompletedEventArgs>(service_getCustomerGroupCompleted); //service.getCustomerGroupAsync(); objSFD = new SaveFileDialog(); objSFD.Filter = "Excel Files | *.xls"; objSFD.DefaultExt = "xls"; //btngrExport.Clicked += new CGroupButtonsClickEventHandler(btngrExport_Clicked); }
private void SaveSvg_Click(object sender, RoutedEventArgs e) { var d = new SaveFileDialog { Filter = "Svg files (*.svg)|*.svg", DefaultExt = ".svg" }; if (true == d.ShowDialog()) { using (var s = d.OpenFile()) { var rc = new SilverlightRenderContext(new Canvas()); SvgExporter.Export(this.plot1.ActualModel, s, this.plot1.ActualWidth, this.plot1.ActualHeight, true, rc); } } }
public static void ExportToExcel(C1DataGrid grid) { SaveFileDialog objSFD = new SaveFileDialog() { DefaultExt = "xls", Filter = "Excel Files (*.xls)|*.xls|All files (*.*)|*.*", FilterIndex = 1 }; if (objSFD.ShowDialog() == true) { ExportDataGrid(grid, objSFD); } }
private void ExportReport() { string departmentName = this.SelectedReport; string reportFileName = string.Format("{0}Expenses.pdf", departmentName); SaveFileDialog dialog = new SaveFileDialog(); dialog.DefaultFileName = reportFileName; dialog.Filter = "PDF files|*.pdf"; if (dialog.ShowDialog() == true) { this.expenseViewModel.ExportReport(departmentName, dialog.OpenFile()); } }
/// <summary> /// Executes the save client code. /// </summary> /// <param name="o">The o.</param> private void ExecuteSaveClientCode(object o) { var openFileDialog = new SaveFileDialog { Filter = "C# Files (.cs)|*.cs", FilterIndex = 1 }; var userClickedOk = openFileDialog.ShowDialog(); if (userClickedOk != true) return; var stream = new StreamWriter(openFileDialog.OpenFile()); stream.Write(StatusData.ClientCode); stream.Close(); }
private void button3_Click(object sender, RoutedEventArgs e) { SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "PDF documents(*pdf)|*.pdf"; bool? result = dialog.ShowDialog(); if (result.HasValue && result.Value) { using (Stream stream = dialog.OpenFile()) { this.pdfDocumentViewer1.SaveToFile(stream); } } }
/// <summary> /// The btn save_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void btnSave_Click(object sender, RoutedEventArgs e) { var saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "png files (*.png)|*.png|All files (*.*)|*.*"; saveFileDialog1.FilterIndex = 1; if (saveFileDialog1.ShowDialog() == true) { BitmapSource bs = CanvasToPrint.PrintToPngFile( this.canvas1, this.canvas2, this.canvas3, this.canvas4, saveFileDialog1.OpenFile()); this.OutputImage.Source = bs; } }
public static void SaveToJPG(this UIElement element) { WriteableBitmap bitmap = new WriteableBitmap(element, element.RenderTransform); SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.DefaultExt = "JPG"; saveDialog.Filter = "JPG Files|*.jpg"; bool? result = saveDialog.ShowDialog(); if (!result.HasValue || !result.Value) return; using (Stream stream = saveDialog.OpenFile()) { SaveToJPG(bitmap, stream); } }
public void ExportData() { Status = string.Empty; var saveFile = new SaveFileDialog(); var dialogResult = saveFile.ShowDialog(); if (!dialogResult.HasValue || !dialogResult.Value) return; WorkStarted("exporting database"); var tasks = (IEnumerable<Task>)ExportData(saveFile, ExportIndexesOnly).GetEnumerator(); tasks.ExecuteInSequence(OnTaskFinished, OnException); }