Ejemplo n.º 1
0
        /// <summary>
        /// Displays the save file dialog for the current operating system.  Returns true if the user selected or entered a file name.  Read the FileName property for the selected file.
        /// </summary>
        public Boolean ShowDialog()
        {
            using (var dialogSaveFile = new VistaSaveFileDialog()) {
                dialogSaveFile.AddExtension                 = this.AddExtension;
                dialogSaveFile.CheckFileExists              = this.CheckFileExists;
                dialogSaveFile.CheckPathExists              = this.CheckPathExists;
                dialogSaveFile.CreatePrompt                 = this.CreatePrompt;
                dialogSaveFile.DefaultExt                   = this.DefaultExtension;
                dialogSaveFile.Filter                       = this.Filter;
                dialogSaveFile.InitialDirectory             = this.InitialDirectory;
                dialogSaveFile.OverwritePrompt              = this.OverWritePrompt;
                dialogSaveFile.ShowHelp                     = false;
                dialogSaveFile.SupportMultiDottedExtensions = this.SupportMultiDottedExtensions;
                dialogSaveFile.Title         = this.Title;
                dialogSaveFile.ValidateNames = this.ValidateNames;

                DialogResult result = dialogSaveFile.ShowDialog();

                if (result == DialogResult.OK)
                {
                    _fileName = dialogSaveFile.FileName;
                    return(true);
                }
                //user cancelled
                return(false);
            }
        }
Ejemplo n.º 2
0
        private void ExportAlarmWorxPortal()
        {
            VistaSaveFileDialog selectFileDialog = new VistaSaveFileDialog();
            VistaOpenFileDialog openFileDialog   = new VistaOpenFileDialog();

            openFileDialog.Title        = "Select DB Text File Location";
            openFileDialog.AddExtension = true;
            openFileDialog.DefaultExt   = ".db";
            openFileDialog.Filter       = "DB File|*.db";
            if (Directory.Exists(S7Model.WinCCPortalDigitalAlarmsImportFilePath))
            {
                openFileDialog.InitialDirectory = Properties.Settings.Default.WinCCPortalDigitalAlarmsImportFilePath;
            }

            if ((bool)openFileDialog.ShowDialog())
            {
                selectFileDialog.Title        = "Select Export Location";
                selectFileDialog.AddExtension = true;
                selectFileDialog.DefaultExt   = ".csv";
                selectFileDialog.Filter       = "CSV File|*.csv";
                if (Directory.Exists(S7Model.WinCCPortalDigitalAlarmsExportFilePath))
                {
                    selectFileDialog.InitialDirectory = Properties.Settings.Default.WinCCPortalDigitalAlarmsExportFilePath;
                }

                if ((bool)selectFileDialog.ShowDialog())
                {
                    S7Model.ExportAlarmWorxPortal(openFileDialog.FileName, selectFileDialog.FileName);
                }
            }
        }
Ejemplo n.º 3
0
        private async void SavePlainTextButton_Click(object sender, RoutedEventArgs e)
        {
            // Status Update
            StatusLabel.Content = "Generating Folder Structure...";

            // If Unified folder doesn't exist then create one, otherwise generate one
            if (JUnifiedFolder == null)
            {
                // Dispatch a thread to handling generation stuff
                await Task.Factory.StartNew(FolderIterator);
            }

            // Generate text from JSON
            string indentation = "";

            RecursiveText(JUnifiedFolder, indentation);

            // Select Path To Save File
            VistaSaveFileDialog saveFileDialog = new VistaSaveFileDialog();

            saveFileDialog.DefaultExt       = ".txt";
            saveFileDialog.FileName         = "Folder Structure";
            saveFileDialog.Filter           = "Text Files(*.txt) | *.txt";
            saveFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
            saveFileDialog.Title            = "Select where to save Text file";
            saveFileDialog.ValidateNames    = true;
            bool?result = saveFileDialog.ShowDialog();

            if (result == true)
            {
                // Save File Content & Update Status
                System.IO.File.WriteAllText(saveFileDialog.FileName, PlainFolderStructure);
                StatusLabel.Content = "Saved to file: " + saveFileDialog.FileName;
            }
        }
Ejemplo n.º 4
0
        public string GetFileSavePath(string title, string defaultExt, string filter)
        {
            if (VistaSaveFileDialog.IsVistaFileDialogSupported)
            {
                VistaSaveFileDialog saveFileDialog = new VistaSaveFileDialog {
                    Title = title, DefaultExt = defaultExt, CheckFileExists = false, RestoreDirectory = true, Filter = filter
                };

                if (saveFileDialog.ShowDialog() == true)
                {
                    return(saveFileDialog.FileName);
                }
            }
            else
            {
                Microsoft.Win32.SaveFileDialog ofd = new Microsoft.Win32.SaveFileDialog {
                    Title = title, DefaultExt = defaultExt, CheckFileExists = false, RestoreDirectory = true, Filter = filter
                };

                if (ofd.ShowDialog() == true)
                {
                    return(ofd.FileName);
                }
            }

            return("");
        }
Ejemplo n.º 5
0
        private void Button_Today_DB_Click(object sender, RoutedEventArgs e)
        {
            using (var p = new ExcelPackage())
                using (var sqlcmd = new SqlCommandExecutor("EXEC pr_GetDactyloscopyReport"))
                    using (var sqlReader = sqlcmd.ExecuteReader())
                    {
                        var ws    = p.Workbook.Worksheets.Add("BANK");
                        int count = sqlReader.FieldCount;
                        for (var i = 1; sqlReader.Read(); i++)
                        {
                            for (int j = 1; j <= count; j++)
                            {
                                ws.Cells[i, j].Value = sqlReader.GetValue(j - 1);
                                ws.Cells[i, j].Style.Font.SetFromFont(new Font("Times New Roman", 12));
                            }
                        }

                        var dlg = new VistaSaveFileDialog()
                        {
                            Filter          = "Open XML Spreadsheet |*.xlsx",
                            FileName        = "Отчет для дактилоскопии",
                            DefaultExt      = ".xlsx",
                            OverwritePrompt = true,
                            CreatePrompt    = false,
                        };
                        if (dlg.ShowDialog() == true)
                        {
                            using (var fs = File.Create(dlg.FileName))
                                p.SaveAs(fs);
                        }
                    }
        }
Ejemplo n.º 6
0
        public MainForm()
        {
            try
            {
                finishedLoading          = false;
                activeOrInActiveMainForm = this;

                Program.Settings = Settings.LoadSettings();
                Program.Settings.DirectoryList.Initialize();

                InitializeComponent();
                initFilesDataGridViewCheckAllCheckBox();
                foldersListBox.DataSource             = Program.Settings.DirectoryList.Directories;
                compileResultsDataGridView.DataSource = new List <CompileCommandResult>();
                folderBrowserDialog = new VistaFolderBrowserDialog();
                outputFileDialog    = new VistaSaveFileDialog()
                {
                    AddExtension = true,
                    Filter       = @"*.css|*.css"
                };
            }
            catch (Exception e)
            {
                ExceptionHandler.LogException(e);
            }
        }
Ejemplo n.º 7
0
        private async Task onSaveObjectAsExecute()
        {
            VistaSaveFileDialog sfd = new VistaSaveFileDialog
            {
                FileName   = export.NameTableIndex.Name,
                DefaultExt = export.DomainObject.FileExtension,
                Filter     = $"{export.DomainObject.FileTypeDesc}|*{export.DomainObject.FileExtension}",
                Title      = "Save Object As..."
            };

            bool?result = sfd.ShowDialog();

            if (!result.HasValue || !result.Value)
            {
                return;
            }

            int compressor = menuViewModel.IsCompressorClusterFit ? 0 : menuViewModel.IsCompressorRangeFit ? 1 : 2;

            int errorMetric = menuViewModel.IsErrorMetricPerceptual ? 0 : 1;

            DdsSaveConfig config = new DdsSaveConfig(FileFormat.Unknown, compressor, errorMetric, menuViewModel.IsWeightColorByAlpha, false);

            await export.DomainObject.SaveObject(sfd.FileName, config);
        }
Ejemplo n.º 8
0
 private static void ExportPublicKey(string publicKey)
 {
     try
     {
         if (!string.IsNullOrEmpty(publicKey))
         {
             using (var saveFileDialog = new VistaSaveFileDialog())
             {
                 saveFileDialog.Title      = "Export Public Key";
                 saveFileDialog.DefaultExt = ".txt";
                 saveFileDialog.FileName   = "KRYPTOR PUBLIC KEY";
                 if (saveFileDialog.ShowDialog() == DialogResult.OK)
                 {
                     File.WriteAllText(saveFileDialog.FileName, publicKey);
                     File.SetAttributes(saveFileDialog.FileName, FileAttributes.ReadOnly);
                 }
             }
         }
     }
     catch (Exception ex) when(ExceptionFilters.FileAccessExceptions(ex))
     {
         Logging.LogException(ex.ToString(), Logging.Severity.Low);
         DisplayMessage.ErrorMessageBox(ex.GetType().Name, "Unable to export public key.");
     }
 }
Ejemplo n.º 9
0
        bool SaveProj()
        {
            if (!firstSaved || !File.Exists(FileName))
            {
                var sfd = new VistaSaveFileDialog
                {
                    FileName     = FileName,
                    Filter       = "ConfuserEx Projects (*.crproj)|*.crproj|All Files (*.*)|*.*",
                    DefaultExt   = ".crproj",
                    AddExtension = true
                };
                if (!(sfd.ShowDialog(Application.Current.MainWindow) ?? false) || sfd.FileName == null)
                {
                    return(false);
                }

                FileName = sfd.FileName;
            }
            var proj = ((IViewModel <ConfuserProject>)Project).Model;

            proj.Save().Save(FileName);
            Project.IsModified = false;
            firstSaved         = true;
            return(true);
        }
Ejemplo n.º 10
0
        public string SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions)
        {
            var fd = new VistaSaveFileDialog();

            fd.Title            = title;
            fd.InitialDirectory = directory;
            fd.FileName         = defaultName;
            if (extensions != null)
            {
                fd.Filter       = GetFilterFromFileExtensionList(extensions);
                fd.FilterIndex  = 1;
                fd.DefaultExt   = extensions[0].Extensions[0];
                fd.AddExtension = true;
            }
            else
            {
                fd.DefaultExt   = string.Empty;
                fd.Filter       = string.Empty;
                fd.AddExtension = false;
            }
            var res      = fd.ShowDialog(new WindowWrapper(GetActiveWindow()));
            var filename = res == DialogResult.OK ? fd.FileName : "";

            fd.Dispose();
            return(filename);
        }
Ejemplo n.º 11
0
        private void SaveDat(object sender, RoutedEventArgs e)
        {
            if (DatManager.Items.Count < 1)
            {
                MessageBox.Show("Nothing to save");
                return;
            }

            var saveFileDialog = new VistaSaveFileDialog
            {
                Title            = "Save dat file",
                DefaultExt       = ".dat",
                CheckFileExists  = false,
                RestoreDirectory = true,
                Filter           = "dat files (*.dat)|*.dat",
            };

            if (saveFileDialog.ShowDialog() == true)
            {
                if (DatManager.SaveDat(saveFileDialog.FileName))
                {
                    MessageBox.Show("Dat saved.", "Success");
                }
                else
                {
                    MessageBox.Show("Dat failed to save.", "Fail");
                }
            }
        }
Ejemplo n.º 12
0
    public void SaveEach()
    {
        VistaSaveFileDialog save = new VistaSaveFileDialog();

        save.ShowDialog();

        if (save.FileName != "")
        {
            for (int x = 0; x < GetComponent <GroupSelection>().Groups.Count; x++)
            {
                if (save.FileName.Contains(".xfbin"))
                {
                    SaveGroupsToXfbin(x, save.FileName.Replace(".xfbin", "_" + GetComponent <GroupSelection>().GroupNames[x] + ".xfbin"));
                }
                else
                {
                    SaveGroupsToXfbin(x, save.FileName + "_" + GetComponent <GroupSelection>().GroupNames[x] + ".xfbin");
                }
            }

            MessageBox.Show(".xfbin files saved.");
        }
        else
        {
            MessageBox.Show("No name specified.");
        }
    }
        public IObservable <string?> ShowSaveFileDialog(System.Windows.Window?owner, bool addExtension,
                                                        bool checkFileExists, bool checkPathExists, string defaultExt, bool dereferenceLinks, string filter,
                                                        bool createPrompt, bool overwritePrompt, string title, string initialDirectory)
        {
            return(CurrentDispatcher.InvokeAsync(
                       () =>
            {
                var dialog = new VistaSaveFileDialog
                {
                    AddExtension = addExtension,
                    CheckFileExists = checkFileExists,
                    DefaultExt = defaultExt,
                    DereferenceLinks = dereferenceLinks,
                    Filter = filter,
                    Title = title,
                    CheckPathExists = checkPathExists,
                    CreatePrompt = createPrompt,
                    OverwritePrompt = overwritePrompt,
                    InitialDirectory = initialDirectory
                };

                TranslateDefaultExt(dialog);

                var tempresult = owner != null
                        ? dialog.ShowDialog(owner)
                        : dialog.ShowDialog(_mainWindow);

                return tempresult == false ? null : dialog.FileName;
            }));
        }
Ejemplo n.º 14
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var path = $"{Directory.GetCurrentDirectory()}\\Documents\\Персонализация.xlsm";

            using (var p = new ExcelPackage(new FileInfo(path)))
                using (var sqlcmd = new SqlCommandExecutor("EXEC pr_GetReportForVTB"))
                    using (var sqlReader = sqlcmd.ExecuteReader())
                    {
                        var ws    = p.Workbook.Worksheets.First();
                        int count = sqlReader.FieldCount;
                        for (var i = 5; sqlReader.Read(); i++)
                        {
                            for (int j = 1; j <= count; j++)
                            {
                                ws.Cells[i, j].Value = sqlReader.GetValue(j - 1);
                            }
                        }
                        // ws.Cells[] starts from 1, 1
                        // GetValue() starts from 0

                        var dlg = new VistaSaveFileDialog()
                        {
                            Filter          = "Open XML Macro-Enabled Spreadsheet |*.xlsm",
                            FileName        = "Персонализация ВТБ",
                            DefaultExt      = ".xlsm",
                            OverwritePrompt = true,
                            CreatePrompt    = false,
                        };
                        if (dlg.ShowDialog() == true)
                        {
                            using (var fs = File.Create(dlg.FileName))
                                p.SaveAs(fs);
                        }
                    }
        }
Ejemplo n.º 15
0
        private void Button_Report_Click(object sender, RoutedEventArgs e)
        {
            var path = $"{Directory.GetCurrentDirectory()}\\Documents\\Форма.xlsx";

            using (var p = new ExcelPackage(new FileInfo(path)))
                using (var sqlcmd = new SqlCommandExecutor("EXEC pr_GetAddedPersonsFromYesterday"))
                    using (var sqlReader = sqlcmd.ExecuteReader())
                    {
                        var ws    = p.Workbook.Worksheets.First();
                        int count = sqlReader.FieldCount;
                        for (var i = 4; sqlReader.Read(); i++)
                        {
                            for (int j = 1; j <= count; j++)
                            {
                                ws.Cells[i, j].Value = sqlReader.GetValue(j - 1);
                            }
                        }
                        // ws.Cells[] starts from 1, 1
                        // GetValue() starts from 0

                        var dlg = new VistaSaveFileDialog()
                        {
                            Filter          = "Open XML Spreadsheet |*.xlsx",
                            FileName        = $"Залитые за {DateTime.Now.AddDays(-1).ToString("dd-MM-yyyy")}",
                            DefaultExt      = ".xlsx",
                            OverwritePrompt = true,
                            CreatePrompt    = false,
                        };
                        if (dlg.ShowDialog() == true)
                        {
                            using (var fs = File.Create(dlg.FileName))
                                p.SaveAs(fs);
                        }
                    }
        }
Ejemplo n.º 16
0
        private void ExportAsScriptMenuItem_Click(object sender, RoutedEventArgs e)
        {
            VistaSaveFileDialog fileDialog = new VistaSaveFileDialog();

            fileDialog.AddExtension    = true;
            fileDialog.DefaultExt      = ".txt";
            fileDialog.Filter          = "Script files (*.txt)|*.txt";
            fileDialog.OverwritePrompt = true;
            fileDialog.Title           = "Export Script";
            bool?res = fileDialog.ShowDialog(this);

            if (res ?? false)
            {
                try {
                    Mouse.SetCursor(Cursors.Wait);
                    _chapterManager.ExportScript(fileDialog.FileName);
                    Mouse.SetCursor(Cursors.Arrow);
                }
                catch (Exception ex) {
                    Mouse.SetCursor(Cursors.Arrow);
                    using (TaskDialog dialog = new TaskDialog()) {
                        dialog.WindowTitle     = "Error";
                        dialog.MainIcon        = TaskDialogIcon.Error;
                        dialog.MainInstruction = "There was an error exporting the script.";
                        dialog.Content         = ex.Message;
                        TaskDialogButton okButton = new TaskDialogButton(ButtonType.Ok);
                        dialog.Buttons.Add(okButton);
                        TaskDialogButton button = dialog.ShowDialog(this);
                    }
                }
            }
        }
    public bool SaveFilePanel(ExtensionFilter filter, string defaultFileName, string defExt, out string resultPath)
    {
        var fd = new VistaSaveFileDialog();

        fd.Title = "Save As";

        var finalFilename = "";

        if (!string.IsNullOrEmpty(defaultFileName))
        {
            finalFilename += defaultFileName;
        }

        fd.FileName     = finalFilename;
        fd.Filter       = GetFilterFromFileExtensionList(filter);
        fd.FilterIndex  = 1;
        fd.DefaultExt   = defExt;
        fd.AddExtension = true;

        var res      = fd.ShowDialog(new WindowWrapper(GetActiveWindow()));
        var filename = res == DialogResult.OK ? fd.FileName : string.Empty;

        fd.Dispose();
        resultPath = filename;

        return(!string.IsNullOrEmpty(resultPath));
    }
Ejemplo n.º 18
0
        private async Task onExportHexViewExecute()
        {
            VistaSaveFileDialog sfd = new VistaSaveFileDialog
            {
                FileName   = title,
                DefaultExt = ".txt",
                Filter     = "Text Files|*.txt",
                Title      = "Save Hex View As..."
            };

            bool?result = sfd.ShowDialog();

            if (!result.HasValue || !result.Value)
            {
                return;
            }

            StreamWriter stream = new StreamWriter(File.OpenWrite(sfd.FileName));

            foreach (DomainHexData hexData in viewModel.HexData)
            {
                string line = $"0x{hexData.Index:X8} 0x{hexData.FileIndex:X8} {hexData.HexValues} {hexData.AsciiValues}";

                await stream.WriteLineAsync(line);
            }

            await stream.FlushAsync();

            stream.Close();
        }
Ejemplo n.º 19
0
        private async void SaveJSONButton_Click(object sender, RoutedEventArgs e)
        {
            // Status Update
            StatusLabel.Content = "Generating Folder Structure...";

            // If Unified folder doesn't exist then create one, otherwise generate one; What about changed made after?
            if (JUnifiedFolder == null)
            {
                // Dispatch a thread to handling generation stuff
                await Task.Factory.StartNew(FolderIterator);

                // FolderIterator();
            }

            // Select Path To Save File
            VistaSaveFileDialog saveFileDialog = new VistaSaveFileDialog();

            saveFileDialog.DefaultExt       = ".json";
            saveFileDialog.FileName         = App.DefaultJSONFileName;
            saveFileDialog.Filter           = "JSON Files(*.json) | *.json";
            saveFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
            saveFileDialog.Title            = "Select where to save JSON file";
            saveFileDialog.ValidateNames    = true;
            bool?result = saveFileDialog.ShowDialog();

            if (result == true)
            {
                // Save File Content & Update Status
                System.IO.File.WriteAllText(saveFileDialog.FileName, JsonConvert.SerializeObject(JUnifiedFolder, Formatting.Indented));
                StatusLabel.Content = "Saved to file: " + saveFileDialog.FileName;
            }
        }
Ejemplo n.º 20
0
 public BrowseSaveFileCommand(Action <string> actionOnExecute, Func <object, bool> executeFunc, string filter)
     : base(null, executeFunc)
 {
     m_saveAction = actionOnExecute;
     m_dialog     = new VistaSaveFileDialog {
         Filter = filter, AddExtension = true
     };
 }
 /// <summary>
 /// Méthode qui exécute l'exportation
 /// </summary>
 /// <param name="obj"></param>
 private void Export(string obj)
 {
     if (saveFileDialog == null)
     {
         saveFileDialog            = new VistaSaveFileDialog();
         saveFileDialog.Filter     = "Json file|*.json|All files|*.*";
         saveFileDialog.DefaultExt = "json";
     }
 }
Ejemplo n.º 22
0
        private void SelectTemplateTargetFile(object param)
        {
            VistaSaveFileDialog saveFile = new VistaSaveFileDialog();
            bool?result = saveFile.ShowDialog();

            if (result.HasValue && result.Value)
            {
                TargetFilePath = saveFile.FileName;
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Allows the user to save a mod set.
        /// </summary>
        public void SaveModSet()
        {
            var dialog = new VistaSaveFileDialog {
                Title = _xamlSaveModSetTitle.Get(), Filter = Constants.WpfJsonFormat, AddExtension = true, DefaultExt = ".json"
            };

            if ((bool)dialog.ShowDialog())
            {
                new ModSet(ApplicationTuple.Config).Save(dialog.FileName);
            }
        }
    /// <summary>
    /// Allows the user to save a mod set.
    /// </summary>
    public void SaveModSet()
    {
        var dialog = new VistaSaveFileDialog {
            Title = Resources.SaveModSetDialogTitle.Get(), Filter = Constants.DialogJsonFilter, AddExtension = true, DefaultExt = ".json"
        };

        if ((bool)dialog.ShowDialog() !)
        {
            new ModSet(ApplicationTuple.Config).Save(dialog.FileName);
        }
    }
Ejemplo n.º 25
0
        private async Task ExportModpacks()
        {
            var exportWindow = new ModpackExportWindow()
            {
                Owner = Window
            };
            var  exportViewModel = (ModpackExportViewModel)exportWindow.ViewModel;
            bool?result          = exportWindow.ShowDialog();

            if (result.HasValue && result.Value)
            {
                var  dialog = new VistaSaveFileDialog();
                bool unpackedAllowed;
                dialog.Filter       = BuildExportFilter(exportViewModel.Modpacks, out unpackedAllowed);
                dialog.AddExtension = true;
                dialog.DefaultExt   = unpackedAllowed ? ".fmp" : ".fmpa";
                result = dialog.ShowDialog(Window);
                if (result.HasValue && result.Value)
                {
                    if (dialog.FileName.EndsWith(".fmpa"))
                    {
                        var progressWindow = new ProgressWindow()
                        {
                            Owner = Window
                        };
                        var progressViewModel = (ProgressViewModel)progressWindow.ViewModel;
                        progressViewModel.ActionName = App.Instance.GetLocalizedResourceString("ExportingAction");

                        Task closeWindowTask = null;
                        try
                        {
                            var task = ExportArchive(exportViewModel.Modpacks.Where(modpackTemplate => modpackTemplate.Export), dialog.FileName);

                            closeWindowTask = task.ContinueWith(t => progressWindow.Dispatcher.Invoke(progressWindow.Close));
                            progressWindow.ShowDialog();
                        }
                        finally
                        {
                            if (closeWindowTask != null)
                            {
                                await closeWindowTask;
                            }
                        }
                    }
                    else
                    {
                        var exportTemplate = await ModpackExport.CreateTemplateV2(exportViewModel.Modpacks.Where(modpackTemplate => modpackTemplate.Export));

                        ModpackExport.ExportTemplate(exportTemplate, dialog.FileName);
                    }
                }
            }
        }
Ejemplo n.º 26
0
        public string GetSaveFilePath(string defaultFileName, string filter)
        {
            var dialog = new VistaSaveFileDialog {
                FileName = defaultFileName
            };

            if (dialog.ShowDialog() == true)
            {
                return(dialog.FileName);
            }
            return(null);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Export a CSV file.
        /// </summary>
        private void Export()
        {
            VistaSaveFileDialog saveFileDialog = new VistaSaveFileDialog {
                Filter = "Csv File|*.csv", DefaultExt = "csv", CheckPathExists = true
            };

            saveFileDialog.ShowDialog();
            if (!string.IsNullOrEmpty(saveFileDialog.FileName))
            {
                this.ExportChaptersToCSV(saveFileDialog.FileName);
            }
        }
Ejemplo n.º 28
0
        public static string SaveFile(string title, string allowedExtensions = "Any File|*.*", string defaultExtension = "*.*")
        {
            VistaSaveFileDialog Dialog = new VistaSaveFileDialog();

            Dialog.Title            = title;
            Dialog.RestoreDirectory = true;
            Dialog.Filter           = allowedExtensions;
            Dialog.DefaultExt       = defaultExtension;
            Dialog.ValidateNames    = true;
            Dialog.ShowDialog();
            return(Dialog.FileName);
        }
Ejemplo n.º 29
0
        public static string BrowseTsiFile(System.Windows.Window owner, bool isSaveDialog, string initialDirectory = null, string fileName = null, string type = "tsi")
        {
            VistaFileDialog dlg;

            if (isSaveDialog)
            {
                dlg = new VistaSaveFileDialog
                {
                    DefaultExt    = type,
                    AddExtension  = true,
                    ValidateNames = true
                };
            }
            else
            {
                dlg = new VistaOpenFileDialog
                {
                    Multiselect = false
                };
            }

            // fixme: make a class
            switch (type)
            {
            case "tsi":
                dlg.Filter = "TSI | *.tsi";
                break;

            case "csv":
                dlg.Filter = "CSV | *.csv";
                break;
            }
            dlg.CheckPathExists = true;

            if (initialDirectory != null)
            {
                dlg.InitialDirectory = initialDirectory;
                // workaround to set InitialDirectory
                dlg.FileName = Path.Combine(dlg.InitialDirectory, " ");
            }

            if (fileName != null)
            {
                fileName     = System.IO.Path.ChangeExtension(fileName, "." + type);
                dlg.FileName = fileName;
            }

            if (dlg.ShowDialog(owner).GetValueOrDefault())
            {
                return(dlg.FileName);
            }
            return(null);
        }
Ejemplo n.º 30
0
        private void Save()
        {
            var dlg = new VistaSaveFileDialog {
                Filter       = "Solution File (*.sln)|*.sln",
                AddExtension = true,
                DefaultExt   = ".sln"
            };

            if (dlg.ShowDialog() == true)
            {
                InternalSave(dlg.FileName);
            }
        }
Ejemplo n.º 31
0
 private void ShowSaveFileDialog()
 {
     VistaSaveFileDialog dialog = new VistaSaveFileDialog();
     dialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
     dialog.DefaultExt = "txt";
     // As of .Net 3.5 SP1, WPF's Microsoft.Win32.SaveFileDialog class still uses the old style
     if( !VistaFileDialog.IsVistaFileDialogSupported )
         MessageBox.Show(this, "Because you are not using Windows Vista or later, the regular save file dialog will be used. Please use Windows Vista to see the new dialog.", "Sample save file dialog");
     if( (bool)dialog.ShowDialog(this) )
         MessageBox.Show(this, "The selected file was: " + dialog.FileName, "Sample save file dialog");
 }