当前位置: 首页>>代码示例>>C#>>正文


C# SaveFileDialog.ShowDialog方法代码示例

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


在下文中一共展示了SaveFileDialog.ShowDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RegisterCommands

        private void RegisterCommands(ImagePresentationViewModel viewModel)
        {
            viewModel.SaveCommand = UICommand.Regular(() =>
            {
                var dialog = new SaveFileDialog
                {
                    Filter = "PNG Image|*.png|Bitmap Image|*.bmp",
                    InitialDirectory = Settings.Instance.DefaultPath
                };
                var dialogResult = dialog.ShowDialog();
                if (dialogResult.HasValue && dialogResult.Value)
                {
                    var tmp = viewModel.Image;
                    using (var bmp = new Bitmap(tmp))
                    {
                        if (File.Exists(dialog.FileName))
                        {
                            File.Delete(dialog.FileName);
                        }

                        switch (dialog.FilterIndex)
                        {
                            case 0:
                                bmp.Save(dialog.FileName, ImageFormat.Png);
                                break;
                            case 1:
                                bmp.Save(dialog.FileName, ImageFormat.Bmp);
                                break;
                        }
                    }
                }
            });
        }
开发者ID:PictoCrypt,项目名称:ImageTools,代码行数:33,代码来源:ImagePresentationController.cs

示例2: SelectPath_Click

 private void SelectPath_Click(object sender, RoutedEventArgs e)
 {
     if (_isInFileMode)
     {
         var sfd = new SaveFileDialog
         {
             Filter =
                 string.Format("{0}|{1}|MP3|*.mp3|AAC|*.aac|WMA|*.wma",
                     Application.Current.Resources["CopyFromOriginal"], "*" + _defaultExtension),
             FilterIndex = (int)(DownloadSettings.Format +1),
             FileName = Path.GetFileName(SelectedPath)
         };
         if (sfd.ShowDialog(this) == true)
         {
             SelectedPath = sfd.FileName;
             DownloadSettings.Format = (AudioFormat)(sfd.FilterIndex -1);
             if (sfd.FilterIndex > 1)
                 DownloadSettings.IsConverterEnabled = true;
             OnPropertyChanged("DownloadSettings");
             CheckIfFileExists();
         }
     }
     else
     {
         var fbd = new WPFFolderBrowserDialog {InitialDirectory = DownloadSettings.DownloadFolder};
         if (fbd.ShowDialog(this) == true)
             SelectedPath = fbd.FileName;
     }
 }
开发者ID:WELL-E,项目名称:Hurricane,代码行数:29,代码来源:DownloadTrackWindow.xaml.cs

示例3: ExportToExcel

        private void ExportToExcel()
        {
            DgStats.SelectAllCells();
            DgStats.ClipboardCopyMode = DataGridClipboardCopyMode.IncludeHeader;
            ApplicationCommands.Copy.Execute(null, DgStats);
            var stats = (string) Clipboard.GetData(DataFormats.CommaSeparatedValue);
            //String result = (string)Clipboard.GetData(DataFormats..Text);
            DgStats.UnselectAllCells();

            DgUnmatched.SelectAllCells();
            DgUnmatched.ClipboardCopyMode = DataGridClipboardCopyMode.IncludeHeader;
            ApplicationCommands.Copy.Execute(null, DgUnmatched);
            var unmatched = (string) Clipboard.GetData(DataFormats.CommaSeparatedValue);
            DgUnmatched.UnselectAllCells();
            var saveFileDialog = new SaveFileDialog();
            saveFileDialog.FileName = string.Format("{0}.Reconcile.csv", Path.GetFileName(_vm.BankFile.FilePath));
            if (saveFileDialog.ShowDialog() == true)
            {
                var file = new StreamWriter(saveFileDialog.FileName);
                file.WriteLine(stats);
                file.WriteLine("");
                file.WriteLine(unmatched);
                file.Close();
            }
        }
开发者ID:FrankMedvedik,项目名称:coopcheck,代码行数:25,代码来源:AccountPaymentsView.xaml.cs

示例4: SelectClose_Click

         private void SelectClose_Click(object sender, RoutedEventArgs e)
         { 
             if (string.IsNullOrWhiteSpace(textBox.Text)) 
             { 
                 textBox.Text = String.Empty; 
                 Close(); 
             } 
             else 
             { 
                 string messageBoxText = "Save?"; 
                 string caption = "Word Processor"; 
                 MessageBoxButton button = MessageBoxButton.YesNoCancel; 
                 MessageBoxImage icon = MessageBoxImage.Warning; 
                 MessageBoxResult result = MessageBox.Show(messageBoxText, caption, button, icon); 
                 switch (result) 
                 { 
                     case MessageBoxResult.Yes: 
                         SaveFileDialog saveFileDialog = new SaveFileDialog(); 
                         saveFileDialog.Filter = "Text files (*.txt)|*.txt"; 
                         if (saveFileDialog.ShowDialog() == true) 
                             File.WriteAllText(saveFileDialog.FileName, textBox.Text); 
                         break; 
 
 
                     case MessageBoxResult.No: 
                         Close(); 
                         break; 
 
 
                     case MessageBoxResult.Cancel: 
                         break; 
                 } 
             } 
         } 
开发者ID:taylorsmith4546,项目名称:06-Notepad,代码行数:34,代码来源:MainWindow.xaml.cs

示例5: 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

示例6: 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

示例7: 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

示例8: XBuild_OnClick

        private void XBuild_OnClick(object sender, RoutedEventArgs e)
        {
            CPPFileAnalyzer analyzer;
            try
            {
                analyzer = new CPPFileAnalyzer(GetString(XSource));
            }
            catch
            {
                MessageBox.Show("Error parsing code! Please check your code before building chart!", "CChart error",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            try
            {
                Visualizer visualizer = new Visualizer(analyzer.Result);
                SaveFileDialog sfd=new SaveFileDialog();
                sfd.DefaultExt = ".png";
                sfd.Filter = "Images (.png)|*.png";
                if (sfd.ShowDialog().Value)
                {
                    visualizer.Image.Save(sfd.FileName);
                }

            }
            catch
            {
                MessageBox.Show("Error building chart!", "CChart error",
                                MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
开发者ID:Gronzo,项目名称:cchart,代码行数:32,代码来源:MainWindow.xaml.cs

示例9: 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

示例10: BtnGenKey_OnClick

        private void BtnGenKey_OnClick(object sender, RoutedEventArgs e)
        {
            var dlg = new SaveFileDialog();
            dlg.Filter = "Key documents (.key)|*.key";

            var result = dlg.ShowDialog();
            if (result.HasValue && result.Value)
            {
                var key = string.Empty;

                using (var rsa = new RSACryptoServiceProvider())
                {
                    key = rsa.ToXmlString(true);
                }

                using (var writer = new StreamWriter(new FileStream(dlg.FileName, FileMode.Truncate)))
                {
                    writer.Write(key);
                }

                TbKey.Text = dlg.FileName;
                Application.Current.Properties["KeyPath"] = dlg.FileName;

                ValidateConfig();
            }
        }
开发者ID:vrublevskiy,项目名称:UANB_wpf_client,代码行数:26,代码来源:Start.xaml.cs

示例11: BtnExport_OnClick

        private async void BtnExport_OnClick(object sender, RoutedEventArgs e)
        {            
            // Get input field values
            var deckIndex = ComboBoxDeckPicker.SelectedIndex;
            var deck = deckIndex <= 0 ? (Guid?)null : decks.ElementAt(deckIndex - 1).DeckId;
            var region = (StatsRegion)ComboBoxRegion.SelectedItem;
            var time = (TimeFrame)ComboBoxTime.SelectedItem;
            var mode = (GameMode)ComboBoxMode.SelectedItem;

            // create exporting objects
            var filter = new StatsFilter(deck, region, mode, time);
            // TODO: needs to be selectable with further export types
            var exporter = new CSVExporter();

            // set up and open save dialog
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.FileName = GetDefaultFileName();
            dlg.DefaultExt = "." + exporter.FileExtension;
            dlg.InitialDirectory = Settings.Default.DefaultExportPath;
            dlg.Filter = exporter.Name + " Files | *." + exporter.FileExtension;
            Nullable<bool> result = dlg.ShowDialog();
            // close export dialog
			await Hearthstone_Deck_Tracker.API.Core.MainWindow.HideMetroDialogAsync(this);

            // Process save file dialog box results
            if (result == true)
            {
                // Save document
                string filename = dlg.FileName;                
                await Converter.Export(exporter, filter, filename);                
            }
            
        }
开发者ID:ChuckFork,项目名称:hdt-plugin-statsconverter,代码行数:33,代码来源:ExportDialog.xaml.cs

示例12: 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

示例13: 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

示例14: mbar_salvaconnome_click

 private void mbar_salvaconnome_click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (gridChanged || progetti[0].Properties["Script"] != textEditor.Text)
         {
             if (MessageBox.Show("Applicare le modifiche alla schermata corrente prima di salvare?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
             {
                 //DataGrid dg = detailPresenter.GetChildOfType<DataGrid>();
                 btn_save_Click(detailPresenter, null);
                 progetti[0].Properties["Script"] = textEditor.Text;
             }
         }
         SaveFileDialog sfd = new SaveFileDialog();
         int newRelease = progetti[0].release + 1;
         if (!String.IsNullOrEmpty(progetti[0].Properties["Nuovo progetto"]))
             sfd.FileName = progetti[0].Properties["Nuovo progetto"] + " - r" + newRelease.ToString("00"); 
         if (Directory.Exists(saveDir))
             sfd.InitialDirectory = saveDir;
         sfd.AddExtension = true;
         sfd.DefaultExt = ".xml";
         sfd.Filter = "Vireox Project File|*.vrx";
         if (!(bool)sfd.ShowDialog()) return;
         progetti[0].release = newRelease;
         actualprojectFileName = sfd.FileName;
         updateMRU(sfd.FileName);
         showWaitingPopup("Saving file " + System.IO.Path.GetFileName(sfd.FileName) + "...");
         progetti[0].Properties["Script"] = textEditor.Text;
         bw_save.RunWorkerAsync(sfd.FileName);
     }
     catch (Exception xe)
     {
         System.Windows.MessageBox.Show(xe.Message);
     }
 }
开发者ID:ekox86,项目名称:vireoxConfigurator,代码行数:35,代码来源:Main_Menubar.cs

示例15: Export

        public void Export(object parameter)
        {
            RadGridView grid = parameter as RadGridView;
            if (grid != null)
            {
                grid.ElementExporting -= this.ElementExporting;
                grid.ElementExporting += this.ElementExporting;

                grid.ElementExported -= this.ElementExported;
                grid.ElementExported += this.ElementExported;

                string extension = "xls";
                ExportFormat format = ExportFormat.Html;

                SaveFileDialog dialog = new SaveFileDialog();
                dialog.DefaultExt = extension;
                dialog.Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, "Excel");
                dialog.FilterIndex = 1;

                if (dialog.ShowDialog() == true)
                {
                    using (Stream stream = dialog.OpenFile())
                    {
                        GridViewExportOptions options = new GridViewExportOptions();
                        options.Format = format;
                        options.ShowColumnHeaders = true;
                        options.Encoding = System.Text.Encoding.UTF8;
                        grid.Export(stream, options);
                    }
                }
            }
        }
开发者ID:netintellect,项目名称:PluralsightSpaJumpStartFinal,代码行数:32,代码来源:ExportingModel.cs


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