public ViewModelEditorTool(BaseEditorTool tool) { this.Tool = tool; if (IsDesignTime) { return; } var itemViewModels = tool.AbstractItems.Select(i => tool.CreateItemViewModel(i)).ToList(); if (itemViewModels.Count > 0) { foreach (var viewModelEditorToolItem in itemViewModels) { viewModelEditorToolItem.IsSelectedChanged += this.ItemIsSelectedChangedHandler; } this.ItemsVisibility = Visibility.Visible; } else { this.ItemsVisibility = Visibility.Collapsed; } var filterViewModels = tool.AbstractFilters.Select(f => new ViewModelEditorToolItemFilter(f)).ToList(); foreach (var filter in filterViewModels) { filter.OnIsSelectedChanged = this.FilterOnIsSelectedChanged; } this.FiltersCollection = filterViewModels; this.allItemsCollection = itemViewModels; this.SelectDefaultFilter(); }
public static void SetActiveTool(BaseEditorTool tool, BaseEditorToolItem item) { if (activeTool is not null) { activeTool.Dispose(); activeTool = null; } if (tool is null) { return; } activeTool = tool.Activate(item); }