📄 scroll_widget.cs
字号:
protected virtual void draw_arrow_button(Graphics g, Rectangle rcArrow, draw_tools.arrow_type button, DrawItemState state)
{
Color color;
if ((draw_tools.arrow_type.left > button) || (draw_tools.arrow_type.bottom < button))
{
throw new ArgumentOutOfRangeException();
}
if (DrawItemState.Inactive == (state & DrawItemState.Inactive))
{
color = this.m_clr_arrow;
}
else
{
color = this.m_clr_active_arrow;
if (DrawItemState.HotLight == (state & DrawItemState.HotLight))
{
if (DrawItemState.Selected == (state & DrawItemState.Selected))
{
LinearGradientBrush brush;
if (this.vertical)
{
brush = new LinearGradientBrush(rcArrow, this.m_clr_hot_end, this.m_clr_hot_begin, LinearGradientMode.Vertical);
}
else
{
brush = new LinearGradientBrush(rcArrow, this.m_clr_hot_end, this.m_clr_hot_begin, LinearGradientMode.Horizontal);
}
g.FillRectangle(brush, rcArrow);
brush.Dispose();
}
else
{
LinearGradientBrush brush2;
if (this.vertical)
{
brush2 = new LinearGradientBrush(rcArrow, this.m_clr_end, this.m_clr_begin, LinearGradientMode.Vertical);
}
else
{
brush2 = new LinearGradientBrush(rcArrow, this.m_clr_end, this.m_clr_begin, LinearGradientMode.Horizontal);
}
g.FillRectangle(brush2, rcArrow);
brush2.Dispose();
}
g.DrawRectangle(new Pen(this.m_clr_active_arrow_frame), rcArrow);
}
}
switch (button)
{
case draw_tools.arrow_type.left:
draw_tools.draw_simple_arrow(g, rcArrow.Left + ((rcArrow.Width + 2) / 2), rcArrow.Top + ((rcArrow.Height - 6) / 2), 7, color, draw_tools.arrow_type.left);
return;
case draw_tools.arrow_type.top:
draw_tools.draw_simple_arrow(g, rcArrow.Left + ((rcArrow.Width - 6) / 2), rcArrow.Top + ((rcArrow.Height + 2) / 2), 7, color, draw_tools.arrow_type.top);
return;
case draw_tools.arrow_type.right:
draw_tools.draw_simple_arrow(g, rcArrow.Right - ((rcArrow.Width + 2) / 2), rcArrow.Top + ((rcArrow.Height - 6) / 2), 7, color, draw_tools.arrow_type.right);
return;
case draw_tools.arrow_type.bottom:
draw_tools.draw_simple_arrow(g, rcArrow.Left + ((rcArrow.Width - 6) / 2), rcArrow.Bottom - ((rcArrow.Height + 2) / 2), 7, color, draw_tools.arrow_type.bottom);
return;
}
}
protected virtual void draw_thumb_button(Graphics g, Rectangle rcThumb, DrawItemState state)
{
Color color;
Color color2;
Color color3;
Pen pen;
if (DrawItemState.Inactive == (DrawItemState.Inactive & state))
{
color3 = this.m_clr_thumb_frame;
color = this.m_clr_begin;
color2 = this.m_clr_end;
}
else
{
color3 = this.m_clr_active_thumb_frame;
if ((DrawItemState.HotLight | DrawItemState.Selected) == ((DrawItemState.HotLight | DrawItemState.Selected) & state))
{
color = this.m_clr_toggle_begin;
color2 = this.m_clr_toggle_end;
}
else
{
color = this.m_clr_hot_begin;
color2 = this.m_clr_hot_end;
}
}
if (this.vertical)
{
int num = rcThumb.Height / 2;
Rectangle rect = Rectangle.FromLTRB(rcThumb.Left, rcThumb.Top, rcThumb.Right, rcThumb.Top + num);
if ((0 < rect.Width) && (0 < rect.Height))
{
using (LinearGradientBrush brush = new LinearGradientBrush(rect, color, color2, LinearGradientMode.Vertical))
{
g.FillRectangle(brush, rect);
}
}
Rectangle rectangle2 = Rectangle.FromLTRB(rcThumb.Left, rcThumb.Bottom - (rcThumb.Height - num), rcThumb.Right, rcThumb.Bottom);
if ((0 >= rectangle2.Width) || (0 >= rectangle2.Height))
{
goto Label_0275;
}
using (LinearGradientBrush brush2 = new LinearGradientBrush(rectangle2, color2, color, LinearGradientMode.Vertical))
{
g.FillRectangle(brush2, rectangle2);
using (Pen pen = new Pen(color2))
{
g.DrawLine(pen, rectangle2.Left, rectangle2.Top, rectangle2.Right, rectangle2.Top);
}
goto Label_0275;
}
}
int num2 = rcThumb.Width / 2;
Rectangle rectangle3 = Rectangle.FromLTRB(rcThumb.Left, rcThumb.Top, rcThumb.Left + num2, rcThumb.Bottom);
if ((0 < rectangle3.Width) && (0 < rectangle3.Height))
{
using (LinearGradientBrush brush3 = new LinearGradientBrush(rectangle3, color, color2, LinearGradientMode.Horizontal))
{
g.FillRectangle(brush3, rectangle3);
}
}
Rectangle rectangle4 = Rectangle.FromLTRB(rcThumb.Right - (rcThumb.Width - num2), rcThumb.Top, rcThumb.Right, rcThumb.Bottom);
if ((0 < rectangle4.Width) && (0 < rectangle4.Height))
{
using (LinearGradientBrush brush4 = new LinearGradientBrush(rectangle4, color2, color, LinearGradientMode.Horizontal))
{
g.FillRectangle(brush4, rectangle4);
using (Pen pen2 = new Pen(color2))
{
g.DrawLine(pen2, rectangle4.Left, rectangle4.Top, rectangle4.Left, rectangle4.Bottom);
}
}
}
Label_0275:
pen = new Pen(color3);
try
{
g.DrawRectangle(pen, rcThumb);
}
finally
{
if (pen != null)
{
pen.Dispose();
}
}
}
protected virtual void draw_tunnel(Graphics g, Rectangle rcTunnel)
{
using (Brush brush = new SolidBrush(this.m_clr_tunnel))
{
g.FillRectangle(brush, rcTunnel);
}
using (Pen pen = new Pen(this.m_clr_frame))
{
g.DrawRectangle(pen, rcTunnel.Left, rcTunnel.Top, rcTunnel.Width - 1, rcTunnel.Height - 1);
}
}
protected static unsafe IntPtr host_wndproc(IntPtr hwnd, int uMsg, IntPtr wParam, IntPtr lParam)
{
hostproc_scrolls _scrolls;
if (!ms_host_procscrolls_map.TryGetValue(hwnd, ref _scrolls))
{
IntPtr ptr = win32api_wrapper.DefWindowProc(hwnd, uMsg, wParam, lParam);
ClientLogger.WriteException(new Exception("没有找到滚动条宿主窗口的WndProc"));
return ptr;
}
IntPtr ptr2 = win32api_wrapper.CallWindowProc(_scrolls.hostproc, hwnd, uMsg, wParam, lParam);
int num = uMsg;
if (num <= 0x47)
{
if (num <= 20)
{
switch (num)
{
case 2:
if (_scrolls.hscroll != null)
{
_scrolls.hscroll.on_host_destroy();
}
if (_scrolls.vscroll != null)
{
_scrolls.vscroll.on_host_destroy();
}
return ptr2;
case 20:
if (_scrolls.hscroll != null)
{
_scrolls.hscroll.on_update_pos(false);
}
if (_scrolls.vscroll != null)
{
_scrolls.vscroll.on_update_pos(false);
}
return ptr2;
}
return ptr2;
}
switch (num)
{
case 70:
case 0x47:
{
win32api_wrapper.WINDOWPOS* windowposPtr = (win32api_wrapper.WINDOWPOS*) lParam;
bool fForceVisable = 0x80 != (windowposPtr->flags & 0x80);
if (_scrolls.hscroll != null)
{
_scrolls.hscroll.on_update_pos(fForceVisable);
}
if (_scrolls.vscroll != null)
{
_scrolls.vscroll.on_update_pos(fForceVisable);
}
return ptr2;
}
case 0x18:
if (_scrolls.hscroll != null)
{
_scrolls.hscroll.on_update_pos(IntPtr.Zero != wParam);
}
if (_scrolls.vscroll != null)
{
_scrolls.vscroll.on_update_pos(IntPtr.Zero != wParam);
}
return ptr2;
}
return ptr2;
}
if (num <= 0xb8)
{
switch (num)
{
case 0xa2:
goto Label_01FE;
case 0xb8:
goto Label_018D;
}
return ptr2;
}
switch (num)
{
case 0x114:
case 0x115:
goto Label_018D;
case 0x202:
goto Label_01FE;
default:
return ptr2;
}
Label_018D:
if ((_scrolls.hscroll != null) && _scrolls.hscroll.m_sensitive)
{
_scrolls.hscroll.on_update_pos(false);
}
if ((_scrolls.vscroll != null) && _scrolls.vscroll.m_sensitive)
{
_scrolls.vscroll.on_update_pos(false);
}
return ptr2;
Label_01FE:
if ((_scrolls.hscroll != null) && _scrolls.hscroll.m_hook_host)
{
bool flag1 = _scrolls.hscroll.m_for_pane;
}
if ((_scrolls.vscroll != null) && _scrolls.vscroll.m_hook_host)
{
bool flag2 = _scrolls.vscroll.m_for_pane;
}
return ptr2;
}
[DllImport("imm32.dll")]
private static extern int ImmGetCompositionString(IntPtr hIMC, int dwIndex, StringBuilder lpBuf, int dwBufLen);
[DllImport("imm32.dll")]
private static extern IntPtr ImmGetContext(IntPtr hWnd);
[DllImport("imm32.dll")]
private static extern bool ImmReleaseContext(IntPtr hWnd, IntPtr hIMC);
[DllImport("kernel32.dll")]
private static extern int LCMapStringA(int Locale, int dwMapFlags, string lpSrcStr, int cchSrc, StringBuilder lpDestStr, int cchDest);
protected void on_change_host(Control host)
{
if (((this.m_host != null) && this.m_host.IsHandleCreated) && !this.m_host.IsDisposed)
{
if (ms_host_procscrolls_map.ContainsKey(this.m_host.Handle))
{
if (this.vertical)
{
ms_host_procscrolls_map.get_Item(this.m_host.Handle).vscroll = null;
}
else
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -