Ejemplo n.º 1
0
        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);
                }
            };
        }
Ejemplo n.º 2
0
 public ToolContext(IImageVm imageVm)
 {
     ImageVm = imageVm;
 }