Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ModalDialogBase.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 {
10  public abstract class ModalDialogBase : IModalDialog
11  {
12  private readonly Dispatcher dispatcher;
13  private readonly Window parentWindow;
14  protected CommonFileDialog Dialog;
15 
16  protected ModalDialogBase(Dispatcher dispatcher, Window parentWindow)
17  {
18  this.dispatcher = dispatcher;
19  this.parentWindow = parentWindow;
20  }
21 
22  /// <inheritdoc/>
23  public object DataContext { get; set; }
24 
26  {
27  if (dispatcher.CheckAccess())
28  {
29  return (DialogResult)Dialog.ShowDialog(parentWindow);
30  }
31  return dispatcher.Invoke(() => (DialogResult)Dialog.ShowDialog(parentWindow));
32  }
33 
34  public abstract DialogResult Show();
35  }
36 }
An interface representing a modal dialog.
Definition: IModalDialog.cs:8
DialogResult
An enum representing the result of a dialog invocation.
Definition: DialogResult.cs:9
ModalDialogBase(Dispatcher dispatcher, Window parentWindow)