/// <summary> /// Default constructor /// </summary> 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'"); //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; AttachToSurface(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! /* The order in in which the tools are added matters, at least some of them. * The TransformTool should come before the HitToom and the MoveTool after the HitTool. * The order of the drawing tools does not matter. * It's also important to remark that the tools do not depend on the Model. */ registeredTools = new CollectionBase<ITool>(); this.AddTool(new TransformTool("Transform Tool")); this.AddTool(new HitTool("Hit Tool")); this.AddTool(new MoveTool("Move Tool")); this.AddTool(new RectangleTool("Rectangle Tool")); this.AddTool(new ComplexRectangleTool("ComplexRectangle Tool")); this.AddTool(new EllipseTool("Ellipse Tool")); this.AddTool(new SelectionTool("Selection Tool")); this.AddTool(new DragDropTool("DragDrop Tool")); this.AddTool(new ConnectionTool("Connection Tool")); this.AddTool(new ConnectorMoverTool("Connector Mover Tool")); this.AddTool( new GroupTool("Group Tool")); this.AddTool(new UngroupTool("Ungroup Tool")); this.AddTool(new SendToBackTool("SendToBack Tool")); this.AddTool(new SendBackwardsTool("SendBackwards Tool")); this.AddTool(new SendForwardsTool("SendForwards Tool")); this.AddTool(new SendToFrontTool("SendToFront Tool")); this.AddTool(new HoverTool("Hover Tool")); this.AddTool(new ContextTool("Context Tool")); this.AddTool(new CopyTool("Copy Tool")); this.AddTool(new PasteTool("Paste Tool")); this.AddTool(new ScribbleTool("Scribble Tool")); this.AddTool(new PolygonTool("Polygon Tool")); this.AddTool(new MultiLineTool("MultiLine Tool")); #endregion #region Hotkeys HotKeys keys = new HotKeys(this); this.keyboardListeners.Add(keys); #endregion #region Activities //this is in a way a waste of memory; the layouts should not necessarily be loaded //before they are actually requested. You could register only the (string) names instead. //But for just a few algorithms this is OK and the advantage of this registration is that //one can register actions from outside the library, in the hosting form for example. registeredActivity = new CollectionBase<IActivity>(); AddActivity(new RandomLayout(this)); AddActivity(new FruchtermanReingoldLayout(this)); AddActivity(new StandardTreeLayout(this)); AddActivity(new RadialTreeLayout(this)); AddActivity(new BalloonTreeLayout(this)); AddActivity(new ForceDirectedLayout(this)); #endregion }
/// <summary> /// Default constructor /// </summary> 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'"); } //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; AttachToSurface(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! /* * The order in in which the tools are added matters, at least some of them. * The TransformTool should come before the HitToom and the MoveTool after the HitTool. * The order of the drawing tools does not matter. * It's also important to remark that the tools do not depend on the Model. */ registeredTools = new CollectionBase <ITool>(); this.AddTool(new TransformTool("Transform Tool")); this.AddTool(new HitTool("Hit Tool")); this.AddTool(new MoveTool("Move Tool")); this.AddTool(new RectangleTool("Rectangle Tool")); this.AddTool(new ComplexRectangleTool("ComplexRectangle Tool")); this.AddTool(new EllipseTool("Ellipse Tool")); this.AddTool(new SelectionTool("Selection Tool")); this.AddTool(new DragDropTool("DragDrop Tool")); this.AddTool(new ConnectionTool("Connection Tool")); this.AddTool(new ConnectorMoverTool("Connector Mover Tool")); this.AddTool(new GroupTool("Group Tool")); this.AddTool(new UngroupTool("Ungroup Tool")); this.AddTool(new SendToBackTool("SendToBack Tool")); this.AddTool(new SendBackwardsTool("SendBackwards Tool")); this.AddTool(new SendForwardsTool("SendForwards Tool")); this.AddTool(new SendToFrontTool("SendToFront Tool")); this.AddTool(new HoverTool("Hover Tool")); this.AddTool(new ContextTool("Context Tool")); this.AddTool(new CopyTool("Copy Tool")); this.AddTool(new PasteTool("Paste Tool")); this.AddTool(new ScribbleTool("Scribble Tool")); this.AddTool(new PolygonTool("Polygon Tool")); this.AddTool(new MultiLineTool("MultiLine Tool")); #endregion #region Hotkeys HotKeys keys = new HotKeys(this); this.keyboardListeners.Add(keys); #endregion #region Activities //this is in a way a waste of memory; the layouts should not necessarily be loaded //before they are actually requested. You could register only the (string) names instead. //But for just a few algorithms this is OK and the advantage of this registration is that //one can register actions from outside the library, in the hosting form for example. registeredActivity = new CollectionBase <IActivity>(); AddActivity(new RandomLayout(this)); AddActivity(new FruchtermanReingoldLayout(this)); AddActivity(new StandardTreeLayout(this)); AddActivity(new RadialTreeLayout(this)); AddActivity(new BalloonTreeLayout(this)); AddActivity(new ForceDirectedLayout(this)); #endregion }