예제 #1
0
        public virtual void OnMouseEnter(Point point)
        {
            System.Diagnostics.Trace.Assert(currentItem == null && currentRow == null);

            if (point.Y > RowHeight + Padding.Vertical)
            {
                Point rowRelativePoint;
                currentRow = SelectChild(point, out rowRelativePoint);
                if (currentRow == null)
                {
                    return;
                }

                currentRow.OnMouseEnter(rowRelativePoint);
            }
            else
            {
                Point itemRelativePoint;
                currentItem = GetItemFromPosition(point, out itemRelativePoint);
                if (currentItem == null)
                {
                    return;
                }

                currentItem.OnMouseEnter(itemRelativePoint);
            }
        }
예제 #2
0
        public void OnMouseClick(MouseEventArgs e, Point point)
        {
            if (point.Y > RowHeight + Padding.Vertical)
            {
                Point         rowRelativePoint;
                CustomListRow row = SelectChild(point, out rowRelativePoint);
                if (row == null)
                {
                    return;
                }

                row.OnMouseClick(e, rowRelativePoint);
            }
            else
            {
                Point          itemRelativePoint;
                CustomListItem item = GetItemFromPosition(point, out itemRelativePoint);
                if (item == null)
                {
                    return;
                }

                item.OnMouseClick(e, itemRelativePoint);
            }
        }
예제 #3
0
        public void OnMouseDoubleClick(MouseEventArgs e, Point point)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (DefaultMenuItem != null)
                {
                    DefaultMenuItem.PerformClick();
                }
            }

            if (point.Y > RowHeight + Padding.Vertical)
            {
                Point         rowRelativePoint;
                CustomListRow row = SelectChild(point, out rowRelativePoint);
                if (row == null)
                {
                    return;
                }

                row.OnMouseDoubleClick(e, rowRelativePoint);
            }
            else
            {
                Point          itemRelativePoint;
                CustomListItem item = GetItemFromPosition(point, out itemRelativePoint);
                if (item == null)
                {
                    return;
                }

                item.OnMouseDoubleClick(e, itemRelativePoint);
            }
        }
예제 #4
0
        private CustomListItem GetItemFromPosition(Point point, out Point itemRelativePoint)
        {
            int left = Padding.Left;

            for (int i = 0; i < ParentPanel.level1ColWidths.Length; i++)
            {
                if (i >= Items.Count)
                {
                    continue;
                }

                CustomListItem item = Items[i];

                if (item == null)
                {
                    continue;
                }

                int width = item.itemBorder.Horizontal + ParentPanel.level1ColWidths[i];

                if (point.X >= left && point.X < left + width)
                {
                    itemRelativePoint = new Point(point.X - left, point.Y - Padding.Top);
                    return(item);
                }

                left += width;
            }

            itemRelativePoint = new Point();
            return(null);
        }
예제 #5
0
        /// <summary>
        /// Construct a header.
        /// </summary>
        public CustomListRow(object tag, Color back, Color fore, Color border, Font font)
        {
            this.BackColor           = back;
            this.ForeColor           = fore;
            this.BorderColor         = border;
            this.SelectedBackColor   = back;
            this.DrawGroupBox        = false;
            this.ShowOnlyHorizBorder = true;

            CustomListItem name = new CustomListItem(tag, font, fore, new Padding(10, 3, 3, 3));

            AddItem(name);

            init();
        }
예제 #6
0
        public virtual void OnMouseLeave()
        {
            System.Diagnostics.Trace.Assert(currentItem == null || currentRow == null);

            if (currentItem != null)
            {
                currentItem.OnMouseLeave();
                currentItem = null;
            }

            if (currentRow != null)
            {
                currentRow.OnMouseLeave();
                currentRow = null;
            }
        }
예제 #7
0
        public virtual void OnMouseMove(Point point)
        {
            System.Diagnostics.Trace.Assert(currentItem == null || currentRow == null);

            if (point.Y > RowHeight + Padding.Vertical)
            {
                if (currentItem != null)
                {
                    currentItem.OnMouseLeave();
                    currentItem = null;
                }

                Point rowRelativePoint;
                CustomListRow row = SelectChild(point, out rowRelativePoint);

                if (row != null && currentRow == row)
                {
                    currentRow.OnMouseMove(rowRelativePoint);
                    return;
                }

                if (currentRow != null)
                    currentRow.OnMouseLeave();

                currentRow = row;

                if (currentRow != null)
                    currentRow.OnMouseEnter(rowRelativePoint);
            }
            else
            {
                if(currentRow != null)
                {
                    currentRow.OnMouseLeave();
                    currentRow = null;
                }
                
                Point itemRelativePoint;
                CustomListItem item = GetItemFromPosition(point, out itemRelativePoint);

                if (item != null && currentItem == item)
                {
                    currentItem.OnMouseMove(itemRelativePoint);
                    return;
                }

                if (currentItem != null)
                    currentItem.OnMouseLeave();

                currentItem = item;

                if (currentItem != null)
                    currentItem.OnMouseEnter(itemRelativePoint);
            }
        }
예제 #8
0
        public virtual void OnMouseEnter(Point point)
        {
            System.Diagnostics.Trace.Assert(currentItem == null && currentRow == null);

            if (point.Y > RowHeight + Padding.Vertical)
            {
                Point rowRelativePoint;
                currentRow = SelectChild(point, out rowRelativePoint);
                if (currentRow == null)
                    return;
                
                currentRow.OnMouseEnter(rowRelativePoint);
            }
            else
            {
                Point itemRelativePoint;
                currentItem = GetItemFromPosition(point, out itemRelativePoint);
                if (currentItem == null)
                    return;

                currentItem.OnMouseEnter(itemRelativePoint);
            }
        }
예제 #9
0
 public void AddItem(CustomListItem item)
 {
     item.Row = this;
     this.Items.Add(item);
 }
예제 #10
0
 public void AddItemToRow(CustomListRow row, CustomListItem item)
 {
     row.AddItem(item);
     Refresh();
 }
예제 #11
0
 public ListPanelItemClickedEventArgs(CustomListItem item)
 {
     Item = item;
 }
예제 #12
0
 public ListPanelItemClickedEventArgs(CustomListItem item)
 {
     Item = item;
 }
예제 #13
0
        public virtual void OnMouseMove(Point point)
        {
            System.Diagnostics.Trace.Assert(currentItem == null || currentRow == null);

            if (point.Y > RowHeight + Padding.Vertical)
            {
                if (currentItem != null)
                {
                    currentItem.OnMouseLeave();
                    currentItem = null;
                }

                Point         rowRelativePoint;
                CustomListRow row = SelectChild(point, out rowRelativePoint);

                if (row != null && currentRow == row)
                {
                    currentRow.OnMouseMove(rowRelativePoint);
                    return;
                }

                if (currentRow != null)
                {
                    currentRow.OnMouseLeave();
                }

                currentRow = row;

                if (currentRow != null)
                {
                    currentRow.OnMouseEnter(rowRelativePoint);
                }
            }
            else
            {
                if (currentRow != null)
                {
                    currentRow.OnMouseLeave();
                    currentRow = null;
                }

                Point          itemRelativePoint;
                CustomListItem item = GetItemFromPosition(point, out itemRelativePoint);

                if (item != null && currentItem == item)
                {
                    currentItem.OnMouseMove(itemRelativePoint);
                    return;
                }

                if (currentItem != null)
                {
                    currentItem.OnMouseLeave();
                }

                currentItem = item;

                if (currentItem != null)
                {
                    currentItem.OnMouseEnter(itemRelativePoint);
                }
            }
        }
예제 #14
0
 public void AddItem(CustomListItem item)
 {
     item.Row = this;
     this.Items.Add(item);
 }
예제 #15
0
        public void DrawSelf(Graphics g, Rectangle bounds)
        {
            int rowHeight = RowHeight;
            int headWidth = HeaderWidth;

            using (Brush ParentBackBrush = new SolidBrush(ParentPanel.BackColor))
            {
                g.FillRectangle(ParentBackBrush, bounds);
            }

            int top  = bounds.Top + Padding.Top;
            int left = bounds.Left + Padding.Left;

            for (int i = 0; i < Items.Count; i++)
            {
                CustomListItem item     = Items[i];
                Size           itemSize = item.PreferredSize;

                int itemTop = top;

                if ((item.Anchor & AnchorStyles.Bottom) > 0)
                {
                    itemTop += rowHeight - itemSize.Height;
                }
                else if ((item.Anchor & AnchorStyles.Top) == 0)
                {
                    itemTop += Convert.ToInt32(Math.Ceiling(Convert.ToDouble(rowHeight - itemSize.Height) / 2.0d));
                }

                Rectangle itemBounds;
                if (Parent != null && (i == Items.Count - 1 || Items[i + 1].InCorrectColumn))
                {
                    int colWidth = 1;
                    if (ParentPanel.level1ColWidths.Length > i)
                    {
                        colWidth = ParentPanel.level1ColWidths[i];
                    }
                    itemBounds = new Rectangle(new Point(left, itemTop), item.WrappedSize(headWidth - (left - bounds.Left)));
                    left      += colWidth;
                }
                else
                {
                    itemBounds = new Rectangle(left, itemTop, itemSize.Width, itemSize.Height);
                    left      += itemSize.Width;
                }

                if (itemBounds.Right > bounds.Right - Padding.Right)
                {
                    itemBounds.Width -= itemBounds.Right - (bounds.Right - Padding.Right);
                }
                if (itemBounds.Bottom > bounds.Bottom - Padding.Bottom)
                {
                    itemBounds.Height -= itemBounds.Bottom - (bounds.Bottom - Padding.Bottom);
                }

                if (i > 0 && Selected && !string.IsNullOrEmpty(item.Tag.ToString()))
                {
                    if ((i < Items.Count - 1 && !Items[i + 1].InCorrectColumn))
                    {
                        g.FillRectangle(SystemBrushes.Highlight, new Rectangle(itemBounds.Left - 2, itemBounds.Top - 3, itemBounds.Width + Items[i + 1].PreferredSize.Width + 4, Items[i + 1].PreferredSize.Height + 2));
                    }
                    else if (item.InCorrectColumn)
                    {
                        g.FillRectangle(SystemBrushes.Highlight, new Rectangle(itemBounds.Left - 2, itemBounds.Top - 1, itemBounds.Width + 4, itemBounds.Height));
                    }
                }

                item.DrawSelf(g, itemBounds, Selected && i > 0 && !(i < Items.Count - 1 && !Items[i + 1].InCorrectColumn));
            }

            top += rowHeight + Padding.Bottom;

            if (DrawChildren)
            {
                foreach (CustomListRow child in Children)
                {
                    int       childHeight = child.RowAndChildrenHeight;
                    Rectangle childBounds = new Rectangle(bounds.Left + Padding.Left + Indent, top, bounds.Width - (Padding.Horizontal + Indent), childHeight);
                    child.DrawSelf(g, childBounds);
                    top += childHeight;
                }
            }

            if (ShowBorder)
            {
                if (ShowOnlyHorizBorder)
                {
                    int w = 1;
                    if (ParentPanel.level1ColWidths.Length >= 2)
                    {
                        w = 450;
                    }

                    using (Brush brush = new LinearGradientBrush(Point.Empty, new Point(w, 0), BorderColor, BackColor))
                    {
                        g.FillRectangle(brush, bounds.Left, bounds.Top + rowHeight, w, 1);
                    }
                }
                else
                {
                    g.DrawRectangle(BorderPen, bounds.Left, bounds.Top, headWidth, rowHeight);
                }

                if (DrawGroupBox)
                {
                    g.DrawRectangle(BorderPen, bounds.Left, bounds.Top, headWidth, RowAndChildrenHeight);
                }
            }
        }
예제 #16
0
        public virtual void OnMouseLeave()
        {
            System.Diagnostics.Trace.Assert(currentItem == null || currentRow == null);

            if (currentItem != null)
            {
                currentItem.OnMouseLeave();
                currentItem = null;
            }

            if (currentRow != null)
            {
                currentRow.OnMouseLeave();
                currentRow = null;
            }
        }
예제 #17
0
        /// <summary>
        /// Construct a header.
        /// </summary>
        public CustomListRow(object tag, Color back, Color fore, Color border, Font font)
        {
            this.BackColor = back;
            this.ForeColor = fore;
            this.BorderColor = border;
            this.SelectedBackColor = back;
            this.DrawGroupBox = false;
            this.ShowOnlyHorizBorder = true;

            CustomListItem name = new CustomListItem(tag, font, fore, new Padding(10, 3, 3, 3));

            AddItem(name);

            init();
        }
예제 #18
0
 public void AddItemToRow(CustomListRow row, CustomListItem item)
 {
     row.AddItem(item);
     Refresh();
 }