private void ShowToolTip() { if (enteredItem != null && lastTooltipItem == null) { if (!string.IsNullOrEmpty(enteredItem.ToolTip)) { tipToolTip.Show(enteredItem.ToolTip, this, enteredItem.X - xOffiest, Height + 5); lastTooltipItem = enteredItem; } } else if (enteredItem != lastTooltipItem) { if (enteredItem != null && !string.IsNullOrEmpty(enteredItem.ToolTip)) { tipToolTip.Show(enteredItem.ToolTip, this, enteredItem.X - xOffiest, Height + 5); lastTooltipItem = enteredItem; } else { tipToolTip.Hide(this); lastTooltipItem = null; } } else { tipToolTip.Hide(this); lastTooltipItem = null; } }
protected override void OnLostFocus(EventArgs e) { if (enteredItem != null) { enteredItem = null; Invalidate(); } base.OnLostFocus(e); }
protected override bool ProcessDialogKey(Keys keyData) { if (keyData == Keys.Right) { if (enteredItem == null) { if (sortedItems.Count > 0) { enteredItem = sortedItems[0]; if (!ScrollToItem(enteredItem)) { Invalidate(); } return(false); } } else { TaskMgrListHeaderItem last_selectedItem = enteredItem; int index = sortedItems.IndexOf(last_selectedItem); if (index < sortedItems.Count - 1) { enteredItem = sortedItems[index + 1]; } if (!ScrollToItem(enteredItem)) { Invalidate(); } return(false); } } else if (keyData == Keys.Left) { if (enteredItem != null) { TaskMgrListHeaderItem last_selectedItem = enteredItem; int index = sortedItems.IndexOf(last_selectedItem); if (index >= 1) { enteredItem = sortedItems[index - 1]; } if (!ScrollToItem(enteredItem)) { Invalidate(); } return(false); } } else if (keyData == Keys.Down) { if (Parent != null) { Parent.Focus(); } } return(base.ProcessDialogKey(keyData)); }
internal void RebulidColumnsIndexForInsert(int insertIndex, TaskMgrListHeaderItem insertItem) { insertItem.SetDisplayIndex(insertIndex); sortedItems.Insert(insertIndex, insertItem); for (int i = insertIndex + 1; i < sortedItems.Count; i++) { sortedItems[i].SetDisplayIndex(i); } ColumnsIndexChanged(); }
private void Items_HearderRemoved(TaskMgrListHeaderItem obj) { vsed = false; obj.taskMgrListHeaderInternal = null; if (sortedItems.Contains(obj)) { sortedItems.Remove(obj); RebulidColumnsIndexForDelete(obj.DisplayIndex); } Vsitem(); }
protected override void OnMouseLeave(EventArgs e) { if (enteredItem != null) { enteredItem.MouseEntered = false; enteredItem = null; Invalidate(); } tipToolTip.Hide(this); base.OnMouseLeave(e); }
protected override void OnGotFocus(EventArgs e) { if (enteredItem == null) { if (items.Count > 0) { enteredItem = items[0]; Invalidate(); } } base.OnGotFocus(e); }
private void Items_HearderInserted(TaskMgrListHeaderItem obj, int index) { if (arredItem == null) { if (obj.ArrowType == TaskMgrListHeaderSortArrow.Ascending || obj.ArrowType == TaskMgrListHeaderSortArrow.Descending) { arredItem = obj; } } vsed = false; obj.taskMgrListHeaderInternal = this; RebulidColumnsIndexForInsert(index, obj); Vsitem(); }
public TaskMgrListHeaderItem this[string key] { get { TaskMgrListHeaderItem result = null; foreach (TaskMgrListHeaderItem ix in List) { if (ix.Name == key) { return(ix); } } return(result); } }
public bool ScrollToItem(TaskMgrListHeaderItem item) { //item.X -Width + item.Width = +xOffiest int xrpos = item.X - xOffiest; if (xrpos < 0) { XOffest = item.X; return(true); } else if (xrpos + item.Width > Width) { XOffest = item.X - Width + item.Width; return(true); } return(false); }
private void Items_HearderAdd(TaskMgrListHeaderItem obj) { if (arredItem == null) { if (obj.ArrowType == TaskMgrListHeaderSortArrow.Ascending || obj.ArrowType == TaskMgrListHeaderSortArrow.Descending) { arredItem = obj; } } vsed = false; obj.taskMgrListHeaderInternal = this; if (obj.DisplayIndex == -1) { obj.SetDisplayIndex(items.IndexOf(obj)); } sortedItems.Add(obj); Vsitem(); }
protected override void OnMouseUp(MouseEventArgs e) { if (moveItem != null) { if (moveItem.TargetIndex != 0 && moveItem.TargetIndex != sortedItems.IndexOf(moveItem)) { moveItem.DisplayIndex = moveItem.TargetIndex; LastMoveCloumNowIndex = moveItem.TargetIndex; moveItem.TargetIndex = 0; } moveItem.MovingDrawX = moveItem.X; moveItem.IsMoveing = false; drawBlueLineLeft = false; drawBlueLineRight = false; vsed = false; Invalidate(); moveItem = null; } else if (resizeItem != null) { resizeItem = null; } else if (enteredItem != null) { if (e.Button == MouseButtons.Left) { ReSetEnterItemArrow(); } CloumClick?.Invoke(this, new TaskMgrListHeaderEventArgs(enteredItem, Items.IndexOf(enteredItem), e)); } mouseDowned = false; base.OnMouseUp(e); }
private void ReSetEnterItemArrow() { foreach (TaskMgrListHeaderItem ii in items) { if (ii != enteredItem) { ii.ArrowType = TaskMgrListHeaderSortArrow.None; } } if (enteredItem.ArrowType == TaskMgrListHeaderSortArrow.None) { enteredItem.ArrowType = TaskMgrListHeaderSortArrow.Ascending; } else if (enteredItem.ArrowType == TaskMgrListHeaderSortArrow.Ascending) { enteredItem.ArrowType = TaskMgrListHeaderSortArrow.Descending; } else if (enteredItem.ArrowType == TaskMgrListHeaderSortArrow.Descending) { enteredItem.ArrowType = TaskMgrListHeaderSortArrow.Ascending; } arredItem = enteredItem; Invalidate(); }
protected override void OnMouseMove(MouseEventArgs e) { if (!m) { int x = e.X; m = true; t.Start(); if (mouseDowned && resizeItem != null) { if (x - (resizeItem.X - XOffest) > 35) { resizeItem.Width = x - (resizeItem.X - XOffest); vsed = false; Vsitem(); Invalidate(); CloumWidthChanged?.Invoke(this, null); } } else if (mouseDowned && moveItem != null) { int mxr = e.X + XOffest; int mxl = mxr - mouseDownXPosInBlock; if (mxr >= firstBlockW && mxr <= allWidth) { if (mxl >= firstBlockW && mxl <= allWidth - moveItem.Width) { moveItem.MovingDrawX = mxl; } //向左移动 if (e.X < mouseDownXPos) { drawBlueLineLeft = true; drawBlueLineRight = false; for (int i = movingDownIndex; i > 0; i--) { int xx = sortedItems[i].X - xOffiest; int w = sortedItems[i].Width; int fw = 0; if (i > 1) { fw = sortedItems[i - 1].Width; } int ii = xx + w; sortedItems[i].DrawBlueLine = (x > xx - fw / 2 && x <= ii - w / 2); if (sortedItems[i].DrawBlueLine) { moveItem.TargetIndex = i; } } } //向右移动 else if (e.X > mouseDownXPos) { drawBlueLineLeft = false; drawBlueLineRight = true; for (int i = movingDownIndex; i < sortedItems.Count; i++) { int xx = sortedItems[i].X - xOffiest; int w = sortedItems[i].Width; int nw = 0; if (i < sortedItems.Count - 1) { nw = sortedItems[i + 1].Width; } int ii = xx + w; sortedItems[i].DrawBlueLine = (x > ii - w / 2 && x <= ii + nw / 2); if (sortedItems[i].DrawBlueLine) { moveItem.TargetIndex = i; } } } Invalidate(); } } else { for (int i = 0; i < sortedItems.Count; i++) { int xx = sortedItems[i].X - xOffiest; int ii = xx + sortedItems[i].Width; if (CanSizeCloum && x > ii - 3 && x < ii + 3 && resizeItem == null) { Cursor = Cursors.SizeWE; if (enteredItem != null) { enteredItem.MouseEntered = false; } enteredItem = null; if (e.Button == MouseButtons.Left) { resizeItem = sortedItems[i]; } moveItem = null; break; } else if (CanMoveCloum && x > xx + 3 && x < ii - 3 && moveItem == null && e.Button == MouseButtons.Left) { if (enteredItem != null) { enteredItem.MouseEntered = false; enteredItem = null; } resizeItem = null; moveItem = sortedItems[i]; moveItem.IsMoveing = true; moveItem.MovingDrawX = moveItem.X; if (items.Count > 0) { firstBlockW = sortedItems[0].Width; } movingDownIndex = sortedItems.IndexOf(moveItem); mouseDownXPosInBlock = x - xx; break; } else { moveItem = null; resizeItem = null; Cursor = Cursors.Default; if (x > xx && x < (xx + sortedItems[i].Width)) { if (enteredItem != null) { enteredItem.MouseEntered = false; } sortedItems[i].MouseEntered = true; enteredItem = sortedItems[i]; Invalidate(); ShowToolTip(); break; } } } } } base.OnMouseMove(e); }
public int IndexOf(TaskMgrListHeaderItem control) { return(List.IndexOf(control)); }
public bool Contains(TaskMgrListHeaderItem control) { return(List.Contains(control)); }
public void Insert(int index, TaskMgrListHeaderItem control) { List.Insert(index, control); HearderInserted?.Invoke(control, index); }
public void Remove(TaskMgrListHeaderItem control) { List.Remove(control); HearderRemoved?.Invoke(control); }
public void Add(TaskMgrListHeaderItem newcontrol) { List.Add(newcontrol); HearderAdd?.Invoke(newcontrol); }
public TaskMgrListHeaderEventArgs(TaskMgrListHeaderItem i, int index, MouseEventArgs e) { item = i; this.index = index; eM = e; }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (Vsitem()) { return; } Graphics g = e.Graphics; using (Pen p = new Pen(lineBrush)) { TaskMgrListHeaderItem thisItem = null; int h = Height - 1; bool arrdrawed = false; for (int i = 0; i < sortedItems.Count; i++) { thisItem = sortedItems[i]; int x = (thisItem.IsMoveing ? (thisItem.MovingDrawX - XOffest) : (thisItem.X - XOffest)); if (thisItem == enteredItem) { if (thisItem.IsHot) { g.FillRectangle(hotBrushHover, new Rectangle((x + 1), 0, thisItem.Width - 1, h)); } else { TaskMgrListApis.MHeaderDrawItem(hTheme, g.GetHdc(), (x + 1), 0, thisItem.Width - 1, h, TaskMgrListApis.M_DRAW_HEADER_HOT); g.ReleaseHdc(); } } else if (thisItem.IsHot) { g.FillRectangle(hotBrush, new Rectangle((x + 1), 0, thisItem.Width - 1, h)); } string tb = thisItem.TextBig; string ts = thisItem.TextSmall; if (tb != "" || ts != "") { StringFormat f = thisItem.AlignmentStringFormat; if (tb != "") { g.DrawString(tb, fb, Brushes.Black, new Rectangle(x + 3, 10, thisItem.Width - 6, 24), f); } if (ts != "") { g.DrawString(ts, fs, new SolidBrush(Color.FromArgb(76, 96, 122)), new Rectangle(x + 3, Height - 22, thisItem.Width - 6, 18), f); } } if (!arrdrawed) { if (thisItem.ArrowType == TaskMgrListHeaderSortArrow.Ascending) { int posx = x + thisItem.Width / 2 - 4; TaskMgrListApis.MHeaderDrawItem(hTheme, g.GetHdc(), posx, 0, 9, 6, TaskMgrListApis.M_DRAW_HEADER_SORTUP); g.ReleaseHdc(); arrdrawed = true; } else if (thisItem.ArrowType == TaskMgrListHeaderSortArrow.Descending) { int posx = x + thisItem.Width / 2 - 4; TaskMgrListApis.MHeaderDrawItem(hTheme, g.GetHdc(), posx, 0, 9, 6, TaskMgrListApis.M_DRAW_HEADER_SORTDOWN); g.ReleaseHdc(); arrdrawed = true; } } g.DrawLine(p, new Point(x + thisItem.Width, 0), new Point(x + thisItem.Width, h)); if (thisItem.DrawBlueLine) { if (drawBlueLineRight) { g.DrawLine(blueLinePen, new Point(thisItem.X + thisItem.Width, 0), new Point(thisItem.X + thisItem.Width, h)); } else if (drawBlueLineLeft) { g.DrawLine(blueLinePen, new Point(thisItem.X, 0), new Point(thisItem.X, h)); } } } g.DrawLine(new Pen(Color.FromArgb(160, 160, 160)), new Point(0, Height - 1), new Point(Width, Height - 1)); } }