Example #1
0
 public Controller(IDiagramControl surface)
     : base(surface)
 {
     //create the view
     View = new View(surface);
     View.AttachToModel(Model);
 }
Example #2
0
 public View(IDiagramControl control)
   : base(control) {
   control.Document.Model.Selection.OnNewSelection += new EventHandler(Selection_OnNewSelection);
   // this.Model.OnEntityAdded += new EventHandler<EntityEventArgs>(Model_OnEntityAdded);
   this.HorizontalRuler.Visible = true;
   this.VerticalRuler.Visible = true;
 }
Example #3
0
 protected ViewBase(IDiagramControl surface)
 {
     if (surface == null)
         throw new NullReferenceException();
     this.parentControl = surface;
     this.parentControl.SizeChanged += new EventHandler(parentControl_SizeChanged);
 }
    // ------------------------------------------------------------------
    /// <summary>
    /// Constructor.
    /// </summary>
    /// <param name="pageSettings">PageSettings: The page setup for the
    /// diagram.</param>
    /// <param name="diagram">IDiagramControl: The diagram to print.
    /// </param>
    /// <param name="printPreviewOnly">bool: Specifies if only a print
    /// preview is to be performed.  If true, then a PrintPreviewDialog
    /// is shown.  If false, then a PrintDialog is shown and the diagram
    /// is printed if the user elects to.</param>
    // ------------------------------------------------------------------
    public DiagramPrinter(
        PageSettings pageSettings,
        IDiagramControl diagram,
        bool printPreviewOnly) {
      this.myDiagram = diagram;
      this.numberOfPages = diagram.Controller.Model.Pages.Count;
      this.myPageSettings = pageSettings;
      this.myDocument = new PrintDocument();
      this.myDocument.DefaultPageSettings = this.myPageSettings;
      this.myDocument.PrintPage +=
          new PrintPageEventHandler(PrintPage);

      if (printPreviewOnly) {
        this.PrintPreview();
      } else {
        this.Print();
      }
    }
Example #5
0
 public View(IDiagramControl control)
     : base(control)
 {
     Selection.OnNewSelection += new EventHandler(Selection_OnNewSelection);
        // this.Model.OnEntityAdded += new EventHandler<EntityEventArgs>(Model_OnEntityAdded);
 }
        /// <summary>
        /// Attaches this controller to the surface.
        /// </summary>
        /// <param name="surface">The surface.</param>
        private void AttachToSurface(IDiagramControl surface)
        {
            #region Mouse events
            surface.MouseDown += new System.Windows.Forms.MouseEventHandler(surface_MouseDown);
            surface.MouseUp += new System.Windows.Forms.MouseEventHandler(surface_MouseUp);
            surface.MouseMove += new System.Windows.Forms.MouseEventHandler(surface_MouseMove);
            surface.MouseHover += new EventHandler(surface_MouseHover);
            surface.MouseWheel += new MouseEventHandler(surface_MouseWheel);
            #endregion

            #region Keyboard events
            surface.KeyDown += new System.Windows.Forms.KeyEventHandler(surface_KeyDown);
            surface.KeyUp += new System.Windows.Forms.KeyEventHandler(surface_KeyUp);
            surface.KeyPress += new System.Windows.Forms.KeyPressEventHandler(surface_KeyPress);
            #endregion

            #region Dragdrop events
            surface.DragDrop += new DragEventHandler(surface_DragDrop);
            surface.DragEnter += new DragEventHandler(surface_DragEnter);
            surface.DragLeave += new EventHandler(surface_DragLeave);
            surface.DragOver += new DragEventHandler(surface_DragOver);
            surface.GiveFeedback += new GiveFeedbackEventHandler(surface_GiveFeedback);
            #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
        }
 ///<summary>
 ///Default constructor
 ///</summary>
 public Controller(IDiagramControl surface)
     : base(surface)
 {
     this.AddTool(new TextTool("Text Tool"));
 }
Example #9
0
        /// <summary>
        /// Attaches the view to the diagram control (aka surface).
        /// </summary>
        /// <param name="surface"></param>
        private void AttachToSurface(IDiagramControl surface)
        {
            if (surface != null)
            {
                this.parentControl = surface;
                Graphics graphics = this.Graphics;
                dpiX = graphics.DpiX;
                dpiY = graphics.DpiX;
                graphics.Dispose();

                clientRectangle = Rectangle.Round(parentControl.ClientRectangle);
                this.parentControl.SizeChanged += new EventHandler(parentControl_SizeChanged);
            }
            //else
            //    throw new InconsistencyException("The surface control is 'null'");
        }
Example #10
0
        ///<summary>
        ///Default constructor
        ///</summary>
        protected ViewBase(IDiagramControl surface)
        {
            if (surface == null)
                throw new NullReferenceException();

            AttachToSurface(surface);
        }
Example #11
0
 public Controller(IDiagramControl surface) : base(surface)
 {
     //create the view
     View = new View(surface);
     View.AttachToModel(Model);
 }
Example #12
0
 public Controller(IDiagramControl surface)
     : base(surface)
 {
     base.AddTool(new CustomPanTool());
 }
Example #13
0
 public Controller(IDiagramControl surface)
   : base(surface) {
   base.AddTool(new CustomPanTool());
 }
        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
        }
Example #15
0
    // ------------------------------------------------------------------
    ///<summary>
    ///Default constructor
    ///</summary>
    // ------------------------------------------------------------------
    protected ViewBase(IDiagramControl surface) {
      if (surface == null)
        throw new NullReferenceException();

      // Render and print each page in landscape.
      mLandscape = true;

      AttachToSurface(surface);
    }