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


C# SaveFileDialog.ShowDialog方法代码示例

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


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

示例1: cmdSaveToFile_Click

 private void cmdSaveToFile_Click(object sender, RoutedEventArgs e)
 {
     SaveFileDialog dlg=new SaveFileDialog();
     dlg.Filter = "*.conf|*.conf";
     if (dlg.ShowDialog() == true)
         ProtokollerConfiguration.SaveToFile(dlg.FileName);
 }
开发者ID:WaDeSo,项目名称:DotNetSiemensPLCToolBoxLibrary,代码行数:7,代码来源:Protocoling.xaml.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: 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

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

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

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

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

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

示例14: OpenSaveFileDialog

        public bool OpenSaveFileDialog(string title, string defaultFileName, string initialDirectory, string filter, bool overwritePrompt,
                                       out string selectedFilePath, out int selectedFilterIndex)
        {
            var dialog = new SaveFileDialog
                         {
                             OverwritePrompt = overwritePrompt,
                             Title = title,
                             Filter = filter,
                             FileName = defaultFileName,
                             ValidateNames = true,
                             InitialDirectory = initialDirectory
                         };

            bool? result = dialog.ShowDialog();
            if (result ?? false)
            {
                selectedFilePath = dialog.FileName;
                selectedFilterIndex = dialog.FilterIndex;
                return true;
            }
            else
            {
                selectedFilePath = null;
                selectedFilterIndex = -1;
                return false;
            }
        }
开发者ID:campersau,项目名称:NuGetPackageExplorer,代码行数:27,代码来源:UIServices.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


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