コード例 #1
0
        /// <summary>
        /// Starts a drag.
        /// </summary>
        /// <param name="b"> The bitmap to display as the drag image.  It will be re-scaled to the
        ///          enlarged size. </param>
        /// <param name="screenX"> The x position on screen of the left-top of the bitmap. </param>
        /// <param name="screenY"> The y position on screen of the left-top of the bitmap. </param>
        /// <param name="textureLeft"> The left edge of the region inside b to use. </param>
        /// <param name="textureTop"> The top edge of the region inside b to use. </param>
        /// <param name="textureWidth"> The width of the region inside b to use. </param>
        /// <param name="textureHeight"> The height of the region inside b to use. </param>
        /// <param name="source"> An object representing where the drag originated </param>
        /// <param name="dragInfo"> The data associated with the object that is being dragged </param>
        /// <param name="dragAction"> The drag action: either <seealso cref="#DRAG_ACTION_MOVE"/> or
        ///        <seealso cref="#DRAG_ACTION_COPY"/> </param>
        public void StartDrag(Bitmap b, int screenX, int screenY, int textureLeft, int textureTop, int textureWidth, int textureHeight, IDragSource source, object dragInfo, int dragAction)
        {
            if (PROFILE_DRAWING_DURING_DRAG)
            {
                Debug.StartMethodTracing("Launcher");
            }

            // Hide soft keyboard, if visible
            if (mInputMethodManager == null)
            {
                mInputMethodManager = (InputMethodManager)mContext.GetSystemService(Context.InputMethodService);
            }
            mInputMethodManager.HideSoftInputFromWindow(mWindowToken, 0);

            if (mListener != null)
            {
                mListener.OnDragStart(source, dragInfo, dragAction);
            }

            int registrationX = ((int)mMotionDownX) - screenX;
            int registrationY = ((int)mMotionDownY) - screenY;

            mTouchOffsetX = mMotionDownX - screenX;
            mTouchOffsetY = mMotionDownY - screenY;

            mDragging   = true;
            mDragSource = source;
            mDragInfo   = dragInfo;

            //mVibrator.vibrate(VIBRATE_DURATION);
            DragView dragView = mDragView = new DragView(mContext, b, registrationX, registrationY, textureLeft, textureTop, textureWidth, textureHeight);

            dragView.Show(mWindowToken, (int)mMotionDownX, (int)mMotionDownY);
        }
コード例 #2
0
 private void EndDrag()
 {
     if (mDragging)
     {
         mDragging = false;
         if (mOriginator != null)
         {
             mOriginator.Visibility = ViewStates.Invisible;
         }
         if (mListener != null)
         {
             mListener.OnDragEnd();
         }
         if (mDragView != null)
         {
             mDragView.Remove();
             mDragView = null;
         }
     }
 }
コード例 #3
0
 /// <summary>
 /// Estimate the surface area where this object would land if dropped at the
 /// given location.
 /// </summary>
 /// <param name="source"> DragSource where the drag started </param>
 /// <param name="x"> X coordinate of the drop location </param>
 /// <param name="y"> Y coordinate of the drop location </param>
 /// <param name="xOffset"> Horizontal offset with the object being dragged where the
 ///            original touch happened </param>
 /// <param name="yOffset"> Vertical offset with the object being dragged where the
 ///            original touch happened </param>
 /// <param name="dragView"> The DragView that's being dragged around on screen. </param>
 /// <param name="dragInfo"> Data associated with the object being dragged </param>
 /// <param name="recycle"> <seealso cref="Rect"/> object to be possibly recycled. </param>
 /// <returns> Estimated area that would be occupied if object was dropped at
 ///         the given location. Should return null if no estimate is found,
 ///         or if this target doesn't provide estimations. </returns>
 public Rect EstimateDropLocation(IDragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, object dragInfo, Rect recycle)
 {
     return(null);
 }
コード例 #4
0
 /// <summary>
 /// Check if a drop action can occur at, or near, the requested location.
 /// This may be called repeatedly during a drag, so any calls should return
 /// quickly.
 /// </summary>
 /// <param name="source"> DragSource where the drag started </param>
 /// <param name="x"> X coordinate of the drop location </param>
 /// <param name="y"> Y coordinate of the drop location </param>
 /// <param name="xOffset"> Horizontal offset with the object being dragged where the
 ///            original touch happened </param>
 /// <param name="yOffset"> Vertical offset with the object being dragged where the
 ///            original touch happened </param>
 /// <param name="dragView"> The DragView that's being dragged around on screen. </param>
 /// <param name="dragInfo"> Data associated with the object being dragged </param>
 /// <returns> True if the drop will be accepted, false otherwise. </returns>
 public bool AcceptDrop(IDragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, object dragInfo)
 {
     return(true);
 }
コード例 #5
0
 public void OnDragExit(IDragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, object dragInfo)
 {
 }
コード例 #6
0
        public void OnDragOver(IDragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, object dragInfo)
        {
            View v = (View)dragInfo;

            int w    = v.Width;
            int h    = v.Height;
            int left = x - xOffset;
            int top  = y - yOffset;

            DragLayer.LayoutParams lp = new DragLayer.LayoutParams(w, h, left, top);
            this.UpdateViewLayout(v, lp);
        }