private DockCluster FindTargetCluster(DragTarget target)
        {
            foreach (DockCluster cluster in _clusters)
            {
                if (!cluster.ExcludeCluster && cluster.ScreenRect.Equals(target.ScreenRect))
                {
                    return(cluster);
                }
            }

            return(null);
        }
 /// <summary>
 /// Initialize a new instance of the DockCluster class.
 /// </summary>
 /// <param name="paletteDragDrop">Drawing palette.</param>
 /// <param name="renderer">Drawing renderer.</param>
 /// <param name="target">Initial target for the cluster.</param>
 public DockCluster(IPaletteDragDrop paletteDragDrop,
                    IRenderer renderer,
                    DragTarget target)
 {
     _paletteDragDrop = paletteDragDrop;
     _renderer        = renderer;
     ScreenRect       = target.ScreenRect;
     DrawRect         = target.DrawRect;
     _hintToTarget    = new HintToTarget
     {
         { target.Hint& DragTargetHint.ExcludeFlags, target }
     };
     ExcludeCluster = (target.Hint & DragTargetHint.ExcludeCluster) == DragTargetHint.ExcludeCluster;
 }
            /// <summary>
            /// Add the new target to the cluster.
            /// </summary>
            /// <param name="target">Target to add into cluster.</param>
            public void Add(DragTarget target)
            {
                // Find the hint that excludes extra flags
                DragTargetHint hint = target.Hint & DragTargetHint.ExcludeFlags;

                // Can only add one of each hint value
                if (!_hintToTarget.ContainsKey(hint))
                {
                    _hintToTarget.Add(hint, target);

                    // Make sure the drawing rectangle encloses all targets
                    DrawRect = Rectangle.Union(DrawRect, target.DrawRect);
                }
            }
Exemplo n.º 4
0
        /// <summary>
        /// Called to request feedback be shown for the specified target.
        /// </summary>
        /// <param name="screenPt">Current screen point of mouse.</param>
        /// <param name="target">Target that needs feedback.</param>
        /// <returns>Updated drag target.</returns>
        public override DragTarget Feedback(Point screenPt, DragTarget target)
        {
            // If the current target no longer matches the new point, we need a new target.
            if ((target != null) && !target.IsMatch(screenPt, PageDragEndData))
            {
                target = null;
            }

            // Only find a new target if we do not already have a target
            if (target == null)
            {
                target = FindTarget(screenPt, PageDragEndData);
            }

            if (_solid != null)
            {
                _solid.SolidRect = (target != null) ? target.DrawRect : Rectangle.Empty;
            }

            return(target);
        }
        /// <summary>
        /// Called to request feedback be shown for the specified target.
        /// </summary>
        /// <param name="screenPt">Current screen point of mouse.</param>
        /// <param name="target">Target that needs feedback.</param>
        /// <returns>Updated drag target.</returns>
        public override DragTarget Feedback(Point screenPt, DragTarget target)
        {
            DragTarget matchTarget = null;

            // Update each cluster so it shows/hides docking indicators based on mouse position
            foreach (DockCluster cluster in _clusters)
            {
                DragTarget clusterTarget = cluster.Feedback(screenPt, _dragFeedback);

                // We use the first matching target found in a cluster
                if ((clusterTarget != null) && (matchTarget == null))
                {
                    matchTarget = clusterTarget;
                }
            }

            // Update the solid feedback rectangle with area of the specific target
            if (_solid != null)
            {
                _solid.SolidRect = (matchTarget != null) ? matchTarget.DrawRect : Rectangle.Empty;
            }

            return(matchTarget);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Called to request feedback be shown for the specified target.
 /// </summary>
 /// <param name="screenPt">Current screen point of mouse.</param>
 /// <param name="target">Target that needs feedback.</param>
 /// <returns>Updated drag target.</returns>
 public abstract DragTarget Feedback(Point screenPt, DragTarget target);