Beispiel #1
0
        /// <summary>
        /// 更新布局方法
        /// </summary>
        public override void Update()
        {
            int width = Width - 15, height = Height;
            int uHeight   = 80;
            int dTop      = uHeight * 3;
            int cellsSize = m_cells.Count;

            for (int i = 0; i < cellsSize; i++)
            {
                UserSecurityCellT2 cell = m_cells[i];
                cell.Index = i;
                if (i == 0 || i == 1)
                {
                    cell.PaintRect = new RECT(0, uHeight * i, width, uHeight * (i + 1));
                }
                else if (i == 2)
                {
                    cell.PaintRect = new RECT(0, uHeight * 2, width / 2, uHeight * 3);
                }
                else if (i == 3)
                {
                    cell.PaintRect = new RECT(width / 2, uHeight * 2, width, uHeight * 3);
                }
                else if (i == 4)
                {
                    cell.PaintRect = new RECT(0, uHeight * 3, width / 2, uHeight * 4);
                }
                else if (i == 5)
                {
                    cell.PaintRect = new RECT(width / 2, uHeight * 3, width, uHeight * 4);
                }
                else
                {
                    int index = (i - 6) % 3;
                    if (index == 0)
                    {
                        dTop += uHeight;
                    }
                    int uwidth = width / 3;
                    cell.PaintRect = new RECT(uwidth * index, dTop, uwidth * (index + 1), dTop + uHeight);
                }
                if (!m_useAnimation || (cell.Left == 0 && cell.Top == 0))
                {
                    cell.Bounds = cell.PaintRect;
                }
            }
            base.Update();
            Invalidate();
        }
Beispiel #2
0
        /// <summary>
        /// 单元格拖动方法
        /// </summary>
        /// <param name="cell">单元格</param>
        public void OnCellDragging(UserSecurityCellT2 cell)
        {
            ControlHost host      = Native.Host;
            RECT        tempRect  = new RECT();
            RECT        bounds    = cell.Bounds;
            int         cellsSize = m_cells.Count;
            int         thisIndex = -1;

            for (int i = 0; i < cellsSize; i++)
            {
                UserSecurityCellT2 iCell = m_cells[i];
                if (iCell == cell)
                {
                    thisIndex = i;
                    break;
                }
            }
            int mx = bounds.left + (bounds.right - bounds.left) / 2;
            int my = bounds.top + (bounds.bottom - bounds.top) / 2;

            for (int i = 0; i < cellsSize; i++)
            {
                UserSecurityCellT2 iCell = m_cells[i];
                if (iCell != cell)
                {
                    RECT iBounds = iCell.PaintRect;
                    if (host.GetIntersectRect(ref tempRect, ref bounds, ref iBounds) > 0)
                    {
                        if (mx >= iBounds.left && mx <= iBounds.right && my >= iBounds.top && my <= iBounds.bottom)
                        {
                            m_cells[thisIndex] = iCell;
                            m_cells[i]         = cell;
                            Update();
                            break;
                        }
                    }
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// 执行秒表方法
 /// </summary>
 /// <param name="timerID">秒表ID</param>
 public override void OnTimer(int timerID)
 {
     base.OnTimer(timerID);
     if (m_timerID == timerID)
     {
         //是否绘图
         bool paint = false;
         if (m_cellState == 1)
         {
             if (m_selectedCell != null && !m_selectedCell.IsDragging)
             {
                 m_tick2++;
                 if (m_isEditing)
                 {
                     if (m_tick2 > 20)
                     {
                         m_isEditing = false;
                         paint       = true;
                         m_cellState = 0;
                         Update();
                     }
                 }
                 else
                 {
                     if (m_tick2 > 20)
                     {
                         m_isEditing = true;
                         m_cellState = 0;
                         paint       = true;
                         Update();
                     }
                 }
             }
         }
         //查询最新数据
         if (m_tick % 50 == 0)
         {
             List <UserSecurityCategory> categories = new List <UserSecurityCategory>();
             m_userSecurityService.GetCategories(categories);
             int categoriesSize = categories.Count;
             if (categoriesSize > 0)
             {
                 LatestDataInfo dataInfo = new LatestDataInfo();
                 dataInfo.m_codes      = categories[0].m_codes;
                 dataInfo.m_formatType = 1;
                 m_quoteService.GetLatestDatas(m_latestDataRequestID, dataInfo);
                 categories.Clear();
             }
         }
         int width = Width - 15, height = Height;
         int cellsSize = m_cells.Count;
         for (int i = 0; i < cellsSize; i++)
         {
             UserSecurityCellT2 cell = m_cells[i];
             if (!cell.IsDragging)
             {
                 RECT bounds    = cell.Bounds;
                 RECT paintRect = cell.PaintRect;
                 //当前区域
                 int left = bounds.left, top = bounds.top, right = bounds.right, bottom = bounds.bottom;
                 //绘图区域
                 int pLeft = paintRect.left, pTop = paintRect.top, pRight = paintRect.right, pBottom = paintRect.bottom;
                 int subLeft = Math.Abs(left - pLeft), subTop = Math.Abs(top - pTop), subRight = Math.Abs(right - pRight), subBottom = Math.Abs(bottom - pBottom);
                 if (subTop > height || subBottom > height)
                 {
                     paint       = true;
                     cell.Bounds = paintRect;
                 }
                 else
                 {
                     ///左
                     if (subLeft > 0)
                     {
                         paint = true;
                         left  = GetAnimationPos(left, pLeft);
                     }
                     //上
                     if (subTop > 0)
                     {
                         paint = true;
                         top   = GetAnimationPos(top, pTop);
                     }
                     //右
                     if (subRight > 0)
                     {
                         paint = true;
                         right = GetAnimationPos(right, pRight);
                     }
                     //下
                     if (subBottom > 0)
                     {
                         paint  = true;
                         bottom = GetAnimationPos(bottom, pBottom);
                     }
                     cell.Bounds = new RECT(left, top, right, bottom);
                 }
             }
         }
         m_tick++;
         if (m_tick > 1000)
         {
             m_tick = 0;
         }
         //关闭抖动
         if (m_useAnimation && m_isEditing)
         {
             if (m_tick % 2 == 0)
             {
                 paint = true;
             }
         }
         //绘图
         if (paint)
         {
             Invalidate();
         }
     }
 }
Beispiel #4
0
 /// <summary>
 /// 单元格鼠标滚动
 /// </summary>
 /// <param name="cell">单元格</param>
 /// <param name="mp">坐标</param>
 /// <param name="button">按钮</param>
 /// <param name="clicks">点击次数</param>
 /// <param name="delta">鼠标滚轮值</param>
 public void OnCellMouseWheel(UserSecurityCellT2 cell, POINT mp, MouseButtonsA button, int clicks, int delta)
 {
     OnMouseWheel(MousePoint, button, clicks, delta);
 }
Beispiel #5
0
 /// <summary>
 /// 单元格鼠标按下方法
 /// </summary>
 /// <param name="cell">单元格</param>
 /// <param name="mp">坐标</param>
 /// <param name="button">按钮</param>
 /// <param name="clicks">点击次数</param>
 /// <param name="delta">鼠标滚轮值</param>
 public void OnCellMouseDown(UserSecurityCellT2 cell, POINT mp, MouseButtonsA button, int clicks, int delta)
 {
     m_selectedCell = cell;
     m_cellState    = 1;
     m_tick2        = 0;
 }