public ToggleButtonHandle(Figure owner, ILocator locator)
     : base(owner, locator)
 {
     FillColor = new Color (1, 1, 0.0, 0.3);
     Width = 15.0;
     Height = 15.0;
 }
 protected AbstractHandle(Figure owner)
 {
     Owner = owner;
     LineWidth = 1.0;
     FillColor = new Cairo.Color (0.2, 1.0, 0.2, 0.8);
     LineColor = new Cairo.Color (0.0, 0.0, 0.0, 1.0);
 }
 public void VisitFigure(Figure figure)
 {
     var tf = figure as TypeFigure;
     if (tf != null) {
         tf.Grouping = grouping;
     }
 }
        public ConnectionFigure(Figure startFigure, Figure endFigure)
        {
            if (startFigure != null)
                StartConnector = startFigure.ConnectorAt (0.0, 0.0);

            if (endFigure != null)
                EndConnector  = endFigure.ConnectorAt (0.0, 0.0);
        }
 public PointD Locate(Figure owner)
 {
     PointD topleft = owner.DisplayBox.TopLeft;
     return new PointD {
         X = topleft.X + x,
         Y = topleft.Y + y,
     };
 }
        public PointD Locate(Figure owner)
        {
            if (owner == null)
                return new PointD ();

            PolyLineFigure figure = (PolyLineFigure) owner;
            return figure.PointAt (index);
        }
 public LineConnectionFigure(Figure startFigure, Figure endFigure)
     : base(startFigure, endFigure)
 {
     Line = new PolyLineFigure ();
     Line.Parent = this;
     Line.AddPoint (0.0, 0.0);
     Line.AddPoint (0.0, 0.0);
     UpdateConnection ();
 }
        public void VisitFigure(Figure hostFigure)
        {
            if (!Drawing.Includes (hostFigure) ||
                DeletedFigures.Contains (hostFigure))
                return;

            Drawing.Remove (hostFigure);
            DeletedFigures.Add (hostFigure);
        }
        public void VisitFigure(Figure hostFigure)
        {
            if (AddedFigures.Contains (hostFigure) ||
                Drawing.Includes (hostFigure))
                return;

            Drawing.Add (hostFigure);
            AddedFigures.Add (hostFigure);
        }
 public ResizeHandleUndoActivity(IDrawingView view, Figure owner)
     : base(view)
 {
     Undoable = true;
     Redoable = true;
     Owner = owner;
     OldDisplayBox = Owner.DisplayBox;
     NewDisplayBox = Owner.DisplayBox;
 }
        protected virtual PointD Chop(Figure target, PointD point)
        {
            if (target == null)
                return new PointD (0, 0);
            else if (target.ContainsPoint (point.X, point.Y))
                return target.DisplayBox.Center;

            double angle = Geometry.AngleFromPoint (DisplayBox, point);
            return Geometry.EdgePointFromAngle (DisplayBox, angle);
        }
        protected override bool IsConnectionPossible(Figure figure)
        {
            if (!figure.Includes (Connection) &&
                figure.CanConnect &&
                Connection.CanConnectStart (figure)) {

                return true;
            }
            return false;
        }
        protected override PointD Chop(Figure target, PointD point)
        {
            if (target.ContainsPoint (point.X, point.Y))
                return target.DisplayBox.Center;

            double angle = Geometry.AngleFromPoint (DisplayBox, point);

            var p = new PointD (0.0, 0.0);
            RectangleD r = target.DisplayBox;

            p.X = r.Center.X + r.Width/2 * Math.Cos (angle);
            p.Y = r.Center.Y + r.Height/2 * Math.Sin (angle);

            return p;
        }
        public void VisitFigure(Figure figure)
        {
            var point = view.DrawingToView (figure.DisplayBox.X, figure.DisplayBox.Y);
            var rect = new RectangleD (point.X, point.Y);
            rect.Width = figure.DisplayBox.Width;
            rect.Height = figure.DisplayBox.Height;

            if (!GdkCairoHelper.RectangleInsideGdkRegion (rect, region))
                return;

            if (view.SelectionEnumerator.Contains (figure))
                figure.DrawSelected (context);
            else
                figure.Draw (context);

            figures.Add (figure);
        }
        public PointD Locate(Figure owner)
        {
            if (owner == null)
                return new PointD (0, 0);

            RectangleD r = owner.DisplayBox;

            switch (position) {
            case QuickActionPosition.Up:
                    return new PointD (r.X + r.Width * relative, r.Y - padding);
            case QuickActionPosition.Bottom:
                    return new PointD (r.X + r.Width * relative, r.Y2 + padding);
            case QuickActionPosition.Left:
                    return new PointD (r.X - padding, r.Y + r.Height * relative);
            case QuickActionPosition.Right:
                    return new PointD (r.X2 + padding, r.Y + r.Height * relative);
            default:
                    return new PointD(0, 0);
            }
        }
 protected AbstractConnector(Figure owner)
 {
     Owner = owner;
 }
 public InheritanceLine(Figure derivedFigure, Figure baseFigure)
     : base(derivedFigure, baseFigure)
 {
     Line.EndTerminal = new TriangleArrowLineTerminal ();
 }
 public void AddWithDragging(Figure figure)
 {
     Tool = new DragCreationTool(this, figure);
 }
 private double CalculateFigureX(Figure figure)
 {
     switch (Alignment) {
     case VStackAlignment.Center:
         return Position.X + (Width - figure.DisplayBox.Width)/2;
     case VStackAlignment.Left:
         return Position.X;
     case VStackAlignment.Right:
         return Position.X + (Width - figure.DisplayBox.Width);
     default:
         return Position.X;
     }
 }
 public SouthHandle(Figure owner)
     : base(owner, RelativeLocator.South)
 {
 }
 public ChopBoxConnector(Figure figure)
     : base(figure)
 {
 }
 public DragCreationTool(IDrawingEditor editor, Figure ptype)
     : base(editor, ptype)
 {
 }
 public void AddWithResizing(Figure figure)
 {
     Tool = new ResizeCreationTool(this, figure);
 }
 public FigureTool(IDrawingEditor editor, Figure fig, ITool dt)
     : base(editor)
 {
     DefaultTool = dt;
     Figure = fig;
 }
 public virtual void DisplayMenu(Figure figure, MouseEvent ev)
 {
 }
 public virtual bool CanConnectStart(Figure figure)
 {
     return true;
 }
 public virtual bool CanConnectEnd(Figure figure)
 {
     return true;
 }
 public override bool CanConnectStart(Figure figure)
 {
     return figure is ClassFigure && !figure.Includes (EndFigure);
 }
 public PolyLineFigureTool(IDrawingEditor editor, Figure fig, ITool dt)
     : base(editor, fig, dt)
 {
 }
 public MenuTool(IDrawingEditor editor, Figure figure)
     : base(editor)
 {
     this.figure = figure;
 }