Exemplo n.º 1
0
        protected ControllerBase(IDiagramControl surface)
        {
            //doesn't work if you supply a null reference
            if (surface == null)
            {
                throw new NullReferenceException("The diagram control assigned to the controller cannot be 'null'");
            }

            mModel = new Model();
            mModel.OnEntityAdded   += new EventHandler <EntityEventArgs>(mModel_OnEntityAdded);
            mModel.OnEntityRemoved += new EventHandler <EntityEventArgs>(mModel_OnEntityRemoved);
            //create the undo/redo manager
            mUndoManager = new UndoManager(15);
            mUndoManager.OnHistoryChange += new EventHandler(mUndoManager_OnHistoryChange);

            #region Instantiation of listeners
            mouseListeners    = new CollectionBase <IMouseListener>();
            keyboardListeners = new CollectionBase <IKeyboardListener>();
            dragdropListeners = new CollectionBase <IDragDropListener>();
            #endregion
            //keep a reference to the parent control
            parentControl = surface;

            ListenTo(parentControl);



            //Make sure the static selection class knows about the model
            Selection.Controller = this;
            //Initialize the colorscheme
            ArtPallet.Init();

            #region Tools: the registration order matters!

            registeredTools = new CollectionBase <ITool>();

            TransformTool transformer = new TransformTool("Transform Tool");
            transformer.Controller = this;
            this.AddTool(transformer);

            HitTool hitter = new HitTool("Hit Tool");
            hitter.Controller = this;
            this.AddTool(hitter);

            MoveTool mover = new MoveTool("Move Tool");
            mover.Controller = this;
            this.AddTool(mover);

            RectangleTool recter = new RectangleTool("Rectangle Tool");
            recter.Controller = this;
            this.AddTool(recter);

            EllipseTool ellipser = new EllipseTool("Ellipse Tool");
            ellipser.Controller = this;
            this.AddTool(ellipser);

            SelectionTool selecter = new SelectionTool("Selection Tool");
            selecter.Controller = this;
            this.AddTool(selecter);

            DragDropTool dragdropper = new DragDropTool("DragDrop Tool");
            dragdropper.Controller = this;
            this.AddTool(dragdropper);

            ConnectionTool connecter = new ConnectionTool("Connection Tool");
            connecter.Controller = this;
            this.AddTool(connecter);

            ConnectorMoverTool conmover = new ConnectorMoverTool("Connector Mover Tool");
            conmover.Controller = this;
            this.AddTool(conmover);

            GroupTool grouper = new GroupTool("Group Tool");
            grouper.Controller = this;
            this.AddTool(grouper);

            UngroupTool ungrouper = new UngroupTool("Ungroup Tool");
            ungrouper.Controller = this;
            this.AddTool(ungrouper);

            SendToBackTool sendback = new SendToBackTool("SendToBack Tool");
            sendback.Controller = this;
            this.AddTool(sendback);

            SendBackwardsTool sendbackwards = new SendBackwardsTool("SendBackwards Tool");
            sendbackwards.Controller = this;
            this.AddTool(sendbackwards);

            SendForwardsTool sendforwards = new SendForwardsTool("SendForwards Tool");
            sendforwards.Controller = this;
            this.AddTool(sendforwards);

            SendToFrontTool sendfront = new SendToFrontTool("SendToFront Tool");
            sendfront.Controller = this;
            this.AddTool(sendfront);

            TextTool texttool = new TextTool("Text Tool");
            texttool.Controller = this;
            this.AddTool(texttool);

            HoverTool hoverer = new HoverTool("Hover Tool");
            hoverer.Controller = this;
            this.AddTool(hoverer);

            #endregion
        }
Exemplo n.º 2
0
        protected ControllerBase(IDiagramControl surface)
        {
            //doesn't work if you supply a null reference
            if(surface==null)
                throw new NullReferenceException("The diagram control assigned to the controller cannot be 'null'");

            mModel = new Model();
            mModel.OnEntityAdded += new EventHandler<EntityEventArgs>(mModel_OnEntityAdded);
            mModel.OnEntityRemoved += new EventHandler<EntityEventArgs>(mModel_OnEntityRemoved);
            //create the undo/redo manager
            mUndoManager = new UndoManager(15);
            mUndoManager.OnHistoryChange += new EventHandler(mUndoManager_OnHistoryChange);

            #region Instantiation of listeners
            mouseListeners = new CollectionBase<IMouseListener>();
            keyboardListeners = new CollectionBase<IKeyboardListener>();
            dragdropListeners = new CollectionBase<IDragDropListener>();
            #endregion
            //keep a reference to the parent control
            parentControl = surface;

            ListenTo(parentControl);

            //Make sure the static selection class knows about the model
            Selection.Controller = this;
            //Initialize the colorscheme
            ArtPallet.Init();

            ConnectionPen.Init();

               #region Tools: the registration order matters!

            registeredTools = new CollectionBase<ITool>();

            //customized
            DDTConnectionTool DDTConnectionTool = new DDTConnectionTool("DDTConnection Tool");
            DDTConnectionTool.Controller = this;
            this.AddTool(DDTConnectionTool);

            DDTConnectionTool NormalConnectionTool = new NormalConnectionTool("NormalConnection Tool");
            NormalConnectionTool.Controller = this;
            this.AddTool(NormalConnectionTool);

            DDTConnectionTool SingleArrowConnectionTool = new SingleArrowConnectionTool("SingleArrowConnection Tool");
            SingleArrowConnectionTool.Controller = this;
            this.AddTool(SingleArrowConnectionTool);

            DDTConnectionTool DoubleArrowConnectionTool = new DoubleArrowConnectionTool("DoubleArrowConnection Tool");
            DoubleArrowConnectionTool.Controller = this;
            this.AddTool(DoubleArrowConnectionTool);

            DDTConnectionTool WideArrowConnectionTool = new WideArrowConnectionTool("WideArrowConnection Tool");
            WideArrowConnectionTool.Controller = this;
            this.AddTool(WideArrowConnectionTool);

            DDTConnectionTool DiamondArrowConnectionTool = new DiamondArrowConnectionTool("DiamondArrowConnection Tool");
            DiamondArrowConnectionTool.Controller = this;
            this.AddTool(DiamondArrowConnectionTool);

            DDTConnectionTool OneToOneConnectionTool = new OneToOneConnectionTool("OneToOneConnection Tool");
            OneToOneConnectionTool.Controller = this;
            this.AddTool(OneToOneConnectionTool);

            DDTConnectionTool OneToManyConnectionTool = new OneToManyConnectionTool("OneToManyConnection Tool");
            OneToManyConnectionTool.Controller = this;
            this.AddTool(OneToManyConnectionTool);

            DDTConnectionTool ManyToManyConnectionTool = new ManyToManyConnectionTool("ManyToManyConnection Tool");
            ManyToManyConnectionTool.Controller = this;
            this.AddTool(ManyToManyConnectionTool);

            DDTConnectionTool DashedArrowConnectionTool = new DashedArrowConnectionTool("DashedArrowConnection Tool");
            DashedArrowConnectionTool.Controller = this;
            this.AddTool(DashedArrowConnectionTool);

            /*
             * TBC
             */

            TransformTool transformer = new TransformTool("Transform Tool");
            transformer.Controller = this;
            this.AddTool(transformer);

            HitTool hitter = new HitTool("Hit Tool");
            hitter.Controller = this;
            this.AddTool(hitter);

            MoveTool mover = new MoveTool("Move Tool");
            mover.Controller = this;
            this.AddTool(mover);

            RectangleTool recter = new RectangleTool("Rectangle Tool");
            recter.Controller = this;
            this.AddTool(recter);

            EllipseTool ellipser = new EllipseTool("Ellipse Tool");
            ellipser.Controller = this;
            this.AddTool(ellipser);

            SelectionTool selecter = new SelectionTool("Selection Tool");
            selecter.Controller = this;
            this.AddTool(selecter);

            DragDropTool dragdropper = new DragDropTool("DragDrop Tool");
            dragdropper.Controller = this;
            this.AddTool(dragdropper);

            ConnectionTool connecter = new ConnectionTool("Connection Tool");
            connecter.Controller = this;
            this.AddTool(connecter);

            ConnectorMoverTool conmover = new ConnectorMoverTool("Connector Mover Tool");
            conmover.Controller = this;
            this.AddTool(conmover);

            GroupTool grouper = new GroupTool("Group Tool");
            grouper.Controller = this;
            this.AddTool(grouper);

            UngroupTool ungrouper = new UngroupTool("Ungroup Tool");
            ungrouper.Controller = this;
            this.AddTool(ungrouper);

            SendToBackTool sendback = new SendToBackTool("SendToBack Tool");
            sendback.Controller = this;
            this.AddTool(sendback);

            SendBackwardsTool sendbackwards = new SendBackwardsTool("SendBackwards Tool");
            sendbackwards.Controller = this;
            this.AddTool(sendbackwards);

            SendForwardsTool sendforwards = new SendForwardsTool("SendForwards Tool");
            sendforwards.Controller = this;
            this.AddTool(sendforwards);

            SendToFrontTool sendfront = new SendToFrontTool("SendToFront Tool");
            sendfront.Controller = this;
            this.AddTool(sendfront);

            TextTool texttool = new TextTool("Text Tool");
            texttool.Controller = this;
            this.AddTool(texttool);

            HoverTool hoverer = new HoverTool("Hover Tool");
            hoverer.Controller = this;
            this.AddTool(hoverer);

            //this.AddTool(new ContextTool("Context Tool"));
            #endregion
        }