Ejemplo n.º 1
0
        /// <summary>
        /// 拖动滚动中
        /// </summary>
        public virtual void onDragScrolling()
        {
            int width = Width, height = Height;

            if (m_allowDragScroll && m_readyToDragScroll)
            {
                if (!onDragScrollPermit())
                {
                    m_readyToDragScroll = false;
                    return;
                }
                bool    paint    = false;
                FCPoint newPoint = Native.TouchPoint;
                if (m_hScrollBar != null && m_hScrollBar.Visible)
                {
                    if (Math.Abs(newPoint.x - m_startMovePoint.x) > width / 10)
                    {
                        m_isDragScrolling2 = true;
                    }
                    int newPos = m_startMovePosX + m_startMovePoint.x - newPoint.x;
                    if (newPos != m_hScrollBar.Pos)
                    {
                        m_hScrollBar.Pos = newPos;
                        m_hScrollBar.update();
                        paint = true;
                    }
                }
                if (m_vScrollBar != null && m_vScrollBar.Visible)
                {
                    if (Math.Abs(newPoint.y - m_startMovePoint.y) > height / 10)
                    {
                        m_isDragScrolling2 = true;
                    }
                    int newPos = m_startMovePosY + m_startMovePoint.y - newPoint.y;
                    if (newPos != m_vScrollBar.Pos)
                    {
                        m_vScrollBar.Pos = newPos;
                        m_vScrollBar.update();
                        paint = true;
                    }
                }
                if (paint)
                {
                    m_isDragScrolling = true;
                    invalidate();
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 更新滚动条的布局
 /// </summary>
 public virtual void updateScrollBar()
 {
     if (Native != null)
     {
         FCHScrollBar hScrollBar = HScrollBar;
         FCVScrollBar vScrollBar = VScrollBar;
         if (Visible)
         {
             int width = Width, height = Height;
             //滚动条尺寸
             int hBarHeight = (hScrollBar != null) ? hScrollBar.Height : 0;
             int vBarWidth = (vScrollBar != null) ? vScrollBar.Width : 0;
             int wmax = getContentWidth(), hmax = getContentHeight();
             if (hScrollBar != null)
             {
                 hScrollBar.ContentSize = wmax;
                 hScrollBar.Size        = new FCSize(width - vBarWidth, hBarHeight);
                 hScrollBar.PageSize    = width - vBarWidth;
                 hScrollBar.Location    = new FCPoint(0, height - hBarHeight);
                 if (wmax <= width)
                 {
                     hScrollBar.Visible = false;
                 }
                 else
                 {
                     hScrollBar.Visible = true;
                 }
             }
             if (vScrollBar != null)
             {
                 vScrollBar.ContentSize = hmax;
                 vScrollBar.Size        = new FCSize(vBarWidth, height - hBarHeight);
                 vScrollBar.PageSize    = height - hBarHeight;
                 vScrollBar.Location    = new FCPoint(width - vBarWidth, 0);
                 int vh = (hScrollBar != null && hScrollBar.Visible) ? height - hBarHeight : height;
                 if (hmax <= vh)
                 {
                     vScrollBar.Visible = false;
                 }
                 else
                 {
                     vScrollBar.Visible = true;
                 }
             }
             //修改尺寸
             if (hScrollBar != null && vScrollBar != null)
             {
                 if (hScrollBar.Visible && !vScrollBar.Visible)
                 {
                     hScrollBar.Width    = width;
                     hScrollBar.PageSize = width;
                 }
                 else if (!hScrollBar.Visible && vScrollBar.Visible)
                 {
                     vScrollBar.Height   = height;
                     vScrollBar.PageSize = height;
                 }
             }
             if (hScrollBar != null && hScrollBar.Visible)
             {
                 hScrollBar.update();
             }
             if (vScrollBar != null && vScrollBar.Visible)
             {
                 vScrollBar.update();
             }
         }
     }
 }