/// <summary> /// Add the favoratable browser view and viewmodel to the list of open controls <see cref="OpenFavoriteControls"/>. /// </summary> /// <param name="view">The view.</param> /// <param name="viewModel">The view model.</param> private void AddFavoritesControl(IPanelFilterableDataGridView view, IFavoritesBrowserViewModel viewModel) { if (view == null || viewModel == null) { return; } this.OpenFavoriteControls.Add(view, viewModel); this.RefreshControl(view); logger.Debug("{0} Added to the Favorites FilterStringService", view.FilterableControl.Name); }
/// <summary> /// Add the deprecatable browser view and viewmodel to the list of open controls <see cref="OpenDeprecatedControls"/>. /// </summary> /// <param name="view">The view.</param> /// <param name="viewModel">The view model.</param> private void AddDeprecatedControl(IPanelFilterableDataGridView view, IDeprecatableBrowserViewModel viewModel) { if (view == null || viewModel == null) { return; } this.OpenDeprecatedControls.Add(view, viewModel); this.RefreshControl(view); logger.Debug("{0} Added deprecatable to the FilterStringService", view.FilterableControl.Name); }
/// <summary> /// Handles the refreshing of the control when needed /// </summary> /// <param name="view">The view to refresh.</param> private void RefreshControl(IPanelFilterableDataGridView view) { var control = view.FilterableControl; control.FilterString = string.Empty; // filters are always reenabled in case they were manually turned off. control.IsFilterEnabled = true; // deprecation state can be told no matter if the browser has the favorites vm assigned or not if (!this.ShowDeprecatedThings) { control.FilterString = DeprecatedFilterString; } // if the control is favoratable if (this.OpenFavoriteControls.TryGetValue(view, out var viewModel)) { if (!this.ShowDeprecatedThings && viewModel.ShowOnlyFavorites) { control.FilterString = FavoriteAndHideDeprecatedFilterString; } else if (this.ShowDeprecatedThings && viewModel.ShowOnlyFavorites) { control.FilterString = FavoriteFilterString; } else if (!this.ShowDeprecatedThings && !viewModel.ShowOnlyFavorites) { control.FilterString = DeprecatedFilterString; } else { control.FilterString = string.Empty; } return; } control.RefreshData(); }
/// <summary> /// Remove the view from all registered disctionaries. /// </summary> /// <param name="view">The view to remove.</param> private void RemoveView(IPanelFilterableDataGridView view) { this.OpenDeprecatedControls.Remove(view); this.OpenFavoriteControls.Remove(view); }