Beispiel #1
0
        public CreatureEditorPanelVM(CreatureVM creature)
        {
            Creature         = creature;
            ToolCollectionVM = new ToolCollectionVM();
            CreatureStructureEditorCanvasVM = new CreatureStructureEditorCanvasVM(Creature, ToolCollectionVM);
            Settings = new CreatureSettings(this);
            ToolCollectionVM.InfoMessageCollection = CreatureStructureEditorCanvasVM.InfoMessageCollection;
            ToolCollectionVM.Tools.Add(new SelectAllTool());
            ToolCollectionVM.Tools.Add(new MoveTool());
            ToolCollectionVM.Tools.Add(new PanTool());
            ToolCollectionVM.Tools.Add(new PlaceJointTool());
            ToolCollectionVM.Tools.Add(new PlaceBoneTool());

            Behaviours = new ObservableCollection <BaseBehaviour>
            {
                new UndoBehaviour(CreatureStructureEditorCanvasVM.HistoryStack),
                new RedoBehaviour(CreatureStructureEditorCanvasVM.HistoryStack),
                new RotateLeftBehaviour(),
                new RotateRightBehaviour(),
                new FlipHorizontalBehaviour(),
                new FlipVeticalBehaviour(),
                new SaveBehaviour(),
                new DeleteBehaviour(),
                new ClearBehaviour()
            };

            Behaviours.CollectionChanged             += CollectionChanged;
            ToolCollectionVM.Tools.CollectionChanged += CollectionChanged;
        }
        public CreatureStructureEditorCanvasVM(CreatureVM creature, ToolCollectionVM toolCollectionVM)
        {
            HistoryStack = new HistoryStackVM <CreatureStructureEditorCanvasVM>(this);
            HistoryStack.PropertyChanged += (o, e) => Reset();
            Creature = creature;
            CameraVM = new CameraVM {
                OffsetX = -CanvasWidth / 2, OffsetY = -CanvasHeight / 2
            };
            ToolCollectionVM = toolCollectionVM;

            CanvasSizeChangedCommand = new DelegateHandleCommand <SizeChange>(CanvasSizeChanged, o => true);
            CanvasMouseDownCommand   =
                new DelegateHandleCommand <MouseInfo>(mouseInfo =>
                                                      ToolCollectionVM.SelectedTool?.OnCanvasMouseDown(mouseInfo,
                                                                                                       this,
                                                                                                       Keyboard.Modifiers) ==
                                                      true,
                                                      o => true);
            CanvasMouseUpCommand =
                new DelegateHandleCommand <MouseInfo>(mouseInfo =>
                                                      ToolCollectionVM.SelectedTool?.OnCanvasMouseUp(mouseInfo,
                                                                                                     this,
                                                                                                     Keyboard.Modifiers) ==
                                                      true,
                                                      o => true);
            CanvasMouseMoveCommand =
                new DelegateHandleCommand <MouseInfo>(mouseInfo =>
                                                      ToolCollectionVM.SelectedTool?.OnCanvasMouseMove(mouseInfo,
                                                                                                       this,
                                                                                                       Keyboard.Modifiers) ==
                                                      true,
                                                      o => true);
            CanvasMouseWheelCommand = new DelegateHandleCommand <MouseWheelInfo>(mouseWheelInfo =>
                                                                                 ToolCollectionVM
                                                                                 .SelectedTool?.OnCanvasMouseWheel(mouseWheelInfo,
                                                                                                                   this,
                                                                                                                   Keyboard
                                                                                                                   .Modifiers) ==
                                                                                 true,
                                                                                 o => true);
            CanvasMouseEnterCommand =
                new DelegateCommand(o => ToolCollectionVM.SelectedTool?.OnCanvasMouseEnter(this, Keyboard.Modifiers), o => true);
            CanvasMouseLeaveCommand =
                new DelegateCommand(o => ToolCollectionVM.SelectedTool?.OnCanvasMouseLeave(this, Keyboard.Modifiers), o => true);
        }