Ejemplo n.º 1
0
 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;
        }
Ejemplo n.º 5
0
 public void SendFrameToBack(DocumentFrame documentFrame)
 {
     _document.SendFrameToBack(documentFrame);
 }
Ejemplo n.º 6
0
 public void UpdateDrag(Point firstPoint, Point currentPoint, Size delta, DocumentFrame frame, DocumentFrameMemento memento)
 {
     frame.RestoreFromMemento(memento);
     frame.OffsetInDocument += delta;
 }
Ejemplo n.º 7
0
 public void Paint(DocumentFrame frame, Graphics g, DocumentPaintResources resources)
 {
     // The move handle isn't painted.
 }
Ejemplo n.º 8
0
 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);
        }
Ejemplo n.º 10
0
        public void SendFrameToBack(DocumentFrame documentFrame)
        {
            ThrowOnInvalidDocumentFrame(documentFrame);

            _frames.Remove(documentFrame);
            _frames.Insert(0, documentFrame);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 13
0
        public void SelectNone()
        {
            _selectedFrame = null;

            if (SelectedFrameChanged != null) SelectedFrameChanged(this, EventArgs.Empty);
        }
Ejemplo n.º 14
0
 public void DeleteFrame(DocumentFrame documentFrame)
 {
     _document.DeleteFrame(documentFrame);
 }
Ejemplo n.º 15
0
 public void BringFrameToFront(DocumentFrame documentFrame)
 {
     _document.BringFrameToFront(documentFrame);
 }
Ejemplo n.º 16
0
 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;
        }
Ejemplo n.º 19
0
        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;
            }
Ejemplo n.º 21
0
            internal override void Restore(DocumentFrame frame)
            {
                base.Restore(frame);

                LabelDocumentFrame labelFrame = (LabelDocumentFrame)frame;

                labelFrame._callOutOffsetInDocument = _callOutOffsetInDocument;
            }
Ejemplo n.º 22
0
 public DocumentFrameMemento(DocumentFrame frame)
 {
     _offsetInDocument = frame.OffsetInDocument;
 }
Ejemplo n.º 23
0
        public void DeleteFrame(DocumentFrame documentFrame)
        {
            ThrowOnInvalidDocumentFrame(documentFrame);

            _frames.Remove(documentFrame);
            documentFrame.Dispose();
        }
Ejemplo n.º 24
0
 internal virtual void Restore(DocumentFrame frame)
 {
     frame.OffsetInDocument = _offsetInDocument;
 }
Ejemplo n.º 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;
        }