namespace VideoBrowser.ViewModels { using System; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Windows.Input; using VideoBrowser.Common; using VideoBrowser.Controls.CefSharpBrowser.Models; using VideoBrowser.Extensions; /// /// Defines the . /// public class DownloadFlyoutViewModel : NotifyPropertyChanged { #region Fields private bool _isOpen; private string _message; #endregion Fields #region Constructors /// /// Initializes a new instance of the class. /// /// The models. internal DownloadFlyoutViewModel(ObservableCollection models) { this.DownloadItemModels = models; this.DownloadItemModels.CollectionChanged += this.OnDownloadItemModels_CollectionChanged; this.ShowDownloadTabCommand = new RelayCommand(this.OnShowDownloadTab, nameof(this.ShowDownloadTabCommand)); } #endregion Constructors #region Properties /// /// Gets or sets the DownloadItemModels. /// public ObservableCollection DownloadItemModels { get; internal set; } /// /// Gets or sets a value indicating whether IsOpen. /// public bool IsOpen { get => _isOpen; set => this.Set(this.PropertyChangedHandler, ref _isOpen, value); } /// /// Gets or sets the Message. /// public string Message { get => _message; internal set => this.Set(this.PropertyChangedHandler, ref _message, value); } /// /// Gets or sets the ShowDownloadTabAction. /// public Action ShowDownloadTabAction { get; set; } /// /// Gets the ShowDownloadTabCommand. /// public ICommand ShowDownloadTabCommand { get; } #endregion Properties #region Methods /// /// The OnDownloadItemModels_CollectionChanged. /// /// The sender. /// The e. private void OnDownloadItemModels_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { this.IsOpen = true; } } /// /// The OnShowDownloadTab. /// /// The obj. private void OnShowDownloadTab(object obj) { this.ShowDownloadTabAction?.Invoke(); } #endregion Methods } }