public DragController(Point firstPoint, DocumentFrame frame, IHandleFlyweight handle)
 {
     _firstPoint = firstPoint;
     _frame = frame;
     _handle = handle;
     _memento = frame.CreateMemento();
 }
        public void UpdateDrag(Point firstPoint, Point currentPoint, Size delta, DocumentFrame frame, DocumentFrameMemento memento)
        {
            LabelDocumentFrame labelFrame = (LabelDocumentFrame)frame;

            labelFrame.RestoreFromMemento(memento);
            labelFrame.CallOutOffsetInDocument += delta;
        }
        public bool IsHit(DocumentFrame frame, Point point)
        {
            Point centrePoint = GetCentrePoint(frame);

            Size delta = new Size(centrePoint) - new Size(point);

            return delta.Width * delta.Width + delta.Height * delta.Height < _radius * _radius;
        }
        public void Paint(DocumentFrame frame, Graphics g, DocumentPaintResources resources)
        {
            Point centrePoint = GetCentrePoint(frame);

            SmoothingMode oldSmoothingMode = g.SmoothingMode;
            g.SmoothingMode = SmoothingMode.AntiAlias;

            Rectangle drawRectangle = new Rectangle(centrePoint, new Size(0, 0));
            drawRectangle.Inflate(_radius, _radius);

            g.FillEllipse(resources.HandleBrush, drawRectangle);

            g.SmoothingMode = oldSmoothingMode;
        }
 public void SendFrameToBack(DocumentFrame documentFrame)
 {
     _document.SendFrameToBack(documentFrame);
 }
 public void UpdateDrag(Point firstPoint, Point currentPoint, Size delta, DocumentFrame frame, DocumentFrameMemento memento)
 {
     frame.RestoreFromMemento(memento);
     frame.OffsetInDocument += delta;
 }
 public void Paint(DocumentFrame frame, Graphics g, DocumentPaintResources resources)
 {
     // The move handle isn't painted.
 }
 public bool IsHit(DocumentFrame frame, Point point)
 {
     return frame.HitBounds.Contains(point);
 }
        Rectangle GetHandleBounds(DocumentFrame frame)
        {
            Rectangle shiftedRectangle = frame.HitBounds;
            shiftedRectangle.Offset(
                _outerRectangleShift.X * (shiftedRectangle.Width + 10),
                _outerRectangleShift.Y * (shiftedRectangle.Height + 10));

            Rectangle cutOutRectangle = frame.HitBounds;
            cutOutRectangle.Inflate(20, 20);

            return Rectangle.Intersect(shiftedRectangle, cutOutRectangle);
        }
Exemple #10
0
        public void SendFrameToBack(DocumentFrame documentFrame)
        {
            ThrowOnInvalidDocumentFrame(documentFrame);

            _frames.Remove(documentFrame);
            _frames.Insert(0, documentFrame);
        }
Exemple #11
0
        public void BringFrameToFront(DocumentFrame documentFrame)
        {
            ThrowOnInvalidDocumentFrame(documentFrame);

            _frames.Remove(documentFrame);
            _frames.Add(documentFrame);
        }
        Point GetCentrePoint(DocumentFrame frame)
        {
            LabelDocumentFrame labelFrame = (LabelDocumentFrame)frame;

            return new Point(labelFrame.CallOutOffsetInDocument);
        }
        public void SelectNone()
        {
            _selectedFrame = null;

            if (SelectedFrameChanged != null) SelectedFrameChanged(this, EventArgs.Empty);
        }
 public void DeleteFrame(DocumentFrame documentFrame)
 {
     _document.DeleteFrame(documentFrame);
 }
 public void BringFrameToFront(DocumentFrame documentFrame)
 {
     _document.BringFrameToFront(documentFrame);
 }
 public void AddNewFrame(DocumentFrame documentFrame)
 {
     _document.Frames.Add(documentFrame);
 }
 public bool IsHit(DocumentFrame frame, Point point)
 {
     return GetHandleBounds(frame).Contains(point);
 }
        public void Paint(DocumentFrame frame, Graphics g, DocumentPaintResources resources)
        {
            SmoothingMode oldSmoothingMode = g.SmoothingMode;
            g.SmoothingMode = SmoothingMode.AntiAlias;

            using (GraphicsPath path = Interlace.Drawing.Utilities.CreateRoundedRectanglePath(GetHandleBounds(frame), 5.0f))
            {
                g.FillPath(resources.HandleBrush, path);
            }

            g.SmoothingMode = oldSmoothingMode;
        }
        void PasteUpControl_MouseDown(object sender, MouseEventArgs e)
        {
            // Test hitting a handle first:
            if (_selectedFrame != null)
            {
                IHandleFlyweight handle = _selectedFrame.FindHitHandleOrNull(e.Location);

                if (handle != null)
                {
                    _dragController = new DragController(e.Location, _selectedFrame, handle);
                    _dragController.BeginDrag();

                    return;
                }
            }

            // Then try hitting a frame:
            DocumentFrame hitFrame = FindHitFrameOrNull(e.Location);

            if (_selectedFrame != hitFrame)
            {
                _selectedFrame = hitFrame;

                if (SelectedFrameChanged != null) SelectedFrameChanged(this, EventArgs.Empty);

                Invalidate();
            }
        }
            internal override void Restore(DocumentFrame frame)
            {
                base.Restore(frame);

                RectangularDocumentFrame rectangularFrame = (RectangularDocumentFrame)frame;
                rectangularFrame._clipBounds = _clipBounds;
            }
            internal override void Restore(DocumentFrame frame)
            {
                base.Restore(frame);

                LabelDocumentFrame labelFrame = (LabelDocumentFrame)frame;

                labelFrame._callOutOffsetInDocument = _callOutOffsetInDocument;
            }
 public DocumentFrameMemento(DocumentFrame frame)
 {
     _offsetInDocument = frame.OffsetInDocument;
 }
Exemple #23
0
        public void DeleteFrame(DocumentFrame documentFrame)
        {
            ThrowOnInvalidDocumentFrame(documentFrame);

            _frames.Remove(documentFrame);
            documentFrame.Dispose();
        }
 internal virtual void Restore(DocumentFrame frame)
 {
     frame.OffsetInDocument = _offsetInDocument;
 }
Exemple #25
0
        void ThrowOnInvalidDocumentFrame(DocumentFrame documentFrame)
        {
            if (documentFrame == null)
            {
                throw new ArgumentNullException("documentFrame");
            }

            if (!_frames.Contains(documentFrame))
            {
                throw new ArgumentException(
                    "The document frame supplied to a document method is not actually within the document.", "documentFrame");
            }
        }
        public void UpdateDrag(Point firstPoint, Point currentPoint, Size delta, DocumentFrame frame, DocumentFrameMemento memento)
        {
            RectangularDocumentFrame rectangularFrame = (RectangularDocumentFrame)frame;
            frame.RestoreFromMemento(memento);

            Rectangle clipBounds = rectangularFrame.ClipBounds;

            if (_isEast) clipBounds.Width += delta.Width;

            if (_isSouth)
            {
                clipBounds.Y += delta.Height;
                clipBounds.Height -= delta.Height;
            }

            if (_isWest)
            {
                clipBounds.X += delta.Width;
                clipBounds.Width -= delta.Width;
            }

            if (_isNorth) clipBounds.Height += delta.Height;

            clipBounds.Intersect(rectangularFrame.ObjectBounds);

            rectangularFrame.ClipBounds = clipBounds;
        }