Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
FileSaveModalDialog.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System.Collections.Generic;
4 using System.Windows;
5 using System.Windows.Threading;
6 using Microsoft.WindowsAPICodePack.Dialogs;
7 using SiliconStudio.Presentation.Services;
8 
9 namespace SiliconStudio.Presentation.Dialogs
10 {
12  {
13  internal FileSaveModalDialog(Dispatcher dispatcher, Window parentWindow)
14  : base(dispatcher, parentWindow)
15  {
16  Dialog = new CommonSaveFileDialog();
17  Filters = new List<FileDialogFilter>();
18  }
19 
20  /// <inheritdoc/>
21  public IList<FileDialogFilter> Filters { get; set; }
22 
23  /// <inheritdoc/>
24  public string FilePath { get; private set; }
25 
26  /// <inheritdoc/>
27  public string InitialDirectory { get { return SaveDlg.InitialDirectory; } set { SaveDlg.InitialDirectory = value; } }
28 
29  /// <inheritdoc/>
30  public string DefaultFileName { get { return SaveDlg.DefaultFileName; } set { SaveDlg.DefaultFileName = value; } }
31 
32  /// <inheritdoc/>
33  public string DefaultExtension { get { return SaveDlg.DefaultExtension; } set { SaveDlg.DefaultExtension = value; } }
34 
35  private CommonSaveFileDialog SaveDlg { get { return (CommonSaveFileDialog)Dialog; } }
36 
37  /// <inheritdoc/>
38  public override DialogResult Show()
39  {
40  SaveDlg.Filters.Clear();
41  foreach (var filter in Filters)
42  {
43  SaveDlg.Filters.Add(new CommonFileDialogFilter(filter.Description, filter.ExtensionList));
44  }
45  SaveDlg.AlwaysAppendDefaultExtension = true;
46  var result = InvokeDialog();
47  FilePath = result != DialogResult.Cancel ? SaveDlg.FileName : null;
48  return result;
49  }
50  }
51 }
override DialogResult Show()
Display the modal dialog. This method will block until the user close the dialog. A DialogResult valu...
An interface representing a modal file save dialog.
DialogResult
An enum representing the result of a dialog invocation.
Definition: DialogResult.cs:9