示例#1
0
 protected override void OnMouseLeave(EventArgs e)
 {
     rowAtMousePosition = null;
     if (itemAtMousePosition != null)
     {
         OnLeaveItem(itemAtMousePosition);
         itemAtMousePosition = null;
     }
     base.OnMouseLeave(e);
 }
示例#2
0
        protected override void OnMouseHover(EventArgs e)
        {
            base.OnMouseHover(e);
            DynamicListItem item = GetItemFromPoint(PointToClient(Control.MousePosition));

            if (item != null)
            {
                item.OnMouseHover(this);
            }
        }
示例#3
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            DynamicListItem item = GetItemFromPoint(e.Location);

            if (item != null)
            {
                item.OnMouseUp(new DynamicListMouseEventArgs(this, e));
            }
        }
示例#4
0
        protected override void OnDoubleClick(EventArgs e)
        {
            base.OnDoubleClick(e);
            DynamicListItem item = GetItemFromPoint(PointToClient(Control.MousePosition));

            if (item != null)
            {
                item.PerformDoubleClick(this);
            }
        }
示例#5
0
 public ItemPaintEventArgs(Graphics graphics, Rectangle rectangle, Rectangle fillRectangle,
                           DynamicList list, DynamicListColumn column,
                           DynamicListItem item, bool isMouseEntered)
     : base(graphics, rectangle)
 {
     this.fillRectangle  = fillRectangle;
     this.list           = list;
     this.column         = column;
     this.item           = item;
     this.isMouseEntered = isMouseEntered;
 }
示例#6
0
        protected override DynamicListItem CreateItem()
        {
            DynamicListItem item = base.CreateItem();

            item.Paint += delegate(object sender, ItemPaintEventArgs e) {
                if (e.Item != plus && expandedIn != null && !expandedRowColor.IsEmpty && expandedIn.Contains(e.List))
                {
                    using (Brush b = new SolidBrush(expandedRowColor)) {
                        e.Graphics.FillRectangle(b, e.FillRectangle);
                    }
                }
            };
            return(item);
        }
示例#7
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            DynamicListRow row = GetRowFromPoint(e.Y);

            if (rowAtMousePosition != row)
            {
                rowAtMousePosition = row;
                Invalidate();
            }
            if (row == null)
            {
                return;
            }
            int columnIndex = GetColumnIndexFromPoint(e.X);

            if (columnIndex < 0)
            {
                return;
            }
            DynamicListItem item = row[columnIndex];

            if (itemAtMousePosition != item)
            {
                if (itemAtMousePosition != null)
                {
                    OnLeaveItem(itemAtMousePosition);
                }
                ResetMouseEventArgs();                 // raise hover again
                itemAtMousePosition = item;
                if (item != null)
                {
                    if (item.Cursor != null)
                    {
                        this.Cursor = item.Cursor;
                    }
                    item.OnMouseEnter(this);
                }
            }
            if (item != null)
            {
                item.OnMouseMove(new DynamicListMouseEventArgs(this, e));
            }
        }
 public DynamicListItem this[int columnIndex] {
     [DebuggerStepThrough]
     get {
         if (columnIndex < 0)
         {
             throw new ArgumentOutOfRangeException("columnIndex", columnIndex, "columnIndex must be >= 0");
         }
         if (columnIndex > DynamicList.MaxColumnCount)
         {
             throw new ArgumentOutOfRangeException("columnIndex", columnIndex, "columnIndex must be <= " + DynamicList.MaxColumnCount);
         }
         if (columnIndex >= items.Length)
         {
             Array.Resize(ref items, columnIndex * 2 + 1);
         }
         DynamicListItem item = items[columnIndex];
         if (item == null)
         {
             items[columnIndex] = item = CreateItem();
         }
         return(item);
     }
 }
示例#9
0
        public int GetRequiredWidth(Graphics graphics)
        {
            int width = 0;

            for (int i = 0; i < columns.Count; i++)
            {
                if (columns[i].AutoSize)
                {
                    int minimumWidth = DynamicListColumn.DefaultWidth;
                    foreach (DynamicListRow row in Rows)
                    {
                        DynamicListItem item = row[i];
                        item.MeasureMinimumWidth(graphics, ref minimumWidth);
                    }
                    width += minimumWidth;
                }
                else
                {
                    width += columns[i].Width;
                }
                width += 1;
            }
            return(width);
        }
示例#10
0
		protected override void OnMouseMove(MouseEventArgs e)
		{
			base.OnMouseMove(e);
			DynamicListRow row = GetRowFromPoint(e.Y);
			if (rowAtMousePosition != row) {
				rowAtMousePosition = row;
				Invalidate();
			}
			if (row == null)
				return;
			int columnIndex = GetColumnIndexFromPoint(e.X);
			if (columnIndex < 0)
				return;
			DynamicListItem item = row[columnIndex];
			if (itemAtMousePosition != item) {
				if (itemAtMousePosition != null) {
					OnLeaveItem(itemAtMousePosition);
				}
				ResetMouseEventArgs(); // raise hover again
				itemAtMousePosition = item;
				if (item != null) {
					if (item.Cursor != null)
						this.Cursor = item.Cursor;
					item.OnMouseEnter(this);
				}
			}
			if (item != null) {
				item.OnMouseMove(new DynamicListMouseEventArgs(this, e));
			}
		}
示例#11
0
 public DynamicTreeRow()
 {
     plus     = this[0];
     ShowPlus = true;
 }
示例#12
0
 internal void RaiseItemChanged(DynamicListItem item)
 {
     OnItemChanged(EventArgs.Empty);
 }
示例#13
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //Debug.WriteLine("OnPaint");
            Graphics g = e.Graphics;

            allowedControls.Clear();

            int columnIndex = -1;

            foreach (DynamicListColumn col in Columns)
            {
                columnIndex += 1;
                if (!col.AutoSize)
                {
                    continue;
                }
                int minimumWidth = DynamicListColumn.DefaultWidth;
                foreach (DynamicListRow row in Rows)
                {
                    DynamicListItem item = row[columnIndex];
                    item.MeasureMinimumWidth(e.Graphics, ref minimumWidth);
                }
                col.MinimumWidth = minimumWidth;
            }

            int  controlIndex = 0;
            int  xPos;
            int  yPos       = -scrollOffset;
            Size clientSize = ClientSize;

            foreach (DynamicListRow row in Rows)
            {
                if (yPos + row.Height > 0 && yPos < clientSize.Height)
                {
                    xPos = 0;
                    for (columnIndex = 0; columnIndex < columns.Count; columnIndex++)
                    {
                        DynamicListColumn col  = columns[columnIndex];
                        Rectangle         rect = new Rectangle(xPos, yPos, col.Width, row.Height);
                        if (columnIndex == columns.Count - 1)
                        {
                            rect.Width = clientSize.Width - 1 - rect.Left;
                        }
                        DynamicListItem item = row[columnIndex];
                        Control         ctl  = item.Control;
                        if (ctl != null)
                        {
                            allowedControls.Add(ctl);
                            if (rect != ctl.Bounds)
                            {
                                ctl.Bounds = rect;
                            }
                            if (!this.Controls.Contains(ctl))
                            {
                                this.Controls.Add(ctl);
                                this.Controls.SetChildIndex(ctl, controlIndex);
                            }
                            controlIndex += 1;
                        }
                        else
                        {
                            item.PaintTo(e.Graphics, rect, this, col, item == itemAtMousePosition);
                        }
                        xPos += col.Width + 1;
                    }
                }
                yPos += row.Height + lineMarginY;
            }
            xPos = 0;
            Form containerForm = FindForm();
            bool isFocused;

            if (containerForm is IActivatable)
            {
                isFocused = (containerForm as IActivatable).IsActivated;
            }
            else
            {
                isFocused = this.Focused;
            }
            for (columnIndex = 0; columnIndex < columns.Count - 1; columnIndex++)
            {
                DynamicListColumn col = columns[columnIndex];

                xPos += col.Width + 1;

                Color separatorColor;
                if (isFocused)
                {
                    separatorColor = col.ColumnSeperatorColor;
                    if (separatorColor.IsEmpty)
                    {
                        separatorColor = col.ColumnSeperatorColorInactive;
                    }
                }
                else
                {
                    separatorColor = col.ColumnSeperatorColorInactive;
                    if (separatorColor.IsEmpty)
                    {
                        separatorColor = col.ColumnSeperatorColor;
                    }
                }
                if (separatorColor.IsEmpty)
                {
                    separatorColor = BackColor;
                }
                using (Pen separatorPen = new Pen(separatorColor)) {
                    e.Graphics.DrawLine(separatorPen, xPos - 1, 1, xPos - 1, Math.Min(clientSize.Height, yPos) - 2);
                }
            }
            removedControls.Clear();
            foreach (Control ctl in Controls)
            {
                if (!allowedControls.Contains(ctl))
                {
                    removedControls.Add(ctl);
                }
            }
            foreach (Control ctl in removedControls)
            {
                Debug.WriteLine("Removing control");
                Controls.Remove(ctl);
                Debug.WriteLine("Control removed");
            }
            allowedControls.Clear();
            removedControls.Clear();
            base.OnPaint(e);
        }
示例#14
0
		protected override void OnMouseLeave(EventArgs e)
		{
			rowAtMousePosition = null;
			if (itemAtMousePosition != null) {
				OnLeaveItem(itemAtMousePosition);
				itemAtMousePosition = null;
			}
			base.OnMouseLeave(e);
		}
示例#15
0
 protected virtual void OnLeaveItem(DynamicListItem item)
 {
     itemAtMousePosition.OnMouseLeave(this);
     this.Cursor = Cursors.Default;
 }
示例#16
0
		protected virtual void OnLeaveItem(DynamicListItem item)
		{
			itemAtMousePosition.OnMouseLeave(this);
			this.Cursor = Cursors.Default;
		}
		internal void RaiseItemChanged(DynamicListItem item)
		{
			OnItemChanged(EventArgs.Empty);
		}
		public DynamicTreeRow()
		{
			plus = this[0];
			ShowPlus = true;
		}
示例#19
0
		public ItemPaintEventArgs(Graphics graphics, Rectangle rectangle, Rectangle fillRectangle,
		                          DynamicList list, DynamicListColumn column,
		                          DynamicListItem item, bool isMouseEntered)
			: base(graphics, rectangle)
		{
			this.fillRectangle = fillRectangle;
			this.list = list;
			this.column = column;
			this.item = item;
			this.isMouseEntered = isMouseEntered;
		}