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


C# SaveFileDialog类代码示例

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


SaveFileDialog类属于命名空间,在下文中一共展示了SaveFileDialog类的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: Main

        static void Main(string[] args)
        {
            var xEngine = new Engine();

            DefaultEngineConfiguration.Apply(xEngine);

            var xOutputXml = new OutputHandlerXml();
            xEngine.OutputHandler = new MultiplexingOutputHandler(
                xOutputXml,
                new OutputHandlerFullConsole());

            xEngine.Execute();

            global::System.Console.WriteLine("Do you want to save test run details?");
            global::System.Console.Write("Type yes, or nothing to just exit: ");
            var xResult = global::System.Console.ReadLine();
            if (xResult != null && xResult.Equals("yes", StringComparison.OrdinalIgnoreCase))
            {
                var xSaveDialog = new SaveFileDialog();
                xSaveDialog.Filter = "XML documents|*.xml";
                if (xSaveDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                xOutputXml.SaveToFile(xSaveDialog.FileName);
            }
        }
开发者ID:nwiede,项目名称:Cosmos,代码行数:28,代码来源:Program.cs

示例3: SaveFileService

        /// <summary>
        /// Initializes a new instance of the <see cref="SaveFileService"/> class.
        /// </summary>
        public SaveFileService() {
            saveFileDialog = new SaveFileDialog();
#if NET
            saveFileDialog.AddExtension = true;
            saveFileDialog.CheckPathExists = true;
#endif
        }
开发者ID:Geminior,项目名称:Caliburn.Micro.Extras,代码行数:10,代码来源:SaveFileService.cs

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

示例5: ExportButton_Click

        private void ExportButton_Click(object sender, RoutedEventArgs e)
        {
            IDocumentFormatProvider provider = this.provider;
            SaveFileDialog dialog = new SaveFileDialog();

            if ((provider as DocxFormatProvider) != null)
            {
                dialog.DefaultExt = "docx";
                dialog.Filter = "Word document (docx) | *.docx |All Files (*.*) | *.*";
            }
            else if ((provider as PdfFormatProvider) != null)
            {
                dialog.DefaultExt = "pdf";
                dialog.Filter = "Pdf document (pdf) | *.pdf |All Files (*.*) | *.*";
            }
            else if ((provider as HtmlFormatProvider) != null)
            {
                dialog.DefaultExt = "html";
                dialog.Filter = "Html document (html) | *.html |All Files (*.*) | *.*";
            }
            else
            {
                MessageBox.Show("Unknown output format!");
                return;
            }

            SaveFile(dialog, provider, document);
            (this.Parent as RadWindow).Close();
        }
开发者ID:Motaz-Al-Zoubi,项目名称:xaml-sdk,代码行数:29,代码来源:PrintPreview.xaml.cs

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

示例7: Aplikacja

    //konstruktor wczytujący kalendarz z pliku
    public Aplikacja()
    {
        kalendarz = new Kalendarz();
        data = new Data_dzien();
        while (data.DzienTygodnia() != DniTygodnia.poniedziałek) { data--; }

        //inicjalizacja OpenFileDialog
        otwórz_plik = new OpenFileDialog();
        otwórz_plik.InitialDirectory = "c:\\";
        otwórz_plik.FileName = "";
        otwórz_plik.Filter = "pliki Kalendarza (*.kalen)|*.kalen|All files (*.*)|*.*";
        otwórz_plik.FilterIndex = 2;
        otwórz_plik.RestoreDirectory = true;
        //**************KONIEC INICJALIZACJI OpenFileDialog**************

        //inicjalizacja SaveFileDialog
        zapisz_plik = new SaveFileDialog();
        zapisz_plik.AddExtension = true;
        zapisz_plik.FileName = "";
        zapisz_plik.InitialDirectory = "c:\\";
        zapisz_plik.Filter = "pliki Kalendarza (*.kalen)|*.kalen|All files (*.*)|*.*";
        zapisz_plik.FilterIndex = 1;
        zapisz_plik.RestoreDirectory = true;
        //**************KONIEC INICJALIZACJI SaveFileDialog**************

        if (otwórz_plik.ShowDialog() == DialogResult.OK)
        {
            Stream plik = otwórz_plik.OpenFile();
            kalendarz.Wczytaj(plik);
            plik.Flush();
            plik.Close();
        }
    }
开发者ID:acekk,项目名称:Kalendarz,代码行数:34,代码来源:Aplikacja.cs

示例8: Button_Click

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (_recorder.IsRecording)
            {
                _recorder.Stop();

                button.Content = "Start";

                SaveFileDialog dialog = new SaveFileDialog
                {
                    Filter = "Excel files|*.csv"
                };

                dialog.ShowDialog();

                if (!string.IsNullOrWhiteSpace(dialog.FileName))
                {
                    System.IO.File.Copy(_recorder.Result, dialog.FileName);
                }
            }
            else
            {
                _recorder.Start();

                button.Content = "Stop";
            }
        }
开发者ID:pmargreff,项目名称:Kinect-2-CSV,代码行数:29,代码来源:MainWindow.xaml.cs

示例9: ExportToExcel

        private void ExportToExcel()
        {
            this.BusyIndicator.IsBusy = true;
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.DefaultExt = "xlsx";
            dialog.Filter = "Excel Workbook (xlsx) | *.xlsx |All Files (*.*) | *.*";

            var result = dialog.ShowDialog();
            if ((bool)result)
            {
                try
                {
                    using (var stream = dialog.OpenFile())
                    {
                        var workbook = GenerateWorkbook();

                        XlsxFormatProvider provider = new XlsxFormatProvider();
                        provider.Export(workbook, stream);
                    }
                }
                catch (IOException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            this.BusyIndicator.IsBusy = false;
        }
开发者ID:Motaz-Al-Zoubi,项目名称:xaml-sdk,代码行数:27,代码来源:Example.xaml.cs

示例10: exportHandler

    // What to do when the user wants to export a SVG file
    private void exportHandler(object sender, EventArgs e)
    {
        Stream stream;
        SaveFileDialog saveFileDialog = new SaveFileDialog();

        saveFileDialog.Filter = "SVG files|*.svg";
        saveFileDialog.RestoreDirectory = true;

        if(saveFileDialog.ShowDialog() == DialogResult.OK)
        {
            if((stream = saveFileDialog.OpenFile()) != null)
            {
                // Insert code here that generates the string of SVG
                //   commands to draw the shapes

                String SVGtext = "<?xml version=\"1.0\" standalone=\"no\"?>" +
                    "\r\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"" +
                    "\r\n\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">" +
                    "\r\n<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">";
                foreach (Shape shape in shapes)
                {
                    SVGtext = SVGtext + shape.Conversion("SVG");
                }
                SVGtext = SVGtext + "\r\n</svg>";
                    using (StreamWriter writer = new StreamWriter(stream))
                {
                        // Write strings to the file here using:
                        writer.WriteLine(SVGtext);
                }
            }
        }
    }
开发者ID:YannickMeijer,项目名称:Lab4,代码行数:33,代码来源:ShapeDrawing.cs

示例11: CreateNewPrinterSettingsFile

        private void CreateNewPrinterSettingsFile()
        {
            printerSettings = new Settings
            {
                XAxis = new Axis { Minimum = 0, Maximum = 40, PointsPerMillimeter = 10},
                YAxis = new Axis { Minimum = 0, Maximum = 20, PointsPerMillimeter = 10 },
                ZAxis = new Axis { Minimum = 0, Maximum = 80, PointsPerMillimeter = 20 }
            };
            var json = JsonConvert.SerializeObject(printerSettings);

            var createNewSettingsFileDialog = new SaveFileDialog
            {
                InitialDirectory = SettingsFolder,
                DefaultExt = ".json",
                Filter = "Files (.json)|*.json|All files (*.*)|*.*",
                CheckPathExists = true
            };
            createNewSettingsFileDialog.ShowDialog();
            if (createNewSettingsFileDialog.FileName != "")
            {
                SettingsFolder = Path.GetDirectoryName(createNewSettingsFileDialog.FileName);
                SettingsFile = Path.GetFileName(createNewSettingsFileDialog.FileName);
                LabelSettingsFolder.Content = SettingsFolder;
                TextSettingsFileName.Text = SettingsFile;
                File.WriteAllText(createNewSettingsFileDialog.FileName, json);
            }
        }
开发者ID:MelvinLervick,项目名称:r3d,代码行数:27,代码来源:MaintainSettings.xaml.cs

示例12: Button_Click_1

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            List<ExportRowHelper> ExportColumnNames = new List<ExportRowHelper>();

            foreach (var item in ufgMain.Children)
            {
                CheckBox cb = item as CheckBox;
                if (cb.IsChecked.Value)
                {
                    ExportColumnNames.Add(new ExportRowHelper() { ColumnName = cb.Tag.ToString(), ColumnValue = cb.Content.ToString() });
                }
            }
            if (ExportColumnNames.Count() <= 0)
            {
                Common.MessageBox.Show("请选择需要导出的列");
                return;
            }
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.FileName = string.Format("GlassID导出列表.xls");
            if (sfd.ShowDialog() == true)
            {
                string filename = sfd.FileName;
                string ErrMsg = string.Empty;
                bool bSucc = false;

                bSucc = _export.ExportGlassIDToExcel(_lst, ExportColumnNames, filename, ref ErrMsg);
                if (bSucc)
                {
                    var process = System.Diagnostics.Process.Start(filename);
                }
                else
                    Common.MessageBox.Show(ErrMsg);
            }
            this.Close();
        }
开发者ID:shew990,项目名称:github,代码行数:35,代码来源:ExportGlassIDs.xaml.cs

示例13: OnSaveImageClick

        // Handles save image click
        private void OnSaveImageClick(object sender, RoutedEventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Filter = "24-bit Bitmap (*.bmp)|*.bmp|JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|GIF (*.gif)|*.gif|PNG (*.png)|*.png";
            dlg.FilterIndex = 4;
            bool? dlgResult = dlg.ShowDialog(Window.GetWindow(this));
            if(dlgResult.HasValue && dlgResult.Value)
            {
                Visualizer visualizer = Visualizer;
                RenderTargetBitmap bitmap = new RenderTargetBitmap((int)previewPage.PageWidth, (int)previewPage.PageHeight, 96, 96, PixelFormats.Pbgra32);

                visualizer.RenderTo(bitmap);

                BitmapEncoder encoder = null;
                string ext = System.IO.Path.GetExtension(dlg.FileName);
                if (ext == "bmp") encoder = new BmpBitmapEncoder();
                else if ((ext == "jpg") || (ext == "jpeg")) encoder = new JpegBitmapEncoder();
                else encoder = new PngBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(bitmap));
                using (FileStream stream = new FileStream(dlg.FileName, FileMode.Create, FileAccess.Write))
                {
                    encoder.Save(stream);
                    stream.Flush();
                }
            }
        }
开发者ID:prabuddha1987,项目名称:NuGenBioChem,代码行数:27,代码来源:PublishTab.xaml.cs

示例14: ExportDataGrid

    public static void ExportDataGrid(DataGrid dGrid, String author, String companyName, String mergeCells, int boldHeaderRows, string fileName)
    {
        if (Application.Current.HasElevatedPermissions)
        {

            var filePath ="C:" + Path.DirectorySeparatorChar +"Nithesh"+Path.DirectorySeparatorChar +fileName + ".XML";

            File.Create(filePath);
            Stream outputStream = File.Open(filePath, FileMode.Open, FileAccess.ReadWrite);

            ExportToExcel(dGrid, author, companyName, mergeCells, boldHeaderRows, "XML", outputStream);
        }
        else
        {
            SaveFileDialog objSFD = new SaveFileDialog() { DefaultExt = "xml", Filter = FILE_FILTER, FilterIndex = 2, DefaultFileName = fileName };

            if (objSFD.ShowDialog() == true)
            {
                string strFormat = objSFD.SafeFileName.Substring(objSFD.SafeFileName.IndexOf('.') + 1).ToUpper();
                Stream outputStream = objSFD.OpenFile();

                ExportToExcel(dGrid, author, companyName, mergeCells, boldHeaderRows, strFormat, outputStream);
            }
        }
    }
开发者ID:shenoyroopesh,项目名称:Gama,代码行数:25,代码来源:DataGridExtensions.cs

示例15: button1_Click

 private void button1_Click(object sender, RoutedEventArgs e)
 {
     SaveFileDialog dialog = new SaveFileDialog();
     dialog.FileName = "result.csv";
     dialog.Filter = "CSVファイル(*.csv)|*.csv|全てのファイル(*.*)|*.*";
     dialog.OverwritePrompt = true;
     dialog.CheckPathExists = true;
     bool? res = dialog.ShowDialog();
     if (res.HasValue && res.Value)
     {
         try
         {
             if (mainWin.fileWriter != null) mainWin.fileWriter.Flush();
             System.IO.Stream fstream = dialog.OpenFile();
             System.IO.Stream fstreamAppend = new System.IO.FileStream(dialog.FileName+"-log.csv", System.IO.FileMode.OpenOrCreate);
             if (fstream != null && fstreamAppend != null)
             {
                 textBox1.Text = dialog.FileName;
                 mainWin.fileWriter = new System.IO.StreamWriter(fstream);
                 mainWin.logWriter = new System.IO.StreamWriter(fstreamAppend);
             }
         }
         catch (Exception exp)
         {
             MessageBox.Show(exp.ToString());
         }
     }
 }
开发者ID:einbrain,项目名称:WPFDemoServer,代码行数:28,代码来源:Window1.xaml.cs


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