Example #1
0
        /// <summary>
        /// Get currently dragging edge or null
        /// if currently no edige is being dragged.</summary>
        /// <returns></returns>
        public DragEdge GetDraggingEdge()
        {
            if (!m_isConnecting)
            {
                return(null);
            }

            var         d2dControl = this.AdaptedControl as D2dAdaptableControl;
            D2dGraphics gfx        = d2dControl.D2dGraphics;
            var         invXform   = Matrix3x2F.Invert(gfx.Transform);

            var edge = new DragEdge();

            edge.FromNode   = m_draggingContext.ActualFromNode();
            edge.FromRoute  = m_draggingContext.ActualFromRoute(edge.FromNode);
            edge.ToNode     = m_draggingContext.ActualToNode();
            edge.ToRoute    = m_draggingContext.ActualToRoute(edge.ToNode);
            edge.Label      = m_draggingContext.ExistingEdge != null ? m_draggingContext.ExistingEdge.Label : null;
            edge.StartPoint = edge.FromRoute == null?Matrix3x2F.TransformPoint(invXform, m_edgeDragPoint) : m_draggingContext.FromRoutePos;

            edge.EndPoint = edge.ToRoute == null?Matrix3x2F.TransformPoint(invXform, m_edgeDragPoint) : m_draggingContext.ToRoutePos;

            return(edge);
        }
 private Rect ComputeBottomLayDown(DragEdge dragEdge)
 {
     int bl = PaddingLeft, bt = PaddingTop;
     int br, bb;
     if (dragEdge == DragEdge.Right) {
         bl = MeasuredWidth - mDragDistance;
     } else if (dragEdge == DragEdge.Bottom) {
         bt = MeasuredHeight - mDragDistance;
     }
     if (dragEdge == DragEdge.Left || dragEdge == DragEdge.Right) {
         br = bl + mDragDistance;
         bb = bt + MeasuredHeight;
     } else {
         br = bl + MeasuredWidth;
         bb = bt + mDragDistance;
     }
     return new Rect(bl, bt, br, bb);
 }
 protected bool IsViewTotallyFirstShowed(View child, Rect relativePosition, DragEdge edge, int surfaceLeft,
     int surfaceTop, int surfaceRight, int surfaceBottom)
 {
     if (mShowEntirely[child]) return false;
     int childLeft = relativePosition.Left;
     int childRight = relativePosition.Right;
     int childTop = relativePosition.Top;
     int childBottom = relativePosition.Bottom;
     bool r = false;
     if (mShowMode == ShowMode.LayDown) {
         if ((edge == DragEdge.Right && surfaceRight <= childLeft)
             || (edge == DragEdge.Left && surfaceLeft >= childRight)
             || (edge == DragEdge.Top && surfaceTop >= childBottom)
             || (edge == DragEdge.Bottom && surfaceBottom <= childTop)) r = true;
     } else if (mShowMode == ShowMode.PullOut) {
         if ((edge == DragEdge.Right && childRight <= Width)
             || (edge == DragEdge.Left && childLeft >= PaddingLeft)
             || (edge == DragEdge.Top && childTop >= PaddingTop)
             || (edge == DragEdge.Bottom && childBottom <= Height)) r = true;
     }
     return r;
 }
 protected bool IsViewShowing(View child, Rect relativePosition, DragEdge availableEdge, int surfaceLeft,
     int surfaceTop, int surfaceRight, int surfaceBottom)
 {
     int childLeft = relativePosition.Left;
     int childRight = relativePosition.Right;
     int childTop = relativePosition.Top;
     int childBottom = relativePosition.Bottom;
     if (mShowMode == ShowMode.LayDown) {
         switch (availableEdge) {
         case DragEdge.Right:
             if (surfaceRight > childLeft && surfaceRight <= childRight) {
                 return true;
             }
             break;
         case DragEdge.Left:
             if (surfaceLeft < childRight && surfaceLeft >= childLeft) {
                 return true;
             }
             break;
         case DragEdge.Top:
             if (surfaceTop >= childTop && surfaceTop < childBottom) {
                 return true;
             }
             break;
         case DragEdge.Bottom:
             if (surfaceBottom > childTop && surfaceBottom <= childBottom) {
                 return true;
             }
             break;
         }
     } else if (mShowMode == ShowMode.PullOut) {
         switch (availableEdge) {
         case DragEdge.Right:
             if (childLeft <= Width && childRight > Width) return true;
             break;
         case DragEdge.Left:
             if (childRight >= PaddingLeft && childLeft < PaddingLeft) return true;
             break;
         case DragEdge.Top:
             if (childTop < PaddingTop && childBottom >= PaddingTop) return true;
             break;
         case DragEdge.Bottom:
             if (childTop < Height && childTop >= PaddingTop) return true;
             break;
         }
     }
     return false;
 }
 public void Open(bool smooth, bool notify, DragEdge edge)
 {
     CurrentDragEdge = edge;
     Open(smooth, notify);
 }
 public void Open(bool smooth, DragEdge edge)
 {
     CurrentDragEdge = edge;
     Open(smooth, true);
 }
 public void Open(DragEdge edge)
 {
     CurrentDragEdge = edge;
     Open(true, true);
 }