Example #1
0
        /// <summary>
        /// Start using a <see cref="P:Northwoods.Go.GoToolDragging.DragSelection" />, creating it if needed, and moving the
        /// originally selected objects back to their original position.
        /// </summary>
        /// <remarks>
        /// This also sets <see cref="P:Northwoods.Go.GoTool.CurrentObject" /> to a corresponding
        /// outline object in the drag selection, and remembers the original current
        /// object in the <see cref="P:Northwoods.Go.GoToolDragging.DragSelectionOriginalObject" /> property.  This
        /// allows <see cref="M:Northwoods.Go.GoToolDragging.DoDragging(Northwoods.Go.GoInputState)" />to continue calculating move offsets based
        /// on the position of the <see cref="P:Northwoods.Go.GoTool.CurrentObject" />, even though
        /// the objects are part of the drag selection instead of the
        /// original selected objects.
        /// </remarks>
        public virtual void MakeDragSelection()
        {
            if (DragSelection != null)
            {
                return;
            }
            DragSelectionOriginalObject = base.CurrentObject;
            DragSelection = CreateDragSelection();
            if (DragSelection == null || DragSelection.IsEmpty)
            {
                DragSelectionOriginalObject = null;
                DragSelection = null;
                return;
            }
            SizeF offset = GoTool.SubtractPoints(GoTool.SubtractPoints(base.FirstInput.DocPoint, MoveOffset), DragSelectionOriginalObject.Position);

            if (offset.Width != 0f || offset.Height != 0f)
            {
                base.View.MoveSelection((EffectiveSelection != null) ? EffectiveSelection : base.Selection, offset, grid: false);
            }
            if (base.CurrentObject.View != base.View)
            {
                base.CurrentObject = DragSelection.Primary;
            }
        }
Example #2
0
        /// <summary>
        /// This method is called repeatedly by <see cref="M:Northwoods.Go.GoBalloon.DoResize(Northwoods.Go.GoView,System.Drawing.RectangleF,System.Drawing.PointF,System.Int32,Northwoods.Go.GoInputState,System.Drawing.SizeF,System.Drawing.SizeF)" /> while
        /// the user is dragging the <see cref="F:Northwoods.Go.GoBalloon.AnchorHandle" /> resize handle.
        /// </summary>
        /// <param name="p">the point (in document coordinates) currently specified by the user's mouse</param>
        /// <param name="view"></param>
        /// <param name="evttype"></param>
        /// <remarks>
        /// When <paramref name="evttype" /> is <c>GoInputState.</c><see cref="F:Northwoods.Go.GoInputState.Finish" />,
        /// this calls <see cref="M:Northwoods.Go.GoView.PickObject(System.Boolean,System.Boolean,System.Drawing.PointF,System.Boolean)" /> to
        /// find the selectable document object at the given point <paramref name="p" />.
        /// The <see cref="P:Northwoods.Go.GoBalloon.Anchor" /> is set to that object.
        /// If no object is found at that point, the <see cref="P:Northwoods.Go.GoBalloon.Anchor" /> is set to null
        /// and the <see cref="P:Northwoods.Go.GoBalloon.UnanchoredOffset" /> is set to the offset between that
        /// point and the <see cref="P:Northwoods.Go.GoComment.Label" />'s Position.
        /// If the user tries to reanchor this balloon to itself, no change is made.
        /// This method does nothing unless the <paramref name="evttype" /> is <see cref="F:Northwoods.Go.GoInputState.Finish" />.
        /// </remarks>
        protected virtual void PickNewAnchor(PointF p, GoView view, GoInputState evttype)
        {
            if (evttype != GoInputState.Finish)
            {
                return;
            }
            GoObject goObject = view.PickObject(doc: true, view: false, p, selectableOnly: true);

            if (goObject == this)
            {
                return;
            }
            Anchor = goObject;
            if (goObject == null)
            {
                if (Label != null)
                {
                    UnanchoredOffset = GoTool.SubtractPoints(p, Label.Position);
                }
                else
                {
                    UnanchoredOffset = GoTool.SubtractPoints(p, base.Position);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Create a new selection object containing an image of all of the real selected objects.
        /// </summary>
        /// <returns>a new <see cref="T:Northwoods.Go.GoSelection" /> holding view objects that represent the
        /// objects in the <see cref="P:Northwoods.Go.GoView.Selection" /></returns>
        /// <remarks>
        /// This creates a new <see cref="T:Northwoods.Go.GoSelection" /> for this view.
        /// The objects that are in this selection have been added to the default
        /// layer of the view.
        /// </remarks>
        public virtual GoSelection CreateDragSelection()
        {
            GoSelection     goSelection     = new GoSelection(null);
            PointF          position        = base.CurrentObject.Position;
            SizeF           offset          = GoTool.SubtractPoints(base.CurrentObject.Location, position);
            GoDragRectangle goDragRectangle = new GoDragRectangle();

            goDragRectangle.Bounds  = base.CurrentObject.Bounds;
            goDragRectangle.Offset  = offset;
            goDragRectangle.Visible = false;
            base.View.Layers.Default.Add(goDragRectangle);
            goSelection.Add(goDragRectangle);
            GoCollection goCollection = new GoCollection();

            goCollection.InternalChecksForDuplicates = false;
            foreach (GoObject item in (EffectiveSelection != null) ? EffectiveSelection : base.Selection)
            {
                goCollection.Add(item.DraggingObject);
            }
            base.View.Document.Layers.SortByZOrder(goCollection);
            RectangleF bounds = GoDocument.ComputeBounds(goCollection, base.View);
            float      num    = 1E+21f;
            float      num2   = 1E+21f;

            foreach (GoObject item2 in goCollection)
            {
                if (item2.Top < num)
                {
                    num = item2.Top;
                }
                if (item2.Left < num2)
                {
                    num2 = item2.Left;
                }
            }
            float num3 = base.View.WorldScale.Width;

            if (bounds.Width * num3 > 2000f || bounds.Height * num3 > 2000f)
            {
                num3 *= Math.Min(2000f / (bounds.Width * num3), 2000f / (bounds.Height * num3));
            }
            Bitmap      bitmapFromCollection = base.View.GetBitmapFromCollection(goCollection, bounds, num3, paper: false);
            GoDragImage goDragImage          = new GoDragImage();

            goDragImage.Image  = bitmapFromCollection;
            goDragImage.Bounds = new RectangleF(bounds.X, bounds.Y, (float)bitmapFromCollection.Width / num3, (float)bitmapFromCollection.Height / num3);
            if (num < 1E+21f && num2 < 1E+21f)
            {
                goDragImage.Offset = new SizeF(num2 - bounds.X + offset.Width, num - bounds.Y + offset.Height);
            }
            else
            {
                goDragImage.Offset = offset;
            }
            base.View.Layers.Default.Add(goDragImage);
            goSelection.Add(goDragImage);
            return(goSelection);
        }
Example #4
0
 /// <summary>
 /// Cancelling a drag involves moving the selection back to the original position
 /// before aborting the transaction.
 /// </summary>
 public override void DoCancelMouse()
 {
     if (base.CurrentObject != null && DragSelection == null)
     {
         SizeF offset = GoTool.SubtractPoints(GoTool.SubtractPoints(base.FirstInput.DocPoint, MoveOffset), base.CurrentObject.Position);
         if (offset.Width != 0f || offset.Height != 0f)
         {
             base.View.MoveSelection((EffectiveSelection != null) ? EffectiveSelection : base.Selection, offset, grid: false);
         }
     }
     base.TransactionResult = null;
     StopTool();
 }
Example #5
0
        /// <summary>
        /// Perform the drag, for both moving and copying, including the final move or copy
        /// on a mouse up event.
        /// </summary>
        /// <param name="evttype"></param>
        /// <remarks>
        /// Whether the drag is performing a move or a copy is determined by the
        /// value of the <see cref="M:Northwoods.Go.GoToolDragging.MayBeCopying" /> and <see cref="M:Northwoods.Go.GoToolDragging.MayBeMoving" /> predicates.
        /// This method is sensitive to the <see cref="P:Northwoods.Go.GoView.DragsRealtime" /> property.
        /// When this property is false, dragging uses the <see cref="P:Northwoods.Go.GoToolDragging.DragSelection" />
        /// selection instead of the normal <see cref="P:Northwoods.Go.GoView.Selection" /> collection.
        /// It calls <see cref="M:Northwoods.Go.GoToolDragging.MakeDragSelection" /> to create the drag selection if needed
        /// and then moves the drag selection.
        /// When not copying and when <see cref="P:Northwoods.Go.GoView.DragsRealtime" /> is true, it calls
        /// <see cref="M:Northwoods.Go.GoToolDragging.ClearDragSelection" /> to stop using any drag selection and then it
        /// moves the regular <see cref="P:Northwoods.Go.GoView.Selection" />.
        /// </remarks>
        public virtual void DoDragging(GoInputState evttype)
        {
            if (base.CurrentObject == null)
            {
                return;
            }
            SizeF         sizeF         = GoTool.SubtractPoints(base.LastInput.DocPoint, base.CurrentObject.Position);
            SizeF         sizeF2        = new SizeF(sizeF.Width - MoveOffset.Width, sizeF.Height - MoveOffset.Height);
            bool          flag          = MayBeCopying() && MustBeCopying();
            bool          flag2         = MayBeMoving();
            DragEventArgs dragEventArgs = base.LastInput.DragEventArgs;

            if (dragEventArgs != null && !base.View.IsInternalDragDrop(dragEventArgs))
            {
                flag = false;
            }
            if (EffectiveSelection == null)
            {
                myEffectiveSelection = ComputeEffectiveSelection(base.Selection, !flag);
            }
            if (evttype != GoInputState.Finish)
            {
                GoSelection goSelection = null;
                if (flag || !base.View.DragsRealtime)
                {
                    MakeDragSelection();
                    goSelection = DragSelection;
                }
                else if (flag2)
                {
                    ClearDragSelection();
                    goSelection = EffectiveSelection;
                }
                if (goSelection != null)
                {
                    GoObject goObject = null;
                    foreach (GoObject item in goSelection)
                    {
                        if (!(item is IGoLink) && item.CanMove())
                        {
                            goObject = item;
                            break;
                        }
                    }
                    SizeF offset = sizeF2;
                    if (goObject != null)
                    {
                        PointF location = goObject.Location;
                        PointF p        = new PointF(location.X + sizeF2.Width, location.Y + sizeF2.Height);
                        p             = base.View.SnapPoint(p, goObject);
                        offset.Width  = p.X - location.X;
                        offset.Height = p.Y - location.Y;
                    }
                    base.View.MoveSelection(goSelection, offset, grid: false);
                }
                return;
            }
            SizeF offset2 = sizeF2;

            if (DragSelection != null)
            {
                offset2 = GoTool.SubtractPoints(base.CurrentObject.Position, DragSelectionOriginalObject.Position);
                ClearDragSelection();
            }
            if (flag)
            {
                if (CopiesEffectiveSelection)
                {
                    myEffectiveSelection = ComputeEffectiveSelection(base.Selection, move: false);
                    base.View.CopySelection(EffectiveSelection, offset2, grid: true);
                }
                else
                {
                    base.View.CopySelection(base.Selection, offset2, grid: true);
                }
            }
            else if (flag2)
            {
                if (EffectiveSelection == null)
                {
                    myEffectiveSelection = ComputeEffectiveSelection(base.Selection, move: true);
                }
                base.View.MoveSelection(EffectiveSelection, offset2, grid: true);
            }
        }
Example #6
0
 /// <summary>
 /// Start a drag-and-drop operation.
 /// </summary>
 /// <remarks>
 /// <para>
 /// This first remembers the <see cref="P:Northwoods.Go.GoToolDragging.MoveOffset" /> between the <see cref="P:Northwoods.Go.GoTool.CurrentObject" />'s
 /// position and the mouse point (the first input event point).
 /// It removes any selection handles, so those do not need to be dragged along.
 /// It also starts a transaction.
 /// If the view's <see cref="P:Northwoods.Go.GoView.AllowDragOut" /> property is true, we call
 /// <c>Control.DoDragDrop</c> to start the standard modal drag-and-drop process.
 /// </para>
 /// <para>
 /// This depends on the cooperation of <see cref="M:Northwoods.Go.GoView.OnDragOver(System.Windows.Forms.DragEventArgs)" />, <see cref="M:Northwoods.Go.GoView.OnDragDrop(System.Windows.Forms.DragEventArgs)" />,
 /// and <see cref="M:Northwoods.Go.GoView.OnQueryContinueDrag(System.Windows.Forms.QueryContinueDragEventArgs)" /> to call <see cref="M:Northwoods.Go.GoToolDragging.DoMouseMove" />,
 /// <see cref="M:Northwoods.Go.GoToolDragging.DoMouseUp" />, and <see cref="M:Northwoods.Go.GoToolDragging.DoCancelMouse" /> appropriately when the
 /// drop target is the same view as the drag source.
 /// If the view's <see cref="P:Northwoods.Go.GoView.AllowDragOut" /> property is false, the
 /// normal calls to <see cref="M:Northwoods.Go.GoToolDragging.DoMouseMove" />, <see cref="M:Northwoods.Go.GoToolDragging.DoMouseUp" />, and
 /// <see cref="M:Northwoods.Go.GoToolDragging.DoCancelMouse" /> occur.
 /// </para>
 /// <para>
 /// If <see cref="P:Northwoods.Go.GoToolDragging.SelectsWhenStarts" /> is false, this method does not
 /// modify the current selection and does not set
 /// <see cref="P:Northwoods.Go.GoTool.CurrentObject" /> or <see cref="P:Northwoods.Go.GoToolDragging.MoveOffset" />.
 /// </para>
 /// </remarks>
 public override void Start()
 {
     if (SelectsWhenStarts)
     {
         base.CurrentObject = base.View.PickObject(doc: true, view: false, base.FirstInput.DocPoint, selectableOnly: true);
         if (base.CurrentObject == null)
         {
             return;
         }
         MoveOffset = GoTool.SubtractPoints(base.FirstInput.DocPoint, base.CurrentObject.Position);
     }
     StartTransaction();
     if (SelectsWhenStarts && !base.Selection.Contains(base.CurrentObject))
     {
         if (base.FirstInput.Shift || base.FirstInput.Control)
         {
             base.Selection.Add(base.CurrentObject);
         }
         else
         {
             base.Selection.Select(base.CurrentObject);
         }
     }
     if (!base.View.DragRoutesRealtime && base.View.DragsRealtime)
     {
         base.View.Document.SuspendsRouting = true;
     }
     if (HidesSelectionHandles)
     {
         mySelectionHidden = true;
         base.Selection.RemoveAllSelectionHandles();
     }
     if (base.View.AllowDragOut)
     {
         myModalDropped = false;
         try
         {
             if (base.Selection.Primary != null)
             {
                 SizeF hotSpot = GoTool.SubtractPoints(base.LastInput.DocPoint, base.Selection.Primary.Position);
                 base.Selection.HotSpot = hotSpot;
             }
             DoDragDrop(base.Selection, DragDropEffects.All);
         }
         catch (VerificationException ex)
         {
             GoObject.Trace("GoToolDragging Start: " + ex.ToString());
         }
         catch (SecurityException ex2)
         {
             GoObject.Trace("GoToolDragging Start: " + ex2.ToString());
         }
         finally
         {
             if (!myModalDropped)
             {
                 DoCancelMouse();
             }
             else
             {
                 StopTool();
             }
             base.Selection.HotSpot = default(SizeF);
         }
     }
 }