public ToolbarVm(IImageVm imageVm) { Should.NotBeNull(imageVm, nameof(imageVm)); SelectToolCommand = new RelayCommand <ITool>(SelectTool); var toolContext = new ToolContext(imageVm); PanTool = new PaintbrushTool(toolContext); ZoomTool = new PaintbrushTool(toolContext); PaintbrushTool = new PaintbrushTool(toolContext); Tools = new[] { PanTool, ZoomTool, PaintbrushTool }; SelectedTool = Tools[0]; imageVm.MouseUp += (sender, args) => { foreach (var tool in Tools) { tool.ProcessMouseUp(args); } }; imageVm.MouseDown += (sender, args) => { foreach (var tool in Tools) { tool.ProcessMouseDown(args); } }; imageVm.MouseMove += (sender, args) => { foreach (var tool in Tools) { tool.ProcessMouseMove(args); } }; }
public ToolContext(IImageVm imageVm) { ImageVm = imageVm; }