namespace VideoBrowser.Controls.CefSharpBrowser { using MahApps.Metro.Controls; using MahApps.Metro.Controls.Dialogs; using System; using System.ComponentModel; using System.Threading.Tasks; using System.Windows.Input; using VideoBrowser.Common; using VideoBrowser.Controls.CefSharpBrowser.Handlers; using VideoBrowser.Extensions; /// /// Defines the . /// public class CefWindowData : INotifyPropertyChanged { #region Fields private bool _isAirspaceVisible; private bool _isFullScreen; #endregion Fields #region Constructors /// /// Initializes a new instance of the class. /// internal CefWindowData() { this.IsFullScreenCommand = new RelayCommand(this.OnIsFullScreen); this.CefContextMenuHandler = new CefContextMenuHandler(); this.CefRequestHandler = new CefRequestHandler(); } #endregion Constructors #region Events /// /// Defines the PropertyChanged. /// public event PropertyChangedEventHandler PropertyChanged; #endregion Events #region Properties /// /// Gets the CefContextMenuHandler. /// public CefContextMenuHandler CefContextMenuHandler { get; } /// /// Gets the CefRequestHandler. /// public CefRequestHandler CefRequestHandler { get; } /// /// Gets or sets a value indicating whether IsAirspaceVisible. /// public bool IsAirspaceVisible { get => this._isAirspaceVisible; set { if (this.IsMessageBoxVisible) { return; } this.Set(this.PropertyChanged, ref this._isAirspaceVisible, value); } } /// /// Gets or sets a value indicating whether IsFullScreen. /// public bool IsFullScreen { get => _isFullScreen; set => this.Set(this.PropertyChanged, ref _isFullScreen, value); } /// /// Gets the IsFullScreenCommand. /// public ICommand IsFullScreenCommand { get; } /// /// Gets a value indicating whether IsMessageBoxVisible. /// public bool IsMessageBoxVisible { get; private set; } /// /// Gets or sets the MainWindow. /// public MetroWindow MainWindow { get; internal set; } #endregion Properties #region Methods /// /// The ShowMessage. /// /// The title. /// The message. /// The style. /// The . internal async Task ShowMessageAsync(string title, string message, MessageDialogStyle style = MessageDialogStyle.Affirmative) { var currentAirspaceVisible = this.IsAirspaceVisible; this.IsAirspaceVisible = true; this.IsMessageBoxVisible = true; var dispatcher = this.MainWindow.Dispatcher; Task result = null; if (dispatcher.CheckAccess()) { result = this.MainWindow.ShowMessageAsync(title, message, style); } else { await dispatcher.BeginInvoke((Action)(() => result = this.MainWindow.ShowMessageAsync(title, message, style))); } await result; this.IsMessageBoxVisible = false; this.IsAirspaceVisible = false; return result.Result; } /// /// The OnIsFullScreen. /// /// The obj. private void OnIsFullScreen(object obj) { this.IsFullScreen = (bool)obj; } #endregion Methods } }