• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Controls.SaveFileDialog类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Windows.Controls.SaveFileDialog的典型用法代码示例。如果您正苦于以下问题:C# SaveFileDialog类的具体用法?C# SaveFileDialog怎么用?C# SaveFileDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SaveFileDialog类属于System.Windows.Controls命名空间,在下文中一共展示了SaveFileDialog类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ExportButton_Click

        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);
                    }
                }
            }
        }
开发者ID:stevenh77,项目名称:ExportToPdf,代码行数:27,代码来源:MainPage.xaml.cs


示例2: Execute

		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)));
		}
开发者ID:NuvemNine,项目名称:ravendb,代码行数:30,代码来源:ExportDatabaseCommand.cs


示例3: Button1_Click

        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;
        }
开发者ID:Motaz-Al-Zoubi,项目名称:xaml-sdk,代码行数:28,代码来源:MainPage.xaml.cs


示例4: SilverlightSaveModelDialog

 public SilverlightSaveModelDialog()
 {
     _saveFileDialog = new SaveFileDialog
     {
         Filter = "Turtle Pictures (.tur)|*.tur",
     };
 }
开发者ID:dunnmike602,项目名称:Silver-Turtle,代码行数:7,代码来源:SilverlightSaveModelDialog.cs


示例5: SaveImage

        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();
            }
        }
开发者ID:teshca,项目名称:android-geocaching,代码行数:28,代码来源:ImageHelper.cs


示例6: Execute

            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)));
            }
开发者ID:kyanha,项目名称:studio,代码行数:30,代码来源:ExportTask.cs


示例7: Download_Click

        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);
                });
            }
        }
开发者ID:humamAbedrabbo,项目名称:crm,代码行数:28,代码来源:Document_Details.lsml.cs


示例8: Save

        public IEnumerable<IResult> Save()
        {
            var dialog = new SaveFileDialog();
            yield return Show.SaveFileDialog(dialog);

            yield return Show.MessageBox("You saved " + dialog.SafeFileName + ".", "File");
        }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:7,代码来源:BazViewModel.cs


示例9: btnSave_Click

        /// <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();
                }
            }
        }
开发者ID:Ericvf,项目名称:FluxJpeg.Core-fork,代码行数:31,代码来源:Page.xaml.cs


示例10: Execute

        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
); ;
            }
        }
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:31,代码来源:FileSaveAsCommand.cs


示例11: btnSave_Click

        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());
            }               
        }
开发者ID:nilavghosh,项目名称:VChk,代码行数:26,代码来源:ErrorLogDialogBox.xaml.cs


示例12: DefaultProperties

		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");
		}
开发者ID:dfr0,项目名称:moon,代码行数:8,代码来源:SaveFileDialogTest.cs


示例13: btnSave_Click

        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);
        }
开发者ID:7shi,项目名称:Sirius,代码行数:8,代码来源:MainPage.xaml.cs


示例14: Execute

		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));
            }
		}
开发者ID:XpressiveCode,项目名称:ravendb,代码行数:56,代码来源:ExportDatabaseCommand.cs


示例15: SavePng_Click

 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);
         }
     }
 }
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:11,代码来源:MainPage.xaml.cs


示例16: SaveSilverPdf_Click

 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);
         }
     }
 }
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:11,代码来源:MainPage.xaml.cs


示例17: Export_Excel_Click

		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();
		}
开发者ID:CJMarsland,项目名称:xaml-sdk,代码行数:11,代码来源:MainPage.xaml.cs


示例18: DownloadDialogStream

        /// <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();
        }
开发者ID:unicloud,项目名称:AFRP,代码行数:16,代码来源:ImageAndGirdOperation.cs


示例19: DowmLoadDialogStream

        /// <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();
        }
开发者ID:unicloud,项目名称:FRP,代码行数:16,代码来源:ImageAndGridOperation.cs


示例20: SavePdf_Click

 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);
         }
     }
 }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:11,代码来源:MainPage.xaml.cs



注:本文中的System.Windows.Controls.SaveFileDialog类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Controls.ScrollChangedEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Controls.RowDefinition类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap