Пример #1
0
		internal void NotifyListVisibilityChange(DynamicList list, bool visible)
		{
			if (visible)
				OnShown(new DynamicListEventArgs(list));
			else
				OnHidden(new DynamicListEventArgs(list));
		}
Пример #2
0
		protected virtual void OnPlusClick(object sender, DynamicListEventArgs e)
		{
			if (blockClickEvent) { blockClickEvent = false; return; }
			OnExpanding(e);
			// If OnExpanding displaies an error message, focus is lost, form is closed and we can not access the handle anymore
			if (e.List.IsDisposed) return;
			ChildForm frm = new ChildForm();
			frm.Closed += delegate {
				blockClickEvent = true;
				if (expandedIn != null)
					expandedIn.Remove(e.List);
				OnCollapsed(e);
				plus.RaiseItemChanged();
				Timer timer = new Timer();
				timer.Interval = 85;
				timer.Tick += delegate(object sender2, EventArgs e2) {
					((Timer)sender2).Stop();
					((Timer)sender2).Dispose();
					blockClickEvent = false;
				};
				timer.Start();
			};
			Point p = e.List.PointToScreen(e.List.GetPositionFromRow(this));
			p.Offset(e.List.Columns[0].Width, Height);
			frm.StartPosition = FormStartPosition.Manual;
			frm.BackColor = childBorderColor;
			frm.Location = p;
			frm.ShowInTaskbar = false;
			frm.Owner = e.List.FindForm();
			
			VerticalScrollContainer scrollContainer = new VerticalScrollContainer();
			scrollContainer.Dock = DockStyle.Fill;
			
			DynamicList childList = new DynamicList(childColumns, childRows);
			childList.Dock = DockStyle.Fill;
			childList.KeyDown += delegate(object sender2, KeyEventArgs e2) {
				if (e2.KeyData == Keys.Escape) {
					frm.Close();
					// workaround focus problem: sometimes the mainform gets focus after this
					e.List.FindForm().Focus();
				}
			};
			scrollContainer.Controls.Add(childList);
			
			frm.Controls.Add(scrollContainer);
			
			int screenHeight = Screen.FromPoint(p).WorkingArea.Bottom - p.Y;
			screenHeight -= frm.Size.Height - frm.ClientSize.Height;
			int requiredHeight = childList.TotalRowHeight + 4;
			int formHeight = Math.Min(requiredHeight, screenHeight);
			if (formHeight < requiredHeight) {
				int missingHeight = Math.Min(100, requiredHeight - formHeight);
				formHeight += missingHeight;
				frm.Top -= missingHeight;
			}
			// Autosize child window
			int formWidth;
			using (Graphics g = childList.CreateGraphics()) {
				formWidth = 8 + childList.GetRequiredWidth(g);
			}
			int screenWidth = Screen.FromPoint(p).WorkingArea.Right - p.X;
			if (formWidth > screenWidth) {
				int missingWidth = Math.Min(100, formWidth - screenWidth);
				formWidth = screenWidth + missingWidth;
				frm.Left -= missingWidth;
			}
			frm.ClientSize = new Size(formWidth, formHeight);
			frm.MinimumSize = new Size(100, Math.Min(50, formHeight));
			isOpeningChild = true;
			frm.Show();
			isOpeningChild = false;
			childList.Focus();
			if (expandedIn != null)
				expandedIn.Add(e.List);
			OnExpanded(e);
			plus.RaiseItemChanged();
		}
Пример #3
0
        protected virtual void OnPlusClick(object sender, DynamicListEventArgs e)
        {
            if (blockClickEvent)
            {
                blockClickEvent = false; return;
            }
            OnExpanding(e);
            // If OnExpanding displaies an error message, focus is lost, form is closed and we can not access the handle anymore
            if (e.List.IsDisposed)
            {
                return;
            }
            ChildForm frm = new ChildForm();

            frm.Closed += delegate {
                blockClickEvent = true;
                if (expandedIn != null)
                {
                    expandedIn.Remove(e.List);
                }
                OnCollapsed(e);
                plus.RaiseItemChanged();
                Timer timer = new Timer();
                timer.Interval = 85;
                timer.Tick    += delegate(object sender2, EventArgs e2) {
                    ((Timer)sender2).Stop();
                    ((Timer)sender2).Dispose();
                    blockClickEvent = false;
                };
                timer.Start();
            };
            Point p = e.List.PointToScreen(e.List.GetPositionFromRow(this));

            p.Offset(e.List.Columns[0].Width, Height);
            frm.StartPosition = FormStartPosition.Manual;
            frm.BackColor     = childBorderColor;
            frm.Location      = p;
            frm.ShowInTaskbar = false;
            frm.Owner         = e.List.FindForm();

            VerticalScrollContainer scrollContainer = new VerticalScrollContainer();

            scrollContainer.Dock = DockStyle.Fill;

            DynamicList childList = new DynamicList(childColumns, childRows);

            childList.Dock     = DockStyle.Fill;
            childList.KeyDown += delegate(object sender2, KeyEventArgs e2) {
                if (e2.KeyData == Keys.Escape)
                {
                    frm.Close();
                    // workaround focus problem: sometimes the mainform gets focus after this
                    e.List.FindForm().Focus();
                }
            };
            scrollContainer.Controls.Add(childList);

            frm.Controls.Add(scrollContainer);

            int screenHeight = Screen.FromPoint(p).WorkingArea.Bottom - p.Y;

            screenHeight -= frm.Size.Height - frm.ClientSize.Height;
            int requiredHeight = childList.TotalRowHeight + 4;
            int formHeight     = Math.Min(requiredHeight, screenHeight);

            if (formHeight < requiredHeight)
            {
                int missingHeight = Math.Min(100, requiredHeight - formHeight);
                formHeight += missingHeight;
                frm.Top    -= missingHeight;
            }
            // Autosize child window
            int formWidth;

            using (Graphics g = childList.CreateGraphics()) {
                formWidth = 8 + childList.GetRequiredWidth(g);
            }
            int screenWidth = Screen.FromPoint(p).WorkingArea.Right - p.X;

            if (formWidth > screenWidth)
            {
                int missingWidth = Math.Min(100, formWidth - screenWidth);
                formWidth = screenWidth + missingWidth;
                frm.Left -= missingWidth;
            }
            frm.ClientSize  = new Size(formWidth, formHeight);
            frm.MinimumSize = new Size(100, Math.Min(50, formHeight));
            isOpeningChild  = true;
            frm.Show();
            isOpeningChild = false;
            childList.Focus();
            if (expandedIn != null)
            {
                expandedIn.Add(e.List);
            }
            OnExpanded(e);
            plus.RaiseItemChanged();
        }
Пример #4
0
		public DynamicListMouseEventArgs(DynamicList list, MouseEventArgs me)
			: base(me.Button, me.Clicks, me.X, me.Y, me.Delta)
		{
			if (list == null) throw new ArgumentNullException("list");
			this.list = list;
		}
Пример #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
		void HandleLabelEditClick(DynamicList list)
		{
			if (!allowLabelEdit)
				return;
			TextBox txt = new TextBox();
			txt.Text = this.Text;
			AssignControlUntilFocusChange(txt);
			if (BeginLabelEdit != null)
				BeginLabelEdit(this, new DynamicListEventArgs(list));
			bool escape = false;
			txt.KeyDown += delegate(object sender2, KeyEventArgs e2) {
				if (e2.KeyData == Keys.Enter || e2.KeyData == Keys.Escape) {
					e2.Handled = true;
					if (e2.KeyData == Keys.Escape) {
						if (CanceledLabelEdit != null)
							CanceledLabelEdit(this, new DynamicListEventArgs(list));
						escape = true;
					}
					this.Control = null;
					txt.Dispose();
				}
			};
			txt.LostFocus += delegate {
				if (!escape) {
					this.Text = txt.Text;
					if (FinishLabelEdit != null)
						FinishLabelEdit(this, new DynamicListEventArgs(list));
				}
			};
		}
Пример #7
0
		public DynamicListEventArgs(DynamicList list)
		{
			if (list == null) throw new ArgumentNullException("list");
			this.list = list;
		}
Пример #8
0
		internal void OnMouseEnter(DynamicList list)
		{
			if (MouseEnter != null) {
				MouseEnter(this, new DynamicListEventArgs(list));
			}
			if (highlightBrush != null) RaiseItemChanged();
		}
Пример #9
0
		internal void OnMouseHover(DynamicList list)
		{
			if (MouseHover != null) {
				MouseHover(this, new DynamicListEventArgs(list));
			}
		}
Пример #10
0
		public void PerformDoubleClick(DynamicList list)
		{
			if (DoubleClick != null)
				DoubleClick(this, new DynamicListEventArgs(list));
		}
Пример #11
0
		public void PerformClick(DynamicList list)
		{
			if (Click != null)
				Click(this, new DynamicListEventArgs(list));
			HandleLabelEditClick(list);
		}
Пример #12
0
		internal void PaintTo(Graphics g, Rectangle rectangle, DynamicList list, DynamicListColumn column, bool isMouseEntered)
		{
			Rectangle fillRectangle = rectangle;
			fillRectangle.Width += 1;
			if (highlightBrush != null && isMouseEntered) {
				g.FillRectangle(highlightBrush, fillRectangle);
			} else {
				bool isActivated = list.IsActivated;
				Brush bgBrush = GetBrush(isActivated, backgroundBrush, backgroundBrushInactive);
				if (bgBrush == null) {
					bgBrush = GetBrush(isActivated, column.BackgroundBrush, column.BackgroundBrushInactive);
					if (isActivated && list.RowAtMousePosition == row && column.RowHighlightBrush != null)
						bgBrush = column.RowHighlightBrush;
				}
				g.FillRectangle(bgBrush, fillRectangle);
			}
			if (Paint != null) {
				Paint(this, new ItemPaintEventArgs(g, rectangle, fillRectangle, list, column, this, isMouseEntered));
			}
			if (text.Length > 0) {
				g.DrawString(text, font, textBrush, rectangle, textFormat);
			}
		}