private SaveFileDialog GetSaveFileDialog()
        {
            SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();

            sfd.AddExtension                 = false;
            sfd.AutoUpgradeEnabled           = true;
            sfd.CheckFileExists              = true;
            sfd.CheckPathExists              = true;
            sfd.Filter                       = "Starbound Assets|*.player|All files (*.*)|*.*";
            sfd.RestoreDirectory             = true;
            sfd.SupportMultiDottedExtensions = true;
            sfd.DereferenceLinks             = true;
            sfd.Title         = "Save As";
            sfd.ValidateNames = true;
            if (FileOpen == FileOpenMode.Opened)
            {
                sfd.InitialDirectory = CurrentFile.Directory.FullName;
                sfd.FileName         = CurrentFile.Name;
            }
            else if (FileOpen == FileOpenMode.New)
            {
                sfd.InitialDirectory = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Steam\\steamapps\\common\\Starbound\\assets");
                sfd.FileName         = "New Untitled File";
            }


            return(sfd);
        }
Ejemplo n.º 2
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveDialog = new System.Windows.Forms.SaveFileDialog
            {
                AddExtension = true,
                Filter       = "(*.txt)|*.txt|Все файлы (*.*)|*.* "
            };

            if (saveDialog.ShowDialog() == DialogResult.OK)
            {
                using (FileStream fs = new FileStream(saveDialog.FileName, FileMode.OpenOrCreate, FileAccess.Write))
                {
                    FlowDocument flow = new FlowDocument();
                    flow = ChequeBuilder.GetCheque();
                    TextRange textRange = new TextRange(flow.ContentStart, flow.ContentEnd);
                    textRange.Save(fs, System.Windows.DataFormats.Text);
                }
            }
        }