📄 tree_widget.cs
字号:
}
else if (!this.m_selected_items.Contains(item))
{
this.change_focus_item(item, false);
this.select_singleitem(item, true);
}
}
else
{
this.select_singleitem(item, false);
this.change_focus_item(item, true);
}
}
}
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
if (!this.m_hover_item.is_end)
{
if (!this.m_hover_item.is_end)
{
this.m_hover_item.data.on_mouseleave();
}
this.change_hover_item(this.end, true);
}
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
tree<item_type>.iterator right = this.browse_items(new browse_item_handler(this.mousemove_handler), e);
if (!tree<item_type>.iterator.is_equal(this.m_hover_item, right))
{
if (!this.m_hover_item.is_end)
{
this.m_hover_item.data.on_mouseleave();
}
this.change_hover_item(right, true);
if (!this.m_hover_item.is_end)
{
this.m_hover_item.data.on_mouseenter();
}
}
if (right == this.m_items.end)
{
if (!this.m_fDragging)
{
this.Cursor = this.m_NormalCursor;
}
}
else if (((this.AllowDrop && this.m_fToggling) && (!tree<item_type>.iterator.is_equal(this.end, this.focus_item) && !this.m_lastButtonDown.get_Location().Equals(e.get_Location()))) && (!this.m_fDragging && ((MouseButtons.Left == this.m_lastButtonDown.Button) || (MouseButtons.Right == this.m_lastButtonDown.Button))))
{
this.m_fDragging = true;
dragging_data data = new dragging_data(this, this.focus_item, e.Button);
bool fCancel = false;
this.OnPreDragItem(data, ref fCancel);
if (!fCancel)
{
DataObject obj2 = new DataObject("{66FFF7D8-C9A4-4a5d-9707-82D22DF3633F}", data);
base.DoDragDrop(obj2, DragDropEffects.Move | DragDropEffects.Copy);
}
}
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
this.m_fToggling = false;
if (null != this.m_NormalCursor)
{
this.Cursor = this.m_NormalCursor;
}
if (!base.ClientRectangle.Contains(e.X, e.Y))
{
this.m_fDragging = false;
}
else if ((MouseButtons.Left != e.Button) && (MouseButtons.Right != e.Button))
{
this.m_fDragging = false;
}
else
{
this.browse_items(new browse_item_handler(this.mouseup_handler), e);
this.m_fDragging = false;
}
}
protected override void OnMouseWheel(MouseEventArgs e)
{
if (!this.m_fVCanScroll)
{
bool fHCanScroll = this.m_fHCanScroll;
}
else if (0 > e.Delta)
{
this.LineScroll(true, true);
System.Drawing.Point point = base.PointToClient(Cursor.Position);
int num = point.X | (point.Y << 0x10);
win32api_wrapper.PostMessage(base.Handle, 0x200, IntPtr.Zero, (IntPtr) num);
}
else if (0 < e.Delta)
{
this.LineScroll(false, true);
System.Drawing.Point point2 = base.PointToClient(Cursor.Position);
int num2 = point2.X | (point2.Y << 0x10);
win32api_wrapper.PostMessage(base.Handle, 0x200, IntPtr.Zero, (IntPtr) num2);
}
}
protected override void OnPaint(PaintEventArgs e)
{
if (base.DesignMode)
{
win32api_wrapper.ShowScrollBar(base.Handle, 1, this.m_fVScrollable);
win32api_wrapper.ShowScrollBar(base.Handle, 0, this.m_fHScrollable);
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
format.HotkeyPrefix = HotkeyPrefix.Show;
format.Trimming = StringTrimming.EllipsisWord;
format.FormatFlags = StringFormatFlags.NoWrap;
e.Graphics.DrawString("tree_widget\r\n(In design mode)", this.Font, new SolidBrush(Color.Blue), base.ClientRectangle, format);
}
else
{
Rectangle rect = base.ClientRectangle;
if ((0 < rect.Width) && (0 < rect.Height))
{
using (Bitmap image = new Bitmap(rect.Width, rect.Height))
{
using (Graphics graphics = Graphics.FromImage(image))
{
Rectangle clipRect = new Rectangle(0, 0, image.Width, image.Height);
using (PaintEventArgs args = new PaintEventArgs(graphics, clipRect))
{
this.do_paint(args);
}
e.Graphics.DrawImage(image, rect);
}
}
}
}
}
protected override void OnPaintBackground(PaintEventArgs e)
{
if (base.DesignMode)
{
base.OnPaintBackground(e);
}
else
{
Rectangle rect = base.ClientRectangle;
if ((0 < rect.Width) && (0 < rect.Height))
{
using (Bitmap image = new Bitmap(rect.Width, rect.Height))
{
using (Graphics graphics = Graphics.FromImage(image))
{
Rectangle clipRect = new Rectangle(0, 0, image.Width, image.Height);
using (PaintEventArgs args = new PaintEventArgs(graphics, clipRect))
{
this.do_paint(args);
}
e.Graphics.DrawImage(image, rect);
}
}
}
}
}
protected virtual void OnPreDragItem(dragging_data data, ref bool fCancel)
{
}
protected override void OnQueryContinueDrag(QueryContinueDragEventArgs qcdevent)
{
base.OnQueryContinueDrag(qcdevent);
if (qcdevent.Action != DragAction.Continue)
{
this.m_fDragging = false;
this.m_fToggling = false;
}
}
private void OnScroll(ScrollEventArgs se)
{
this.m_fIsScrolling = true;
if (1 == se.get_ScrollOrientation())
{
this.OnVScroll(se);
}
else
{
this.OnHScroll(se);
}
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
if (!base.DesignMode)
{
win32api_wrapper.PostMessage(base.Handle, 0x40a, (IntPtr) 2, IntPtr.Zero);
}
}
private void OnVScroll(ScrollEventArgs se)
{
win32api_wrapper.SCROLLINFO si;
switch (se.Type)
{
case ScrollEventType.SmallDecrement:
this.LineScroll(false, true);
return;
case ScrollEventType.SmallIncrement:
this.LineScroll(true, true);
return;
default:
si = new win32api_wrapper.SCROLLINFO();
si.cbSize = 0x1c;
si.fMask = 0x17;
win32api_wrapper.GetScrollInfo(base.Handle, 1, ref si);
si.fMask = 4;
switch (se.Type)
{
case ScrollEventType.LargeDecrement:
si.nPos -= (int) si.nPage;
if (si.nPage > 0x10)
{
si.nPos += 0x10;
}
if (si.nPos < si.nMin)
{
si.nPos = si.nMin;
}
break;
case ScrollEventType.LargeIncrement:
si.nPos += (int) si.nPage;
if (si.nPage > 0x10)
{
si.nPos -= 0x10;
}
if (si.nPos > si.nMax)
{
si.nPos = si.nMax;
}
break;
case ScrollEventType.ThumbPosition:
case ScrollEventType.ThumbTrack:
si.nPos = se.NewValue;
break;
case ScrollEventType.First:
si.nPos = si.nMin;
break;
case ScrollEventType.Last:
si.nPos = si.nMax;
break;
}
break;
}
win32api_wrapper.SetScrollInfo(base.Handle, 1, ref si, true);
win32api_wrapper.PostMessage(base.Handle, 0x40a, (IntPtr) 2, IntPtr.Zero);
}
public void paint()
{
this.do_paint();
base.Invalidate(Rectangle.Empty);
}
protected void PaintBackground(Graphics g, Rectangle rcClip)
{
rcClip.Width++;
rcClip.Height++;
Image backgroundImage = this.BackgroundImage;
if (backgroundImage != null)
{
if ((rcClip.Left != 0) || (rcClip.Top != 0))
{
Rectangle rect = new Rectangle(0, 0, rcClip.Right, rcClip.Bottom);
using (Bitmap image = new Bitmap(rect.Width, rect.Height))
{
using (Graphics graphics = Graphics.FromImage(image))
{
Imps.Client.Pc.DrawHelper.DrawImage(g, rect, backgroundImage, 1);
g.DrawImage(image, rcClip.X, rcClip.Y, rect, GraphicsUnit.Pixel);
}
return;
}
}
Imps.Client.Pc.DrawHelper.DrawImage(g, rcClip, backgroundImage, 1);
}
else
{
using (Brush brush = new SolidBrush(Color.White))
{
g.FillRectangle(brush, rcClip);
}
}
}
public tree<item_type>.iterator parent(tree<item_type>.iterator item)
{
tree<item_type>.iterator iterator = this.m_items.parent(item);
if ((iterator != this.m_items.end) && (iterator.data == this.m_root_item))
{
return this.end;
}
return iterator;
}
private void PostInitializeComponent()
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -