コード例 #1
0
        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();
        }
コード例 #2
0
        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);
        }