namespace VideoBrowser.Controls.CefSharpBrowser.ViewModels { using Dragablz; using System; using System.Windows.Input; using System.Windows.Media; using VideoBrowser.Common; using VideoBrowser.Extensions; /// /// Defines the . /// public class WebBrowserTabHeaderViewModel : NotifyPropertyChanged { #region Fields private string _header; private ImageSource _image; private bool _isSelected; #endregion Fields #region Constructors /// /// Initializes a new instance of the class. /// public WebBrowserTabHeaderViewModel() { this.MouseUpCommand = new RelayCommand(this.OnMouseUp, nameof(this.MouseUpCommand)); } #endregion Constructors #region Properties /// /// Gets or sets the Header. /// public string Header { get => _header; set => this.Set(this.PropertyChangedHandler, ref _header, value); } /// /// Gets or sets the Image. /// public ImageSource Image { get => _image; set => this.Set(this.PropertyChangedHandler, ref _image, value); } /// /// Gets or sets a value indicating whether IsSelected. /// public bool IsSelected { get => _isSelected; set => this.Set(this.PropertyChangedHandler, ref _isSelected, value); } /// /// Gets the MouseUpCommand. /// public ICommand MouseUpCommand { get; } #endregion Properties #region Methods /// /// The OnMouseUp. /// /// The obj. private void OnMouseUp(object obj) { Logger.Info($"Middle Mouse clicked on a browser tab to close it."); var (_, args, commandParameter) = (ValueTuple)obj; if (args is MouseButtonEventArgs mouseEventArgs && mouseEventArgs.ChangedButton == MouseButton.Middle) { var dragablzItem = commandParameter as System.Windows.FrameworkElement; var closeCommand = TabablzControl.CloseItemCommand; if (closeCommand != null && closeCommand.CanExecute(commandParameter, dragablzItem)) { closeCommand.Execute(dragablzItem, dragablzItem); } } } #endregion Methods } }