namespace VideoBrowser.Controls.CefSharpBrowser { using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.IO; using System.Linq; using VideoBrowser.Controls.CefSharpBrowser.Handlers; using VideoBrowser.Controls.CefSharpBrowser.Models; using VideoBrowser.Controls.CefSharpBrowser.ViewModels; using VideoBrowser.Extensions; using VideoBrowser.ViewModels; /// /// Defines the . /// All singleton instances are saved here. /// public class GlobalBrowserData : IDisposable { #region Constructors /// /// Initializes a new instance of the class. /// internal GlobalBrowserData() { this.InterTabClient = new InterTabClient(this); this.Settings = new SettingsViewModel(); this.Settings.PropertyChanged += this.OnSettings_PropertyChanged; this.DownloadHandler = new DownloadHandler(this.DownloadItemModels) { DownloadPath = this.Settings.OutputFolder }; } #endregion Constructors #region Properties /// /// Gets the AddInButtons. /// public ICollection AddInButtons { get; } = new ObservableCollection(); /// /// Gets the BrowserSettings. /// public BrowserSettings BrowserSettings => this.Settings.BrowserSettings; /// /// Gets the DownloadHandler. /// public DownloadHandler DownloadHandler { get; } /// /// Gets the DownloadItemModels. /// public ObservableCollection DownloadItemModels { get; } = new ObservableCollection(); /// /// Gets the InterTabClient. /// public InterTabClient InterTabClient { get; } /// /// Gets the Settings. /// public SettingsViewModel Settings { get; } /// /// Gets or sets a value indicating whether IsSettingsLoaded. /// internal bool IsSettingsLoaded { get; set; } /// /// Gets the WindowViewModels. /// internal IList WindowViewModels { get; } = new List(); #endregion Properties #region Methods /// /// The Dispose. /// public void Dispose() { this.Settings.PropertyChanged -= this.OnSettings_PropertyChanged; this.DownloadHandler.Dispose(); } /// /// The GetAddInButton. /// /// The addInType. /// The . public AddInButton GetAddInButton(Type addInType) { var addIn = this.AddInButtons.FirstOrDefault(o => o.GetType() == addInType); return addIn; } /// /// The OnSettings_PropertyChanged. /// /// The sender. /// The e. private void OnSettings_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.IsMatch(nameof(this.Settings.OutputFolder)) && Directory.Exists(this.Settings.OutputFolder)) { this.DownloadHandler.DownloadPath = this.Settings.OutputFolder; } } #endregion Methods } }