Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
FolderOpenModalDialog.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.Windows;
4 using System.Windows.Threading;
5 using Microsoft.WindowsAPICodePack.Dialogs;
6 using SiliconStudio.Presentation.Services;
7 
8 namespace SiliconStudio.Presentation.Dialogs
9 {
11  {
12  internal FolderOpenModalDialog(Dispatcher dispatcher, Window parentWindow)
13  : base(dispatcher, parentWindow)
14  {
15  Dialog = new CommonOpenFileDialog { EnsurePathExists = true };
16  OpenDlg.IsFolderPicker = true;
17  }
18 
19  /// <inheritdoc/>
20  public string Directory { get; private set; }
21 
22  /// <inheritdoc/>
23  public string InitialDirectory { get { return OpenDlg.InitialDirectory; } set { OpenDlg.InitialDirectory = value.Replace('/', '\\'); } }
24 
25  private CommonOpenFileDialog OpenDlg { get { return (CommonOpenFileDialog)Dialog; } }
26 
27  public override DialogResult Show()
28  {
29  var result = InvokeDialog();
30  Directory = result != DialogResult.Cancel ? OpenDlg.FileName : null;
31  return result;
32  }
33  }
34 }
override DialogResult Show()
Display the modal dialog. This method will block until the user close the dialog. ...
DialogResult
An enum representing the result of a dialog invocation.
Definition: DialogResult.cs:9
An interface representing a modal folder selection dialog.