namespace VideoBrowser.Controls.CefSharpBrowser { using System; using System.Windows; using System.Windows.Media; using VideoBrowser.Controls.CefSharpBrowser.ViewModels; using VideoBrowser.Helpers; /// /// Defines the . /// public abstract class CreateTabAddInButton : AddInButton { #region Constructors /// /// Initializes a new instance of the class. /// /// The title. /// The icon. /// The name. public CreateTabAddInButton(string title, Geometry icon, string name = null) : base(name) { this.Title = title; this.Icon = icon; } #endregion Constructors #region Properties /// /// Gets the Guid. /// public Guid Guid { get; } = Guid.NewGuid(); /// /// Gets or sets the Title. /// public string Title { get; set; } #endregion Properties #region Methods /// /// The CreateView. /// This method is already in UI Thread. /// /// The . protected abstract UIElement CreateView(); /// /// The Execute. /// /// The viewModel. protected override void Execute(WebBrowserTabControlViewModel viewModel) { if (viewModel.IsTabItemExist(this.Guid)) { viewModel.SetActiveTab(this.Guid); return; } UIThreadHelper.InvokeAsync(() => { var view = this.CreateView(); var tab = new TabItem(this.Guid) { Content = view, Icon = this.Icon, Title = this.Title }; viewModel.AddTab(tab); }); } #endregion Methods } }