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

C# Win32.SaveFileDialog类代码示例

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

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



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

示例1: SaveImageCapture

    public static void SaveImageCapture(BitmapSource bitmap)
    {
        JpegBitmapEncoder encoder = new JpegBitmapEncoder();
            encoder.Frames.Add(BitmapFrame.Create(bitmap));
            encoder.QualityLevel = 100;

            // Configure save file dialog box
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName = "Image"; // Default file name
            dlg.DefaultExt = ".Jpg"; // Default file extension
            dlg.Filter = "Image (.jpg)|*.jpg"; // Filter files by extension

            // Show save file dialog box
            Nullable<bool> result = dlg.ShowDialog();

            // Process save file dialog box results
            if (result == true)
            {
                // Save Image
                string filename = dlg.FileName;
                FileStream fstream = new FileStream(filename, FileMode.Create);
                encoder.Save(fstream);
                fstream.Close();
            }
    }
开发者ID:meanprogrammer,项目名称:KidsCheckinSystem,代码行数:25,代码来源:Helper.cs


示例2: SaveProject

        public void SaveProject()
        {
            string fileToSave = null;

            if (string.IsNullOrEmpty(ArrowState.Self.CurrentGluxFileLocation))
            {
                SaveFileDialog fileDialog = new SaveFileDialog();
                fileDialog.Filter = "*.arox|*.arox";

                var result = fileDialog.ShowDialog();

                if (result.HasValue && result.Value)
                {
                    fileToSave = fileDialog.FileName;
                    ArrowState.Self.CurrentGluxFileLocation = fileToSave;
                }

            }
            else
            {
                fileToSave = ArrowState.Self.CurrentGluxFileLocation;
            }

            if (!string.IsNullOrEmpty(fileToSave))
            {
                FileManager.XmlSerialize(ArrowState.Self.CurrentArrowProject, fileToSave);
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:28,代码来源:FileCommands.cs


示例3: Export

        private void Export(object param)
        {
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.Filter = String.Format("{0} files|*.{1}|{2} files|*.{3}", "Pdf", "pdf", "Text", "txt");

            if (dialog.ShowDialog() == true)
            {
                using (var stream = dialog.OpenFile())
                {
                    RadFixedDocument document = this.CreateDocument();
                    switch (dialog.FilterIndex)
                    {
                        case 1:
                            PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
                            pdfFormatProvider.Export(document, stream);
                            break;
                        case 2:
                            using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8))
                            {
                                TextFormatProvider textFormatProvider = new TextFormatProvider();
                                writer.Write(textFormatProvider.Export(document));
                            }
                            break;
                    }
                }
            }
        }
开发者ID:netintellect,项目名称:PluralsightSpaJumpStartFinal,代码行数:27,代码来源:ExampleViewModel.cs


示例4: CreatePuzzleButton_OnClick

        private void CreatePuzzleButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(_filename))
            {
                MessageBox.Show("Image does not selected!");
                return;
            }

            var filePath = _filename;
            var x = XBlocksCount;
            var y = YBlocksCount;
            var generator = new PuzzleCreator(filePath);
            var images = generator.GetMixedPartsOfImage(x, y);
            Bitmap bitmap = generator.GenerateBitmap(images, x, y);

            var saveFileDialog = new SaveFileDialog();
            saveFileDialog.FileName = "puzzle";
            saveFileDialog.DefaultExt = ".jpg";
            saveFileDialog.Filter = "Image files (*.jpg, *.jpeg, *.png) | *.jpg; *.jpeg; *.png";

            Nullable<bool> result = saveFileDialog.ShowDialog();

            if (result.HasValue && result.Value)
            {
                bitmap.Save(saveFileDialog.FileName);
            }
            else
            {
                MessageBox.Show("Puzzle does not saved!");
            }
        }
开发者ID:OleksandrKudinov,项目名称:PuzzleGenerator,代码行数:31,代码来源:MainWindow.xaml.cs


示例5: Export

        private static void Export()
        {
            var saveFileDialog = new SaveFileDialog { Filter = "CSV files (*.csv)|*.csv" };

            if (saveFileDialog.ShowDialog() == true)
            {
                try
                {
                    using (Stream stream = new FileStream(saveFileDialog.FileName, FileMode.Create))
                    {
                        _grid.Export(stream, new GridViewCsvExportOptions
                            {
                                ColumnDelimiter = CultureInfo.CurrentCulture.TextInfo.ListSeparator,
                                ShowColumnHeaders = true,
                                ShowColumnFooters = false,
                                ShowGroupFooters = false,
                                Culture = CultureInfo.CurrentCulture,
                                Encoding = Encoding.UTF8,
                                Items = (IEnumerable)_grid.ItemsSource
                            });
                    }
                }

                catch (IOException)
                {
                    MessageBox.Show(String.Format(
                            "Export to file {0} was failed. File used by another process. End process and try again.",
                            saveFileDialog.FileName), "Error");
                }
            }
        }
开发者ID:syatin003,项目名称:Wpf,代码行数:31,代码来源:ExportToCSVService.cs


示例6: ExportToCSV

        //Exports the data from the output window to a csv file
        public void ExportToCSV()
        {
            try
            {
                SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                saveFileDialog1.Filter = "CSV|*.csv";
                saveFileDialog1.Title = "Export to CSV";

                string currentDateTime = DateTime.Now.ToString("yyyy-MM-dd--HH-mm-ss");
                saveFileDialog1.FileName = currentDateTime;
                Nullable<bool> saveFileResult = saveFileDialog1.ShowDialog();
                //If saveFileResut is null (user clicked cancel) then do nothing
                if (saveFileResult == false)
                {
                    return;
                }
                //Copy the temporary file with the ping data to a csv file
                else
                {
                    File.Copy(_temporaryPingDataFile, saveFileDialog1.FileName);
                }
            }
            catch (Exception er)
            {
                MessageBox.Show("Error with filename" + Environment.NewLine + Environment.NewLine + er);
                return;
            }
        }
开发者ID:ingram1987,项目名称:tping-gui,代码行数:29,代码来源:helper.cs


示例7: Save

        // yuehan start: 保存 baml 到 xaml 文件
        public override bool Save(DecompilerTextView textView)
        {
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.FileName = Path.GetFileName(DecompilerTextView.CleanUpName(base.Text as string));
            dlg.FileName = Regex.Replace(dlg.FileName, @"\.baml$", ".xaml", RegexOptions.IgnoreCase);
            if (dlg.ShowDialog() == true)
            {
                // 反编译 baml 文件
                var baml = this.Data;
                var asm = this.Ancestors().OfType<AssemblyTreeNode>().FirstOrDefault().LoadedAssembly;
                baml.Position = 0;
                var doc = LoadIntoDocument(asm.GetAssemblyResolver(), asm.AssemblyDefinition, baml);
                var xaml = doc.ToString();

                // 保存 xaml
                FileInfo fi = new FileInfo(dlg.FileName);
                if (fi.Exists) fi.Delete();

                using (var fs = fi.OpenWrite())
                using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8))
                {
                    sw.BaseStream.Seek(0, SeekOrigin.Begin);
                    sw.Write(xaml);
                    sw.Flush();
                    sw.Close();
                }
            }
            return true;
        }
开发者ID:DKeeper1523,项目名称:ilspy_yh,代码行数:30,代码来源:BamlResourceEntryNode.cs


示例8: OnInitialized

 /// <summary>
 /// Invoked when the window is initialized.
 /// </summary>
 /// <param name="e">Empty EventArgs instance.</param>
 protected override void OnInitialized(EventArgs e)
 {
     this.importDialog = (OpenFileDialog)this.Resources["importDialog"];
     this.saveDialog = (SaveFileDialog)this.Resources["saveDialog"];
     this.imageList.ItemsSource = this.currentIcon.Images;
     base.OnInitialized(e);
 }
开发者ID:Inedo,项目名称:iconmaker,代码行数:11,代码来源:MainWindow.xaml.cs


示例9: Execute

 public void Execute(object parameter)
 {
     var exportObject = new ExportData();
     using (var irep=_itemsRepos())
     {
         exportObject.EveItems = irep.GetAll().ToArray();
     }
     using (var brep=_blueprintsRepos())
     {
         exportObject.Blueprints = brep.GetAll().ToArray();
     }
     using (var prep=_prodinfoRepos())
     {
         exportObject.ProductionInfos = prep.GetAll().ToArray();
     }
     var res = JsonConvert.SerializeObject(exportObject,Formatting.Indented);
     var dlg = new SaveFileDialog()
         {
             Title = "Экспорт БД",
             Filter = "Data File *.dat|*.dat"
         };
     if (dlg.ShowDialog() == true)
     {
         using (var writer=File.CreateText(dlg.FileName))
         {
             writer.Write(res);
             writer.Close();
         }
     }
 }
开发者ID:holinov,项目名称:ZenEveCalc,代码行数:30,代码来源:ExportDbCommand.cs


示例10: SaveGame

        public string SaveGame(IClearMine game, string path = null)
        {
            if (game == null)
                throw new ArgumentNullException("game");

            if (String.IsNullOrWhiteSpace(path))
            {
                var savePathDialog = new SaveFileDialog();
                savePathDialog.DefaultExt = Settings.Default.SavedGameExt;
                savePathDialog.Filter = ResourceHelper.FindText("SavedGameFilter", Settings.Default.SavedGameExt);
                if (savePathDialog.ShowDialog() == true)
                {
                    path = savePathDialog.FileName;
                }
                else
                {
                    return null;
                }
            }

            // Pause game to make sure the timestamp correct.
            game.PauseGame();
            var gameSaver = new XmlSerializer(game.GetType());
            using (var file = File.Open(path, FileMode.Create, FileAccess.Write))
            {
                gameSaver.Serialize(file, game);
            }
            game.ResumeGame();

            return path;
        }
开发者ID:nankezhishi,项目名称:ClearMine,代码行数:31,代码来源:GameSerializer.cs


示例11: 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:CJMarsland,项目名称:xaml-sdk,代码行数:28,代码来源:MainWindow.xaml.cs


示例12: Save

        void Save()
        {
            try
            {
                string date = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss");
                SaveFileDialog saveFile = new SaveFileDialog();
                saveFile.AddExtension = true;
                saveFile.Filter = "Text documents (.txt)|*.txt";
                saveFile.DefaultExt = ".txt";
                saveFile.FileName = "Folder_Rename_Save " + date;
                bool? result = saveFile.ShowDialog();
                
                if (result == true)
                {
                    string contents = "";
                    foreach (string ligne in listeAvancement)
                    {
                        contents += ligne + "\r\n";
                    }

                    File.WriteAllText(saveFile.FileName, contents);
                }
            }
            catch { }
        }
开发者ID:unil,项目名称:fbm-tools,代码行数:25,代码来源:MainWindow.xaml.cs


示例13: btnExtractImage_Click

        private void btnExtractImage_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _blf = new PureBLF(_blfLocation);
                var sfd = new SaveFileDialog
                {
                    Title = "Save the extracted BLF Image",
                    Filter = "JPEG Image (*.jpg)|*.jpg",
                    FileName = lblBLFname.Text.Replace(".blf", "")
                };

                if (!((bool)sfd.ShowDialog()))
                {
                    Close();
                    return;
                }
                var imageToExtract = new List<byte>(_blf.BLFChunks[1].ChunkData);
                imageToExtract.RemoveRange(0, 0x08);

                File.WriteAllBytes(sfd.FileName, imageToExtract.ToArray<byte>());

                MetroMessageBox.Show("Exracted!", "The BLF Image has been extracted.");
                Close();
            }
            catch (Exception ex)
            {
                Close();
                MetroMessageBox.Show("Extraction Failed!", "The BLF Image failed to be extracted: \n " + ex.Message);
            }
        }
开发者ID:ChadSki,项目名称:Assembly,代码行数:31,代码来源:HaloImage.xaml.cs


示例14: Execute

        public void Execute(ICSharpCode.TreeView.SharpTreeNode[] selectedNodes)
        {
            //Gets the loaded assembly
            var loadedAssembly = ((AssemblyTreeNode)selectedNodes[0]).LoadedAssembly;

            //Shows the dialog
            var dialog = new SaveFileDialog()
            {
                AddExtension = false,
                Filter = "Patched version of " + loadedAssembly.AssemblyDefinition.Name.Name + "|*.*",
                FileName = Path.GetFileName(Path.ChangeExtension(loadedAssembly.FileName, ".Patched" + Path.GetExtension(loadedAssembly.FileName))),
                InitialDirectory = Path.GetDirectoryName(loadedAssembly.FileName),
                OverwritePrompt = true,
                Title = "Save patched assembly"
            };
            if (dialog.ShowDialog().GetValueOrDefault(false))
            {
                //Writes the assembly
                loadedAssembly.AssemblyDefinition.Write(dialog.FileName);

                //Clears the coloring of the nodes
                foreach (var x in Helpers.PreOrder(selectedNodes[0], x => x.Children))
                    x.Foreground = GlobalContainer.NormalNodesBrush;
                var normalColor = ((SolidColorBrush)GlobalContainer.NormalNodesBrush).Color;
                MainWindow.Instance.RootNode.Foreground =
                    MainWindow.Instance.RootNode.Children.All(x => x.Foreground is SolidColorBrush && ((SolidColorBrush)x.Foreground).Color == normalColor)
                    ? GlobalContainer.NormalNodesBrush
                    : GlobalContainer.ModifiedNodesBrush;
            }
        }
开发者ID:95ulisse,项目名称:ILEdit,代码行数:30,代码来源:SaveEntry.cs


示例15: Execute

        public override void Execute(object parameter)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = "Database file (*.db3) |*.db3";
            if (sfd.ShowDialog() == true)
            {
                SqliteDataProvider dataProvider = new SqliteDataProvider();
                dataProvider.Open(sfd.FileName);

               // string sql = "CREATE TABLE Fossils (id INTEGER PRIMARY KEY AUTOINCREMENT, fossilname TEXT, Descrip TEXT, area REAL, circularity REAL, elongation REAL, perimeter REAL, irregularity REAL , bitmap BLOB)";
                string sql = "CREATE TABLE Authors (Author_id INTEGER PRIMARY KEY AUTOINCREMENT, Author_name TEXT)";
                dataProvider.ExecuteNonQuery(sql);
                string sql1 = "CREATE TABLE Description (Description_id INTEGER PRIMARY KEY AUTOINCREMENT, synonymy TEXT, shell TEXT, init_shell TEXT, crop TEXT, key_edge TEXT, front_end TEXT, rear_end TEXT, ventral_margin TEXT, growth_lines TEXT, sculpture TEXT, compare TEXT)";
                dataProvider.ExecuteNonQuery(sql1);
                string sql2 = "CREATE TABLE Genus (genus_id INTEGER PRIMARY KEY AUTOINCREMENT, genus_name TEXT)";
                dataProvider.ExecuteNonQuery(sql2);
                string sql3 = "CREATE TABLE GenusToAuthor (genus_id INTEGER, author_id INTEGER)";
                dataProvider.ExecuteNonQuery(sql3);
                string sql4 = "CREATE TABLE Parameters (parameters_id INTEGER PRIMARY KEY AUTOINCREMENT, init_shell TEXT, front_rear_end TEXT, age TEXT, length TEXT, sculpture TEXT, h_l REAL)";
                dataProvider.ExecuteNonQuery(sql4);
                string sql5 = "CREATE TABLE Photo (id INTEGER PRIMARY KEY AUTOINCREMENT, square REAL, vertex_x REAL, vertex_y REAL, furrow REAL, bitmap BLOB)";
                dataProvider.ExecuteNonQuery(sql5);
                string sql6 = "CREATE TABLE Species (species_id INTEGER PRIMARY KEY AUTOINCREMENT,species_name TEXT, genus_id INTEGER, description_id INTEGER)";
                dataProvider.ExecuteNonQuery(sql6);
                string sql7 = "CREATE TABLE SpeciesToAuthor (species_id INTEGER, author_id INTEGER)";
                dataProvider.ExecuteNonQuery(sql7);
                string sql8 = "CREATE TABLE Mollusk (mollusk_id INTEGER PRIMARY KEY AUTOINCREMENT, species_id INTEGER, photo_id INTEGER, parameters_id INTEGER)";
                dataProvider.ExecuteNonQuery(sql8);
                UIManager.man.Provider = dataProvider;
            }
        }
开发者ID:Svet-LAN-a,项目名称:mollusksRecognition,代码行数:31,代码来源:Commands.cs


示例16: OnSaveCommand

 private void OnSaveCommand(string obj)
 {
     var sf = new SaveFileDialog();
     var fn = sf.FileName;
     if (!string.IsNullOrEmpty(fn))
         SaveReportToFile(fn);
 }
开发者ID:GHLabs,项目名称:SambaPOS-3,代码行数:7,代码来源:ErrorReportViewModel.cs


示例17: Execute

        public void Execute(object parameter)
        {
            var fileName = Path.GetFileName(LogSource.Instance.LogFileLocation);
            var saveLocation = new SaveFileDialog
            {
                AddExtension = true,
                Filter = ".json | JSON File",
                FileName = fileName,
                Title = "Export log config to..."
            };

            var result = saveLocation.ShowDialog();
            if (!result.HasValue || !result.Value || string.IsNullOrEmpty(saveLocation.FileName))
                return;

            // save the file
            File.Copy(LogSource.Instance.LogFileLocation, saveLocation.FileName);

            // browse to it in explorer
            var args = $"/e, /select, \"{saveLocation.FileName}\"";

            var info = new ProcessStartInfo
            {
                FileName = "explorer.exe",
                Arguments = args
            };
            Process.Start(info);
        }
开发者ID:codekaizen,项目名称:swifttailer,代码行数:28,代码来源:ExportLogConfigCommand.cs


示例18: SaveDocument

        public static bool SaveDocument(Document document)
        {
            if (document.IsTemporal)
            {
                var dialog = new SaveFileDialog { DefaultExt = "md", AddExtension = true };
                dialog.Filter = "Markdown files (*.md)|*.md|All files (*.*)|*.*";
                if (dialog.ShowDialog().Value)
                {
                    string destinationFolder = string.Empty;
                    destinationFolder = new FileInfo(dialog.FileName).DirectoryName;
                    try
                    {
                        var sourceFolder = new FileInfo(document.FullFilename).DirectoryName;
                        DirectoryCopy(sourceFolder, destinationFolder, true);
                        document.FolderPath = destinationFolder;
                        File.Move(document.FullFilename, Path.Combine(document.FolderPath, dialog.FileName));
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                }
                else
                {
                    return false;
                }
            }
            else
            {
            }

            document.HasChanges = false;
            return true;
        }
开发者ID:hmeydac,项目名称:Homeworld,代码行数:34,代码来源:DocumentHub.cs


示例19: snapshotClicked

        private void snapshotClicked(object sender, RoutedEventArgs e)
        {
            e.Handled = true;

            var imageSource = GridZoomControl.SnapshotToBitmapSource();

            if (imageSource == null)
            {
                MessageBox.Show("Failed to snapshot image");
                return;
            }

            var dialog = new SaveFileDialog
            {
                FileName = "Snapshot.png", Filter = "PNG File (*.png)|*.png"
            };

            if (dialog.ShowDialog(this) == true)
            {
                using (var fs = new FileStream(dialog.FileName, FileMode.Create))
                {
                    var encoder = new PngBitmapEncoder();
                    encoder.Frames.Add(BitmapFrame.Create(imageSource));
                    encoder.Save(fs);
                }
            }
        }
开发者ID:CriDos,项目名称:skiasharpwpfextensions,代码行数:27,代码来源:MainWindow.xaml.cs


示例20: FileNameFromSaveFileDialog

 public static string FileNameFromSaveFileDialog(string fileFilter)
 {
     var saveFileDialog = new SaveFileDialog();
     saveFileDialog.Filter = fileFilter;
     var dialogResult = saveFileDialog.ShowDialog();
     return dialogResult.Value == true ? saveFileDialog.FileName : string.Empty;
 }
开发者ID:b1ff,项目名称:RoundScheduler,代码行数:7,代码来源:FileDialogService.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Win32.UserPreferenceChangedEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Win32.RegistryKey类代码示例发布时间: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