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();
            }
    }
示例#2
0
 public void ExitApplication(winForms.RichTextBox htmlTextBox, winForms.RichTextBox csstextBox, MenuItem SaveProject)
 {
     if (SaveProject.IsEnabled == true)
     {
         MessageBoxResult msgBoxRes = MessageBox.Show("Do you want to save content or not?", "Save File", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
         if (msgBoxRes == MessageBoxResult.Yes)
         {
             Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog();
             sfd.DefaultExt = ".html";
             sfd.Filter     = "HTML File (.html)|*html";
             if (sfd.ShowDialog() == true && sfd.FileName.Length > 0)
             {
                 File.WriteAllText(sfd.FileName, htmlTextBox.Text);
             }
             sfd.DefaultExt = ".css";
             sfd.Filter     = "CSS File (.css)|*css";
             if (sfd.ShowDialog() == true && sfd.FileName.Length > 0)
             {
                 File.WriteAllText(sfd.FileName, csstextBox.Text);
             }
             Application.Current.Shutdown();
         }
         else if (msgBoxRes == MessageBoxResult.No)
         {
             Application.Current.Shutdown();
         }
     }
 }
 private void cmdSaveToFile_Click(object sender, RoutedEventArgs e)
 {
     SaveFileDialog dlg=new SaveFileDialog();
     dlg.Filter = "*.conf|*.conf";
     if (dlg.ShowDialog() == true)
         ProtokollerConfiguration.SaveToFile(dlg.FileName);
 }
示例#4
0
        public async Task ExportInterchangeDataAsMergeSql()
        {
            if (_ZenrinParser.Highways == null || !_ZenrinParser.Highways.Any())
            {
                System.Windows.MessageBox.Show("Haven't loaded highways correctly", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            try
            {
                Microsoft.Win32.SaveFileDialog saveFileDialog1 = new Microsoft.Win32.SaveFileDialog();
                saveFileDialog1.Filter           = "SQL files (*.sql)|*.sql";
                saveFileDialog1.RestoreDirectory = true;
                if (saveFileDialog1.ShowDialog() == true)
                {
                    var sb = new StringBuilder();
                    sb.AppendLine(_ZenrinParser.MergeHighwayData(_ZenrinParser.Highways));
                    sb.AppendLine(_ZenrinParser.MergeInterchangeData(_ZenrinParser.Interchanges));

                    Stream stream;
                    if ((stream = saveFileDialog1.OpenFile()) != null)
                    {
                        var utf = Encoding.UTF8.GetBytes(sb.ToString());
                        stream.Write(utf, 0, utf.Length);
                        stream.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(string.Format("{0}\n{1}", "データ保存中にエラーが発生しました", ex.Message),
                                               "データ保存エラー", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#5
0
        public static void ExportToFile(BitmapSource graphBitmap)
        {
            SaveFileDialog saveDialog = new SaveFileDialog();
            const int FilterIndexJpeg = 1;
            const int FilterIndexPng = 2;
            saveDialog.Filter = "JPEG|*.jpg|PNG|*.png";
            saveDialog.Title = "Save Graph As";
            saveDialog.AddExtension = true;
            saveDialog.ShowDialog();

            if (string.IsNullOrEmpty(saveDialog.FileName))
            {
                return;
            }

            using (FileStream fileStream = (FileStream)saveDialog.OpenFile())
            {
                BitmapEncoder bitmapEncoder;

                switch (saveDialog.FilterIndex)
                {
                    case FilterIndexJpeg:
                        bitmapEncoder = new JpegBitmapEncoder();
                        break;
                    case FilterIndexPng:
                        bitmapEncoder = new PngBitmapEncoder();
                        break;
                    default:
                        throw new ArgumentException("Invalid file save type");
                }

                bitmapEncoder.Frames.Add(BitmapFrame.Create(graphBitmap));
                bitmapEncoder.Save(fileStream);
            }
        }
示例#6
0
        /**
         * seems to have little to no use here.
         * ———————————————————————————————————
         * If it is to be useful, this function needs to be re-written.
         */
        #region ExportSQLiteCreateSnippit
#if !NCORE
        /// <summary>
        /// Uses a SaveFileDialog to get a file and continues to the overload.
        /// </summary>
        static public void ExportSQLiteCreateSnippit()
        {
            sfd.Filter = "SQL|*.sql|*.text|*.text|All files|*";
      #if WPF4
            if (!sfd.ShowDialog().Value)
            {
                return;
            }
      #else
            if (sfd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
      #endif
            ExportSQLiteCreateSnippit(sfd.FileName);
        }
示例#7
0
        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);
            }
        }
示例#8
0
文件: PDFExport.cs 项目: ORRNY66/GS
        public string CreatePDFFile(Stone stone)
        {
            string filename = stone.FullFilePath+".pdf";

            Document document = this.CreateDocument();

            DefineStyles();
            PlaceImage(stone);

            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

            // Set the MigraDoc document
            pdfRenderer.Document = document;

            // Create the PDF document
            pdfRenderer.RenderDocument();

            SaveFileDialog savedlg = new SaveFileDialog();
            savedlg.DefaultExt = ".pdf";

               // Save the PDF document...
            if (savedlg.ShowDialog() == true)
            {
                filename = savedlg.FileName;
                pdfRenderer.Save(filename);
                Process.Start(filename);
                return filename;
            }
            else
            {
                return "";
            }

                    // ...and start a viewer.
        }
示例#9
0
        public static string BrowseForOutputFolder(string title)
        {
            // https://stackoverflow.com/a/50261723/5452781
            // Create a "Save As" dialog for selecting a directory (HACK)
            var dialog = new Microsoft.Win32.SaveFileDialog();

            dialog.InitialDirectory = "c:";                      // Use current value for initial dir
            dialog.Title            = title;
            dialog.Filter           = "Project Folder|*.Folder"; // Prevents displaying files
            dialog.FileName         = "Project";                 // Filename will then be "select.this.directory"
            if (dialog.ShowDialog() == true)
            {
                string path = dialog.FileName;
                // Remove fake filename from resulting path
                path = path.Replace("\\Project.Folder", "");
                path = path.Replace("Project.Folder", "");
                // If user has changed the filename, create the new directory
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                return(path);
            }
            return(null);
        }
示例#10
0
        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;
        }
示例#11
0
        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;
        }
示例#12
0
        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 { }
        }
示例#13
0
        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);
            }
        }
示例#14
0
        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;
            }
        }
        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;
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn public static bool SelectOutputFile(string fileType, ref string fileName, ref string path)
        ///
        /// \brief Select output file.
        ///
        /// \par Description.
        ///
        /// \par Algorithm.
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 10/12/2017
        ///
        /// \param          fileType  (string) - Type of the file.
        /// \param [in,out] fileName (ref string) - Filename of the file.
        /// \param [in,out] path     (ref string) - Full pathname of the file.
        ///
        /// \return True if it succeeds, false if it fails.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public static bool SelectOutputFile(string fileType,
                                            ref string fileName,
                                            ref string path)
        {
            //Get the data file name and path
            Microsoft.Win32.SaveFileDialog fileDialog = new Microsoft.Win32.SaveFileDialog();
            fileDialog.CheckFileExists  = false;
            fileDialog.CheckPathExists  = true;
            fileDialog.Filter           = fileType + " Files (." + fileType + ")|*." + fileType;
            fileDialog.FileName         = fileName;
            fileDialog.InitialDirectory = System.IO.Path.GetFullPath(path);
            fileDialog.RestoreDirectory = true;
            fileDialog.Title            = "Select " + fileType + " file";
            if (fileDialog.ShowDialog() == true)
            {
                fileName = System.IO.Path.GetFileName(fileDialog.FileName);
                path     = RelativePath(Directory.GetCurrentDirectory(), Path.GetDirectoryName(fileDialog.FileName));
                return(true);
            }
            else
            {
                CustomizedMessageBox.Show("File Selection canceled", "Select File Dialog", null, Icons.Error);
                return(false);
            }
        }
 private void button3_Click(object sender, RoutedEventArgs e)
 {
     Directory.SetCurrentDirectory("C:/tmp/soundpcker");
     using (ZipFile zip = new ZipFile())
     {
         // add this map file into the "images" directory in the zip archive
         zip.AddFile("pack.mcmeta");
         // add the report into a different directory in the archive
         zip.AddItem("assets");
         zip.AddFile("lcrm");
         zip.Save("CustomSoundInjector_ResourcePack.zip");
     }
         SaveFileDialog saveFileDialog = new SaveFileDialog();
     saveFileDialog.DefaultExt = ".zip";
     saveFileDialog.Filter = "Minecraft ResourcePack (with Bytecode)|*.zip";
     if (saveFileDialog.ShowDialog() == true)
     {
         exportpath = saveFileDialog.FileName;
     }
     else
     {
         MessageBox.Show("Operation Cancelled.", "Cancelled", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     string originExport = "C:/tmp/soundpcker/CustomSoundInjector_ResourcePack.zip";
     File.Copy(originExport, exportpath, true);
     MessageBox.Show("Saved.", "Saved", MessageBoxButton.OK, MessageBoxImage.Information);
 }
示例#18
0
 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();
         }
     }
 }
示例#19
0
        public string getFolderPath()
        {
            string fullPath = string.Empty;
            // Create a "Save As" dialog for selecting a directory (HACK)
            var dialog = new Microsoft.Win32.SaveFileDialog();

            // dialog.InitialDirectory = textbox.Text; // Use current value for initial dir
            dialog.Title    = "Select a Directory";         // instead of default "Save As"
            dialog.Filter   = "Directory|*.this.directory"; // Prevents displaying files
            dialog.FileName = "select";                     // Filename will then be "select.this.directory"
            if (dialog.ShowDialog() == true)
            {
                string path = dialog.FileName;
                // Remove fake filename from resulting path
                path = path.Replace("\\select.this.directory", "");
                path = path.Replace(".this.directory", "");
                // If user has changed the filename, create the new directory
                if (!System.IO.Directory.Exists(path))
                {
                    System.IO.Directory.CreateDirectory(path);
                }
                // Our final value is in path
                // textbox.Text = path;
                fullPath = path;


                Console.Write("directoryPath:"); Console.WriteLine(fullPath);
            }
            return(fullPath);
        }
示例#20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveParsed_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(Parsed.Text))
                {
                    if (!Properties.Settings.Default.DisableErrorPopups)
                    {
                        MessageBox.Show(Strings.NothingParsed, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                    }

                    return;
                }

                Microsoft.Win32.SaveFileDialog dialog = new Microsoft.Win32.SaveFileDialog
                {
                    FileName = "chatlog.txt",
                    Filter   = "Text File | *.txt"
                };

                if (dialog.ShowDialog() != true)
                {
                    return;
                }
                using (StreamWriter sw = new StreamWriter(dialog.OpenFile()))
                {
                    sw.Write(Parsed.Text.Replace("\n", Environment.NewLine));
                }
            }
            catch
            {
                MessageBox.Show(Strings.SaveError, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#21
0
        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");
                }
            }
        }
示例#22
0
        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;
        }
示例#23
0
        public bool? ShowDialog()
        {
            var dialog = new SaveFileDialog();
            if (AddExtension != null)
            {
                dialog.AddExtension = AddExtension.Value;
            }

            if (DefaultExt != null)
            {
                dialog.DefaultExt = DefaultExt;
            }

            if (InitialDirectory != null)
            {
                dialog.InitialDirectory = InitialDirectory;
            }

            if (Filter != null)
            {
                dialog.Filter = Filter;
            }

            bool? result = dialog.ShowDialog(Application.Current.MainWindow);
            FileName = dialog.FileName;
            return result;
        }
示例#24
0
        /// <summary>
        /// Save the generated file as a raw file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void IL2Save(object sender, RoutedEventArgs e)
        {
            if (bitmap != null)
            {
                var dialog = new Microsoft.Win32.SaveFileDialog();
                dialog.InitialDirectory = SRTMdirectory;
                dialog.Title            = "Save generated image";
                dialog.Filter           = "IL2 files (*.tga)|*.tga";

                if (dialog.ShowDialog() == true)
                {
                    Mouse.OverrideCursor = Cursors.Wait;

                    IL2Mapping  map       = new IL2Mapping();
                    IL2Colour[] newPixels = new IL2Colour[settings.ImageWidth * settings.ImageHeight];

                    for (int i = 0; i < settings.ImageHeight * settings.ImageWidth; i++)
                    {
                        newPixels[i] = map.GetColour(Pixels[i]);
                    }

                    TGAWriter.Save(newPixels, settings.ImageWidth, settings.ImageHeight, dialog.FileName);

                    Mouse.OverrideCursor = null;
                }
            }
        }
        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;
                    }
                }
            }
        }
示例#26
0
        private void SaveAs()
        {
            SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();

            dlg.FileName   = curFileName;                        // Default file name
            dlg.DefaultExt = ".rtf";                             // Default file extension
            dlg.Filter     = "Rich Text Documents (.rtf)|*.rtf"; // Filter files by extension

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

            // Process save file dialog box results
            if (result == true)
            {
                // Save document
                string filename = dlg.FileName;

                TextRange  range;
                FileStream fStream;
                range   = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd);
                fStream = new FileStream(filename, FileMode.Create);
                range.Save(fStream, DataFormats.Rtf);
                fStream.Close();

                curFileName         = dlg.SafeFileName;
                curFileNameWithPath = dlg.FileName;
                IsOpenDocSaved      = true;
                IsSaved             = true;
            }
        }
示例#27
0
        private async void BtnDownload_OnItemClick(object sender, ItemClickEventArgs e)
        {
            await ForeachOnSelectedRows(delegate(Message message, CancellationToken token)
            {
                var db      = new SmevContext();
                var vidSved = db.VidSveds.FirstOrDefault(i => i.NamespaceUri == message.NamespaceUri);

                if (vidSved == null)
                {
                    throw new Exception("Вид сведений не существует");
                }

                var dialog = new SaveFileDialog
                {
                    FileName    = $"{vidSved.Prefix}_{(message.IsIncome ? "IN" : "OUT")}_{message.MessageId}.XML",
                    Filter      = @"Файлы xml|*.xml",
                    FilterIndex = 0
                };

                if (dialog.ShowDialog() == true)
                {
                    File.WriteAllBytes(dialog.FileName, message.MessageContent);
                }
            }, new ForEachOnSelectedRowsSettings()
            {
                OperationName       = e.Item.Hint.ToString(),
                OnlyOneRowOperation = true,
                Refresh             = false,
                ShowProgressBar     = false
            });
        }
示例#28
0
        private void dodaj_click(object sender, RoutedEventArgs e)
        {
            if (validate())
            {
                SaveFileDialog dlg = new SaveFileDialog();
                dlg.Filter = "Rich Text Format (*.rtf)|*.rtf|All files (*.*)|*.*";
                dlg.Title  = "Snimanje teksta...";

                if (dlg.ShowDialog() == true)
                {
                    using (FileStream fileStream = new FileStream(dlg.FileName, FileMode.Create))
                    {
                        TextRange range = new TextRange(rtbEdit.Document.ContentStart, rtbEdit.Document.ContentEnd);
                        range.Save(fileStream, DataFormats.Rtf);

                        MainWindow.Automobili_lista.Add(new Klase.Automobili(nazivbox.Text, ComboBoxModel.SelectedValue.ToString(), dlg.FileName, Int32.Parse(textBoxCena.Text), putanjaSlike.Content.ToString(), DateTime.Now));
                        this.Close();
                    }
                }
            }
            else
            {
                MessageBox.Show("Polja nisu dobro popunjena!", "Greška!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#29
0
 private void Button_Outputfile_Click(object sender, RoutedEventArgs e)
 {
     Microsoft.Win32.SaveFileDialog sf = new Microsoft.Win32.SaveFileDialog();
     sf.Filter  = "*.pcap|*.pcap";
     sf.FileOk += Sf_FileOk;
     sf.ShowDialog();
 }
示例#30
0
 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;
 }
 public void Save()
 {
     //To get the button click animation to show. We need to open the Microsoft.Win32.SaveFileDialog in a new thread.
     new System.Threading.Thread(new System.Threading.ThreadStart(async() =>
     {
         //Initailize the open file dialog and title.
         SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog()
         {
             Title = Files.Count > 1 ? String.Format("Merging {0} File(s)", Files.Count) : String.Format("Converting {0}", Path.GetFileName(Files[0].path))
         };
         //If user clicks ok.
         if (saveFileDialog.ShowDialog() == true)
         {
             using (Combiner comb = new Combiner())
             {
                 comb.Output   = saveFileDialog.FileName;
                 comb.Password = Files.Cast <PDFItem>().Any(x => x.password != null) ? MessageDialogResult.Affirmative == await((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("Password protected pdf", "One or more of the pdfs you are merging are password protected. Do you want to protect the merged pdf with a pasword?", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings()
                 {
                     AffirmativeButtonText = "Yes", NegativeButtonText = "No"
                 }) ? (await((MetroWindow)Application.Current.MainWindow).ShowInputAsync("Enter the password for the merged pdf", "Password contain anything")).ToSecureString() : null : null;
                 foreach (var item in Files)
                 {
                     comb.AddFile(File.ReadAllBytes(item.path), null);
                 }
             }
         }
         if (!String.IsNullOrEmpty(saveFileDialog.FileName))
         {
             System.Diagnostics.Process.Start(saveFileDialog.FileName);
         }
     })).Start();
 }
        // 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;
        }
示例#33
0
 // Exports statistics to csv file
 private void ExportStatistics()
 {
     SaveFileDialog exportDialog = new SaveFileDialog();
     exportDialog.DefaultExt = "csv";
     if (exportDialog.ShowDialog() == true)
         StatisticsManager.Instance.ExportStatistics(exportDialog.FileName);
 }
示例#34
0
        private void btnFoto_Click(object sender, RoutedEventArgs e)
        {
            object item = fileTreeView.SelectedItem;

            if (item is FileEntry)
            {
                var    entry  = (FileEntry)item;
                byte[] data   = resource.GetFile(entry.ResourceIdx);
                var    dlg    = new Microsoft.Win32.SaveFileDialog();
                bool?  result = dlg.ShowDialog();
                // Process save file dialog box results
                if (result == true)
                {
                    string filename = dlg.FileName;
                    try
                    {
                        var stream = new FileStream(filename, FileMode.Create, FileAccess.Write);
                        stream.Write(data, 0, data.Length);
                        stream.Close();
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine("Exception " + exception.ToString());
                    }
                }
            }
        }
示例#35
0
        /// <summary>
        /// Initializes a new instance of the IntroductionViewModel class.
        /// </summary>
        public HomeViewModel(IConfigurationService configurationService)
        {
            _configurationService = configurationService;

            selectedFile = _configurationService.IsFileLoaded() ? "hi" : "";

            CreateNewFileCommand = new RelayCommand(() => {
                var saveFileDialog = new SaveFileDialog();
                saveFileDialog.AddExtension = true;
                saveFileDialog.DefaultExt = "pktd";
                saveFileDialog.Filter = "Parakeet File|*.pktd;*.pkd";
                saveFileDialog.FileOk += SaveFileDialog_FileOk;
                saveFileDialog.ShowDialog();
            }, () => string.IsNullOrEmpty(SelectedFile));

            OpenExistingFileCommand = new RelayCommand(() => {
                var openFileDialog = new OpenFileDialog();
                openFileDialog.AddExtension = true;
                openFileDialog.DefaultExt = "pktd";
                openFileDialog.Filter = "Parakeet File|*.pktd;*.pkd";
                openFileDialog.Multiselect = false;
                openFileDialog.FileOk += OpenFileDialog_FileOk;
                openFileDialog.ShowDialog();
            }, () => string.IsNullOrEmpty(SelectedFile));
        }
示例#36
0
        private void SaveCommand()
        {
            // Create SaveFileDialog
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();

            // Set filter for file extension and default file extension
            dlg.DefaultExt = ".txt";
            dlg.Filter     = "TXT Files (*.txt)|*.txt|RTF Files (*.rtf)|*.rtf|DOC Files (*.doc)" +
                             "|*.doc|HTML Files (*.html)|*.html";
            dlg.RestoreDirectory = true;

            // Display OpenFileDialog by calling ShowDialog method
            Nullable <bool> result = dlg.ShowDialog();

            TextRange  range;
            FileStream fStream;

            range = new TextRange(Text_Field.Document.ContentStart, Text_Field.Document.ContentEnd);

            // Get the selected file name and display in a title
            if (result == true)
            {
                // if file exist - append this file if not create and write there information
                fStream = new FileStream(dlg.FileName, FileMode.Append);

                // display name of the file on the title of the form
                string filenameWithoutExt = System.IO.Path.GetFileNameWithoutExtension(dlg.FileName);
                range.Save(fStream, DataFormats.Text);
                DocumentTitle.Text = filenameWithoutExt;

                fStream.Close();
            }
        }
        public void CSVEButton_Click(object sender, RoutedEventArgs e)
        {
            //Employee Export
            string         connection  = (string)System.Windows.Application.Current.FindResource("Connection");
            string         queryString = "SELECT * from Users;";
            SqlDataAdapter adapter     = new SqlDataAdapter(selectCommandText: queryString, selectConnectionString: connection);
            DataSet        ds          = new DataSet();

            adapter.Fill(ds, srcTable: "Users");
            DataTable data = ds.Tables[0];

            // Configure save file dialog box
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            string filename = "";

            dlg.FileName   = "Users";                  // Default file name
            dlg.DefaultExt = ".csv";                   // Default file extension
            dlg.Filter     = "csv Files (.csv)|*.csv"; // Filter files by extension
            filename       = dlg.FileName;

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

            //Process save file dialog box results
            if (result == true)
            {
                //Save document
                filename = dlg.FileName;
                CreateCSVFile(data, filename);
            }
        }
        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!");
            }
        }
示例#39
0
        private void miFileExport_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog();
            sfd.InitialDirectory = Directory.GetCurrentDirectory();
            sfd.Filter           = "PNG|*.png";
            sfd.DefaultExt       = ".png";

            if (sfd.ShowDialog() == true)
            {
                string             path = sfd.FileName;
                RenderTargetBitmap rtb  = new RenderTargetBitmap((int)bSpriteSheet.Width, (int)bSpriteSheet.Height, 96d, 96d, System.Windows.Media.PixelFormats.Default);
                cSpriteSheet.Background.Opacity = 0d;
                rtb.Render(cSpriteSheet);

                var stm = System.IO.File.Create(path);

                BitmapEncoder pngEncoder = new PngBitmapEncoder();
                pngEncoder.Frames.Add(BitmapFrame.Create(rtb));
                pngEncoder.Save(stm);
                cSpriteSheet.Background.Opacity = 1d;
                stm.Close();

                if (lSpriteSheet.Count > 0)
                {
                    WriteXML(path);
                }
            }
        }
示例#40
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            ArrayList line = new ArrayList();

            Write_date_arrlist(line);
            // Set a variable to the Documents path.
            string docPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

            if (_PathPlayList.Count > 0)
            {
                string alltext = "";
                for (int i = 0; i < line.Count; i++)
                {
                    alltext += line[i].ToString() + " ";
                }

                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "Text file (*.txt)|*.txt";
                if (saveFileDialog.ShowDialog() == true)
                {
                    File.WriteAllText(saveFileDialog.FileName, alltext);
                    MessageBox.Show("Lưu playlist thành công.(^.^)", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            else
            {
                MessageBox.Show("Không có dự liệu dể lưu.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
示例#41
0
        private void saveButton_Click(object sender, RoutedEventArgs e)
        {
            if (sequenceTextBox.Text != null)
            {
                InitializeSaveSequenceFileDialog();

                if (saveSequenceFileDialog.ShowDialog() == true)
                {
                    try
                    {
                        Fragment toSave = new Fragment();
                        toSave.Name = sequenceName;
                        ISequence seq = new Bio.Sequence(Alphabets.DNA, sequence);
                        toSave.Sequence = seq;
                        toSave.Length   = sequence.Length;
                        ISequenceFormatter formatter = SequenceFormatters.FindFormatterByFileName(saveSequenceFileDialog.FileName);
                        formatter.Write(seq);
                        formatter.Close();
                        //toSave.Construct.SaveAsBio(saveSequenceFileDialog.FileName);
                    }
                    catch (Exception ex)
                    {
                        MessageBoxResult result = ModernDialog.ShowMessage(ex.Message, "Exception", MessageBoxButton.OK);
                    }
                }
            }
        }
示例#42
0
        public static void ExportPivotToExcel(RadPivotGrid pivot)
        {        
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.DefaultExt = "xlsx";
          //  dialog.Filter = "CSV files (*.csv)|*.csv |All Files (*.*) | *.*";

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

                      //  IWorkbookFormatProvider formatProvider = new CsvFormatProvider();
                        //formatProvider.Export(workbook, stream);
                        XlsxFormatProvider provider = new XlsxFormatProvider();
                        provider.Export(workbook, stream);
                    }
                }
                catch (IOException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
          
        }
示例#43
0
		/// <summary>Stores the image in the specified type under the specified folder, with the <paramref name="filename" />.</summary>
		public static FileInfo SaveAsFileDialog(this BitmapSource image, string filename = null)
		{
			var dlg = new SaveFileDialog
			{
				FileName = filename ?? "Abbildung",
				DefaultExt = ".png",
				Filter = "PNG|*.png|JPG|*.jpg|GIF|*.gif|BMP|*.bmp|TIFF|*.tiff|WMP|*.wmp"
			};
			var result = dlg.ShowDialog();

			if (result == true)
			{
				var fileInfo = new FileInfo(dlg.FileName);
				fileInfo.CreateDirectory_IfNotExists();
				fileInfo.AppendIndexToFile_IfExists();

				var le = fileInfo.Extension.ToLower();
				if (le == ".png")
					image.SaveAs_PngFile(fileInfo);
				if (le == ".jpg")
					image.SaveAs_JpgFile(fileInfo);
				if (le == ".gif")
					image.SaveAs_GifFile(fileInfo);
				if (le == ".bmp")
					image.SaveAs_BmpFile(fileInfo);
				if (le == ".tiff")
					image.SaveAs_TiffFile(fileInfo);
				if (le == ".wmp")
					image.SaveAs_WmpFile(fileInfo);
				return fileInfo;
			}
			return null;
		}
示例#44
0
        }// end:CloseXrML
        #endregion File|Rights...


        #region File|Publish...
        // ---------------------------- OnPublish -----------------------------
        /// <summary>
        ///   Handles the File|Publish... menu selection to
        ///   write a digital rights encrypted document package.</summary>
        private void OnPublish(object sender, EventArgs e)
        {
            // Create a "File Save" dialog positioned to the
            // "Content\" folder to write the encrypted package to.
            WinForms.SaveFileDialog dialog = new WinForms.SaveFileDialog();
            dialog.InitialDirectory = GetContentFolder();
            dialog.Title  = "Publish Rights Managed Package As";
            dialog.Filter = "Rights Managed XPS package (*-RM.xps)|*-RM.xps";

            // Create a new package filename by prefixing
            // the document filename extension with "rm".
            dialog.FileName = _xpsDocumentPath.Insert(
                                  _xpsDocumentPath.LastIndexOf('.'), "-RM" );

            // Show the "Save As" dialog. If the user clicks "Cancel", return.
            if (dialog.ShowDialog() != true)  return;

            // Extract the filename without path.
            _rmxpsPackagePath = dialog.FileName;
            _rmxpsPackageName = _rmxpsPackagePath.Remove(
                                    0, _rmxpsPackagePath.LastIndexOf('\\')+1 );

            WriteStatus("Publishing '" + _rmxpsPackageName + "'.");
            PublishRMPackage(_xpsDocumentPath, _xrmlFilepath, dialog.FileName);

        }// end:OnPublish()
示例#45
0
        private void ButtonS_Click(object sender, RoutedEventArgs e)
        {
            string daily = "";

            daily += title.Text + "\n";
            daily += context.Text + "\n";


            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName   = title.Text;                    // Default file name
            dlg.DefaultExt = ".text";                       // Default file extension
            dlg.Filter     = "Text documents (.txt)|*.txt"; // Filter files by extension

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

            // Process save file dialog box results
            if (result == true)
            {
                // Save document
                string filename = dlg.FileName;
                // Write the string to a file.
                System.IO.StreamWriter file = new System.IO.StreamWriter(dlg.FileName.ToString());
                file.WriteLine(daily);

                file.Close();
            }
        }
        public bool SaveFile(List <string> fileData)
        {
            // creates save fiale dialog object and set its properties
            Microsoft.Win32.SaveFileDialog saveDialog = new Microsoft.Win32.SaveFileDialog();

            saveDialog.Title  = "Zapisz wygenerowaną łatkę";
            saveDialog.Filter = "PATCH files (*.patch)|*.patch";

            try
            {
                // show save filedialog
                if (saveDialog.ShowDialog() == true)
                {
                    // save file if path was choosen correctly
                    using (StreamWriter writer = new StreamWriter(saveDialog.FileName))
                    {
                        foreach (string s in fileData)
                        {
                            writer.WriteLine(s);
                        }
                    }

                    return(true);
                }
            }
            catch (Exception ex)
            {
                // If any error occure save it to log file
                LogsManager.SaveErrorToLogFile(ex.Message);

                return(false);
            }

            return(false);
        }
示例#47
0
        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;
            }
        }
示例#48
0
        public void Execute(object parameter)
        {
            Task Report = new Task(delegate
            {
                MessageBox.Show("report will be ready in a minute");
                StringBuilder stringBuilder = new StringBuilder();
                foreach (var item in Model.AllProcesses)
                {
                    try
                    {
                        stringBuilder.AppendLine($"{item.ProcessName} - {item.StartTime.ToString()}");
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                dlg.FileName   = "Report";
                dlg.DefaultExt = ".text";
                dlg.Filter     = "Text documents (.txt)|*.txt";

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

                if (result == true)
                {
                    File.WriteAllText(dlg.FileName, stringBuilder.ToString());
                }
            });

            Report.Start();
        }
        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);
        }
示例#50
0
        /*
         * Saves data from a graph to json file
         * TODO - make this week
         */
        private void Save()
        {
            //set default file name to tab header
            String defaultName = this.Header.ToString();

            //Remove .utr extention if present
            if (defaultName.EndsWith(".utr"))
            {
                defaultName = defaultName.Substring(0, defaultName.Length - 4);
            }

            //Create save dialog
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName   = defaultName;
            dlg.DefaultExt = ".txt";
            dlg.Filter     = "Text files (.txt)|*.txt";

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

            string json = JsonConvert.SerializeObject(dataTable, Formatting.Indented);

            // Process save file dialog box results
            if (result == true)
            {
                // Save document
                string filename = dlg.FileName;
                File.WriteAllText(filename, json);
            }
        }
示例#51
0
        private void BtnSaveScreenshotAs_OnClick(object sender, RoutedEventArgs e)
        {
            SaveFileDialog ofd = new SaveFileDialog
            {
                Filter   = "Error Screenshot *.png|*.png",
                FileName = "Error_" + OS.WinToolkit.WinToolkitVersion.Replace(".", "-") + "_" +
                           _exception.Date.ToString("dd_MMMM_yyyy-HHmmss")
            };


            var showDialog = ofd.ShowDialog();

            if (showDialog != null && !(bool)showDialog)
            {
                return;
            }


            for (int i = 0; i < _exception.Screenshots.Count; i++)
            {
                string fileName = Path.GetFileNameWithoutExtension(ofd.FileName) + "_" + i;
                string saveTo   = Path.GetDirectoryName(ofd.FileName) + "\\" + fileName + ".png";
                _exception.Screenshots[i].Save(saveTo);
            }
        }
示例#52
0
        public void ButtonDecrypt(object sender, RoutedEventArgs e)
        {
            if (File.Exists("obrazek.png") == true)
            {
                string           Text     = Decrypt();
                char             uvozovky = '"';
                MessageBoxResult r        = MessageBox.Show("The clear message is: " + uvozovky + Text + uvozovky, "Do you want to save your message?", MessageBoxButton.YesNo);
                if (r == MessageBoxResult.Yes)
                {
                    Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                    dlg.FileName   = "encrypted";                   // Default file name
                    dlg.DefaultExt = ".txt";                        // Default file extension
                    dlg.Filter     = "Text documents (.txt)|*.txt"; // Filter files by extension

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

                    // Process save file dialog box results
                    if (result == true)
                    {
                        // Save document
                        string filename = dlg.FileName;
                        System.IO.File.WriteAllText(filename + ".txt", Text);
                    }
                    else
                    {
                        MessageBox.Show("I am sorry, but you didn´t choose the location", "Save-Error");
                    }
                }
            }
            else
            {
                MessageBox.Show("I am sorry, but there is no picture added", "Add-Error");
            }
        }
示例#53
0
        //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;
            }
        }
示例#54
0
        public static string GetManualDir()
        {
            var dialog = new Microsoft.Win32.SaveFileDialog()
            {
                Title    = "Please select your Beat Saber installation folder",
                Filter   = "Directory|*.this.directory",
                FileName = "select"
            };

            if (dialog.ShowDialog() == true)
            {
                string path = dialog.FileName;
                path = path.Replace("\\select.this.directory", "");
                path = path.Replace(".this.directory", "");
                path = path.Replace("\\select.directory", "");
                if (File.Exists(Path.Combine(path, "Beat Saber.exe")))
                {
                    string store;
                    if (File.Exists(Path.Combine(path, "Beat Saber_Data", "Plugins", "steam_api64.dll")))
                    {
                        store = "Steam";
                    }
                    else
                    {
                        store = "Oculus";
                    }
                    return(SetDir(path, store));
                }
            }
            return(null);
        }
示例#55
0
 // Функция сохранения изображения c использованием класса SaveFileDialog
 public void SaveImage()
 {
     Microsoft.Win32.SaveFileDialog saveimg = new Microsoft.Win32.SaveFileDialog();
     saveimg.DefaultExt = ".BMP";      // Задание определенных свойств класса (Расширений)
     saveimg.Filter     = "Image (.BMP)|*.BMP";
     if (saveimg.ShowDialog() == true) // Если окно открылось
     {
         Thickness margin = MyCanvas.Margin;
         MyCanvas.Margin = new Thickness(0);
         RenderTargetBitmap rtb        = CanvasToBitmap();       // Получение изображения в растровом формате
         BitmapEncoder      bmpEncoder = new BmpBitmapEncoder(); // Определяем кодировщик, для кодирования изображения
         bmpEncoder.Frames.Add(BitmapFrame.Create(rtb));         // Задаем фрейм для изображения
         try
         {
             System.IO.MemoryStream ms = new System.IO.MemoryStream();     // Создаем поток в память.
             bmpEncoder.Save(ms);                                          // Кодируем изображение в наш поток
             ms.Close();
             System.IO.File.WriteAllBytes(saveimg.FileName, ms.ToArray()); // Создаем файл, записываем в него масив байтов и закрываем
         }
         catch (Exception ex)                                              // Обработка исключений
         {
             System.Windows.MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
         MyCanvas.Margin = margin;
     }
 }
示例#56
0
        /// <summary>
        /// 生成比较列表清单事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_MakeCompareList_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                FileList.Clear();
                var currTime = DateTime.Now;

                var sfd = new SaveFileDialog();
                sfd.Filter = "文本文件(.txt)|*.txt";
                sfd.ShowDialog();

                if (sfd.FileName == null || sfd.FileName == "")
                {
                    return;
                }

                GetFolderFileList(Tbx_FolderPath.Text);
                var dict = CalcFileList(Tbx_FolderPath.Text);

                var ls = new List <string>();
                foreach (var keyValue in dict)
                {
                    ls.Add($@"{keyValue.Key},{keyValue.Value}");
                }

                File.WriteAllLines(sfd.FileName, ls.ToArray());

                MessageBox.Show($@"列表生成完毕,共计计算{ls.Count}个文件,耗时{Math.Round((DateTime.Now - currTime).TotalSeconds)}秒!");
            }
            catch (Exception ex)
            {
                MessageBox.Show($@"生成比较清单异常,{ex.Message}");
            }
        }
        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);
                }
            }
        }
示例#58
0
        private void NewProject()
        {
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName   = "Urcie Project";                // Default file name
            dlg.DefaultExt = ".urc1";                        // Default file extension
            dlg.Filter     = "Urcie Project (.urc1)|*.urc1"; // Filter files by extension

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

            if (result == true)
            {
                ProjectViewModel viewModel = new ProjectViewModel();
                viewModel.Code = dlg.FileName;
                try
                {
                    viewModel.Code = Path.GetFileNameWithoutExtension(dlg.FileName);
                    viewModel.Path = dlg.FileName;
                    Storage.SaveProject(viewModel.ToModel());
                    OpenProjects.Add(viewModel);
                    SelectedProject          = viewModel;
                    SelectedProject.Original = viewModel.ToModel();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
示例#59
0
        private void SavePlot_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new SaveFileDialog
            {
                Filter = ".svg files|*.svg|.png files|*.png|.pdf files|*.pdf|.xaml files|*.xaml",
                DefaultExt = ".svg"
            };
            if (dlg.ShowDialog(this).Value)
            {
                var ext = Path.GetExtension(dlg.FileName).ToLower();
                switch (ext)
                {
                    case ".png":
                        plot1.SaveBitmap(dlg.FileName, 0, 0, OxyColors.Automatic);
                        break;
                    case ".svg":
                        var rc = new ShapesRenderContext(null);
                        var svg = OxyPlot.SvgExporter.ExportToString(this.vm.Model, plot1.ActualWidth, plot1.ActualHeight, false, rc);
                        File.WriteAllText(dlg.FileName, svg);
                        break;
                    case ".pdf":
                        using (var s = File.Create(dlg.FileName))
                        {
                            PdfExporter.Export(vm.Model, s, plot1.ActualWidth, plot1.ActualHeight);
                        }

                        break;
                    case ".xaml":
                        plot1.SaveXaml(dlg.FileName);
                        break;
                }

                this.OpenContainingFolder(dlg.FileName);
            }
        }