public void AddTool(ToolGroupItem tool) { this.tools.Add(tool); if (this.activeTool == null && tool.IsVisible) { this.DisplayTool(tool); } this.UpdateIsEnabled(); this.OnPropertyChanged("ToolCount"); }
public void SetActive(ToolGroupItem tool) { if (this.tools.Contains(tool)) { this.IsChecked = new bool?(true); this.DisplayTool(tool); } else { this.IsChecked = new bool?(false); } }
private void ToolManager_ToolRemoved(object sender, ToolEventArgs args) { ToolGroupItem tool = this.toolToWrapperMapping[args.Tool]; foreach (ToolGroupButton toolGroupButton in this.toolGroupButtons.Values) { if (toolGroupButton.RemoveTool(tool)) { break; } } this.toolToWrapperMapping.Remove(args.Tool); }
private void ToolManager_ActiveToolChanged(object sender, ToolEventArgs args) { ToolGroupItem tool = (ToolGroupItem)null; if (args.Tool != null) { this.toolToWrapperMapping.TryGetValue(args.Tool, out tool); } foreach (ToolGroupButton toolGroupButton in this.toolGroupButtons.Values) { toolGroupButton.SetActive(tool); } }
public bool RemoveTool(ToolGroupItem tool) { if (!this.tools.Remove(tool)) { return(false); } if (this.activeTool == tool) { this.activeTool = (ToolGroupItem)null; } this.UpdateIsEnabled(); this.OnPropertyChanged("ToolCount"); return(true); }
private void Add(Tool tool) { ToolGroupButton toolGroupButton = (ToolGroupButton)null; if (!this.toolGroupButtons.TryGetValue(tool.Category, out toolGroupButton)) { return; } ToolGroupItem tool1 = new ToolGroupItem(tool); toolGroupButton.AddTool(tool1); if (tool == this.toolManager.ActiveTool) { toolGroupButton.SetActive(tool1); } this.toolToWrapperMapping[tool] = tool1; }
private void DisplayTool(ToolGroupItem tool) { this.activeTool = tool; this.OnPropertyChanged("ActiveTool"); if (this.ToolGroupActiveChanged != null) { this.ToolGroupActiveChanged((object)this, EventArgs.Empty); } this.DataContext = (object)tool; ContextMenu contextMenu = tool.CreateContextMenu(); if (contextMenu != null) { this.ContextMenu = contextMenu; } else { this.ContextMenu = (ContextMenu)null; } }
private void RevalidateToolEnabledState() { SceneView activeView = this.designerContext.ActiveView; this.IsEnabled = activeView != null && activeView.IsDesignSurfaceEnabled; foreach (ToolGroupButton toolGroupButton in this.toolGroupButtons.Values) { ToolGroupItem activeTool = toolGroupButton.ActiveTool; toolGroupButton.UpdateIsEnabled(); if (toolGroupButton.IsChecked.HasValue && toolGroupButton.IsChecked.Value) { if (!toolGroupButton.IsEnabled || toolGroupButton.ActiveTool == null || !toolGroupButton.ActiveTool.IsVisible) { this.toolManager.ActiveTool = this.toolManager.Tools[0]; } else if (activeTool != toolGroupButton.ActiveTool) { this.toolManager.ActiveTool = toolGroupButton.ActiveTool.Tool; } } } }
public SwitchToolCommand(ToolGroupButton button, ToolGroupItem tool) { this.button = button; this.tool = tool; }