Example #1
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            base.OnMouseClick(e);
            if (_vScroll.IsMouseDown)
            {
                return;
            }
            if (Adapter == null)
            {
                return;
            }
            int p     = 0;
            int count = Adapter.GetItemCount();

            for (int i = 0; i < count; i++)
            {
                ViewHolder holder = Adapter.OnCreateViewHolder(this, -_vScroll.Value, i);
                //if (holder.MouseState == Emuns.MouseState.MouseSelected)
                //    continue;
                if (holder.Bounds.Contains(e.Location))
                {
                    holder.MouseState = Emuns.MouseState.MouseSelected;
                    p = i;
                }
                else
                {
                    holder.MouseState = Emuns.MouseState.None;
                }
            }
            SelectedIndex = p;
        }
Example #2
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
     if (DesignMode)
     {
         return;
     }
     if (e.Button == MouseButtons.Left)
     {
         _clickViewHolder = FindPointView(e.Location);
         _animationManager.StartNewAnimation(e.Location, _clickViewHolder.Bounds);
     }
 }
Example #3
0
        /// <summary>
        /// 绘制行
        /// </summary>
        /// <param name="g"></param>
        private void DrawColumn(Graphics g)
        {
            if (adapter == null || adapter.GetCount() == 0)
            {
                VirtualWidth = 0;
                return;
            }
            int y = 0;

            for (int i = 0; i < adapter.GetCount(); i++)
            {
                ViewHolder holder = null;
                if (Rows.Count > i)
                {
                    holder               = Rows[i];
                    holder.position      = i;
                    holder.bounds.X      = 1;
                    holder.bounds.Y      = y;
                    holder.bounds.Width  = this.Width - 2;
                    holder.bounds.Height = adapter.GetRowHeight(i);
                }
                else
                {
                    Rectangle rect = new Rectangle(1, y, this.Width - 2, adapter.GetRowHeight(i));
                    holder          = new ViewHolder(rect);
                    holder.position = i;
                    Rows.Add(holder);
                }
                holder.isMouseClick  = false;
                holder.isMouseMove   = false;
                holder.MouseLocation = Point.Empty;
                if (SelectHolder == holder)
                {
                    holder.isMouseClick  = true;
                    holder.MouseLocation = SelectHolder.MouseLocation;
                }
                else if (MouseHolder == holder)
                {
                    holder.isMouseMove = true;
                }

                adapter.GetView(i, holder, g);
                y           += holder.bounds.Height + itemDivider;
                VirtualWidth = holder.bounds.Width;
            }
            VirtualHeight = y;
            if (listHScroll.Visible)
            {
                VirtualHeight += listHScroll.Height;
            }
        }
Example #4
0
        private ViewHolder FindPointView(Point point)
        {
            int count = Adapter.GetItemCount();

            for (int i = 0; i < count; i++)
            {
                ViewHolder viewHolder = Adapter.OnCreateViewHolder(this, -_vScroll.Value, i);
                if (viewHolder.Bounds.Contains(point))
                {
                    return(viewHolder);
                }
            }
            return(null);
        }
        public override ViewHolder OnCreateViewHolder(Control control, int offset, int position)
        {
            ViewHolder viewHolder = GetViewHolder(position);

            y = position * ItemHeight;
            if (viewHolder == null)
            {
                viewHolder = new ViewHolder(control, new Rectangle(x, y + offset, control.Width, ItemHeight), position);
                CacheViewHolder(viewHolder);//缓存 ViewHolder
            }
            else
            {
                viewHolder.Bounds = new Rectangle(x, y + offset, control.Width, ItemHeight);
            }
            return(viewHolder);
        }
Example #6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            if (Adapter == null)
            {
                return;
            }
            VirtualHeight = 0;
            VirtualWidth  = 0;


            if (_animationManager.IsAnimating() && _clickViewHolder != null)
            {
                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
                Color bg = BackColor.TakeBackColor();//取相反色
                using (SolidBrush hrush = new SolidBrush(Color.FromArgb(50, bg)))
                {
                    float      animationValue = (float)_animationManager.GetProgress();
                    float      x    = _animationManager.GetMouseDown().X - animationValue / 2;
                    float      y    = _animationManager.GetMouseDown().Y - animationValue / 2;
                    RectangleF rect = new RectangleF(x, y, animationValue, animationValue);
                    e.Graphics.FillEllipse(hrush, rect);
                }
                e.Graphics.SmoothingMode = SmoothingMode.Default;
            }

            int count = Adapter.GetItemCount();

            for (int i = 0; i < count; i++)
            {
                ViewHolder viewHolder = Adapter.OnCreateViewHolder(this, -_vScroll.Value, i);
                VirtualHeight += viewHolder.Bounds.Height;
                VirtualWidth  += viewHolder.Bounds.Width;

                if (viewHolder.Bounds.Bottom >= 0 && viewHolder.Bounds.Y <= this.Height)
                {
                    Adapter.OnDrawItem(e.Graphics, viewHolder, i);
                }
            }

            _vScroll.VirtualHeight = VirtualHeight;  //绘制完成计算虚拟高度决定是否绘制滚动条
            if (_MouseVisible && _vScroll.Visible)   //是否绘制滚动条
            {
                _vScroll.ReDrawScroll(e.Graphics);
            }
        }
Example #7
0
        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);
            _MouseVisible = false;
            int count = Adapter.GetItemCount();

            for (int i = 0; i < count; i++)
            {
                ViewHolder viewHolder = Adapter.OnCreateViewHolder(this, -_vScroll.Value, i);
                if (viewHolder.MouseState == Emuns.MouseState.MouseSelected)
                {
                    continue;
                }
                viewHolder.MouseState = Emuns.MouseState.None;
            }
            this.Invalidate();
        }
Example #8
0
        /// <summary>
        /// 绘制行
        /// </summary>
        /// <param name="g"></param>
        private void DrawColumn(Graphics g)
        {
            if (adapter == null || adapter.GetCount() == 0)
            {
                return;
            }
            //Rows.Clear();
            g.TranslateClip(0, columnHeight);//平移 绕过 标题
            int y = headerHeight;

            for (int i = 0; i < adapter.GetCount(); i++)
            {
                ViewHolder holder = null;
                if (Rows.Count > i)
                {
                    holder = Rows[i];
                }
                else
                {
                    Rectangle rect = new Rectangle(1, y, VirtualWidth, columnHeight);
                    holder          = new ViewHolder(rect);
                    holder.position = i;
                    Rows.Add(holder);
                }
                holder.isMouseClick = false;
                holder.isMouseMove  = false;
                if (selectHolder == holder)
                {
                    holder.isMouseClick = true;
                }
                else if (m_mouseHolder == holder)
                {
                    holder.isMouseMove = true;
                }

                adapter.GetView(i, holder, g);
                y += columnHeight;
            }
            g.TranslateClip(0, -columnHeight);
            VirtualHeight = y;
            if (listHScroll.Visible)
            {
                VirtualHeight += listHScroll.Height;
            }
        }
Example #9
0
 protected override void OnMouseClick(MouseEventArgs e)
 {
     foreach (ViewHolder item in Rows)
     {
         if (item.bounds.Contains(m_ptMousePos))
         {
             if (item == selectHolder)
             {
                 break;
             }
             selectHolder = item;
             this.Invalidate();
             OnItemClick(new ItemClickEventArgs(item));
             break;
         }
     }
     base.OnMouseClick(e);
 }
Example #10
0
        /// <summary>
        /// 绘制行
        /// </summary>
        /// <param name="g"></param>
        private void DrawColumn(Graphics g)
        {
            if (adapter == null || adapter.GetCount() == 0)
            {
                return;
            }
            int y = 0;

            for (int i = 0; i < adapter.GetCount(); i++)
            {
                ViewHolder holder = null;
                if (Rows.Count > i)
                {
                    holder = Rows[i];
                }
                else
                {
                    Rectangle rect = new Rectangle(1, y, this.Width - 2, 50);
                    holder          = new ViewHolder(rect);
                    holder.position = i;
                    Rows.Add(holder);
                }
                holder.isMouseClick = false;
                holder.isMouseMove  = false;
                if (selectHolder == holder)
                {
                    holder.isMouseClick = true;
                }
                else if (m_mouseHolder == holder)
                {
                    holder.isMouseMove = true;
                }

                adapter.GetView(i, holder, g);
                y           += holder.bounds.Height;
                VirtualWidth = holder.bounds.Width;
            }
            VirtualHeight = y;
            if (listHScroll.Visible)
            {
                VirtualHeight += listHScroll.Height;
            }
        }
Example #11
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (_vScroll.IsMouseDown)
            {
                return;
            }

            if (_animationManager.IsAnimating())
            {
                return;
            }
            if (Adapter == null)
            {
                return;
            }
            int count = Adapter.GetItemCount();
            int t     = 0;

            for (int i = 0; i < count; i++)
            {
                ViewHolder holder = Adapter.OnCreateViewHolder(this, -_vScroll.Value, i);
                if (holder.MouseState == Emuns.MouseState.MouseSelected)
                {
                    continue;
                }
                if (holder.Bounds.Contains(e.Location))
                {
                    holder.MouseState = Emuns.MouseState.MouseMove;
                    t = i;
                }
                else
                {
                    holder.MouseState = Emuns.MouseState.None;
                }
            }
            if (_MoveHolderIndex == t)
            {
                return;
            }
            this.Invalidate();
        }
Example #12
0
 private void DrawBackColor(Graphics g, ViewHolder holder)
 {
     if (!holder.isMouseMove && !holder.isMouseClick)
     {
         return;
     }
     using (SolidBrush sb = new SolidBrush(SelectedBackColor))
     {
         Rectangle newRec = holder.bounds;
         newRec.Width  -= 1;
         newRec.Height -= 1;
         newRec.X      += 1;
         newRec.Y      += 1;
         if (holder.isMouseMove)
         {
             sb.Color = MouseMoveBackColor;
         }
         g.FillRectangle(sb, newRec);
     }
 }
Example #13
0
 protected override void OnMouseMove(MouseEventArgs e)
 {
     m_ptMousePos    = e.Location;
     m_ptMousePos.Y += chatVScroll.Value;
     //判断鼠标是否在行中
     foreach (ViewHolder item in Rows)
     {
         if (item.bounds.Contains(m_ptMousePos))
         {
             if (item == m_mouseHolder)
             {
                 break;
             }
             m_mouseHolder = item;
             this.Invalidate();
             break;
         }
     }
     base.OnMouseMove(e);
 }
Example #14
0
 public abstract void GetView(int position, ViewHolder holder, Graphics g);
Example #15
0
        public override void GetView(int position, ViewHolder holder, Graphics g)
        {
            FTable owner = this.owner as FTable;

            string[] array = items[position];
            holder.UserData = array;
            DrawBackColor(g, holder);
            StringFormat StringFormat = StringFormat.GenericDefault;

            StringFormat.Alignment     = StringAlignment.Center;
            StringFormat.LineAlignment = StringAlignment.Center;
            Pen p = new Pen(new SolidBrush(Color.FromArgb(70, 70, 70)), 1);

            switch (owner.CellBorderStyle)
            {
            case CellBorderStyle.None:
                break;

            case CellBorderStyle.FixedSingle:
                p.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                break;

            case CellBorderStyle.Dot:
                p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                break;

            default:
                break;
            }
            int i = 0;

            foreach (TableColumn item in owner.Columns)
            {
                if (!item.Visible)
                {
                    continue;
                }
                Rectangle  MyRect = new Rectangle(item.Location.X, holder.bounds.Y, item.Width, holder.bounds.Height);
                SolidBrush sb     = new SolidBrush(item.ForeColor);
                switch (item.TextAlign)
                {
                case HorizontalAlignment.Left:
                    StringFormat.Alignment = StringAlignment.Far;
                    break;

                case HorizontalAlignment.Right:
                    StringFormat.Alignment = StringAlignment.Near;
                    break;
                }
                string value = (array.Length > i) ? array[i] : "";
                if (!string.IsNullOrEmpty(item.BindingData))
                {
                    int pos = 0;
                    int.TryParse(item.BindingData, out pos);
                    value = (array.Length > pos) ? array[pos] : "";
                }

                g.DrawString(value, item.Font, sb, MyRect, StringFormat);
                if (owner.CellBorderStyle != CellBorderStyle.None)
                {
                    //竖线
                    g.DrawLine(p, MyRect.X + item.Width, MyRect.Y, MyRect.X + item.Width, MyRect.Y + holder.bounds.Height);
                }
                i++;
            }
            g.DrawLine(p, 0, holder.bounds.Y + holder.bounds.Height, holder.bounds.Width, holder.bounds.Y + holder.bounds.Height);
        }
Example #16
0
 public void CacheViewHolder(ViewHolder viewHolder)
 {
     holdersList.Add(viewHolder);
 }
 public override void OnDrawItem(Graphics g, ViewHolder viewHolder, int position)
 {
     throw new NotImplementedException();
 }