internal Document (TextBoxBase owner) { lines = 0; this.owner = owner; multiline = true; password_char = ""; calc_pass = false; recalc_pending = false; // Tree related stuff sentinel = new Line (this, LineEnding.None); sentinel.color = LineColor.Black; document = sentinel; // We always have a blank line owner.HandleCreated += new EventHandler(owner_HandleCreated); owner.VisibleChanged += new EventHandler(owner_VisibleChanged); Add (1, String.Empty, owner.Font, owner.ForeColor, LineEnding.None); undo = new UndoManager (this); selection_visible = false; selection_start.line = this.document; selection_start.pos = 0; selection_start.tag = selection_start.line.tags; selection_end.line = this.document; selection_end.pos = 0; selection_end.tag = selection_end.line.tags; selection_anchor.line = this.document; selection_anchor.pos = 0; selection_anchor.tag = selection_anchor.line.tags; caret.line = this.document; caret.pos = 0; caret.tag = caret.line.tags; viewport_x = 0; viewport_y = 0; offset_x = 0; offset_y = 0; crlf_size = 2; // Default selection is empty document_id = random.Next(); string_format.Trimming = StringTrimming.None; string_format.FormatFlags = StringFormatFlags.DisplayFormatControl; UpdateMargins (); }
/// <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 }
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 }
/// <summary> /// The main control for XEditNet applications. /// </summary> // TODO: D: add remarks section public XEditNetCtrl() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); // if ( !this.DesignMode ) // { // Application.EnableVisualStyles(); // Application.DoEvents(); // } SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.ResizeRedraw, true); nodocWnd=new NoDocumentControl(); nodocWnd.Parent=this; findWindow=new FindPopup(this); if ( this.DesignMode ) return; caret=grFactory.CreateCaret(this); caret.Visible=true; quickFixIndicator=new QuickFixIndicator(this, caret); Stylesheet=new Stylesheet(); undoManager=new UndoManager(this); commandMapper=CommandMapper.CreateInstance(this); }
private void Attach(UndoManager undoManager) { // Items filled here should be cleared in the TransactionLogViewer_FormClosed event myUndoItems = undoManager.UndoableTransactions; myRedoItems = undoManager.RedoableTransactions; FillCombo(UndoItemsCombo, myUndoItems); FillCombo(RedoItemsCombo, myRedoItems); TreeControl.MultiColumnTree = new StandardMultiColumnTree((int)ChangeBranch.ColumnContent.Count); if (myUndoItems.Count != 0) { UndoItemsCombo.SelectedIndex = 0; } else if (myRedoItems.Count != 0) { RedoItemsCombo.SelectedIndex = 0; } }