diff --git a/Bin/Debug/CommonControls/.NET4 示例/Itrycn_Project.exe b/Bin/Debug/CommonControls/.NET4 示例/Itrycn_Project.exe index 7d66f5b..87c4bed 100644 Binary files a/Bin/Debug/CommonControls/.NET4 示例/Itrycn_Project.exe and b/Bin/Debug/CommonControls/.NET4 示例/Itrycn_Project.exe differ diff --git a/Bin/Debug/CommonControls/.NET4 示例/Itrycn_Project2.exe b/Bin/Debug/CommonControls/.NET4 示例/Itrycn_Project2.exe index e08bcb6..2d0fe54 100644 Binary files a/Bin/Debug/CommonControls/.NET4 示例/Itrycn_Project2.exe and b/Bin/Debug/CommonControls/.NET4 示例/Itrycn_Project2.exe differ diff --git a/Bin/Debug/CommonControls/.NET4 示例/MyDb.dll b/Bin/Debug/CommonControls/.NET4 示例/MyDb.dll index b59bdf0..20affa9 100644 Binary files a/Bin/Debug/CommonControls/.NET4 示例/MyDb.dll and b/Bin/Debug/CommonControls/.NET4 示例/MyDb.dll differ diff --git a/Bin/Debug/CommonControls/.NET4 示例/MyDb.xml b/Bin/Debug/CommonControls/.NET4 示例/MyDb.xml index d0448da..7c2a910 100644 --- a/Bin/Debug/CommonControls/.NET4 示例/MyDb.xml +++ b/Bin/Debug/CommonControls/.NET4 示例/MyDb.xml @@ -2265,7 +2265,7 @@ - + 判断鼠标位置是不是在指定的矩形中 @@ -4921,195 +4921,11 @@ Win32 API - - - - - - - - - - - - - - - - - - - - - - - - - - - 获取当前前台窗口句柄 - - - - - - 获得当前活动窗体 - - - - - - 设置活动窗体 - - - - - - - 获取类名 - - - - - - - - - 获取当前线程对应的进程ID - - - - - - - - 判断指定句柄是否是一个窗口 - - - - - - - 获取窗口标题 - - - - - - - - - 查找窗口 - - - - - - - - 设置父窗口 - - - - - - - - 移动窗口 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 结束进程 - - - - - - - - 发送消息 - - - - - - - - - - 发送消息 - - - - - - - - - 获取窗口位置和大小 - - - - - - - - 矩形 - - - - - 最左坐标 - - - - - 最上坐标 - - - - - 最右坐标 - - - - - 最下坐标 - - WM_COPYDATA消息的主要目的是允许在进程间传递只读数据。 @@ -5125,26 +4941,6 @@ 用户通道ID - - - - - - - - - - - - - - - - - - - - 获取消息 @@ -5172,6 +4968,19 @@ + + + + + + + + 结束进程 + + + + + @@ -5282,6 +5091,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -5326,12 +5155,12 @@ - + - + 模拟鼠标点击 @@ -5342,7 +5171,7 @@ - + 模拟按键 @@ -5351,16 +5180,16 @@ - + - + - + 移动窗口 @@ -5370,7 +5199,27 @@ - + + + + + + + + + + + + + + + + + + + + + @@ -5378,14 +5227,90 @@ - + The GetParent function retrieves a handle to the specified window's parent or owner. Handle to the window whose parent window handle is to be retrieved. If the window is a child window, the return value is a handle to the parent window. If the window is a top-level window, the return value is a handle to the owner window. If the window is a top-level unowned window or if the function fails, the return value is NULL. - + + + + + + + + + + + + + + + + + + + + + + + + + + + 获取当前前台窗口句柄 + + + + + + 获得当前活动窗体 + + + + + + 设置活动窗体 + + + + + + + 获取类名 + + + + + + + + + 获取当前线程对应的进程ID + + + + + + + + 判断指定句柄是否是一个窗口 + + + + + + + 获取窗口标题 + + + + + + + @@ -5395,7 +5320,7 @@ - + @@ -5405,7 +5330,7 @@ - + @@ -5415,21 +5340,48 @@ - + + + 发送消息 + + + + + + + + + + 发送消息 + + + + + + + - + - + + + 查找窗口 + + + + + + The FindWindowEx function retrieves a handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the specified child window. @@ -5439,7 +5391,7 @@ Pointer to a null-terminated string that specifies the window name (the window's title). If the function succeeds, the return value is a handle to the window that has the specified class and window names.If the function fails, the return value is NULL. - + The InvalidateRect function adds a rectangle to the specified window's update region. @@ -5448,7 +5400,7 @@ Erase state. If the function succeeds, the return value is true.If the function fails, the return value is false. - + The ValidateRect function validates the client area within a rectangle by removing the rectangle from the update region of the specified window. @@ -5456,7 +5408,7 @@ Validation rectangle coordinates. If the function succeeds, the return value is true.If the function fails, the return value is false. - + @@ -5464,14 +5416,14 @@ - + - + @@ -5479,7 +5431,7 @@ - + @@ -5487,7 +5439,7 @@ - + @@ -5495,7 +5447,7 @@ - + @@ -5510,7 +5462,7 @@ - + @@ -5519,7 +5471,7 @@ - + Changes the size, position, and Z order of a child, pop-up, or top-level window. These windows are ordered according to their appearance on the screen. @@ -5534,7 +5486,7 @@ Specifies the window sizing and positioning flags. This parameter can be a combination of the following values. If the function succeeds, the return value is nonzero, if the function fails, the return value is zero. - + diff --git a/Bin/Debug/CommonControls/.NET4 示例/MyDb_SQLite.dll b/Bin/Debug/CommonControls/.NET4 示例/MyDb_SQLite.dll index 22442eb..a99e192 100644 Binary files a/Bin/Debug/CommonControls/.NET4 示例/MyDb_SQLite.dll and b/Bin/Debug/CommonControls/.NET4 示例/MyDb_SQLite.dll differ diff --git a/Bin/Debug/CommonControls/.NET4 示例/RyPrint.dll b/Bin/Debug/CommonControls/.NET4 示例/RyPrint.dll index 7c940e0..1620912 100644 Binary files a/Bin/Debug/CommonControls/.NET4 示例/RyPrint.dll and b/Bin/Debug/CommonControls/.NET4 示例/RyPrint.dll differ diff --git a/Bin/Debug/CommonControls/.NET4 示例/RyWeb.dll b/Bin/Debug/CommonControls/.NET4 示例/RyWeb.dll index b74266b..f6d810a 100644 Binary files a/Bin/Debug/CommonControls/.NET4 示例/RyWeb.dll and b/Bin/Debug/CommonControls/.NET4 示例/RyWeb.dll differ diff --git a/Bin/Debug/CommonControls/.NET4 示例/UserDb/Win.dat b/Bin/Debug/CommonControls/.NET4 示例/UserDb/Win.dat index ec189b4..c97611e 100644 --- a/Bin/Debug/CommonControls/.NET4 示例/UserDb/Win.dat +++ b/Bin/Debug/CommonControls/.NET4 示例/UserDb/Win.dat @@ -1,2 +1,2 @@ [Money_Op] -hwnd=3875764 +hwnd=2562494 diff --git a/Bin/Debug/CommonControls/.NET4 示例/cUpdate.dat b/Bin/Debug/CommonControls/.NET4 示例/cUpdate.dat index 2a90ba4..b009344 100644 --- a/Bin/Debug/CommonControls/.NET4 示例/cUpdate.dat +++ b/Bin/Debug/CommonControls/.NET4 示例/cUpdate.dat @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/Bin/Debug/CommonControls/.NET4 示例/ryControls.dll b/Bin/Debug/CommonControls/.NET4 示例/ryControls.dll index b6d1767..4cf6803 100644 Binary files a/Bin/Debug/CommonControls/.NET4 示例/ryControls.dll and b/Bin/Debug/CommonControls/.NET4 示例/ryControls.dll differ diff --git a/Bin/Debug/CommonControls/.NET4 示例/ryControls.xml b/Bin/Debug/CommonControls/.NET4 示例/ryControls.xml index bdc5975..6f16ded 100644 --- a/Bin/Debug/CommonControls/.NET4 示例/ryControls.xml +++ b/Bin/Debug/CommonControls/.NET4 示例/ryControls.xml @@ -6534,271 +6534,6 @@ 清空所有控件 - - - 鼠标的当前位置 - - - - - - - - - - - - - - - - - - - - 控件的状态。 - - - - - 正常 - - - - - 鼠标经过 - - - - - 鼠标按下 - - - - - 建立圆角路径的样式。 - - - - - 四个角都不是圆角。 - - - - - 四个角都为圆角。 - - - - - 左边两个角为圆角。 - - - - - 右边两个角为圆角。 - - - - - 上边两个角为圆角。 - - - - - 下边两个角为圆角。 - - - - - 左下角为圆角。 - - - - - 右下角为圆角。 - - - - - - - - - - 普通按钮按下事件 - - - - - 分割按钮按下事件 - - - - - - - - - - 下拉菜单与按钮的距离 - - - - - 图片高度 - - - - - 分割按钮的宽度 - - - - - 当鼠标按下时图片和文字是否产生偏移 - - - - - 是否一直显示按钮边框,设置为false则只在鼠标经过和按下时显示边框 - - - - - 当显示分割按钮时,分割按钮的箭头颜色 - - - - - 按钮的边框颜色 - - - - - 按钮内边框颜色 - - - - - 鼠标经过和按下时按钮的渐变背景颜色 - - - - - 鼠标经过和按下时按钮的渐变背景颜色 - - - - - 图片宽度 - - - - - 图片高度 - - - - - 按钮圆角样式 - - - - - 按钮圆角弧度 - - - - - 图片与文字之间的间距 - - - - - 按钮当前状态 - - - - - 鼠标当前所在位置 - - - - - 普通按钮矩形位置 - - - - - 分割按钮矩形位置 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 获取图像以及文字的位置 - - - - - - - - 画边框与背景 - - - - - 画分割按钮 - - - - - - - - - - - - 建立带有圆角样式的矩形路径 - - 用来建立路径的矩形。 - 圆角的大小 - 圆角的样式 - 是否把矩形长宽减 1,以便画出边框 - 建立的路径 - This enum represents the possible browser commands @@ -7974,6 +7709,1343 @@ + + + a form that supports custom theme + + + + + 标签新建按钮事件 + + + + + 标签关闭按钮事件 + + + + + 标签创建时事件 + + + + + 在标签栏创建时激发 + + + + + + + 内边距 + + + + + 默认内边距 + + + + + 标题 + + + + + 皮肤/主题 + + + + + 是否可拖动改变窗体大小 + + + + + 窗体边界大小,鼠标移动到该边界将变成指针形状,拖动可改变窗体大小 + + + + + 窗体边框大小 + + + + + 标题栏高度 + + + + + 窗体圆角程度 + + + + + 窗体圆角样式 + + + + + 控制按钮相对于右上角的偏移量 + + + + + 关闭/最大化/最小化按钮之间的距离,可以设置成负值使它们重叠 + + + + + 标题栏图标尺寸 + + + + + 标题栏图标与窗体左边框的距离 + + + + + 标题距离左边的距离 + + + + + 窗体关闭按钮的尺寸 + + + + + 窗体最大化/还原按钮的大小 + + + + + 窗体最小化按钮的大小 + + + + + 是否显示阴影 + + + + + 窗体阴影宽度 + + + + + 使用阴影来缩放 + + + + + 窗体阴影颜色 + + + + + 阴影从里到外是逐渐变浅的,这个值设置深色部分的透明度,ARGB中的A值 + + + + + 阴影从里到外是逐渐变浅的,这个值设置浅色部分的透明度,ARGB中的A值 + + + + + 表示去掉自画的边框及标题栏后,剩下的可用的客户区区域,坐标相对于窗体左上角 + + + + + 表示去掉自画的边框及标题栏后,剩下的可用的客户区大小 + + + + + 表示MDI标签栏的区域,包括bottom-region + + + + + MGdUI皮肤 + + + + + 获取子窗体 + + + + + + 通过sendmessage方式激活子窗体以避免闪烁 + + + + + + 当子窗体关闭时激发 + + + + + + + 子窗体可视化变化 + + + + + + + 获取当前的子窗体列表 + + + + + + 判断所接收到的 wm_nc-calc-size 消息是否指示窗体即将最小化 + + + + + 判断所接收到的 wm_nc-calc-size 消息是否指示窗体即将最大化 + + + + + to make the client area to have 3D view + + + + + 消息 + + + + + + 画UI + + + + + + 在画背景时激发 + + + + + + 重写该方法解决窗体每次还原都会变大的问题 + + + + + 重写该方法解决在VS设计器中,每次保存一个新的尺寸,再打开尺寸会变大的问题 + + + + + 创建控件时激发 + + + + + 窗体可见变化时激发 + + + + + + 大小改变时激发 + + + + + + 在位置变化时激发 + + + + + + 窗体激活 + + + + + + 窗体关闭后激发 + + + + + + 加载时 + + + + + + 在子窗体激活时激发 + + + + + + 标签菜单 + + + + + 窗体上移动鼠标时激发 + + + + + + 获取当前点击的标签项 + + + + + 在窗体上按下鼠标时激发 + + + + + + 在窗体上放开鼠标时激发 + + + + + + 在鼠标离开窗体时激发 + + + + + + Required designer variable. + + + + + Clean up any resources being used. + + true if managed resources should be disposed; otherwise, false. + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + Required designer variable. + + + + + Clean up any resources being used. + + true if managed resources should be disposed; otherwise, false. + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + 该类处理mdi-bar的绘制及鼠标事件管理 + + + + + use left,top,right to location the bar in owner form, + the margin is from Form.ClientRectangle + + + + + 整个标签栏高度,包含标签栏底部区域、标签、标签顶部空隙 + + + + + 标签栏底部区域的高度 + + + + + 是否显示标签栏边框 + + + + + 是否显示标签栏背景 + + + + + 标签栏左内边距 + + + + + 标签栏右内边距 + + + + + 标签高度 + + + + + 激活的标签高度 + + + + + tab顶部与bar顶部的空间,这个值用来计算 BarHeight + + + + + 每个标签的左右边界可以不是垂直的,而是都有一个斜度 + + + + + tab与tab之间的距离,用负值可以使tab有重叠的效果 + + + + + 标签是否显示图标 + + + + + 是否显示标签关闭按钮 + + + + + 标签图标大小 + + + + + 标签图标距离左边的距离 + + + + + 标签文字距离左边的距离 + + + + + 标签关闭按钮的大小 + + + + + 标签关闭按钮距离右边的距离 + + + + + 是否显示新建标签按钮 + + + + + 新建标签按钮的大小 + + + + + 新建标签距离左边的距离 + + + + + 按钮与Bar底部的距离 + + + + + 一个tab允许的最小宽度 + + + + + 一个tab允许的最大显示宽度 + + + + + 标签正常宽度 + + + + + 同步_listTabItems与mdi主窗体实际存在的子form + + + + + 为每个tab分配空间,如果tab数目太多,则有些会被隐藏 + + + + + 重绘整个标签栏 + + + + + + 处理鼠标事件。该方法会触发一些click事件,重刷一些按钮等 + + + + + + + 该类表示一个单独的标签项 + + + + + 该标签所对应的窗体 + + + + + 最终分配到的整个tab的宽度 + + + + + 表示所对应的form是否仍未被关闭 + + + + + 是否因空间不足而被隐藏 + + + + + 返回全部显示该标签文本所需的长度 + + + + + + 返回显示全部文本时该tab所需的宽度,该宽度不超过bar-container + 规定的tabmaxwidth + + + + + + 居左 + + + + + 显示在最后一个标签后面 + + + + + 该类封装设置一个主题所需的信息,可以继承该类实现不同的主题 + + + + + 主题名称,用于标识主题,对主题进行简单描述 + + + + + 窗体边界大小,鼠标移动到该边界将变成指针形状,拖动可改变窗体大小 + + + + + 窗体边框大小 + + + + + 窗体标题栏高度 + + + + + 标题栏图标与窗体左边框的距离 + + + + + 标题栏图标尺寸 + + + + + 标题栏文本左边距 + + + + + 控制按钮(关闭按钮)相对于窗体右上角的偏移量 + + + + + 窗体关闭按钮的尺寸 + + + + + 窗体最大化/还原按钮的大小 + + + + + 窗体最小化按钮的大小 + + + + + 关闭/最大化/最小化按钮之间的距离,可以设置成负值使它们重叠 + + + + + 窗体圆角程度 + + + + + 窗体圆角样式 + + + + + 是否使用默认的圆角样式,该样式为左上角和右上角圆角, + 最好在窗体边框较粗时才使用该样式 + + + + + 是否在标题栏上绘制图标 + + + + + 是否在标题栏上绘制文本 + + + + + 是否显示窗体阴影 + + + + + 窗体阴影大小 + + + + + 拖动窗体阴影是否可以改变窗体大小 + + + + + 阴影的颜色,可以设置成其他颜色而不一定是黑色 + + + + + 阴影从里到外是逐渐变浅的,这个值设置深色部分的透明度,ARGB中的A值 + + + + + 阴影从里到外是逐渐变浅的,这个值设置浅色部分的透明度,ARGB中的A值 + + + + + 是否在客户区边界画线使其看起来有立体感 + + + + + 窗体标题栏文字是否居中显示 + + + + + 窗体边框最外一像素的颜色 + + + + + 窗体边框第二最外像素的颜色 + + + + + 窗体边框其他部分颜色,如果窗体边框大小大于2,则其他像素将用此颜色画出 + + + + + 标题栏颜色是从上到下渐变的,这个值设置上边的颜色值 + + + + + 标题栏颜色是从上到下渐变的,这个值设置下边的颜色值 + + + + + 标题栏文字颜色 + + + + + 窗体背景颜色,该值将覆盖窗体自带的BackColor属性值 + + + + + 窗体关闭按钮的颜色集合 + + + + + 窗体最大化/还原按钮的颜色集合 + + + + + 窗体最小化按钮的颜色集合 + + + + + 默认状态下关闭按钮背景图片 + + + + + 鼠标移过去时关闭按钮背景图片 + + + + + 鼠标按下时关闭按钮背景图片 + + + + + 默认状态下最大化按钮背景图片 + + + + + 鼠标移过去时最大化按钮背景图片 + + + + + 鼠标按下时最大化按钮背景图片 + + + + + 默认状态下恢复按钮背景图片 + + + + + 鼠标移过去时恢复按钮背景图片 + + + + + 鼠标按下时恢复按钮背景图片 + + + + + 默认状态下最小化按钮背景图片 + + + + + 鼠标移过去时最小化按钮背景图片 + + + + + 鼠标按下时最小化按钮背景图片 + + + + + 是否用SendMessage的方式切换子窗体,以避免子窗体切换时产生的闪烁 + + + + + Mdi-Bar与窗体左、上、右边界的距离,只用到这三个值,Bottom值没用到。 + 用这三个值来确定Mdi-Bar的宽度及其在窗体中的位置 + + + + + 内部左边空白,第一个标签将从这个空白距离之后开始 + + + + + 标签栏内部右边空白 + + + + + 标签栏背景颜色 + + + + + 标签栏边框颜色 + + + + + 标签栏背景图片 + + + + + 是否显示标签栏边框 + + + + + 标签栏下边区域的背景颜色 + + + + + 标签栏下边区域的高度 + + + + + 标签高度 + + + + + 被选中的标签高度,可以设置成与TabHeight不一样的值,以突出显示被选中状态 + + + + + 标签之间的距离,设成负值可以使标签有重叠的效果 + + + + + 标签的最大宽度,任何情况下标签都不能超过这个宽度 + + + + + 标签正常宽度,如果标签需要很短的宽度(比如20像素)就可以显示完上面的文字, + 但是Mdi-Bar上有足够的空间时,标签会以正常宽度(比如100像素)显示 + + + + + 标签最小宽度,当标签小于这个宽度时将被隐藏 + + + + + 标签梯度大小,标签可以不以矩形方式显示,而是有一个梯度/斜度。 + + + + + 标签顶部空白,这个值用于参与计算Mdi-Bar高度,计算方式为: + Mdi-Bar Height = BottomRegionHeight + TabHeight + TabTopSpace + + + + + 标签上是否显示子窗体图标 + + + + + 标签上是否显示子窗体关闭图标 + + + + + 选中状态的标签的上部背景色,与下部背景色不同时,标签背景色就有渐变效果 + + + + + 选中状态的标签的下部背景色,与上部背景色不同时,标签背景色就有渐变效果 + + + + + 标签激活时字体颜色 + + + + + 非选中状态的标签的字体颜色 + + + + + 非选中状态的标签的上部背景色 + + + + + 非选中状态的标签的下部背景色 + + + + + 标签外边框颜色 + + + + + 标签内边框颜色,这个颜色一般具有一定的透明度 + + + + + 是否显示标签边框 + + + + + 是否显示默认的新建标签按钮(NewTabBtn) + + + + + NewTabBtn与下边框的距离,这个值用来定位按钮的Y坐标 + + + + + 新建标签按钮与左边框的距离,这个值用来定位按钮的X坐标 + + + + + 新建标签按钮大小 + + + + + 按钮颜色集合 + + + + + 是否一直显示ListAllBtn,即使在没有标签被隐藏的情况下 + + + + + 《显示全部标签》按钮的位置 + + + + + 《显示全部标签》按钮与下边框的距离,这个值用来定位按钮的Y坐标 + + + + + 《显示全部标签》按钮与左边框的距离,这个值用来定位按钮的X坐标 + + + + + 《显示全部标签》按钮的颜色 + + + + + 《显示全部标签》按钮的大小 + + + + + 皮肤主题 + + + + + 引发 ValueChanged 事件 + + + + + + 引发 ThemeChanged 事件 + + + + + + 指示鼠标位于哪个区域 + + + + + 控件Value值发生变化后引发 + + + + + 控件绘制MainLine前引发, 可以设置Cancel参数来取消默认的绘制 + + + + + 控件绘制Button前引发 + + + + + 引发 ValueChanged 事件 + + + + + 引发 BeforePaintMainLine 事件 + + + + + 引发 BeforePaintButton 事件 + + + + + 将Value值加一个LargeChange量 + + + + + 将Value值减一个LargeChange量 + + + + + 将Value值加一个SmallChange量 + + + + + 将Value值减一个SmallChange量 + + + + + 提供产生各种路径的静态方法,比如圆角路径、关闭按钮上的x路径、+号路径 + + + + + 圆角样式 + + + + + 无 + + + + + 所有 + + + + + 上 + + + + + 下 + + + + + 左 + + + + + 右 + + + + + SimpleObject指的是只有一种状态(不像普通按钮一样有三种状态),并且其上的元素 + 布局比较简单的Object + + + + + + + + + + + + + + + + + + + + DevExpress风格皮肤 + + + + + DevExpress风格皮肤 + + + + + 新风格皮肤 + + + + + 新风格皮肤 + + + + + 基础皮肤 + + + + + VS2013风格皮肤 + + + + + this theme is just for chrome one quarter style + + + + + for diamond ring style only + + + + + Location of cursor hot spot returnet in WM_NCHITTEST. + + + + + On the screen background or on a dividing line between windows + (same as HTNOWHERE, except that the DefWindowProc function produces a system beep to indicate an error). + + + + + In a window currently covered by another window in the same thread + (the message will be sent to underlying windows in the same thread until one of them returns a code that is not HTTRANSPARENT). + + + + + On the screen background or on a dividing line between windows. + + + + In a client area. + + + In a title bar. + + + In a window menu or in a Close button in a child window. + + + In a size box (same as HTSIZE). + + + In a menu. + + + In a horizontal scroll bar. + + + In the vertical scroll bar. + + + In a Minimize button. + + + In a Maximize button. + + + In the left border of a resizable window + (the user can click the mouse to resize the window horizontally). + + + + In the right border of a resizable window + (the user can click the mouse to resize the window horizontally). + + + + In the upper-horizontal border of a window. + + + In the upper-left corner of a window border. + + + In the upper-right corner of a window border. + + + In the lower-horizontal border of a resizable window + (the user can click the mouse to resize the window vertically). + + + In the lower-left corner of a border of a resizable window + (the user can click the mouse to resize the window diagonally). + + + In the lower-right corner of a border of a resizable window + (the user can click the mouse to resize the window diagonally). + + + In the border of a window that does not have a sizing border. + + + In a Close button. + + + In a Help button. + + + + Contains the new coordinates of a window that has been moved or resized, that is, it is the proposed new window coordinates. + + + + + Contains the coordinates of the window before it was moved or resized. + + + + + Contains the coordinates of the window's client area before the window was moved or resized. + + + + + Pointer to a WINDOWPOS structure that contains the size and position values specified in the operation that moved or resized the window. + + + + + + + + + + 是否在这个按钮上按下了鼠标未释放 + + + + + 是否可见 + + + + + + + + + + 画两次可以加深颜色 + + + + + 用于在click事件中传回数据 + + + + + 获取或设置是否将绘制完全限制在指定的区域内 + + + + + + + + + + + + + + 线条图 diff --git a/Bin/Debug/CommonControls/.NET4 示例/ryUpdate.dll b/Bin/Debug/CommonControls/.NET4 示例/ryUpdate.dll index f4747e9..b0c2da2 100644 Binary files a/Bin/Debug/CommonControls/.NET4 示例/ryUpdate.dll and b/Bin/Debug/CommonControls/.NET4 示例/ryUpdate.dll differ diff --git a/Bin/Debug/CommonControls/.NET4/MyDb.dll b/Bin/Debug/CommonControls/.NET4/MyDb.dll index b59bdf0..20affa9 100644 Binary files a/Bin/Debug/CommonControls/.NET4/MyDb.dll and b/Bin/Debug/CommonControls/.NET4/MyDb.dll differ diff --git a/Bin/Debug/CommonControls/.NET4/MyDb.xml b/Bin/Debug/CommonControls/.NET4/MyDb.xml index d0448da..7c2a910 100644 --- a/Bin/Debug/CommonControls/.NET4/MyDb.xml +++ b/Bin/Debug/CommonControls/.NET4/MyDb.xml @@ -2265,7 +2265,7 @@ - + 判断鼠标位置是不是在指定的矩形中 @@ -4921,195 +4921,11 @@ Win32 API - - - - - - - - - - - - - - - - - - - - - - - - - - - 获取当前前台窗口句柄 - - - - - - 获得当前活动窗体 - - - - - - 设置活动窗体 - - - - - - - 获取类名 - - - - - - - - - 获取当前线程对应的进程ID - - - - - - - - 判断指定句柄是否是一个窗口 - - - - - - - 获取窗口标题 - - - - - - - - - 查找窗口 - - - - - - - - 设置父窗口 - - - - - - - - 移动窗口 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 结束进程 - - - - - - - - 发送消息 - - - - - - - - - - 发送消息 - - - - - - - - - 获取窗口位置和大小 - - - - - - - - 矩形 - - - - - 最左坐标 - - - - - 最上坐标 - - - - - 最右坐标 - - - - - 最下坐标 - - WM_COPYDATA消息的主要目的是允许在进程间传递只读数据。 @@ -5125,26 +4941,6 @@ 用户通道ID - - - - - - - - - - - - - - - - - - - - 获取消息 @@ -5172,6 +4968,19 @@ + + + + + + + + 结束进程 + + + + + @@ -5282,6 +5091,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -5326,12 +5155,12 @@ - + - + 模拟鼠标点击 @@ -5342,7 +5171,7 @@ - + 模拟按键 @@ -5351,16 +5180,16 @@ - + - + - + 移动窗口 @@ -5370,7 +5199,27 @@ - + + + + + + + + + + + + + + + + + + + + + @@ -5378,14 +5227,90 @@ - + The GetParent function retrieves a handle to the specified window's parent or owner. Handle to the window whose parent window handle is to be retrieved. If the window is a child window, the return value is a handle to the parent window. If the window is a top-level window, the return value is a handle to the owner window. If the window is a top-level unowned window or if the function fails, the return value is NULL. - + + + + + + + + + + + + + + + + + + + + + + + + + + + 获取当前前台窗口句柄 + + + + + + 获得当前活动窗体 + + + + + + 设置活动窗体 + + + + + + + 获取类名 + + + + + + + + + 获取当前线程对应的进程ID + + + + + + + + 判断指定句柄是否是一个窗口 + + + + + + + 获取窗口标题 + + + + + + + @@ -5395,7 +5320,7 @@ - + @@ -5405,7 +5330,7 @@ - + @@ -5415,21 +5340,48 @@ - + + + 发送消息 + + + + + + + + + + 发送消息 + + + + + + + - + - + + + 查找窗口 + + + + + + The FindWindowEx function retrieves a handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the specified child window. @@ -5439,7 +5391,7 @@ Pointer to a null-terminated string that specifies the window name (the window's title). If the function succeeds, the return value is a handle to the window that has the specified class and window names.If the function fails, the return value is NULL. - + The InvalidateRect function adds a rectangle to the specified window's update region. @@ -5448,7 +5400,7 @@ Erase state. If the function succeeds, the return value is true.If the function fails, the return value is false. - + The ValidateRect function validates the client area within a rectangle by removing the rectangle from the update region of the specified window. @@ -5456,7 +5408,7 @@ Validation rectangle coordinates. If the function succeeds, the return value is true.If the function fails, the return value is false. - + @@ -5464,14 +5416,14 @@ - + - + @@ -5479,7 +5431,7 @@ - + @@ -5487,7 +5439,7 @@ - + @@ -5495,7 +5447,7 @@ - + @@ -5510,7 +5462,7 @@ - + @@ -5519,7 +5471,7 @@ - + Changes the size, position, and Z order of a child, pop-up, or top-level window. These windows are ordered according to their appearance on the screen. @@ -5534,7 +5486,7 @@ Specifies the window sizing and positioning flags. This parameter can be a combination of the following values. If the function succeeds, the return value is nonzero, if the function fails, the return value is zero. - + diff --git a/Bin/Debug/CommonControls/.NET4/MyDb_MSSQL.dll b/Bin/Debug/CommonControls/.NET4/MyDb_MSSQL.dll index aea2286..c0a5756 100644 Binary files a/Bin/Debug/CommonControls/.NET4/MyDb_MSSQL.dll and b/Bin/Debug/CommonControls/.NET4/MyDb_MSSQL.dll differ diff --git a/Bin/Debug/CommonControls/.NET4/MyDb_MySQL.dll b/Bin/Debug/CommonControls/.NET4/MyDb_MySQL.dll index 57b2b9a..6d26184 100644 Binary files a/Bin/Debug/CommonControls/.NET4/MyDb_MySQL.dll and b/Bin/Debug/CommonControls/.NET4/MyDb_MySQL.dll differ diff --git a/Bin/Debug/CommonControls/.NET4/MyDb_SQLite.dll b/Bin/Debug/CommonControls/.NET4/MyDb_SQLite.dll index 22442eb..a99e192 100644 Binary files a/Bin/Debug/CommonControls/.NET4/MyDb_SQLite.dll and b/Bin/Debug/CommonControls/.NET4/MyDb_SQLite.dll differ diff --git a/Bin/Debug/CommonControls/.NET4/RyPrint.dll b/Bin/Debug/CommonControls/.NET4/RyPrint.dll index 7c940e0..1620912 100644 Binary files a/Bin/Debug/CommonControls/.NET4/RyPrint.dll and b/Bin/Debug/CommonControls/.NET4/RyPrint.dll differ diff --git a/Bin/Debug/CommonControls/.NET4/RyWeb.dll b/Bin/Debug/CommonControls/.NET4/RyWeb.dll index f4bd044..486873b 100644 Binary files a/Bin/Debug/CommonControls/.NET4/RyWeb.dll and b/Bin/Debug/CommonControls/.NET4/RyWeb.dll differ diff --git a/Bin/Debug/CommonControls/.NET4/ryControls.dll b/Bin/Debug/CommonControls/.NET4/ryControls.dll index b6d1767..4cf6803 100644 Binary files a/Bin/Debug/CommonControls/.NET4/ryControls.dll and b/Bin/Debug/CommonControls/.NET4/ryControls.dll differ diff --git a/Bin/Debug/CommonControls/.NET4/ryControls.xml b/Bin/Debug/CommonControls/.NET4/ryControls.xml index bdc5975..6f16ded 100644 --- a/Bin/Debug/CommonControls/.NET4/ryControls.xml +++ b/Bin/Debug/CommonControls/.NET4/ryControls.xml @@ -6534,271 +6534,6 @@ 清空所有控件 - - - 鼠标的当前位置 - - - - - - - - - - - - - - - - - - - - 控件的状态。 - - - - - 正常 - - - - - 鼠标经过 - - - - - 鼠标按下 - - - - - 建立圆角路径的样式。 - - - - - 四个角都不是圆角。 - - - - - 四个角都为圆角。 - - - - - 左边两个角为圆角。 - - - - - 右边两个角为圆角。 - - - - - 上边两个角为圆角。 - - - - - 下边两个角为圆角。 - - - - - 左下角为圆角。 - - - - - 右下角为圆角。 - - - - - - - - - - 普通按钮按下事件 - - - - - 分割按钮按下事件 - - - - - - - - - - 下拉菜单与按钮的距离 - - - - - 图片高度 - - - - - 分割按钮的宽度 - - - - - 当鼠标按下时图片和文字是否产生偏移 - - - - - 是否一直显示按钮边框,设置为false则只在鼠标经过和按下时显示边框 - - - - - 当显示分割按钮时,分割按钮的箭头颜色 - - - - - 按钮的边框颜色 - - - - - 按钮内边框颜色 - - - - - 鼠标经过和按下时按钮的渐变背景颜色 - - - - - 鼠标经过和按下时按钮的渐变背景颜色 - - - - - 图片宽度 - - - - - 图片高度 - - - - - 按钮圆角样式 - - - - - 按钮圆角弧度 - - - - - 图片与文字之间的间距 - - - - - 按钮当前状态 - - - - - 鼠标当前所在位置 - - - - - 普通按钮矩形位置 - - - - - 分割按钮矩形位置 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 获取图像以及文字的位置 - - - - - - - - 画边框与背景 - - - - - 画分割按钮 - - - - - - - - - - - - 建立带有圆角样式的矩形路径 - - 用来建立路径的矩形。 - 圆角的大小 - 圆角的样式 - 是否把矩形长宽减 1,以便画出边框 - 建立的路径 - This enum represents the possible browser commands @@ -7974,6 +7709,1343 @@ + + + a form that supports custom theme + + + + + 标签新建按钮事件 + + + + + 标签关闭按钮事件 + + + + + 标签创建时事件 + + + + + 在标签栏创建时激发 + + + + + + + 内边距 + + + + + 默认内边距 + + + + + 标题 + + + + + 皮肤/主题 + + + + + 是否可拖动改变窗体大小 + + + + + 窗体边界大小,鼠标移动到该边界将变成指针形状,拖动可改变窗体大小 + + + + + 窗体边框大小 + + + + + 标题栏高度 + + + + + 窗体圆角程度 + + + + + 窗体圆角样式 + + + + + 控制按钮相对于右上角的偏移量 + + + + + 关闭/最大化/最小化按钮之间的距离,可以设置成负值使它们重叠 + + + + + 标题栏图标尺寸 + + + + + 标题栏图标与窗体左边框的距离 + + + + + 标题距离左边的距离 + + + + + 窗体关闭按钮的尺寸 + + + + + 窗体最大化/还原按钮的大小 + + + + + 窗体最小化按钮的大小 + + + + + 是否显示阴影 + + + + + 窗体阴影宽度 + + + + + 使用阴影来缩放 + + + + + 窗体阴影颜色 + + + + + 阴影从里到外是逐渐变浅的,这个值设置深色部分的透明度,ARGB中的A值 + + + + + 阴影从里到外是逐渐变浅的,这个值设置浅色部分的透明度,ARGB中的A值 + + + + + 表示去掉自画的边框及标题栏后,剩下的可用的客户区区域,坐标相对于窗体左上角 + + + + + 表示去掉自画的边框及标题栏后,剩下的可用的客户区大小 + + + + + 表示MDI标签栏的区域,包括bottom-region + + + + + MGdUI皮肤 + + + + + 获取子窗体 + + + + + + 通过sendmessage方式激活子窗体以避免闪烁 + + + + + + 当子窗体关闭时激发 + + + + + + + 子窗体可视化变化 + + + + + + + 获取当前的子窗体列表 + + + + + + 判断所接收到的 wm_nc-calc-size 消息是否指示窗体即将最小化 + + + + + 判断所接收到的 wm_nc-calc-size 消息是否指示窗体即将最大化 + + + + + to make the client area to have 3D view + + + + + 消息 + + + + + + 画UI + + + + + + 在画背景时激发 + + + + + + 重写该方法解决窗体每次还原都会变大的问题 + + + + + 重写该方法解决在VS设计器中,每次保存一个新的尺寸,再打开尺寸会变大的问题 + + + + + 创建控件时激发 + + + + + 窗体可见变化时激发 + + + + + + 大小改变时激发 + + + + + + 在位置变化时激发 + + + + + + 窗体激活 + + + + + + 窗体关闭后激发 + + + + + + 加载时 + + + + + + 在子窗体激活时激发 + + + + + + 标签菜单 + + + + + 窗体上移动鼠标时激发 + + + + + + 获取当前点击的标签项 + + + + + 在窗体上按下鼠标时激发 + + + + + + 在窗体上放开鼠标时激发 + + + + + + 在鼠标离开窗体时激发 + + + + + + Required designer variable. + + + + + Clean up any resources being used. + + true if managed resources should be disposed; otherwise, false. + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + Required designer variable. + + + + + Clean up any resources being used. + + true if managed resources should be disposed; otherwise, false. + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + 该类处理mdi-bar的绘制及鼠标事件管理 + + + + + use left,top,right to location the bar in owner form, + the margin is from Form.ClientRectangle + + + + + 整个标签栏高度,包含标签栏底部区域、标签、标签顶部空隙 + + + + + 标签栏底部区域的高度 + + + + + 是否显示标签栏边框 + + + + + 是否显示标签栏背景 + + + + + 标签栏左内边距 + + + + + 标签栏右内边距 + + + + + 标签高度 + + + + + 激活的标签高度 + + + + + tab顶部与bar顶部的空间,这个值用来计算 BarHeight + + + + + 每个标签的左右边界可以不是垂直的,而是都有一个斜度 + + + + + tab与tab之间的距离,用负值可以使tab有重叠的效果 + + + + + 标签是否显示图标 + + + + + 是否显示标签关闭按钮 + + + + + 标签图标大小 + + + + + 标签图标距离左边的距离 + + + + + 标签文字距离左边的距离 + + + + + 标签关闭按钮的大小 + + + + + 标签关闭按钮距离右边的距离 + + + + + 是否显示新建标签按钮 + + + + + 新建标签按钮的大小 + + + + + 新建标签距离左边的距离 + + + + + 按钮与Bar底部的距离 + + + + + 一个tab允许的最小宽度 + + + + + 一个tab允许的最大显示宽度 + + + + + 标签正常宽度 + + + + + 同步_listTabItems与mdi主窗体实际存在的子form + + + + + 为每个tab分配空间,如果tab数目太多,则有些会被隐藏 + + + + + 重绘整个标签栏 + + + + + + 处理鼠标事件。该方法会触发一些click事件,重刷一些按钮等 + + + + + + + 该类表示一个单独的标签项 + + + + + 该标签所对应的窗体 + + + + + 最终分配到的整个tab的宽度 + + + + + 表示所对应的form是否仍未被关闭 + + + + + 是否因空间不足而被隐藏 + + + + + 返回全部显示该标签文本所需的长度 + + + + + + 返回显示全部文本时该tab所需的宽度,该宽度不超过bar-container + 规定的tabmaxwidth + + + + + + 居左 + + + + + 显示在最后一个标签后面 + + + + + 该类封装设置一个主题所需的信息,可以继承该类实现不同的主题 + + + + + 主题名称,用于标识主题,对主题进行简单描述 + + + + + 窗体边界大小,鼠标移动到该边界将变成指针形状,拖动可改变窗体大小 + + + + + 窗体边框大小 + + + + + 窗体标题栏高度 + + + + + 标题栏图标与窗体左边框的距离 + + + + + 标题栏图标尺寸 + + + + + 标题栏文本左边距 + + + + + 控制按钮(关闭按钮)相对于窗体右上角的偏移量 + + + + + 窗体关闭按钮的尺寸 + + + + + 窗体最大化/还原按钮的大小 + + + + + 窗体最小化按钮的大小 + + + + + 关闭/最大化/最小化按钮之间的距离,可以设置成负值使它们重叠 + + + + + 窗体圆角程度 + + + + + 窗体圆角样式 + + + + + 是否使用默认的圆角样式,该样式为左上角和右上角圆角, + 最好在窗体边框较粗时才使用该样式 + + + + + 是否在标题栏上绘制图标 + + + + + 是否在标题栏上绘制文本 + + + + + 是否显示窗体阴影 + + + + + 窗体阴影大小 + + + + + 拖动窗体阴影是否可以改变窗体大小 + + + + + 阴影的颜色,可以设置成其他颜色而不一定是黑色 + + + + + 阴影从里到外是逐渐变浅的,这个值设置深色部分的透明度,ARGB中的A值 + + + + + 阴影从里到外是逐渐变浅的,这个值设置浅色部分的透明度,ARGB中的A值 + + + + + 是否在客户区边界画线使其看起来有立体感 + + + + + 窗体标题栏文字是否居中显示 + + + + + 窗体边框最外一像素的颜色 + + + + + 窗体边框第二最外像素的颜色 + + + + + 窗体边框其他部分颜色,如果窗体边框大小大于2,则其他像素将用此颜色画出 + + + + + 标题栏颜色是从上到下渐变的,这个值设置上边的颜色值 + + + + + 标题栏颜色是从上到下渐变的,这个值设置下边的颜色值 + + + + + 标题栏文字颜色 + + + + + 窗体背景颜色,该值将覆盖窗体自带的BackColor属性值 + + + + + 窗体关闭按钮的颜色集合 + + + + + 窗体最大化/还原按钮的颜色集合 + + + + + 窗体最小化按钮的颜色集合 + + + + + 默认状态下关闭按钮背景图片 + + + + + 鼠标移过去时关闭按钮背景图片 + + + + + 鼠标按下时关闭按钮背景图片 + + + + + 默认状态下最大化按钮背景图片 + + + + + 鼠标移过去时最大化按钮背景图片 + + + + + 鼠标按下时最大化按钮背景图片 + + + + + 默认状态下恢复按钮背景图片 + + + + + 鼠标移过去时恢复按钮背景图片 + + + + + 鼠标按下时恢复按钮背景图片 + + + + + 默认状态下最小化按钮背景图片 + + + + + 鼠标移过去时最小化按钮背景图片 + + + + + 鼠标按下时最小化按钮背景图片 + + + + + 是否用SendMessage的方式切换子窗体,以避免子窗体切换时产生的闪烁 + + + + + Mdi-Bar与窗体左、上、右边界的距离,只用到这三个值,Bottom值没用到。 + 用这三个值来确定Mdi-Bar的宽度及其在窗体中的位置 + + + + + 内部左边空白,第一个标签将从这个空白距离之后开始 + + + + + 标签栏内部右边空白 + + + + + 标签栏背景颜色 + + + + + 标签栏边框颜色 + + + + + 标签栏背景图片 + + + + + 是否显示标签栏边框 + + + + + 标签栏下边区域的背景颜色 + + + + + 标签栏下边区域的高度 + + + + + 标签高度 + + + + + 被选中的标签高度,可以设置成与TabHeight不一样的值,以突出显示被选中状态 + + + + + 标签之间的距离,设成负值可以使标签有重叠的效果 + + + + + 标签的最大宽度,任何情况下标签都不能超过这个宽度 + + + + + 标签正常宽度,如果标签需要很短的宽度(比如20像素)就可以显示完上面的文字, + 但是Mdi-Bar上有足够的空间时,标签会以正常宽度(比如100像素)显示 + + + + + 标签最小宽度,当标签小于这个宽度时将被隐藏 + + + + + 标签梯度大小,标签可以不以矩形方式显示,而是有一个梯度/斜度。 + + + + + 标签顶部空白,这个值用于参与计算Mdi-Bar高度,计算方式为: + Mdi-Bar Height = BottomRegionHeight + TabHeight + TabTopSpace + + + + + 标签上是否显示子窗体图标 + + + + + 标签上是否显示子窗体关闭图标 + + + + + 选中状态的标签的上部背景色,与下部背景色不同时,标签背景色就有渐变效果 + + + + + 选中状态的标签的下部背景色,与上部背景色不同时,标签背景色就有渐变效果 + + + + + 标签激活时字体颜色 + + + + + 非选中状态的标签的字体颜色 + + + + + 非选中状态的标签的上部背景色 + + + + + 非选中状态的标签的下部背景色 + + + + + 标签外边框颜色 + + + + + 标签内边框颜色,这个颜色一般具有一定的透明度 + + + + + 是否显示标签边框 + + + + + 是否显示默认的新建标签按钮(NewTabBtn) + + + + + NewTabBtn与下边框的距离,这个值用来定位按钮的Y坐标 + + + + + 新建标签按钮与左边框的距离,这个值用来定位按钮的X坐标 + + + + + 新建标签按钮大小 + + + + + 按钮颜色集合 + + + + + 是否一直显示ListAllBtn,即使在没有标签被隐藏的情况下 + + + + + 《显示全部标签》按钮的位置 + + + + + 《显示全部标签》按钮与下边框的距离,这个值用来定位按钮的Y坐标 + + + + + 《显示全部标签》按钮与左边框的距离,这个值用来定位按钮的X坐标 + + + + + 《显示全部标签》按钮的颜色 + + + + + 《显示全部标签》按钮的大小 + + + + + 皮肤主题 + + + + + 引发 ValueChanged 事件 + + + + + + 引发 ThemeChanged 事件 + + + + + + 指示鼠标位于哪个区域 + + + + + 控件Value值发生变化后引发 + + + + + 控件绘制MainLine前引发, 可以设置Cancel参数来取消默认的绘制 + + + + + 控件绘制Button前引发 + + + + + 引发 ValueChanged 事件 + + + + + 引发 BeforePaintMainLine 事件 + + + + + 引发 BeforePaintButton 事件 + + + + + 将Value值加一个LargeChange量 + + + + + 将Value值减一个LargeChange量 + + + + + 将Value值加一个SmallChange量 + + + + + 将Value值减一个SmallChange量 + + + + + 提供产生各种路径的静态方法,比如圆角路径、关闭按钮上的x路径、+号路径 + + + + + 圆角样式 + + + + + 无 + + + + + 所有 + + + + + 上 + + + + + 下 + + + + + 左 + + + + + 右 + + + + + SimpleObject指的是只有一种状态(不像普通按钮一样有三种状态),并且其上的元素 + 布局比较简单的Object + + + + + + + + + + + + + + + + + + + + DevExpress风格皮肤 + + + + + DevExpress风格皮肤 + + + + + 新风格皮肤 + + + + + 新风格皮肤 + + + + + 基础皮肤 + + + + + VS2013风格皮肤 + + + + + this theme is just for chrome one quarter style + + + + + for diamond ring style only + + + + + Location of cursor hot spot returnet in WM_NCHITTEST. + + + + + On the screen background or on a dividing line between windows + (same as HTNOWHERE, except that the DefWindowProc function produces a system beep to indicate an error). + + + + + In a window currently covered by another window in the same thread + (the message will be sent to underlying windows in the same thread until one of them returns a code that is not HTTRANSPARENT). + + + + + On the screen background or on a dividing line between windows. + + + + In a client area. + + + In a title bar. + + + In a window menu or in a Close button in a child window. + + + In a size box (same as HTSIZE). + + + In a menu. + + + In a horizontal scroll bar. + + + In the vertical scroll bar. + + + In a Minimize button. + + + In a Maximize button. + + + In the left border of a resizable window + (the user can click the mouse to resize the window horizontally). + + + + In the right border of a resizable window + (the user can click the mouse to resize the window horizontally). + + + + In the upper-horizontal border of a window. + + + In the upper-left corner of a window border. + + + In the upper-right corner of a window border. + + + In the lower-horizontal border of a resizable window + (the user can click the mouse to resize the window vertically). + + + In the lower-left corner of a border of a resizable window + (the user can click the mouse to resize the window diagonally). + + + In the lower-right corner of a border of a resizable window + (the user can click the mouse to resize the window diagonally). + + + In the border of a window that does not have a sizing border. + + + In a Close button. + + + In a Help button. + + + + Contains the new coordinates of a window that has been moved or resized, that is, it is the proposed new window coordinates. + + + + + Contains the coordinates of the window before it was moved or resized. + + + + + Contains the coordinates of the window's client area before the window was moved or resized. + + + + + Pointer to a WINDOWPOS structure that contains the size and position values specified in the operation that moved or resized the window. + + + + + + + + + + 是否在这个按钮上按下了鼠标未释放 + + + + + 是否可见 + + + + + + + + + + 画两次可以加深颜色 + + + + + 用于在click事件中传回数据 + + + + + 获取或设置是否将绘制完全限制在指定的区域内 + + + + + + + + + + + + + + 线条图 diff --git a/Bin/Debug/CommonControls/.NET4/ryUpdate.dll b/Bin/Debug/CommonControls/.NET4/ryUpdate.dll index f4747e9..b0c2da2 100644 Binary files a/Bin/Debug/CommonControls/.NET4/ryUpdate.dll and b/Bin/Debug/CommonControls/.NET4/ryUpdate.dll differ diff --git a/Bin/Release/CommonControls/.NET4 示例/Itrycn_Project.exe b/Bin/Release/CommonControls/.NET4 示例/Itrycn_Project.exe index afa1540..0bf19d8 100644 Binary files a/Bin/Release/CommonControls/.NET4 示例/Itrycn_Project.exe and b/Bin/Release/CommonControls/.NET4 示例/Itrycn_Project.exe differ diff --git a/Bin/Release/CommonControls/.NET4 示例/MyDb.dll b/Bin/Release/CommonControls/.NET4 示例/MyDb.dll index 9e3a194..716755b 100644 Binary files a/Bin/Release/CommonControls/.NET4 示例/MyDb.dll and b/Bin/Release/CommonControls/.NET4 示例/MyDb.dll differ diff --git a/Bin/Release/CommonControls/.NET4 示例/MyDb.xml b/Bin/Release/CommonControls/.NET4 示例/MyDb.xml index d0448da..7c2a910 100644 --- a/Bin/Release/CommonControls/.NET4 示例/MyDb.xml +++ b/Bin/Release/CommonControls/.NET4 示例/MyDb.xml @@ -2265,7 +2265,7 @@ - + 判断鼠标位置是不是在指定的矩形中 @@ -4921,195 +4921,11 @@ Win32 API - - - - - - - - - - - - - - - - - - - - - - - - - - - 获取当前前台窗口句柄 - - - - - - 获得当前活动窗体 - - - - - - 设置活动窗体 - - - - - - - 获取类名 - - - - - - - - - 获取当前线程对应的进程ID - - - - - - - - 判断指定句柄是否是一个窗口 - - - - - - - 获取窗口标题 - - - - - - - - - 查找窗口 - - - - - - - - 设置父窗口 - - - - - - - - 移动窗口 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 结束进程 - - - - - - - - 发送消息 - - - - - - - - - - 发送消息 - - - - - - - - - 获取窗口位置和大小 - - - - - - - - 矩形 - - - - - 最左坐标 - - - - - 最上坐标 - - - - - 最右坐标 - - - - - 最下坐标 - - WM_COPYDATA消息的主要目的是允许在进程间传递只读数据。 @@ -5125,26 +4941,6 @@ 用户通道ID - - - - - - - - - - - - - - - - - - - - 获取消息 @@ -5172,6 +4968,19 @@ + + + + + + + + 结束进程 + + + + + @@ -5282,6 +5091,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -5326,12 +5155,12 @@ - + - + 模拟鼠标点击 @@ -5342,7 +5171,7 @@ - + 模拟按键 @@ -5351,16 +5180,16 @@ - + - + - + 移动窗口 @@ -5370,7 +5199,27 @@ - + + + + + + + + + + + + + + + + + + + + + @@ -5378,14 +5227,90 @@ - + The GetParent function retrieves a handle to the specified window's parent or owner. Handle to the window whose parent window handle is to be retrieved. If the window is a child window, the return value is a handle to the parent window. If the window is a top-level window, the return value is a handle to the owner window. If the window is a top-level unowned window or if the function fails, the return value is NULL. - + + + + + + + + + + + + + + + + + + + + + + + + + + + 获取当前前台窗口句柄 + + + + + + 获得当前活动窗体 + + + + + + 设置活动窗体 + + + + + + + 获取类名 + + + + + + + + + 获取当前线程对应的进程ID + + + + + + + + 判断指定句柄是否是一个窗口 + + + + + + + 获取窗口标题 + + + + + + + @@ -5395,7 +5320,7 @@ - + @@ -5405,7 +5330,7 @@ - + @@ -5415,21 +5340,48 @@ - + + + 发送消息 + + + + + + + + + + 发送消息 + + + + + + + - + - + + + 查找窗口 + + + + + + The FindWindowEx function retrieves a handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the specified child window. @@ -5439,7 +5391,7 @@ Pointer to a null-terminated string that specifies the window name (the window's title). If the function succeeds, the return value is a handle to the window that has the specified class and window names.If the function fails, the return value is NULL. - + The InvalidateRect function adds a rectangle to the specified window's update region. @@ -5448,7 +5400,7 @@ Erase state. If the function succeeds, the return value is true.If the function fails, the return value is false. - + The ValidateRect function validates the client area within a rectangle by removing the rectangle from the update region of the specified window. @@ -5456,7 +5408,7 @@ Validation rectangle coordinates. If the function succeeds, the return value is true.If the function fails, the return value is false. - + @@ -5464,14 +5416,14 @@ - + - + @@ -5479,7 +5431,7 @@ - + @@ -5487,7 +5439,7 @@ - + @@ -5495,7 +5447,7 @@ - + @@ -5510,7 +5462,7 @@ - + @@ -5519,7 +5471,7 @@ - + Changes the size, position, and Z order of a child, pop-up, or top-level window. These windows are ordered according to their appearance on the screen. @@ -5534,7 +5486,7 @@ Specifies the window sizing and positioning flags. This parameter can be a combination of the following values. If the function succeeds, the return value is nonzero, if the function fails, the return value is zero. - + diff --git a/Bin/Release/CommonControls/.NET4 示例/MyDb_SQLite.dll b/Bin/Release/CommonControls/.NET4 示例/MyDb_SQLite.dll index 4e0df6a..91ab9c9 100644 Binary files a/Bin/Release/CommonControls/.NET4 示例/MyDb_SQLite.dll and b/Bin/Release/CommonControls/.NET4 示例/MyDb_SQLite.dll differ diff --git a/Bin/Release/CommonControls/.NET4 示例/RyPrint.dll b/Bin/Release/CommonControls/.NET4 示例/RyPrint.dll index 34cc36c..70fa08b 100644 Binary files a/Bin/Release/CommonControls/.NET4 示例/RyPrint.dll and b/Bin/Release/CommonControls/.NET4 示例/RyPrint.dll differ diff --git a/Bin/Release/CommonControls/.NET4 示例/RyWeb.dll b/Bin/Release/CommonControls/.NET4 示例/RyWeb.dll index b74266b..f6d810a 100644 Binary files a/Bin/Release/CommonControls/.NET4 示例/RyWeb.dll and b/Bin/Release/CommonControls/.NET4 示例/RyWeb.dll differ diff --git a/Bin/Release/CommonControls/.NET4 示例/ryControls.dll b/Bin/Release/CommonControls/.NET4 示例/ryControls.dll index 1a16cd4..a2b8852 100644 Binary files a/Bin/Release/CommonControls/.NET4 示例/ryControls.dll and b/Bin/Release/CommonControls/.NET4 示例/ryControls.dll differ diff --git a/Bin/Release/CommonControls/.NET4 示例/ryControls.xml b/Bin/Release/CommonControls/.NET4 示例/ryControls.xml index bdc5975..6f16ded 100644 --- a/Bin/Release/CommonControls/.NET4 示例/ryControls.xml +++ b/Bin/Release/CommonControls/.NET4 示例/ryControls.xml @@ -6534,271 +6534,6 @@ 清空所有控件 - - - 鼠标的当前位置 - - - - - - - - - - - - - - - - - - - - 控件的状态。 - - - - - 正常 - - - - - 鼠标经过 - - - - - 鼠标按下 - - - - - 建立圆角路径的样式。 - - - - - 四个角都不是圆角。 - - - - - 四个角都为圆角。 - - - - - 左边两个角为圆角。 - - - - - 右边两个角为圆角。 - - - - - 上边两个角为圆角。 - - - - - 下边两个角为圆角。 - - - - - 左下角为圆角。 - - - - - 右下角为圆角。 - - - - - - - - - - 普通按钮按下事件 - - - - - 分割按钮按下事件 - - - - - - - - - - 下拉菜单与按钮的距离 - - - - - 图片高度 - - - - - 分割按钮的宽度 - - - - - 当鼠标按下时图片和文字是否产生偏移 - - - - - 是否一直显示按钮边框,设置为false则只在鼠标经过和按下时显示边框 - - - - - 当显示分割按钮时,分割按钮的箭头颜色 - - - - - 按钮的边框颜色 - - - - - 按钮内边框颜色 - - - - - 鼠标经过和按下时按钮的渐变背景颜色 - - - - - 鼠标经过和按下时按钮的渐变背景颜色 - - - - - 图片宽度 - - - - - 图片高度 - - - - - 按钮圆角样式 - - - - - 按钮圆角弧度 - - - - - 图片与文字之间的间距 - - - - - 按钮当前状态 - - - - - 鼠标当前所在位置 - - - - - 普通按钮矩形位置 - - - - - 分割按钮矩形位置 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 获取图像以及文字的位置 - - - - - - - - 画边框与背景 - - - - - 画分割按钮 - - - - - - - - - - - - 建立带有圆角样式的矩形路径 - - 用来建立路径的矩形。 - 圆角的大小 - 圆角的样式 - 是否把矩形长宽减 1,以便画出边框 - 建立的路径 - This enum represents the possible browser commands @@ -7974,6 +7709,1343 @@ + + + a form that supports custom theme + + + + + 标签新建按钮事件 + + + + + 标签关闭按钮事件 + + + + + 标签创建时事件 + + + + + 在标签栏创建时激发 + + + + + + + 内边距 + + + + + 默认内边距 + + + + + 标题 + + + + + 皮肤/主题 + + + + + 是否可拖动改变窗体大小 + + + + + 窗体边界大小,鼠标移动到该边界将变成指针形状,拖动可改变窗体大小 + + + + + 窗体边框大小 + + + + + 标题栏高度 + + + + + 窗体圆角程度 + + + + + 窗体圆角样式 + + + + + 控制按钮相对于右上角的偏移量 + + + + + 关闭/最大化/最小化按钮之间的距离,可以设置成负值使它们重叠 + + + + + 标题栏图标尺寸 + + + + + 标题栏图标与窗体左边框的距离 + + + + + 标题距离左边的距离 + + + + + 窗体关闭按钮的尺寸 + + + + + 窗体最大化/还原按钮的大小 + + + + + 窗体最小化按钮的大小 + + + + + 是否显示阴影 + + + + + 窗体阴影宽度 + + + + + 使用阴影来缩放 + + + + + 窗体阴影颜色 + + + + + 阴影从里到外是逐渐变浅的,这个值设置深色部分的透明度,ARGB中的A值 + + + + + 阴影从里到外是逐渐变浅的,这个值设置浅色部分的透明度,ARGB中的A值 + + + + + 表示去掉自画的边框及标题栏后,剩下的可用的客户区区域,坐标相对于窗体左上角 + + + + + 表示去掉自画的边框及标题栏后,剩下的可用的客户区大小 + + + + + 表示MDI标签栏的区域,包括bottom-region + + + + + MGdUI皮肤 + + + + + 获取子窗体 + + + + + + 通过sendmessage方式激活子窗体以避免闪烁 + + + + + + 当子窗体关闭时激发 + + + + + + + 子窗体可视化变化 + + + + + + + 获取当前的子窗体列表 + + + + + + 判断所接收到的 wm_nc-calc-size 消息是否指示窗体即将最小化 + + + + + 判断所接收到的 wm_nc-calc-size 消息是否指示窗体即将最大化 + + + + + to make the client area to have 3D view + + + + + 消息 + + + + + + 画UI + + + + + + 在画背景时激发 + + + + + + 重写该方法解决窗体每次还原都会变大的问题 + + + + + 重写该方法解决在VS设计器中,每次保存一个新的尺寸,再打开尺寸会变大的问题 + + + + + 创建控件时激发 + + + + + 窗体可见变化时激发 + + + + + + 大小改变时激发 + + + + + + 在位置变化时激发 + + + + + + 窗体激活 + + + + + + 窗体关闭后激发 + + + + + + 加载时 + + + + + + 在子窗体激活时激发 + + + + + + 标签菜单 + + + + + 窗体上移动鼠标时激发 + + + + + + 获取当前点击的标签项 + + + + + 在窗体上按下鼠标时激发 + + + + + + 在窗体上放开鼠标时激发 + + + + + + 在鼠标离开窗体时激发 + + + + + + Required designer variable. + + + + + Clean up any resources being used. + + true if managed resources should be disposed; otherwise, false. + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + Required designer variable. + + + + + Clean up any resources being used. + + true if managed resources should be disposed; otherwise, false. + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + 该类处理mdi-bar的绘制及鼠标事件管理 + + + + + use left,top,right to location the bar in owner form, + the margin is from Form.ClientRectangle + + + + + 整个标签栏高度,包含标签栏底部区域、标签、标签顶部空隙 + + + + + 标签栏底部区域的高度 + + + + + 是否显示标签栏边框 + + + + + 是否显示标签栏背景 + + + + + 标签栏左内边距 + + + + + 标签栏右内边距 + + + + + 标签高度 + + + + + 激活的标签高度 + + + + + tab顶部与bar顶部的空间,这个值用来计算 BarHeight + + + + + 每个标签的左右边界可以不是垂直的,而是都有一个斜度 + + + + + tab与tab之间的距离,用负值可以使tab有重叠的效果 + + + + + 标签是否显示图标 + + + + + 是否显示标签关闭按钮 + + + + + 标签图标大小 + + + + + 标签图标距离左边的距离 + + + + + 标签文字距离左边的距离 + + + + + 标签关闭按钮的大小 + + + + + 标签关闭按钮距离右边的距离 + + + + + 是否显示新建标签按钮 + + + + + 新建标签按钮的大小 + + + + + 新建标签距离左边的距离 + + + + + 按钮与Bar底部的距离 + + + + + 一个tab允许的最小宽度 + + + + + 一个tab允许的最大显示宽度 + + + + + 标签正常宽度 + + + + + 同步_listTabItems与mdi主窗体实际存在的子form + + + + + 为每个tab分配空间,如果tab数目太多,则有些会被隐藏 + + + + + 重绘整个标签栏 + + + + + + 处理鼠标事件。该方法会触发一些click事件,重刷一些按钮等 + + + + + + + 该类表示一个单独的标签项 + + + + + 该标签所对应的窗体 + + + + + 最终分配到的整个tab的宽度 + + + + + 表示所对应的form是否仍未被关闭 + + + + + 是否因空间不足而被隐藏 + + + + + 返回全部显示该标签文本所需的长度 + + + + + + 返回显示全部文本时该tab所需的宽度,该宽度不超过bar-container + 规定的tabmaxwidth + + + + + + 居左 + + + + + 显示在最后一个标签后面 + + + + + 该类封装设置一个主题所需的信息,可以继承该类实现不同的主题 + + + + + 主题名称,用于标识主题,对主题进行简单描述 + + + + + 窗体边界大小,鼠标移动到该边界将变成指针形状,拖动可改变窗体大小 + + + + + 窗体边框大小 + + + + + 窗体标题栏高度 + + + + + 标题栏图标与窗体左边框的距离 + + + + + 标题栏图标尺寸 + + + + + 标题栏文本左边距 + + + + + 控制按钮(关闭按钮)相对于窗体右上角的偏移量 + + + + + 窗体关闭按钮的尺寸 + + + + + 窗体最大化/还原按钮的大小 + + + + + 窗体最小化按钮的大小 + + + + + 关闭/最大化/最小化按钮之间的距离,可以设置成负值使它们重叠 + + + + + 窗体圆角程度 + + + + + 窗体圆角样式 + + + + + 是否使用默认的圆角样式,该样式为左上角和右上角圆角, + 最好在窗体边框较粗时才使用该样式 + + + + + 是否在标题栏上绘制图标 + + + + + 是否在标题栏上绘制文本 + + + + + 是否显示窗体阴影 + + + + + 窗体阴影大小 + + + + + 拖动窗体阴影是否可以改变窗体大小 + + + + + 阴影的颜色,可以设置成其他颜色而不一定是黑色 + + + + + 阴影从里到外是逐渐变浅的,这个值设置深色部分的透明度,ARGB中的A值 + + + + + 阴影从里到外是逐渐变浅的,这个值设置浅色部分的透明度,ARGB中的A值 + + + + + 是否在客户区边界画线使其看起来有立体感 + + + + + 窗体标题栏文字是否居中显示 + + + + + 窗体边框最外一像素的颜色 + + + + + 窗体边框第二最外像素的颜色 + + + + + 窗体边框其他部分颜色,如果窗体边框大小大于2,则其他像素将用此颜色画出 + + + + + 标题栏颜色是从上到下渐变的,这个值设置上边的颜色值 + + + + + 标题栏颜色是从上到下渐变的,这个值设置下边的颜色值 + + + + + 标题栏文字颜色 + + + + + 窗体背景颜色,该值将覆盖窗体自带的BackColor属性值 + + + + + 窗体关闭按钮的颜色集合 + + + + + 窗体最大化/还原按钮的颜色集合 + + + + + 窗体最小化按钮的颜色集合 + + + + + 默认状态下关闭按钮背景图片 + + + + + 鼠标移过去时关闭按钮背景图片 + + + + + 鼠标按下时关闭按钮背景图片 + + + + + 默认状态下最大化按钮背景图片 + + + + + 鼠标移过去时最大化按钮背景图片 + + + + + 鼠标按下时最大化按钮背景图片 + + + + + 默认状态下恢复按钮背景图片 + + + + + 鼠标移过去时恢复按钮背景图片 + + + + + 鼠标按下时恢复按钮背景图片 + + + + + 默认状态下最小化按钮背景图片 + + + + + 鼠标移过去时最小化按钮背景图片 + + + + + 鼠标按下时最小化按钮背景图片 + + + + + 是否用SendMessage的方式切换子窗体,以避免子窗体切换时产生的闪烁 + + + + + Mdi-Bar与窗体左、上、右边界的距离,只用到这三个值,Bottom值没用到。 + 用这三个值来确定Mdi-Bar的宽度及其在窗体中的位置 + + + + + 内部左边空白,第一个标签将从这个空白距离之后开始 + + + + + 标签栏内部右边空白 + + + + + 标签栏背景颜色 + + + + + 标签栏边框颜色 + + + + + 标签栏背景图片 + + + + + 是否显示标签栏边框 + + + + + 标签栏下边区域的背景颜色 + + + + + 标签栏下边区域的高度 + + + + + 标签高度 + + + + + 被选中的标签高度,可以设置成与TabHeight不一样的值,以突出显示被选中状态 + + + + + 标签之间的距离,设成负值可以使标签有重叠的效果 + + + + + 标签的最大宽度,任何情况下标签都不能超过这个宽度 + + + + + 标签正常宽度,如果标签需要很短的宽度(比如20像素)就可以显示完上面的文字, + 但是Mdi-Bar上有足够的空间时,标签会以正常宽度(比如100像素)显示 + + + + + 标签最小宽度,当标签小于这个宽度时将被隐藏 + + + + + 标签梯度大小,标签可以不以矩形方式显示,而是有一个梯度/斜度。 + + + + + 标签顶部空白,这个值用于参与计算Mdi-Bar高度,计算方式为: + Mdi-Bar Height = BottomRegionHeight + TabHeight + TabTopSpace + + + + + 标签上是否显示子窗体图标 + + + + + 标签上是否显示子窗体关闭图标 + + + + + 选中状态的标签的上部背景色,与下部背景色不同时,标签背景色就有渐变效果 + + + + + 选中状态的标签的下部背景色,与上部背景色不同时,标签背景色就有渐变效果 + + + + + 标签激活时字体颜色 + + + + + 非选中状态的标签的字体颜色 + + + + + 非选中状态的标签的上部背景色 + + + + + 非选中状态的标签的下部背景色 + + + + + 标签外边框颜色 + + + + + 标签内边框颜色,这个颜色一般具有一定的透明度 + + + + + 是否显示标签边框 + + + + + 是否显示默认的新建标签按钮(NewTabBtn) + + + + + NewTabBtn与下边框的距离,这个值用来定位按钮的Y坐标 + + + + + 新建标签按钮与左边框的距离,这个值用来定位按钮的X坐标 + + + + + 新建标签按钮大小 + + + + + 按钮颜色集合 + + + + + 是否一直显示ListAllBtn,即使在没有标签被隐藏的情况下 + + + + + 《显示全部标签》按钮的位置 + + + + + 《显示全部标签》按钮与下边框的距离,这个值用来定位按钮的Y坐标 + + + + + 《显示全部标签》按钮与左边框的距离,这个值用来定位按钮的X坐标 + + + + + 《显示全部标签》按钮的颜色 + + + + + 《显示全部标签》按钮的大小 + + + + + 皮肤主题 + + + + + 引发 ValueChanged 事件 + + + + + + 引发 ThemeChanged 事件 + + + + + + 指示鼠标位于哪个区域 + + + + + 控件Value值发生变化后引发 + + + + + 控件绘制MainLine前引发, 可以设置Cancel参数来取消默认的绘制 + + + + + 控件绘制Button前引发 + + + + + 引发 ValueChanged 事件 + + + + + 引发 BeforePaintMainLine 事件 + + + + + 引发 BeforePaintButton 事件 + + + + + 将Value值加一个LargeChange量 + + + + + 将Value值减一个LargeChange量 + + + + + 将Value值加一个SmallChange量 + + + + + 将Value值减一个SmallChange量 + + + + + 提供产生各种路径的静态方法,比如圆角路径、关闭按钮上的x路径、+号路径 + + + + + 圆角样式 + + + + + 无 + + + + + 所有 + + + + + 上 + + + + + 下 + + + + + 左 + + + + + 右 + + + + + SimpleObject指的是只有一种状态(不像普通按钮一样有三种状态),并且其上的元素 + 布局比较简单的Object + + + + + + + + + + + + + + + + + + + + DevExpress风格皮肤 + + + + + DevExpress风格皮肤 + + + + + 新风格皮肤 + + + + + 新风格皮肤 + + + + + 基础皮肤 + + + + + VS2013风格皮肤 + + + + + this theme is just for chrome one quarter style + + + + + for diamond ring style only + + + + + Location of cursor hot spot returnet in WM_NCHITTEST. + + + + + On the screen background or on a dividing line between windows + (same as HTNOWHERE, except that the DefWindowProc function produces a system beep to indicate an error). + + + + + In a window currently covered by another window in the same thread + (the message will be sent to underlying windows in the same thread until one of them returns a code that is not HTTRANSPARENT). + + + + + On the screen background or on a dividing line between windows. + + + + In a client area. + + + In a title bar. + + + In a window menu or in a Close button in a child window. + + + In a size box (same as HTSIZE). + + + In a menu. + + + In a horizontal scroll bar. + + + In the vertical scroll bar. + + + In a Minimize button. + + + In a Maximize button. + + + In the left border of a resizable window + (the user can click the mouse to resize the window horizontally). + + + + In the right border of a resizable window + (the user can click the mouse to resize the window horizontally). + + + + In the upper-horizontal border of a window. + + + In the upper-left corner of a window border. + + + In the upper-right corner of a window border. + + + In the lower-horizontal border of a resizable window + (the user can click the mouse to resize the window vertically). + + + In the lower-left corner of a border of a resizable window + (the user can click the mouse to resize the window diagonally). + + + In the lower-right corner of a border of a resizable window + (the user can click the mouse to resize the window diagonally). + + + In the border of a window that does not have a sizing border. + + + In a Close button. + + + In a Help button. + + + + Contains the new coordinates of a window that has been moved or resized, that is, it is the proposed new window coordinates. + + + + + Contains the coordinates of the window before it was moved or resized. + + + + + Contains the coordinates of the window's client area before the window was moved or resized. + + + + + Pointer to a WINDOWPOS structure that contains the size and position values specified in the operation that moved or resized the window. + + + + + + + + + + 是否在这个按钮上按下了鼠标未释放 + + + + + 是否可见 + + + + + + + + + + 画两次可以加深颜色 + + + + + 用于在click事件中传回数据 + + + + + 获取或设置是否将绘制完全限制在指定的区域内 + + + + + + + + + + + + + + 线条图 diff --git a/Bin/Release/CommonControls/.NET4 示例/ryUpdate.dll b/Bin/Release/CommonControls/.NET4 示例/ryUpdate.dll index 5834986..c5773f7 100644 Binary files a/Bin/Release/CommonControls/.NET4 示例/ryUpdate.dll and b/Bin/Release/CommonControls/.NET4 示例/ryUpdate.dll differ diff --git a/Bin/Release/CommonControls/.NET4/MyDb.dll b/Bin/Release/CommonControls/.NET4/MyDb.dll index 9e3a194..716755b 100644 Binary files a/Bin/Release/CommonControls/.NET4/MyDb.dll and b/Bin/Release/CommonControls/.NET4/MyDb.dll differ diff --git a/Bin/Release/CommonControls/.NET4/MyDb.xml b/Bin/Release/CommonControls/.NET4/MyDb.xml index d0448da..7c2a910 100644 --- a/Bin/Release/CommonControls/.NET4/MyDb.xml +++ b/Bin/Release/CommonControls/.NET4/MyDb.xml @@ -2265,7 +2265,7 @@ - + 判断鼠标位置是不是在指定的矩形中 @@ -4921,195 +4921,11 @@ Win32 API - - - - - - - - - - - - - - - - - - - - - - - - - - - 获取当前前台窗口句柄 - - - - - - 获得当前活动窗体 - - - - - - 设置活动窗体 - - - - - - - 获取类名 - - - - - - - - - 获取当前线程对应的进程ID - - - - - - - - 判断指定句柄是否是一个窗口 - - - - - - - 获取窗口标题 - - - - - - - - - 查找窗口 - - - - - - - - 设置父窗口 - - - - - - - - 移动窗口 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 结束进程 - - - - - - - - 发送消息 - - - - - - - - - - 发送消息 - - - - - - - - - 获取窗口位置和大小 - - - - - - - - 矩形 - - - - - 最左坐标 - - - - - 最上坐标 - - - - - 最右坐标 - - - - - 最下坐标 - - WM_COPYDATA消息的主要目的是允许在进程间传递只读数据。 @@ -5125,26 +4941,6 @@ 用户通道ID - - - - - - - - - - - - - - - - - - - - 获取消息 @@ -5172,6 +4968,19 @@ + + + + + + + + 结束进程 + + + + + @@ -5282,6 +5091,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -5326,12 +5155,12 @@ - + - + 模拟鼠标点击 @@ -5342,7 +5171,7 @@ - + 模拟按键 @@ -5351,16 +5180,16 @@ - + - + - + 移动窗口 @@ -5370,7 +5199,27 @@ - + + + + + + + + + + + + + + + + + + + + + @@ -5378,14 +5227,90 @@ - + The GetParent function retrieves a handle to the specified window's parent or owner. Handle to the window whose parent window handle is to be retrieved. If the window is a child window, the return value is a handle to the parent window. If the window is a top-level window, the return value is a handle to the owner window. If the window is a top-level unowned window or if the function fails, the return value is NULL. - + + + + + + + + + + + + + + + + + + + + + + + + + + + 获取当前前台窗口句柄 + + + + + + 获得当前活动窗体 + + + + + + 设置活动窗体 + + + + + + + 获取类名 + + + + + + + + + 获取当前线程对应的进程ID + + + + + + + + 判断指定句柄是否是一个窗口 + + + + + + + 获取窗口标题 + + + + + + + @@ -5395,7 +5320,7 @@ - + @@ -5405,7 +5330,7 @@ - + @@ -5415,21 +5340,48 @@ - + + + 发送消息 + + + + + + + + + + 发送消息 + + + + + + + - + - + + + 查找窗口 + + + + + + The FindWindowEx function retrieves a handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the specified child window. @@ -5439,7 +5391,7 @@ Pointer to a null-terminated string that specifies the window name (the window's title). If the function succeeds, the return value is a handle to the window that has the specified class and window names.If the function fails, the return value is NULL. - + The InvalidateRect function adds a rectangle to the specified window's update region. @@ -5448,7 +5400,7 @@ Erase state. If the function succeeds, the return value is true.If the function fails, the return value is false. - + The ValidateRect function validates the client area within a rectangle by removing the rectangle from the update region of the specified window. @@ -5456,7 +5408,7 @@ Validation rectangle coordinates. If the function succeeds, the return value is true.If the function fails, the return value is false. - + @@ -5464,14 +5416,14 @@ - + - + @@ -5479,7 +5431,7 @@ - + @@ -5487,7 +5439,7 @@ - + @@ -5495,7 +5447,7 @@ - + @@ -5510,7 +5462,7 @@ - + @@ -5519,7 +5471,7 @@ - + Changes the size, position, and Z order of a child, pop-up, or top-level window. These windows are ordered according to their appearance on the screen. @@ -5534,7 +5486,7 @@ Specifies the window sizing and positioning flags. This parameter can be a combination of the following values. If the function succeeds, the return value is nonzero, if the function fails, the return value is zero. - + diff --git a/Bin/Release/CommonControls/.NET4/MyDb_MSSQL.dll b/Bin/Release/CommonControls/.NET4/MyDb_MSSQL.dll index 8b9c804..b4403d7 100644 Binary files a/Bin/Release/CommonControls/.NET4/MyDb_MSSQL.dll and b/Bin/Release/CommonControls/.NET4/MyDb_MSSQL.dll differ diff --git a/Bin/Release/CommonControls/.NET4/MyDb_MySQL.dll b/Bin/Release/CommonControls/.NET4/MyDb_MySQL.dll index 12727d9..07c6248 100644 Binary files a/Bin/Release/CommonControls/.NET4/MyDb_MySQL.dll and b/Bin/Release/CommonControls/.NET4/MyDb_MySQL.dll differ diff --git a/Bin/Release/CommonControls/.NET4/MyDb_SQLite.dll b/Bin/Release/CommonControls/.NET4/MyDb_SQLite.dll index 4e0df6a..91ab9c9 100644 Binary files a/Bin/Release/CommonControls/.NET4/MyDb_SQLite.dll and b/Bin/Release/CommonControls/.NET4/MyDb_SQLite.dll differ diff --git a/Bin/Release/CommonControls/.NET4/RyPrint.dll b/Bin/Release/CommonControls/.NET4/RyPrint.dll index 34cc36c..70fa08b 100644 Binary files a/Bin/Release/CommonControls/.NET4/RyPrint.dll and b/Bin/Release/CommonControls/.NET4/RyPrint.dll differ diff --git a/Bin/Release/CommonControls/.NET4/RyWeb.dll b/Bin/Release/CommonControls/.NET4/RyWeb.dll index 1130d1f..39ae469 100644 Binary files a/Bin/Release/CommonControls/.NET4/RyWeb.dll and b/Bin/Release/CommonControls/.NET4/RyWeb.dll differ diff --git a/Bin/Release/CommonControls/.NET4/ryControls.dll b/Bin/Release/CommonControls/.NET4/ryControls.dll index 1a16cd4..a2b8852 100644 Binary files a/Bin/Release/CommonControls/.NET4/ryControls.dll and b/Bin/Release/CommonControls/.NET4/ryControls.dll differ diff --git a/Bin/Release/CommonControls/.NET4/ryControls.xml b/Bin/Release/CommonControls/.NET4/ryControls.xml index bdc5975..6f16ded 100644 --- a/Bin/Release/CommonControls/.NET4/ryControls.xml +++ b/Bin/Release/CommonControls/.NET4/ryControls.xml @@ -6534,271 +6534,6 @@ 清空所有控件 - - - 鼠标的当前位置 - - - - - - - - - - - - - - - - - - - - 控件的状态。 - - - - - 正常 - - - - - 鼠标经过 - - - - - 鼠标按下 - - - - - 建立圆角路径的样式。 - - - - - 四个角都不是圆角。 - - - - - 四个角都为圆角。 - - - - - 左边两个角为圆角。 - - - - - 右边两个角为圆角。 - - - - - 上边两个角为圆角。 - - - - - 下边两个角为圆角。 - - - - - 左下角为圆角。 - - - - - 右下角为圆角。 - - - - - - - - - - 普通按钮按下事件 - - - - - 分割按钮按下事件 - - - - - - - - - - 下拉菜单与按钮的距离 - - - - - 图片高度 - - - - - 分割按钮的宽度 - - - - - 当鼠标按下时图片和文字是否产生偏移 - - - - - 是否一直显示按钮边框,设置为false则只在鼠标经过和按下时显示边框 - - - - - 当显示分割按钮时,分割按钮的箭头颜色 - - - - - 按钮的边框颜色 - - - - - 按钮内边框颜色 - - - - - 鼠标经过和按下时按钮的渐变背景颜色 - - - - - 鼠标经过和按下时按钮的渐变背景颜色 - - - - - 图片宽度 - - - - - 图片高度 - - - - - 按钮圆角样式 - - - - - 按钮圆角弧度 - - - - - 图片与文字之间的间距 - - - - - 按钮当前状态 - - - - - 鼠标当前所在位置 - - - - - 普通按钮矩形位置 - - - - - 分割按钮矩形位置 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 获取图像以及文字的位置 - - - - - - - - 画边框与背景 - - - - - 画分割按钮 - - - - - - - - - - - - 建立带有圆角样式的矩形路径 - - 用来建立路径的矩形。 - 圆角的大小 - 圆角的样式 - 是否把矩形长宽减 1,以便画出边框 - 建立的路径 - This enum represents the possible browser commands @@ -7974,6 +7709,1343 @@ + + + a form that supports custom theme + + + + + 标签新建按钮事件 + + + + + 标签关闭按钮事件 + + + + + 标签创建时事件 + + + + + 在标签栏创建时激发 + + + + + + + 内边距 + + + + + 默认内边距 + + + + + 标题 + + + + + 皮肤/主题 + + + + + 是否可拖动改变窗体大小 + + + + + 窗体边界大小,鼠标移动到该边界将变成指针形状,拖动可改变窗体大小 + + + + + 窗体边框大小 + + + + + 标题栏高度 + + + + + 窗体圆角程度 + + + + + 窗体圆角样式 + + + + + 控制按钮相对于右上角的偏移量 + + + + + 关闭/最大化/最小化按钮之间的距离,可以设置成负值使它们重叠 + + + + + 标题栏图标尺寸 + + + + + 标题栏图标与窗体左边框的距离 + + + + + 标题距离左边的距离 + + + + + 窗体关闭按钮的尺寸 + + + + + 窗体最大化/还原按钮的大小 + + + + + 窗体最小化按钮的大小 + + + + + 是否显示阴影 + + + + + 窗体阴影宽度 + + + + + 使用阴影来缩放 + + + + + 窗体阴影颜色 + + + + + 阴影从里到外是逐渐变浅的,这个值设置深色部分的透明度,ARGB中的A值 + + + + + 阴影从里到外是逐渐变浅的,这个值设置浅色部分的透明度,ARGB中的A值 + + + + + 表示去掉自画的边框及标题栏后,剩下的可用的客户区区域,坐标相对于窗体左上角 + + + + + 表示去掉自画的边框及标题栏后,剩下的可用的客户区大小 + + + + + 表示MDI标签栏的区域,包括bottom-region + + + + + MGdUI皮肤 + + + + + 获取子窗体 + + + + + + 通过sendmessage方式激活子窗体以避免闪烁 + + + + + + 当子窗体关闭时激发 + + + + + + + 子窗体可视化变化 + + + + + + + 获取当前的子窗体列表 + + + + + + 判断所接收到的 wm_nc-calc-size 消息是否指示窗体即将最小化 + + + + + 判断所接收到的 wm_nc-calc-size 消息是否指示窗体即将最大化 + + + + + to make the client area to have 3D view + + + + + 消息 + + + + + + 画UI + + + + + + 在画背景时激发 + + + + + + 重写该方法解决窗体每次还原都会变大的问题 + + + + + 重写该方法解决在VS设计器中,每次保存一个新的尺寸,再打开尺寸会变大的问题 + + + + + 创建控件时激发 + + + + + 窗体可见变化时激发 + + + + + + 大小改变时激发 + + + + + + 在位置变化时激发 + + + + + + 窗体激活 + + + + + + 窗体关闭后激发 + + + + + + 加载时 + + + + + + 在子窗体激活时激发 + + + + + + 标签菜单 + + + + + 窗体上移动鼠标时激发 + + + + + + 获取当前点击的标签项 + + + + + 在窗体上按下鼠标时激发 + + + + + + 在窗体上放开鼠标时激发 + + + + + + 在鼠标离开窗体时激发 + + + + + + Required designer variable. + + + + + Clean up any resources being used. + + true if managed resources should be disposed; otherwise, false. + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + Required designer variable. + + + + + Clean up any resources being used. + + true if managed resources should be disposed; otherwise, false. + + + + Required method for Designer support - do not modify + the contents of this method with the code editor. + + + + + 该类处理mdi-bar的绘制及鼠标事件管理 + + + + + use left,top,right to location the bar in owner form, + the margin is from Form.ClientRectangle + + + + + 整个标签栏高度,包含标签栏底部区域、标签、标签顶部空隙 + + + + + 标签栏底部区域的高度 + + + + + 是否显示标签栏边框 + + + + + 是否显示标签栏背景 + + + + + 标签栏左内边距 + + + + + 标签栏右内边距 + + + + + 标签高度 + + + + + 激活的标签高度 + + + + + tab顶部与bar顶部的空间,这个值用来计算 BarHeight + + + + + 每个标签的左右边界可以不是垂直的,而是都有一个斜度 + + + + + tab与tab之间的距离,用负值可以使tab有重叠的效果 + + + + + 标签是否显示图标 + + + + + 是否显示标签关闭按钮 + + + + + 标签图标大小 + + + + + 标签图标距离左边的距离 + + + + + 标签文字距离左边的距离 + + + + + 标签关闭按钮的大小 + + + + + 标签关闭按钮距离右边的距离 + + + + + 是否显示新建标签按钮 + + + + + 新建标签按钮的大小 + + + + + 新建标签距离左边的距离 + + + + + 按钮与Bar底部的距离 + + + + + 一个tab允许的最小宽度 + + + + + 一个tab允许的最大显示宽度 + + + + + 标签正常宽度 + + + + + 同步_listTabItems与mdi主窗体实际存在的子form + + + + + 为每个tab分配空间,如果tab数目太多,则有些会被隐藏 + + + + + 重绘整个标签栏 + + + + + + 处理鼠标事件。该方法会触发一些click事件,重刷一些按钮等 + + + + + + + 该类表示一个单独的标签项 + + + + + 该标签所对应的窗体 + + + + + 最终分配到的整个tab的宽度 + + + + + 表示所对应的form是否仍未被关闭 + + + + + 是否因空间不足而被隐藏 + + + + + 返回全部显示该标签文本所需的长度 + + + + + + 返回显示全部文本时该tab所需的宽度,该宽度不超过bar-container + 规定的tabmaxwidth + + + + + + 居左 + + + + + 显示在最后一个标签后面 + + + + + 该类封装设置一个主题所需的信息,可以继承该类实现不同的主题 + + + + + 主题名称,用于标识主题,对主题进行简单描述 + + + + + 窗体边界大小,鼠标移动到该边界将变成指针形状,拖动可改变窗体大小 + + + + + 窗体边框大小 + + + + + 窗体标题栏高度 + + + + + 标题栏图标与窗体左边框的距离 + + + + + 标题栏图标尺寸 + + + + + 标题栏文本左边距 + + + + + 控制按钮(关闭按钮)相对于窗体右上角的偏移量 + + + + + 窗体关闭按钮的尺寸 + + + + + 窗体最大化/还原按钮的大小 + + + + + 窗体最小化按钮的大小 + + + + + 关闭/最大化/最小化按钮之间的距离,可以设置成负值使它们重叠 + + + + + 窗体圆角程度 + + + + + 窗体圆角样式 + + + + + 是否使用默认的圆角样式,该样式为左上角和右上角圆角, + 最好在窗体边框较粗时才使用该样式 + + + + + 是否在标题栏上绘制图标 + + + + + 是否在标题栏上绘制文本 + + + + + 是否显示窗体阴影 + + + + + 窗体阴影大小 + + + + + 拖动窗体阴影是否可以改变窗体大小 + + + + + 阴影的颜色,可以设置成其他颜色而不一定是黑色 + + + + + 阴影从里到外是逐渐变浅的,这个值设置深色部分的透明度,ARGB中的A值 + + + + + 阴影从里到外是逐渐变浅的,这个值设置浅色部分的透明度,ARGB中的A值 + + + + + 是否在客户区边界画线使其看起来有立体感 + + + + + 窗体标题栏文字是否居中显示 + + + + + 窗体边框最外一像素的颜色 + + + + + 窗体边框第二最外像素的颜色 + + + + + 窗体边框其他部分颜色,如果窗体边框大小大于2,则其他像素将用此颜色画出 + + + + + 标题栏颜色是从上到下渐变的,这个值设置上边的颜色值 + + + + + 标题栏颜色是从上到下渐变的,这个值设置下边的颜色值 + + + + + 标题栏文字颜色 + + + + + 窗体背景颜色,该值将覆盖窗体自带的BackColor属性值 + + + + + 窗体关闭按钮的颜色集合 + + + + + 窗体最大化/还原按钮的颜色集合 + + + + + 窗体最小化按钮的颜色集合 + + + + + 默认状态下关闭按钮背景图片 + + + + + 鼠标移过去时关闭按钮背景图片 + + + + + 鼠标按下时关闭按钮背景图片 + + + + + 默认状态下最大化按钮背景图片 + + + + + 鼠标移过去时最大化按钮背景图片 + + + + + 鼠标按下时最大化按钮背景图片 + + + + + 默认状态下恢复按钮背景图片 + + + + + 鼠标移过去时恢复按钮背景图片 + + + + + 鼠标按下时恢复按钮背景图片 + + + + + 默认状态下最小化按钮背景图片 + + + + + 鼠标移过去时最小化按钮背景图片 + + + + + 鼠标按下时最小化按钮背景图片 + + + + + 是否用SendMessage的方式切换子窗体,以避免子窗体切换时产生的闪烁 + + + + + Mdi-Bar与窗体左、上、右边界的距离,只用到这三个值,Bottom值没用到。 + 用这三个值来确定Mdi-Bar的宽度及其在窗体中的位置 + + + + + 内部左边空白,第一个标签将从这个空白距离之后开始 + + + + + 标签栏内部右边空白 + + + + + 标签栏背景颜色 + + + + + 标签栏边框颜色 + + + + + 标签栏背景图片 + + + + + 是否显示标签栏边框 + + + + + 标签栏下边区域的背景颜色 + + + + + 标签栏下边区域的高度 + + + + + 标签高度 + + + + + 被选中的标签高度,可以设置成与TabHeight不一样的值,以突出显示被选中状态 + + + + + 标签之间的距离,设成负值可以使标签有重叠的效果 + + + + + 标签的最大宽度,任何情况下标签都不能超过这个宽度 + + + + + 标签正常宽度,如果标签需要很短的宽度(比如20像素)就可以显示完上面的文字, + 但是Mdi-Bar上有足够的空间时,标签会以正常宽度(比如100像素)显示 + + + + + 标签最小宽度,当标签小于这个宽度时将被隐藏 + + + + + 标签梯度大小,标签可以不以矩形方式显示,而是有一个梯度/斜度。 + + + + + 标签顶部空白,这个值用于参与计算Mdi-Bar高度,计算方式为: + Mdi-Bar Height = BottomRegionHeight + TabHeight + TabTopSpace + + + + + 标签上是否显示子窗体图标 + + + + + 标签上是否显示子窗体关闭图标 + + + + + 选中状态的标签的上部背景色,与下部背景色不同时,标签背景色就有渐变效果 + + + + + 选中状态的标签的下部背景色,与上部背景色不同时,标签背景色就有渐变效果 + + + + + 标签激活时字体颜色 + + + + + 非选中状态的标签的字体颜色 + + + + + 非选中状态的标签的上部背景色 + + + + + 非选中状态的标签的下部背景色 + + + + + 标签外边框颜色 + + + + + 标签内边框颜色,这个颜色一般具有一定的透明度 + + + + + 是否显示标签边框 + + + + + 是否显示默认的新建标签按钮(NewTabBtn) + + + + + NewTabBtn与下边框的距离,这个值用来定位按钮的Y坐标 + + + + + 新建标签按钮与左边框的距离,这个值用来定位按钮的X坐标 + + + + + 新建标签按钮大小 + + + + + 按钮颜色集合 + + + + + 是否一直显示ListAllBtn,即使在没有标签被隐藏的情况下 + + + + + 《显示全部标签》按钮的位置 + + + + + 《显示全部标签》按钮与下边框的距离,这个值用来定位按钮的Y坐标 + + + + + 《显示全部标签》按钮与左边框的距离,这个值用来定位按钮的X坐标 + + + + + 《显示全部标签》按钮的颜色 + + + + + 《显示全部标签》按钮的大小 + + + + + 皮肤主题 + + + + + 引发 ValueChanged 事件 + + + + + + 引发 ThemeChanged 事件 + + + + + + 指示鼠标位于哪个区域 + + + + + 控件Value值发生变化后引发 + + + + + 控件绘制MainLine前引发, 可以设置Cancel参数来取消默认的绘制 + + + + + 控件绘制Button前引发 + + + + + 引发 ValueChanged 事件 + + + + + 引发 BeforePaintMainLine 事件 + + + + + 引发 BeforePaintButton 事件 + + + + + 将Value值加一个LargeChange量 + + + + + 将Value值减一个LargeChange量 + + + + + 将Value值加一个SmallChange量 + + + + + 将Value值减一个SmallChange量 + + + + + 提供产生各种路径的静态方法,比如圆角路径、关闭按钮上的x路径、+号路径 + + + + + 圆角样式 + + + + + 无 + + + + + 所有 + + + + + 上 + + + + + 下 + + + + + 左 + + + + + 右 + + + + + SimpleObject指的是只有一种状态(不像普通按钮一样有三种状态),并且其上的元素 + 布局比较简单的Object + + + + + + + + + + + + + + + + + + + + DevExpress风格皮肤 + + + + + DevExpress风格皮肤 + + + + + 新风格皮肤 + + + + + 新风格皮肤 + + + + + 基础皮肤 + + + + + VS2013风格皮肤 + + + + + this theme is just for chrome one quarter style + + + + + for diamond ring style only + + + + + Location of cursor hot spot returnet in WM_NCHITTEST. + + + + + On the screen background or on a dividing line between windows + (same as HTNOWHERE, except that the DefWindowProc function produces a system beep to indicate an error). + + + + + In a window currently covered by another window in the same thread + (the message will be sent to underlying windows in the same thread until one of them returns a code that is not HTTRANSPARENT). + + + + + On the screen background or on a dividing line between windows. + + + + In a client area. + + + In a title bar. + + + In a window menu or in a Close button in a child window. + + + In a size box (same as HTSIZE). + + + In a menu. + + + In a horizontal scroll bar. + + + In the vertical scroll bar. + + + In a Minimize button. + + + In a Maximize button. + + + In the left border of a resizable window + (the user can click the mouse to resize the window horizontally). + + + + In the right border of a resizable window + (the user can click the mouse to resize the window horizontally). + + + + In the upper-horizontal border of a window. + + + In the upper-left corner of a window border. + + + In the upper-right corner of a window border. + + + In the lower-horizontal border of a resizable window + (the user can click the mouse to resize the window vertically). + + + In the lower-left corner of a border of a resizable window + (the user can click the mouse to resize the window diagonally). + + + In the lower-right corner of a border of a resizable window + (the user can click the mouse to resize the window diagonally). + + + In the border of a window that does not have a sizing border. + + + In a Close button. + + + In a Help button. + + + + Contains the new coordinates of a window that has been moved or resized, that is, it is the proposed new window coordinates. + + + + + Contains the coordinates of the window before it was moved or resized. + + + + + Contains the coordinates of the window's client area before the window was moved or resized. + + + + + Pointer to a WINDOWPOS structure that contains the size and position values specified in the operation that moved or resized the window. + + + + + + + + + + 是否在这个按钮上按下了鼠标未释放 + + + + + 是否可见 + + + + + + + + + + 画两次可以加深颜色 + + + + + 用于在click事件中传回数据 + + + + + 获取或设置是否将绘制完全限制在指定的区域内 + + + + + + + + + + + + + + 线条图 diff --git a/Bin/Release/CommonControls/.NET4/ryUpdate.dll b/Bin/Release/CommonControls/.NET4/ryUpdate.dll index 5834986..c5773f7 100644 Binary files a/Bin/Release/CommonControls/.NET4/ryUpdate.dll and b/Bin/Release/CommonControls/.NET4/ryUpdate.dll differ diff --git a/CHANGELOG.md b/CHANGELOG.md index bc31a23..a0f37eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ -### 2021-02-11更新 +### 2021-02-22更新 +------ +#### ryControls V2.1.2102.2201 +*.[新增]新加入Gdu.WinformUI控件。 + +### 2021-02-11更新 ------ #### MyDb V2.1.2102.1101 - *.[新增]新增Auto类,增加 鼠标模拟操作和按键模拟操作。 diff --git a/Source/.vs/公用控件组V4/v16/.suo b/Source/.vs/公用控件组V4/v16/.suo index 298fd28..b78dcb7 100644 Binary files a/Source/.vs/公用控件组V4/v16/.suo and b/Source/.vs/公用控件组V4/v16/.suo differ diff --git a/Source/Itrycn_Project2/FrmStart.cs b/Source/Itrycn_Project2/FrmStart.cs index b2d7838..52d0fd2 100644 --- a/Source/Itrycn_Project2/FrmStart.cs +++ b/Source/Itrycn_Project2/FrmStart.cs @@ -154,7 +154,8 @@ namespace Itrycn_Project2 //var point= button1.PointToScreen(button1.Location); // ryCommon.Auto.LeftClick(point.X+5, point.Y+5); textBox1.Focus(); - Auto.PasteText("你好"); + Auto.GetRect(Handle,out var size); + MessageBox.Show(size.ToString()); } } } diff --git a/Source/MyDb/Msg/CustomMsg.cs b/Source/MyDb/Msg/CustomMsg.cs index b5ff52e..5e85c41 100644 --- a/Source/MyDb/Msg/CustomMsg.cs +++ b/Source/MyDb/Msg/CustomMsg.cs @@ -58,7 +58,7 @@ namespace QuickMsg /// ~CustomMsg() { - MyDb.RyWin32.SetWindowLong(handle, MyDb.RyWin32.GWL_WNDPROC, oldWndFunc); + WinAPI.User32.SetWindowLong(handle, MyDb.RyWin32.GWL_WNDPROC, oldWndFunc); //System.Windows.Forms.Application.RemoveMessageFilter(this); } /// @@ -75,7 +75,7 @@ namespace QuickMsg /// public void DefWndProc(ref System.Windows.Forms.Message m) { - m.Result = MyDb.RyWin32.CallWindowProc(oldWndFunc, m.HWnd, m.Msg, m.WParam, m.LParam); + m.Result = WinAPI.User32.CallWindowProc(oldWndFunc, m.HWnd, m.Msg, m.WParam, m.LParam); if (m.Msg == MyDb.RyWin32.WM_COPYDATA) { var msg = MyDb.RyWin32.GetMsg(m, out IntPtr handle); diff --git a/Source/MyDb/Msg/MsgClient.cs b/Source/MyDb/Msg/MsgClient.cs index 892615d..e3d94c0 100644 --- a/Source/MyDb/Msg/MsgClient.cs +++ b/Source/MyDb/Msg/MsgClient.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; +using WinAPI; namespace QuickMsg { @@ -112,7 +113,7 @@ namespace QuickMsg /// public bool MainExist() { - return MyDb.RyWin32.IsWindow(main_handle); + return User32.IsWindow(main_handle); } private void MSG_OnMsg(object sender, MsgArgs e) { diff --git a/Source/MyDb/MyDbV4.csproj b/Source/MyDb/MyDbV4.csproj index 16504f4..0b890b9 100644 --- a/Source/MyDb/MyDbV4.csproj +++ b/Source/MyDb/MyDbV4.csproj @@ -100,6 +100,7 @@ + diff --git a/Source/MyDb/SysFuns/Auto.cs b/Source/MyDb/SysFuns/Auto.cs index 846d041..32348c9 100644 --- a/Source/MyDb/SysFuns/Auto.cs +++ b/Source/MyDb/SysFuns/Auto.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms; -using Win32API; +using WinAPI; namespace ryCommon { @@ -200,7 +200,7 @@ namespace ryCommon /// 坐标(屏幕坐标) public static void LeftClick(Point point) { - LeftClick(point.X, point.Y); + LeftClick(point.X, point.Y); } /// ///右键单击鼠标(不支持后台单击) @@ -266,7 +266,7 @@ namespace ryCommon Rectangle windowRect = new Rectangle(); size = new Size(0, 0); if (hdcSrc == IntPtr.Zero) { return windowRect; } - User32.GetWindowRect(handle, ref windowRect); + User32.GetWindowRect(handle, out windowRect); int width = windowRect.Right - windowRect.Left; int height = windowRect.Bottom - windowRect.Top; size = new Size(width, height); @@ -288,7 +288,7 @@ namespace ryCommon /// /// /// - public static bool IsInRect(MyDb.RyWin32.RECT rect, Point mouse_position) + public static bool IsInRect(Rectangle rect, Point mouse_position) { return mouse_position.X >= rect.Left && mouse_position.X <= rect.Right && mouse_position.Y >= rect.Top && mouse_position.Y <= rect.Bottom; } diff --git a/Source/MyDb/SysFuns/ModalResult.cs b/Source/MyDb/SysFuns/ModalResult.cs index fdb6885..ebcb8ba 100644 --- a/Source/MyDb/SysFuns/ModalResult.cs +++ b/Source/MyDb/SysFuns/ModalResult.cs @@ -1,5 +1,6 @@ using System; using System.Windows.Forms; +using WinAPI; namespace ryCommon { @@ -87,7 +88,7 @@ namespace ryCommon if (_parent != null) { sub_Form.StartPosition = FormStartPosition.Manual; - MyDb.RyWin32.GetWindowRect(_parent.Handle, out var rect); + User32.GetWindowRect(_parent.Handle, out var rect); sub_Form.Top = rect.Top + (rect.Bottom- rect.Top - sub_Form.Height) / 2; sub_Form.Left = rect.Left + (rect.Right- rect.Left - sub_Form.Width) / 2; if (_parent.TopMost) { sub_Form.TopMost = true; } @@ -156,7 +157,7 @@ namespace ryCommon case FormLocation.ParentMiddle: if (parent != null) { - MyDb.RyWin32.GetWindowRect(parent.Handle, out var rect); + User32.GetWindowRect(parent.Handle, out var rect); x = rect.Left + (rect.Right- rect.Left - sub_Form.Width) / 2; y = rect.Top + (rect.Bottom- rect.Top - sub_Form.Height) / 2; } diff --git a/Source/MyDb/SysFuns/RyForm.cs b/Source/MyDb/SysFuns/RyForm.cs index 97451a8..0566e9b 100644 --- a/Source/MyDb/SysFuns/RyForm.cs +++ b/Source/MyDb/SysFuns/RyForm.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms; +using WinAPI; namespace ryCommon { @@ -43,8 +44,8 @@ namespace ryCommon { int iSysMenu; const int MF_BYCOMMAND = 0x400; //0x400-关闭 - iSysMenu = MyDb.RyWin32.GetSystemMenu(iHWND, 0); - return MyDb.RyWin32.RemoveMenu(iSysMenu, 6, MF_BYCOMMAND); + iSysMenu = User32.GetSystemMenu(iHWND, 0); + return User32.RemoveMenu(iSysMenu, 6, MF_BYCOMMAND); } /// /// 把窗体放到最前 @@ -52,7 +53,7 @@ namespace ryCommon /// public static void BringToTop(IntPtr iHWND) { - MyDb.RyWin32.SetForegroundWindow(iHWND); + User32.SetForegroundWindow(iHWND); } /// /// 显示窗体 @@ -94,7 +95,7 @@ namespace ryCommon public static string GetWinText(IntPtr Handle) { StringBuilder WinTitle = new StringBuilder(200); - int len = MyDb.RyWin32.GetWindowText(Handle.ToInt32(), WinTitle, 200); + int len = User32.GetWindowText(Handle.ToInt32(), WinTitle, 200); return WinTitle.ToString(); } @@ -106,7 +107,7 @@ namespace ryCommon public static string GetWinClass(IntPtr Handle) { StringBuilder WinClass = new StringBuilder(200); - int len = MyDb.RyWin32.GetClassName(Handle.ToInt32(), WinClass, 200); + int len = User32.GetClassName(Handle.ToInt32(), WinClass, 200); return WinClass.ToString(); } /// @@ -115,7 +116,7 @@ namespace ryCommon /// public static IntPtr GetActiveWindow() { - return MyDb.RyWin32.GetActiveWindow(); + return User32.GetActiveWindow(); } /// /// 设置为当前活动窗口 @@ -124,7 +125,7 @@ namespace ryCommon /// public static IntPtr SetActiveWindow(IntPtr hwnd) { - return MyDb.RyWin32.SetActiveWindow(hwnd); + return User32.SetActiveWindow(hwnd); } /// /// 根据窗口句柄来获得进程id @@ -133,7 +134,7 @@ namespace ryCommon /// public static int GetProcessId(IntPtr hwnd) { - MyDb.RyWin32.GetWindowThreadProcessId(hwnd, out int ID); + User32.GetWindowThreadProcessId(hwnd, out int ID); return ID; } /// @@ -155,8 +156,8 @@ namespace ryCommon public static void SetDesktopForm(IntPtr handle) { //在构造函数中或者Load中 - IntPtr hDeskTop = MyDb.RyWin32.FindWindow("Progman", null); - MyDb.RyWin32.SetParent(handle, hDeskTop); + IntPtr hDeskTop = WinAPI.User32.FindWindow("Progman", null); + WinAPI.User32.SetParent(handle, hDeskTop); } /// /// 结束进程 @@ -165,7 +166,7 @@ namespace ryCommon /// public static long KillPorc(int pid) { - return MyDb.RyWin32.TerminateProcess(pid,1); + return WinAPI.Kernel32.TerminateProcess(pid,1); } /// /// 打开窗体,只打开一个实例(非模态) diff --git a/Source/MyDb/SysFuns/RyWin32.cs b/Source/MyDb/SysFuns/RyWin32.cs index cc43549..3348c77 100644 --- a/Source/MyDb/SysFuns/RyWin32.cs +++ b/Source/MyDb/SysFuns/RyWin32.cs @@ -5,6 +5,8 @@ using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms; +using WinAPI; +using static WinAPI.Struct; namespace MyDb { @@ -13,199 +15,11 @@ namespace MyDb /// public class RyWin32 { - /// - /// - /// - /// - /// - /// - [DllImport("USER32.DLL")] - public static extern int GetSystemMenu(IntPtr hwnd, int bRevert); - /// - /// - /// - /// - /// - /// - /// - [DllImport("USER32.DLL")] - public static extern int RemoveMenu(int hMenu, int nPosition, int wFlags); - /// - /// - /// - /// - /// - [DllImport("user32.dll")] - public static extern bool SetForegroundWindow(IntPtr hWnd); - /// - /// 获取当前前台窗口句柄 - /// - /// - [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] - public static extern IntPtr GetForegroundWindow(); - /// - /// 获得当前活动窗体 - /// - /// - [DllImport("user32.dll")] - public static extern IntPtr GetActiveWindow();//获得当前活动窗体 - /// - /// 设置活动窗体 - /// - /// - /// - [DllImport("user32.dll")] - public static extern IntPtr SetActiveWindow(IntPtr hwnd);//设置活动窗体 - /// - /// 获取类名 - /// - /// - /// - /// - /// - [DllImport("user32", EntryPoint = "GetClassName", SetLastError = false, - CharSet = CharSet.Auto, ExactSpelling = false, - CallingConvention = CallingConvention.StdCall)] - public static extern int GetClassName(int hWnd, StringBuilder lpClassName, int nMaxCount); - /// - /// 获取当前线程对应的进程ID - /// - /// - /// - /// - [DllImport("User32.dll", CharSet = CharSet.Auto)] - public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int ID); - /// - /// 判断指定句柄是否是一个窗口 - /// - /// - /// - [DllImport("user32.dll", EntryPoint = "IsWindow")] - public static extern bool IsWindow(IntPtr hWnd); - /// - /// 获取窗口标题 - /// - /// - /// - /// - /// - [DllImport("user32", SetLastError = true)] - public static extern int GetWindowText( - int hWnd,//窗口句柄 - StringBuilder lpString,//标题 - int nMaxCount //最大值 - ); - /// - /// 查找窗口 - /// - /// - /// - /// - [DllImport("User32.dll", EntryPoint = "FindWindow")] - public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); - /// - /// 设置父窗口 - /// - /// - /// - /// - [DllImport("user32.dll")] - public static extern int SetParent(IntPtr hWndChild, IntPtr hWndParent); - /// - /// 移动窗口 - /// - /// - /// - /// - /// - /// - /// - /// - [DllImport("user32.dll", CharSet = CharSet.Auto)] - public static extern int MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool BRePaint); - /// - /// - /// - /// - /// - /// - /// - /// - /// - [DllImport("User32.dll")] - public extern static IntPtr CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam); - /// - /// - /// - /// - /// - /// - /// - [DllImport("User32.dll")] - public static extern IntPtr SetWindowLong(IntPtr hwnd, int nIndex, IntPtr dwNewLong); /// /// /// public const int GWL_WNDPROC = (-4); - /// - /// 结束进程 - /// - /// - /// - /// - [DllImport("kernel32")] - public static extern long TerminateProcess(int handle, int exitCode); - /// - /// 发送消息 - /// - /// - /// - /// - /// - /// - [DllImport("User32.dll", EntryPoint = "SendMessage")] - private static extern int SendMessage(IntPtr hwnd, int msg, int wParam, ref COPYDATASTRUCT IParam); - /// - /// 发送消息 - /// - /// - /// - /// - /// - [DllImport("user32.dll")] - public static extern void PostMessage(IntPtr hWnd, int msg, int wParam, ref COPYDATASTRUCT IParam); - /// - /// 获取窗口位置和大小 - /// - /// - /// - /// - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); - /// - /// 矩形 - /// - [StructLayout(LayoutKind.Sequential)] - public struct RECT - { - /// - /// 最左坐标 - /// - public int Left; - /// - /// 最上坐标 - /// - public int Top; - /// - /// 最右坐标 - /// - public int Right; - /// - /// 最下坐标 - /// - public int Bottom; - } + /// /// WM_COPYDATA消息的主要目的是允许在进程间传递只读数据。 /// @@ -218,25 +32,7 @@ namespace MyDb /// 用户通道ID /// public const int User_chanel_id = 1001; - /// - /// - /// - public struct COPYDATASTRUCT - { - /// - /// - /// - public IntPtr dwData; - /// - /// - /// - public int cData; - /// - /// - /// - [MarshalAs(UnmanagedType.LPStr)] - public string lpData; - } + /// /// 获取消息 /// @@ -267,7 +63,7 @@ namespace MyDb cdata.dwData = from_handle; cdata.lpData = str; cdata.cData = len + 1; - return SendMessage(to_handle, WM_COPYDATA, wParam, ref cdata); + return User32.SendMessage(to_handle, WM_COPYDATA, wParam, ref cdata); } /// /// 设置父窗口 @@ -278,8 +74,8 @@ namespace MyDb /// public static bool SetParentWin(IntPtr sub_form, IntPtr parent_form,Size size) { - SetParent(sub_form, parent_form); - MoveWindow(sub_form, 0, 0, size.Width, size.Height, false); + User32.SetParent(sub_form, parent_form); + User32.MoveWindow(sub_form, 0, 0, size.Width, size.Height, false); return true; } diff --git a/Source/MyDb/SysFuns/SuperForm.cs b/Source/MyDb/SysFuns/SuperForm.cs index 2c96805..d8ebe7a 100644 --- a/Source/MyDb/SysFuns/SuperForm.cs +++ b/Source/MyDb/SysFuns/SuperForm.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms; +using WinAPI; namespace ryCommon { @@ -31,7 +32,7 @@ namespace ryCommon /// ~SuperForm() { - MyDb.RyWin32.SetWindowLong(handle, MyDb.RyWin32.GWL_WNDPROC, oldWndFunc); + User32.SetWindowLong(handle, MyDb.RyWin32.GWL_WNDPROC, oldWndFunc); } private bool isMouseDown = false; private Point FormLocation; //form的location @@ -104,7 +105,7 @@ namespace ryCommon /// protected virtual void WndProc(ref Message m) { - m.Result = MyDb.RyWin32.CallWindowProc(oldWndFunc, m.HWnd, m.Msg, m.WParam, m.LParam); + m.Result = User32.CallWindowProc(oldWndFunc, m.HWnd, m.Msg, m.WParam, m.LParam); switch (m.Msg) { case 0x0084: diff --git a/Source/MyDb/WinAPI/Kernel32.cs b/Source/MyDb/WinAPI/Kernel32.cs new file mode 100644 index 0000000..9e805bb --- /dev/null +++ b/Source/MyDb/WinAPI/Kernel32.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; + +namespace WinAPI +{ + /// + /// + /// + public static class Kernel32 + { + /// + /// 结束进程 + /// + /// + /// + /// + [DllImport("kernel32")] + public static extern long TerminateProcess(int handle, int exitCode); + } +} diff --git a/Source/MyDb/WinAPI/Structs.cs b/Source/MyDb/WinAPI/Structs.cs index 5b0ba23..5979fb0 100644 --- a/Source/MyDb/WinAPI/Structs.cs +++ b/Source/MyDb/WinAPI/Structs.cs @@ -9,7 +9,7 @@ namespace WinAPI /// /// /// - public class Struct + public static class Struct { #region Struct /// @@ -104,5 +104,24 @@ namespace WinAPI /// SWP_ASYNCWINDOWPOS = 0x4000 }; + /// + /// + /// + public struct COPYDATASTRUCT + { + /// + /// + /// + public IntPtr dwData; + /// + /// + /// + public int cData; + /// + /// + /// + [MarshalAs(UnmanagedType.LPStr)] + public string lpData; + } } } diff --git a/Source/MyDb/WinAPI/User32.cs b/Source/MyDb/WinAPI/User32.cs index 87ca47a..07f5cd0 100644 --- a/Source/MyDb/WinAPI/User32.cs +++ b/Source/MyDb/WinAPI/User32.cs @@ -1,20 +1,18 @@ -using System; -using System.Text; -using System.Drawing; -using System.Runtime.InteropServices; +using System; +using System.Text; +using System.Drawing; +using System.Runtime.InteropServices; using static WinAPI.Struct; using System.Windows.Forms; -namespace Win32API -{ +namespace WinAPI +{ /// /// - /// - public partial class User32 + /// + public partial class User32 { - - - #region UnmanagedMethods + #region UnmanagedMethods /// /// 模拟鼠标点击 /// @@ -23,7 +21,7 @@ namespace Win32API /// /// /// - /// + /// [DllImport("user32")] public static extern int mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo); /// @@ -34,16 +32,16 @@ namespace Win32API /// /// [DllImport("user32.dll", EntryPoint = "keybd_event", SetLastError = true)] - public static extern void keybd_event(Keys bVk, byte bScan, uint dwFlags, uint dwExtraInfo); + public static extern void keybd_event(Keys bVk, byte bScan, uint dwFlags, uint dwExtraInfo); /// /// /// /// - /// + /// [DllImport("User32.dll", CharSet = CharSet.Auto)] - public static extern IntPtr GetWindowDC(IntPtr hWnd); + public static extern IntPtr GetWindowDC(IntPtr hWnd); /// - /// + /// 移动窗口 /// /// /// @@ -51,25 +49,128 @@ namespace Win32API /// /// /// - /// + /// [DllImport("User32.dll", CharSet = CharSet.Auto)] - public static extern bool MoveWindow(IntPtr hWnd, int x, int y, int width, int height, bool repaint); + public static extern bool MoveWindow(IntPtr hWnd, int x, int y, int width, int height, bool repaint); + /// + /// + /// + /// + /// + /// + /// + /// + /// + [DllImport("User32.dll")] + public extern static IntPtr CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam); + /// + /// + /// + /// + /// + /// + /// + [DllImport("User32.dll")] + public static extern IntPtr SetWindowLong(IntPtr hwnd, int nIndex, IntPtr dwNewLong); + /// /// /// /// /// - /// - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern IntPtr SetParent(IntPtr hwndChild, IntPtr hwndParent); - - /// - /// The GetParent function retrieves a handle to the specified window's parent or owner. - /// - /// Handle to the window whose parent window handle is to be retrieved. - /// If the window is a child window, the return value is a handle to the parent window. If the window is a top-level window, the return value is a handle to the owner window. If the window is a top-level unowned window or if the function fails, the return value is NULL. - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern IntPtr GetParent(IntPtr hwnd); + /// + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern IntPtr SetParent(IntPtr hwndChild, IntPtr hwndParent); + + /// + /// The GetParent function retrieves a handle to the specified window's parent or owner. + /// + /// Handle to the window whose parent window handle is to be retrieved. + /// If the window is a child window, the return value is a handle to the parent window. If the window is a top-level window, the return value is a handle to the owner window. If the window is a top-level unowned window or if the function fails, the return value is NULL. + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern IntPtr GetParent(IntPtr hwnd); + /// + /// + /// + /// + /// + /// + [DllImport("USER32.DLL")] + public static extern int GetSystemMenu(IntPtr hwnd, int bRevert); + /// + /// + /// + /// + /// + /// + /// + [DllImport("USER32.DLL")] + public static extern int RemoveMenu(int hMenu, int nPosition, int wFlags); + /// + /// + /// + /// + /// + [DllImport("user32.dll")] + public static extern bool SetForegroundWindow(IntPtr hWnd); + /// + /// 获取当前前台窗口句柄 + /// + /// + [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] + public static extern IntPtr GetForegroundWindow(); + /// + /// 获得当前活动窗体 + /// + /// + [DllImport("user32.dll")] + public static extern IntPtr GetActiveWindow();//获得当前活动窗体 + /// + /// 设置活动窗体 + /// + /// + /// + [DllImport("user32.dll")] + public static extern IntPtr SetActiveWindow(IntPtr hwnd);//设置活动窗体 + /// + /// 获取类名 + /// + /// + /// + /// + /// + [DllImport("user32", EntryPoint = "GetClassName", SetLastError = false, + CharSet = CharSet.Auto, ExactSpelling = false, + CallingConvention = CallingConvention.StdCall)] + public static extern int GetClassName(int hWnd, StringBuilder lpClassName, int nMaxCount); + /// + /// 获取当前线程对应的进程ID + /// + /// + /// + /// + [DllImport("User32.dll", CharSet = CharSet.Auto)] + public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int ID); + /// + /// 判断指定句柄是否是一个窗口 + /// + /// + /// + [DllImport("user32.dll", EntryPoint = "IsWindow")] + public static extern bool IsWindow(IntPtr hWnd); + /// + /// 获取窗口标题 + /// + /// + /// + /// + /// + [DllImport("user32", SetLastError = true)] + public static extern int GetWindowText( + int hWnd,//窗口句柄 + StringBuilder lpString,//标题 + int nMaxCount //最大值 + ); /// /// /// @@ -77,13 +178,13 @@ namespace Win32API /// /// /// - /// - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern int SendMessage( - IntPtr hwnd, - int wMsg, - int wParam, - int lParam); + /// + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern int SendMessage( + IntPtr hwnd, + int wMsg, + int wParam, + int lParam); /// /// /// @@ -91,12 +192,12 @@ namespace Win32API /// /// /// - /// - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern int SendMessage( - IntPtr hwnd, - int wMsg, - IntPtr wParam, + /// + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern int SendMessage( + IntPtr hwnd, + int wMsg, + IntPtr wParam, IntPtr lParam); /// /// @@ -107,118 +208,144 @@ namespace Win32API /// /// [DllImport("user32.dll", SetLastError = true)] - public static extern bool SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam); + public static extern bool SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam); + /// + /// 发送消息 + /// + /// + /// + /// + /// + /// + [DllImport("User32.dll", EntryPoint = "SendMessage")] + public static extern int SendMessage(IntPtr hwnd, int msg, int wParam, ref COPYDATASTRUCT IParam); + /// + /// 发送消息 + /// + /// + /// + /// + /// + [DllImport("user32.dll")] + public static extern void PostMessage(IntPtr hWnd, int msg, int wParam, ref COPYDATASTRUCT IParam); /// /// /// /// - /// - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern IntPtr LoadCursorFromFile(string filename); + /// + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern IntPtr LoadCursorFromFile(string filename); /// /// /// /// - /// - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern bool IsWindowVisible(IntPtr hwnd); - - /// - /// The FindWindowEx function retrieves a handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the specified child window. - /// - /// Handle to the parent window whose child windows are to be searched. - /// Handle to a child window. - /// Specifies class name. - /// Pointer to a null-terminated string that specifies the window name (the window's title). - /// If the function succeeds, the return value is a handle to the window that has the specified class and window names.If the function fails, the return value is NULL. - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern IntPtr FindWindowEx( - IntPtr hwndParent, - IntPtr hwndChildAfter, - [MarshalAs(UnmanagedType.LPTStr)] - string lpszClass, - [MarshalAs(UnmanagedType.LPTStr)] - string lpszWindow); - - /// - /// The InvalidateRect function adds a rectangle to the specified window's update region. - /// - /// Handle to window. - /// Rectangle coordinates. - /// Erase state. - /// If the function succeeds, the return value is true.If the function fails, the return value is false. - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern bool InvalidateRect( - IntPtr hwnd, - ref Rectangle rect, - bool bErase); - - /// - /// The ValidateRect function validates the client area within a rectangle by removing the rectangle from the update region of the specified window. - /// - /// Handle to window. - /// Validation rectangle coordinates. - /// If the function succeeds, the return value is true.If the function fails, the return value is false. - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern bool ValidateRect( - IntPtr hwnd, - ref Rectangle rect); + /// + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern bool IsWindowVisible(IntPtr hwnd); + /// + /// 查找窗口 + /// + /// + /// + /// + [DllImport("User32.dll", EntryPoint = "FindWindow")] + public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); + /// + /// The FindWindowEx function retrieves a handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the specified child window. + /// + /// Handle to the parent window whose child windows are to be searched. + /// Handle to a child window. + /// Specifies class name. + /// Pointer to a null-terminated string that specifies the window name (the window's title). + /// If the function succeeds, the return value is a handle to the window that has the specified class and window names.If the function fails, the return value is NULL. + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern IntPtr FindWindowEx( + IntPtr hwndParent, + IntPtr hwndChildAfter, + [MarshalAs(UnmanagedType.LPTStr)] + string lpszClass, + [MarshalAs(UnmanagedType.LPTStr)] + string lpszWindow); + + /// + /// The InvalidateRect function adds a rectangle to the specified window's update region. + /// + /// Handle to window. + /// Rectangle coordinates. + /// Erase state. + /// If the function succeeds, the return value is true.If the function fails, the return value is false. + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern bool InvalidateRect( + IntPtr hwnd, + ref Rectangle rect, + bool bErase); + + /// + /// The ValidateRect function validates the client area within a rectangle by removing the rectangle from the update region of the specified window. + /// + /// Handle to window. + /// Validation rectangle coordinates. + /// If the function succeeds, the return value is true.If the function fails, the return value is false. + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern bool ValidateRect( + IntPtr hwnd, + ref Rectangle rect); /// /// /// /// /// - /// - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern int GetWindowLong( - IntPtr hWnd, - int dwStyle); + /// + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern int GetWindowLong( + IntPtr hWnd, + int dwStyle); /// /// /// /// - /// - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern IntPtr GetDC( - IntPtr hwnd); + /// + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern IntPtr GetDC( + IntPtr hwnd); /// /// /// /// /// - /// - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern int ReleaseDC( - IntPtr hwnd, - IntPtr hdc); - - //[DllImport("user32", SetLastError = false)] - //internal static extern IntPtr GetDesktopWindow(); - - //[DllImport("user32", CharSet = CharSet.Auto)] - //internal static extern int GetScrollPos( - // IntPtr hwnd, - // int nBar); + /// + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern int ReleaseDC( + IntPtr hwnd, + IntPtr hdc); + + //[DllImport("user32", SetLastError = false)] + //internal static extern IntPtr GetDesktopWindow(); + + //[DllImport("user32", CharSet = CharSet.Auto)] + //internal static extern int GetScrollPos( + // IntPtr hwnd, + // int nBar); /// /// /// /// /// - /// - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern int GetClientRect( - IntPtr hwnd, - [In, Out] ref Rectangle rect); + /// + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern int GetClientRect( + IntPtr hwnd, + [In, Out] ref Rectangle rect); /// /// /// /// /// - /// - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern bool GetWindowRect( - IntPtr hWnd, - [In, Out] ref Rectangle rect); + /// + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern bool GetWindowRect( + IntPtr hWnd, + out Rectangle rect); /// /// /// @@ -231,44 +358,44 @@ namespace Win32API /// /// /// - /// - [DllImport("user32", ExactSpelling = true, SetLastError = true)] - public static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pprSrc, Int32 crKey, ref BLENDFUNCTION pblend, Int32 dwFlags); + /// + [DllImport("user32", ExactSpelling = true, SetLastError = true)] + public static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pprSrc, Int32 crKey, ref BLENDFUNCTION pblend, Int32 dwFlags); /// /// /// /// /// /// - /// - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern uint SetWindowLong( - IntPtr hWnd, - int nIndex, - int dwNewLong); - - /// - /// Changes the size, position, and Z order of a child, pop-up, or top-level window. - /// These windows are ordered according to their appearance on the screen. - /// The topmost window receives the highest rank and is the first window in the Z order. - /// - /// A handle to the window. - /// A handle to the window to precede the positioned window in the Z order. This parameter must be a window handle or one of the following values. - /// Specifies the new position of the left side of the window, in client coordinates. - /// Specifies the new position of the top of the window, in client coordinates. - /// Specifies the new width of the window, in pixels. - /// Specifies the new height of the window, in pixels. - /// Specifies the window sizing and positioning flags. This parameter can be a combination of the following values. - /// If the function succeeds, the return value is nonzero, if the function fails, the return value is zero. - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern int SetWindowPos( - IntPtr hWnd, - IntPtr hWndAfter, - int X, - int Y, - int Width, - int Height, - FlagsSetWindowPos flags); + /// + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern uint SetWindowLong( + IntPtr hWnd, + int nIndex, + int dwNewLong); + + /// + /// Changes the size, position, and Z order of a child, pop-up, or top-level window. + /// These windows are ordered according to their appearance on the screen. + /// The topmost window receives the highest rank and is the first window in the Z order. + /// + /// A handle to the window. + /// A handle to the window to precede the positioned window in the Z order. This parameter must be a window handle or one of the following values. + /// Specifies the new position of the left side of the window, in client coordinates. + /// Specifies the new position of the top of the window, in client coordinates. + /// Specifies the new width of the window, in pixels. + /// Specifies the new height of the window, in pixels. + /// Specifies the window sizing and positioning flags. This parameter can be a combination of the following values. + /// If the function succeeds, the return value is nonzero, if the function fails, the return value is zero. + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern int SetWindowPos( + IntPtr hWnd, + IntPtr hWndAfter, + int X, + int Y, + int Width, + int Height, + FlagsSetWindowPos flags); /// /// /// @@ -279,11 +406,11 @@ namespace Win32API /// /// /// - /// - [DllImport("user32", CharSet = CharSet.Auto)] - public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, - int Y, int cx, int cy, uint uFlags); - - #endregion - } + /// + [DllImport("user32", CharSet = CharSet.Auto)] + public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, + int Y, int cx, int cy, uint uFlags); + + #endregion + } } \ No newline at end of file diff --git a/Source/MyDb/bin/x86/Debug/MyDb.dll b/Source/MyDb/bin/x86/Debug/MyDb.dll index 11202e9..dfdc566 100644 Binary files a/Source/MyDb/bin/x86/Debug/MyDb.dll and b/Source/MyDb/bin/x86/Debug/MyDb.dll differ diff --git a/Source/MyDb/bin/x86/Release/MyDb.dll b/Source/MyDb/bin/x86/Release/MyDb.dll index 06bbe29..0d2b348 100644 Binary files a/Source/MyDb/bin/x86/Release/MyDb.dll and b/Source/MyDb/bin/x86/Release/MyDb.dll differ diff --git a/Source/ryControls/Gdu.WinFormUI/Common/ButtonColorTable.cs b/Source/ryControls/Gdu.WinFormUI/Common/ButtonColorTable.cs new file mode 100644 index 0000000..c04512d --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Common/ButtonColorTable.cs @@ -0,0 +1,91 @@ +using System; +using System.Drawing; + +using MGdu.WinFormUI.MyGraphics; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class ButtonColorTable + { + public Color BorderColorNormal { get; set; } + public Color BorderColorHover { get; set; } + public Color BorderColorPressed { get; set; } + public Color BorderColorDisabled { get; set; } + + public Color BackColorNormal { get; set; } + public Color BackColorHover { get; set; } + public Color BackColorPressed { get; set; } + public Color BackColorDisabled { get; set; } + + public Color ForeColorNormal { get; set; } + public Color ForeColorHover { get; set; } + public Color ForeColorPressed { get; set; } + public Color ForeColorDisabled { get; set; } + + public ButtonColorTable() + { + + } + + public static ButtonColorTable DefaultTable() + { + ButtonColorTable table = new ButtonColorTable(); + + table.ForeColorNormal = table.ForeColorHover = table.ForeColorPressed = Color.Black; + + table.BackColorNormal = Color.LightPink; + table.BackColorHover = Color.HotPink; + table.BackColorPressed = Color.DeepPink; + + return table; + } + + public static ButtonColorTable GetDefaultCloseBtnColor() + { + ButtonColorTable table = new ButtonColorTable(); + + table.ForeColorNormal = Color.Black; + table.ForeColorHover = table.ForeColorPressed = Color.White; + table.BackColorNormal = Color.Transparent; + table.BackColorHover = Color.FromArgb(241,157,147); + table.BackColorPressed = Color.FromArgb(217,98,98); + + return table; + } + + public static ButtonColorTable GetColorTableVs2013Theme() + { + ButtonColorTable table = new ButtonColorTable(); + + table.ForeColorNormal = table.ForeColorHover = table.ForeColorPressed = Color.Black; + table.BackColorHover = Color.FromArgb(255, 252, 244); + table.BackColorPressed = Color.FromArgb(255, 232, 166); + table.BorderColorHover = table.BorderColorPressed = Color.FromArgb(229, 195, 101); + + return table; + } + + public static ButtonColorTable GetDevWhiteThemeMinMaxBtnColor() + { + ButtonColorTable maxTable = new ButtonColorTable(); + maxTable.ForeColorNormal = Color.Black; + maxTable.ForeColorHover = maxTable.ForeColorPressed = Color.White; + maxTable.BackColorNormal = Color.Transparent; + maxTable.BackColorHover = Color.FromArgb(54, 101, 179); + maxTable.BackColorPressed = Color.FromArgb(44, 88, 161); + return maxTable; + } + + public static ButtonColorTable GetDevWhiteThemeCloseBtnColor() + { + ButtonColorTable closeTable = new ButtonColorTable(); + closeTable.ForeColorNormal = closeTable.ForeColorHover = closeTable.ForeColorPressed + = ColorHelper.GetDarkerColor(Color.White, 5); + closeTable.BackColorNormal = Color.FromArgb(199, 80, 80); + closeTable.BackColorHover = Color.FromArgb(224, 67, 67); + closeTable.BackColorPressed = Color.FromArgb(153, 61, 61); + return closeTable; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Common/Common.cs b/Source/ryControls/Gdu.WinFormUI/Common/Common.cs new file mode 100644 index 0000000..e681e7c --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Common/Common.cs @@ -0,0 +1,45 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public delegate GraphicsPath ButtonForePathGetter(Rectangle rect); + public enum GMButtonState + { + Normal, + Hover, + Pressed, + PressLeave, + } + + public enum ButtonBorderType + { + Rectangle, + Ellipse, + } + + public enum MouseOperationType + { + Move, + Down, + Up, + Hover, + Leave, + } + + public enum ForePathRatoteDirection + { + Down, + Left, + Up, + Right, + } + + public enum ForePathRenderMode + { + Draw, + Fill, + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Forms/ControlBoxManager.cs b/Source/ryControls/Gdu.WinFormUI/Forms/ControlBoxManager.cs new file mode 100644 index 0000000..1321f0a --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Forms/ControlBoxManager.cs @@ -0,0 +1,195 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +using MGdu.WinFormUI.MyGraphics; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class ControlBoxManager + { + private GMForm _owner; + + private WLButton closeBtn; + private WLButton maxBtn; + private WLButton resBtn; + private WLButton minBtn; + + #region event handler + + private void CloseBtnClick(object sender, EventArgs e) + { + _owner.Close(); + } + + private void MaxBtnClick(object sender, EventArgs e) + { + _owner.WindowState = FormWindowState.Maximized; + } + + private void ResBtnClick(object sender, EventArgs e) + { + _owner.WindowState = FormWindowState.Normal; + } + + private void MinBtnClick(object sender, EventArgs e) + { + _owner.WindowState = FormWindowState.Minimized; + } + + #endregion + + private void SetControlBoxColor() + { + + closeBtn.ColorTable = _owner.XTheme.CloseBoxColor; + closeBtn.BackImageNormal = _owner.XTheme.CloseBoxBackImageNormal; + closeBtn.BackImageHover = _owner.XTheme.CloseBoxBackImageHover; + closeBtn.BackImagePressed = _owner.XTheme.CloseBoxBackImagePressed; + + // max res box + if (_owner.MaximizeBox) + { + maxBtn.ColorTable = _owner.XTheme.MaxBoxColor; + maxBtn.BackImageNormal = _owner.XTheme.MaxBoxBackImageNormal; + maxBtn.BackImageHover = _owner.XTheme.MaxBoxBackImageHover; + maxBtn.BackImagePressed = _owner.XTheme.MaxBoxBackImagePressed; + + resBtn.ColorTable = _owner.XTheme.MaxBoxColor; + resBtn.BackImageNormal = _owner.XTheme.ResBoxBackImageNormal; + resBtn.BackImageHover = _owner.XTheme.ResBoxBackImageHover; + resBtn.BackImagePressed = _owner.XTheme.ResBoxBackImagePressed; + } + + // min box + if (_owner.MinimizeBox) + { + minBtn.ColorTable = _owner.XTheme.MinBoxColor; + minBtn.BackImageNormal = _owner.XTheme.MinBoxBackImageNormal; + minBtn.BackImageHover = _owner.XTheme.MinBoxBackImageHover; + minBtn.BackImagePressed = _owner.XTheme.MinBoxBackImagePressed; + } + + } + + private void BtnIni() + { + // close box + closeBtn = new WLButton(_owner); + closeBtn.Visible = true; + closeBtn.Bounds = _owner.CloseBoxRect; + + closeBtn.Click += new EventHandler(CloseBtnClick); + closeBtn.ForePathGetter = new ButtonForePathGetter( + GraphicsPathHelper.CreateCloseFlagPath); + + // max res box + if (_owner.MaximizeBox) + { + maxBtn = new WLButton(_owner); + resBtn = new WLButton(_owner); + + if (_owner.WindowState == FormWindowState.Normal) + { + maxBtn.Visible = true; + resBtn.Visible = false; + } + else + { + maxBtn.Visible = false; + resBtn.Visible = true; + } + + maxBtn.Bounds = _owner.MaxBoxRect; + resBtn.Bounds = _owner.MaxBoxRect; + + maxBtn.Click += new EventHandler(MaxBtnClick); + maxBtn.ForePathGetter = new ButtonForePathGetter( + GraphicsPathHelper.CreateMaximizeFlagPath); + + resBtn.Click += new EventHandler(ResBtnClick); + resBtn.ForePathGetter = new ButtonForePathGetter( + GraphicsPathHelper.CreateRestoreFlagPath); + } + + // min box + if (_owner.MinimizeBox) + { + minBtn = new WLButton(_owner); + + minBtn.Visible = true; + minBtn.Bounds = _owner.MinBoxRect; + + minBtn.Click += new EventHandler(MinBtnClick); + minBtn.ForePathGetter = new ButtonForePathGetter( + GraphicsPathHelper.CreateMinimizeFlagPath); + } + + SetControlBoxColor(); + } + + public ControlBoxManager(GMForm owner) + { + _owner = owner; + BtnIni(); + } + + public void FormResize() + { + if(maxBtn != null) + { + if (_owner.WindowState == FormWindowState.Normal) + { + maxBtn.Visible = true; + resBtn.Visible = false; + resBtn.State = GMButtonState.Normal; + } + else + { + resBtn.Visible = true; + maxBtn.Visible = false; + maxBtn.State = GMButtonState.Normal; + } + resBtn.Bounds = maxBtn.Bounds = _owner.MaxBoxRect; + } + if (minBtn != null) + minBtn.Bounds = _owner.MinBoxRect; + closeBtn.Bounds = _owner.CloseBoxRect; + } + + public void MouseOperation(Point location, MouseOperationType type) + { + closeBtn.MouseOperation(location, type); + if (maxBtn != null && maxBtn.Visible) + maxBtn.MouseOperation(location, type); + if(resBtn!=null && resBtn.Visible) + resBtn.MouseOperation(location, type); + if(minBtn!=null) + minBtn.MouseOperation(location, type); + } + + public void DrawBoxes(Graphics g) + { + if (_owner.ControlBox) + { + closeBtn.DrawButton(g); + if (_owner.MinimizeBox && minBtn != null) + minBtn.DrawButton(g); + if (_owner.MaximizeBox) + { + if (maxBtn != null & maxBtn.Visible) + maxBtn.DrawButton(g); + if (resBtn != null && resBtn.Visible) + resBtn.DrawButton(g); + } + } + } + + public void ResetBoxColor() + { + SetControlBoxColor(); + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Forms/GMForm.Designer.cs b/Source/ryControls/Gdu.WinFormUI/Forms/GMForm.Designer.cs new file mode 100644 index 0000000..89f0eef --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Forms/GMForm.Designer.cs @@ -0,0 +1,38 @@ +namespace MGdu.WinFormUI +{ + partial class GMForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Text = "GMForm"; + } + + #endregion + } +} \ No newline at end of file diff --git a/Source/ryControls/Gdu.WinFormUI/Forms/GMForm.cs b/Source/ryControls/Gdu.WinFormUI/Forms/GMForm.cs new file mode 100644 index 0000000..fa638f9 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Forms/GMForm.cs @@ -0,0 +1,1679 @@ +/* + * 本代码受中华人民共和国著作权法保护,作者仅授权下载代码之人在学习和交流范围内 + * 自由使用与修改代码;欲将代码用于商业用途的,请先与作者联系。 + * 使用本代码请保留此处信息。作者联系方式:ping3108@163.com, 欢迎进行技术交流 + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; +using System.Runtime.InteropServices; + +using MGdu.WinFormUI; +using MGdu.WinFormUI.MyGraphics; +using System.Security.Permissions; + +namespace MGdu.WinFormUI +{ + /// + /// a form that supports custom theme + /// + [PermissionSet(SecurityAction.Demand, Name = "FullTrust")] + [System.Runtime.InteropServices.ComVisibleAttribute(true)] + public partial class GMForm : Form + { + + #region private variable + + ControlBoxManager controlBoxManager; + GMShadow _shawdowForm; + Form _lastClosedMdiChild; + List
_listClosedMdiChild; + MdiBarController _mdiBarController; + + #endregion + + #region mdi event support + + EventHandler _mdiNewTabButtonClick; + EventHandler _mdiTabCloseButtonClick; + EventHandler _mdiBarCreated; + /// + /// 标签新建按钮事件 + /// + [Description("标签新建按钮事件")] + + public event EventHandler MdiNewTabButtonClick + { + add + { + _mdiNewTabButtonClick = value; + } + remove + { + _mdiNewTabButtonClick = null; + } + } + /// + /// 标签关闭按钮事件 + /// + [Description("标签关闭按钮事件")] + + public event EventHandler MdiTabCloseButtonClick + { + add + { + _mdiTabCloseButtonClick = value; + } + remove + { + _mdiTabCloseButtonClick = null; + } + } + /// + ///标签创建时事件 + /// + [Description("标签创建时事件")] + + public event EventHandler MdiBarCreated + { + add { _mdiBarCreated = value; } + remove { _mdiBarCreated = null; } + } + + private void OnMdiNewTabButtonClick(object sender, EventArgs e) + { + _mdiNewTabButtonClick?.Invoke(sender, e); + } + + private void OnMdiTabCloseButtonClick(object sender, EventArgs e) + { + _mdiTabCloseButtonClick?.Invoke(sender, e); + } + /// + /// 在标签栏创建时激发 + /// + /// + /// + protected virtual void OnMdiBarCreated(object sender, EventArgs e) + { + _mdiBarCreated?.Invoke(sender, e); + } + + #endregion + + #region property + + #region property private var + + bool _resizable = true; // not with theme + Padding _padding = new Padding(0); // not with theme + + ThemeFormBase _myTheme; + + #endregion + /// + /// 内边距 + /// + + [DefaultValue(typeof(Padding), "0")] + public new Padding Padding + { + get { return _padding; } + set + { + _padding = value; + base.Padding = new Padding( + BorderWidth + _padding.Left, + CaptionHeight + BorderWidth + _padding.Top, + BorderWidth + _padding.Right, + BorderWidth + _padding.Bottom); + } + } + /// + /// 默认内边距 + /// + protected override Padding DefaultPadding + { + get + { + return new Padding( + BorderWidth, + BorderWidth + CaptionHeight, + BorderWidth, + BorderWidth); + } + } + /// + /// 标题 + /// + public override string Text + { + get + { + return base.Text; + } + set + { + base.Text = value; + Invalidate(TextRect); + } + } + /// + /// 皮肤/主题 + /// + [Browsable(false)] + public ThemeFormBase XTheme + { + get + { + if (_myTheme == null) + _myTheme = new ThemeFormBase(); + return _myTheme; + } + set + { + _myTheme = value; + PrepareForNewTheme(); + Invalidate(); + } + } + + #region editable gmform properties + /// + /// 是否可拖动改变窗体大小 + /// + [Category("GMForm")] + [Description("是否可拖动改变窗体大小")] + [DefaultValue(true)] + public bool Resizable + { + get { return _resizable; } + set + { + _resizable = value; + } + } + /// + /// 窗体边界大小,鼠标移动到该边界将变成指针形状,拖动可改变窗体大小 + /// + [Category("GMForm")] + [Description("窗体边界大小,鼠标移动到该边界将变成指针形状,拖动可改变窗体大小")] + [DefaultValue(6)] + public int SideResizeWidth + { + get { return XTheme.SideResizeWidth; } + set + { + if (value != XTheme.SideResizeWidth) + { + XTheme.SideResizeWidth = value; + } + } + } + /// + /// 窗体边框大小 + /// + [Category("GMForm")] + [Description("窗体边框大小")] + [DefaultValue(6)] + public int BorderWidth + { + get { return XTheme.BorderWidth; } + set + { + if (value != XTheme.BorderWidth) + { + XTheme.BorderWidth = value; + Invalidate(); + } + } + } + /// + /// 标题栏高度 + /// + [Category("GMForm")] + [Description("标题栏高度")] + [DefaultValue(30)] + public int CaptionHeight + { + get { return XTheme.CaptionHeight; } + set + { + if (value != XTheme.CaptionHeight) + { + XTheme.CaptionHeight = value; + Invalidate(); + } + } + } + /// + ///窗体圆角程度 + /// + [Category("GMForm")] + [DefaultValue(8)] + [Description("窗体圆角程度")] + public int Radius + { + get { return XTheme.Radius; } + set + { + if (value != XTheme.Radius) + { + XTheme.Radius = (value < 0 ? 0 : value); + Invalidate(); + } + } + } + /// + /// 窗体圆角样式 + /// + [Category("GMForm")] + [DefaultValue(typeof(RoundStyle), "2")] + [Description("窗体圆角样式")] + public RoundStyle Round + { + get { return XTheme.RoundedStyle; } + set + { + if (value != XTheme.RoundedStyle) + { + XTheme.RoundedStyle = value; + Invalidate(); + } + } + } + /// + /// 控制按钮相对于右上角的偏移量 + /// + [Category("GMForm")] + [Description("控制按钮相对于右上角的偏移量")] + [DefaultValue(typeof(Point), "8, 8")] + public Point ControlBoxOffset + { + get { return XTheme.ControlBoxOffset; } + set + { + XTheme.ControlBoxOffset = value; + Invalidate(); + } + } + /// + /// 关闭/最大化/最小化按钮之间的距离,可以设置成负值使它们重叠 + /// + [Category("GMForm")] + [Description("关闭/最大化/最小化按钮之间的距离,可以设置成负值使它们重叠")] + [DefaultValue(0)] + public int ControlBoxSpace + { + get { return XTheme.ControlBoxSpace; } + set + { + XTheme.ControlBoxSpace = value; + Invalidate(); + } + } + /// + /// 标题栏图标尺寸 + /// + [Category("GMForm")] + [Description("标题栏图标尺寸")] + [DefaultValue(typeof(Size), "16,16")] + public Size IconSize + { + get + { + if (ShowIcon) + return XTheme.IconSize; + else + return System.Drawing.Size.Empty; + } + set + { + XTheme.IconSize = value; + Invalidate(); + } + } + /// + /// 标题栏图标与窗体左边框的距离 + /// + [Category("GMForm")] + [Description("标题栏图标与窗体左边框的距离")] + [DefaultValue(2)] + public int IconLeftMargin + { + get { return (this.ShowIcon ? XTheme.IconLeftMargin : 0); } + set + { + XTheme.IconLeftMargin = value; + Invalidate(); + } + } + /// + /// 标题距离左边的距离 + /// + [Category("GMForm")] + [DefaultValue(2), Description("标题距离左边的距离")] + public int TextLeftMargin + { + get { return XTheme.TextLeftMargin; } + set + { + XTheme.TextLeftMargin = value; + Invalidate(); + } + } + /// + /// 窗体关闭按钮的尺寸 + /// + [Category("GMForm")] + [Description("窗体关闭按钮的尺寸")] + [DefaultValue(typeof(Size), "37, 17")] + public Size CloseBoxSize + { + get { return XTheme.CloseBoxSize; } + set + { + XTheme.CloseBoxSize = value; + Invalidate(); + } + } + /// + /// 窗体最大化/还原按钮的大小 + /// + [Category("GMForm")] + [DefaultValue(typeof(Size), "25, 17")] + [Description("窗体最大化/还原按钮的大小")] + public Size MaxBoxSize + { + get { return XTheme.MaxBoxSize; } + set + { + XTheme.MaxBoxSize = value; + Invalidate(); + } + } + /// + /// 窗体最小化按钮的大小 + /// + [Category("GMForm")] + [DefaultValue(typeof(Size), "25, 17")] + [Description("窗体最小化按钮的大小")] + public Size MinBoxSize + { + get { return XTheme.MinBoxSize; } + set + { + XTheme.MinBoxSize = value; + Invalidate(); + } + } + + #endregion + + #region form shadow about + /// + /// 是否显示阴影 + /// + [Category("Form Shadow"), Description("是否显示阴影")] + public bool ShowShadow + { + get { return XTheme.ShowShadow; } + set + { + if (value != XTheme.ShowShadow) + { + XTheme.ShowShadow = value; + } + } + } + /// + /// 窗体阴影宽度 + /// + [Category("Form Shadow"), Description("窗体阴影宽度")] + public int ShadowWidth + { + get { return XTheme.ShadowWidth; } + set + { + XTheme.ShadowWidth = value; + } + } + /// + /// 使用阴影来缩放 + /// + [Category("Form Shadow"), Description("使用阴影来缩放")] + public bool UseShadowToResize + { + get { return XTheme.UseShadowToResize; } + set + { + XTheme.UseShadowToResize = value; + } + } + /// + /// 窗体阴影颜色 + /// + [Category("Form Shadow")] + [Description("窗体阴影颜色")] + public Color ShadowColor + { + get { return XTheme.ShadowColor; } + set + { + XTheme.ShadowColor = value; + } + } + /// + /// 阴影从里到外是逐渐变浅的,这个值设置深色部分的透明度,ARGB中的A值 + /// + [Category("Form Shadow")] + [Description("阴影从里到外是逐渐变浅的,这个值设置深色部分的透明度,ARGB中的A值")] + public int ShadowAValueDark + { + get { return XTheme.ShadowAValueDark; } + set + { + XTheme.ShadowAValueDark = value; + } + } + /// + /// 阴影从里到外是逐渐变浅的,这个值设置浅色部分的透明度,ARGB中的A值 + /// + [Category("Form Shadow")] + [Description("阴影从里到外是逐渐变浅的,这个值设置浅色部分的透明度,ARGB中的A值")] + public int ShadowAValueLight + { + get { return XTheme.ShadowAValueLight; } + set + { + XTheme.ShadowAValueLight = value; + } + } + + #endregion + + #region form resize region, internal readonly + + internal Rectangle TopLeftRect + { + get + { + return new Rectangle(0, 0, SideResizeWidth, SideResizeWidth); + } + } + + internal Rectangle TopRect + { + get + { + return new Rectangle( + SideResizeWidth, + 0, + this.Size.Width - SideResizeWidth * 2, + SideResizeWidth); + } + } + + internal Rectangle TopRightRect + { + get + { + return new Rectangle( + this.Size.Width - SideResizeWidth, + 0, + SideResizeWidth, + SideResizeWidth); + } + } + + internal Rectangle LeftRect + { + get + { + return new Rectangle( + 0, + SideResizeWidth, + SideResizeWidth, + this.Size.Height - SideResizeWidth * 2); + } + } + + internal Rectangle RightRect + { + get + { + return new Rectangle( + this.Size.Width - SideResizeWidth, + SideResizeWidth, + SideResizeWidth, + this.Size.Height - SideResizeWidth * 2); + } + } + + internal Rectangle BottomLeftRect + { + get + { + return new Rectangle( + 0, + this.Size.Height - SideResizeWidth, + SideResizeWidth, + SideResizeWidth); + } + } + + internal Rectangle BottomRect + { + get + { + return new Rectangle( + SideResizeWidth, + this.Size.Height - SideResizeWidth, + this.Size.Width - SideResizeWidth * 2, + SideResizeWidth); + } + } + + internal Rectangle BottomRightRect + { + get + { + return new Rectangle( + this.Size.Width - SideResizeWidth, + this.Size.Height - SideResizeWidth, + SideResizeWidth, + SideResizeWidth); + } + } + + #endregion + + + #region calculated rect + + internal Rectangle CaptionRect + { + get + { + return new Rectangle( + BorderWidth, + BorderWidth, + this.ClientSize.Width - BorderWidth * 2, + CaptionHeight); + } + } + + internal Rectangle CaptionRectToDraw + { + get + { + return new Rectangle( + 0, + 0, + this.ClientSize.Width, + CaptionHeight + BorderWidth); + } + } + + internal Rectangle CloseBoxRect + { + get + { + if (ControlBox) + { + int x = ClientSize.Width - ControlBoxOffset.X - CloseBoxSize.Width; + return new Rectangle( + new Point(x, ControlBoxOffset.Y), + CloseBoxSize); + } + else + return Rectangle.Empty; + } + } + + internal Rectangle MaxBoxRect + { + get + { + if (ControlBox && MaximizeBox) + { + int x = CloseBoxRect.Left - ControlBoxSpace - MaxBoxSize.Width; + return new Rectangle( + new Point(x, ControlBoxOffset.Y), + MaxBoxSize); + } + else + return Rectangle.Empty; + } + } + + internal Rectangle MinBoxRect + { + get + { + if (ControlBox && MinimizeBox) + { + int x; + if (MaximizeBox) + x = MaxBoxRect.Left - ControlBoxSpace - MinBoxSize.Width; + else + x = CloseBoxRect.Left - ControlBoxSpace - MinBoxSize.Width; + return new Rectangle( + new Point(x, ControlBoxOffset.Y), + MinBoxSize); + } + else + return Rectangle.Empty; + } + } + + internal Rectangle IconRect + { + get + { + if (ControlBox && ShowIcon) + { + int x = BorderWidth + IconLeftMargin; + int y = BorderWidth + (CaptionHeight - IconSize.Height) / 2; + return new Rectangle(new Point(x, y), IconSize); + } + else + return new Rectangle(BorderWidth, BorderWidth, 0, 0); + } + } + + internal Rectangle TextRect + { + get + { + int x = IconRect.Right + TextLeftMargin; + int y = BorderWidth; + int height = CaptionHeight; + int right = this.ClientSize.Width - x; + if (ControlBox) + { + right = CloseBoxRect.Left; + if (MinimizeBox) + { + right = MinBoxRect.Left; + } + else if (MaximizeBox) + { + right = MaxBoxRect.Left; + } + } + int width = right - x; + return new Rectangle(x, y, width, height); + } + } + + #endregion + + /// + /// 表示去掉自画的边框及标题栏后,剩下的可用的客户区区域,坐标相对于窗体左上角 + /// + [Browsable(false)] + public Rectangle UserClientBounds + { + get + { + return new Rectangle( + BorderWidth, + BorderWidth + CaptionHeight, + ClientSize.Width - BorderWidth * 2, + ClientSize.Height - BorderWidth * 2 - CaptionHeight); + } + } + + /// + /// 表示去掉自画的边框及标题栏后,剩下的可用的客户区大小 + /// + [Browsable(false)] + public Size UserClientSize + { + get + { + return new Size( + ClientSize.Width - BorderWidth * 2, + ClientSize.Height - BorderWidth * 2 - CaptionHeight); + } + } + + /// + /// 表示MDI标签栏的区域,包括bottom-region + /// + [Browsable(false)] + public Rectangle MdiBarBounds + { + get + { + if (!IsMdiContainer || _mdiBarController == null) + return Rectangle.Empty; + return _mdiBarController.Bounds; + } + } + + #endregion + + #region constructor & initialize + /// + /// MGdUI皮肤 + /// + public GMForm() + : base() + { + InitializeComponent(); + FormIni(); + //if (!DesignMode) + //{ + // base.ShowInTaskbar = ShowInTaskbar; + //} + // 下面这个条件是永远不为true的,如果不把此类直接设置成mdicontainer + //if (this.IsMdiContainer) + // SetMdiClient(); + } + + private void FormIni() + { + this.SetStyle( + ControlStyles.AllPaintingInWmPaint | + ControlStyles.UserPaint | + ControlStyles.OptimizedDoubleBuffer | + ControlStyles.ResizeRedraw, true); + this.DoubleBuffered = true; + this.UpdateStyles(); + base.Padding = DefaultPadding; + + if (ControlBox) + controlBoxManager = new ControlBoxManager(this); + } + + #region MDI-Support + /// + /// 获取子窗体 + /// + /// + public MdiClient GetMdiClient() + { + MdiClient mdiclient = null; + foreach (Control ctl in Controls) + { + if ((mdiclient = ctl as MdiClient) != null) + break; + } + return mdiclient; + } + + /// + /// 通过sendmessage方式激活子窗体以避免闪烁 + /// + /// + public void ActivateMdiChildForm(Form childToActivate) + { + MdiClient mdi = GetMdiClient(); + if (mdi == null) + return; + if (base.ActiveMdiChild == childToActivate) + return; + if (base.MdiChildren.Length < 2) + return; + Control form = null; + bool isNext = false; + int pos = mdi.Controls.IndexOf(childToActivate); + if (pos < 0) + return; + if (pos == 0) + { + form = mdi.Controls[pos + 1]; + isNext = true; + } + else + { + form = mdi.Controls[pos - 1]; + isNext = false; + } + IntPtr next = (isNext ? Win32.WinAPI.TRUE : Win32.WinAPI.FALSE); + Win32.WinAPI.SendMessage(mdi.Handle, + (int)Win32.WinAPI.WindowMessages.WM_MDINEXT, form.Handle, next); + } + + private void SetMdiClient() + { + if (!IsMdiContainer) + return; + + MdiClient mdi = GetMdiClient(); + if (mdi != null) + { + SetMdiStyles(mdi); + UpdateMdiStyles(mdi); + SetMdiClientLocation(mdi); + } + } + + private void SetMdiStyles(MdiClient mdi) + { + // remove the border + + int style = Win32.WinAPI.GetWindowLong(mdi.Handle, (int)Win32.WinAPI.GWLPara.GWL_STYLE); + int exStyle = Win32.WinAPI.GetWindowLong(mdi.Handle, (int)Win32.WinAPI.GWLPara.GWL_EXSTYLE); + + style &= ~(int)Win32.WinAPI.WindowStyle.WS_BORDER; + exStyle &= ~(int)Win32.WinAPI.WindowStyleEx.WS_EX_CLIENTEDGE; + + Win32.WinAPI.SetWindowLong(mdi.Handle, (int)Win32.WinAPI.GWLPara.GWL_STYLE, style); + Win32.WinAPI.SetWindowLong(mdi.Handle, (int)Win32.WinAPI.GWLPara.GWL_EXSTYLE, exStyle); + + Win32.WinAPI.ShowScrollBar(mdi.Handle, (int)Win32.WinAPI.ScrollBar.SB_BOTH, 0 /*false*/); + } + + private void UpdateMdiStyles(MdiClient mdi) + { + // To show style changes, the non-client area must be repainted. Using the + // control's Invalidate method does not affect the non-client area. + // Instead use a Win32 call to signal the style has changed. + + Win32.WinAPI.SetWindowPos(mdi.Handle, IntPtr.Zero, 0, 0, 0, 0, + (uint)Win32.WinAPI.SWPPara.SWP_NOACTIVATE | + (uint)Win32.WinAPI.SWPPara.SWP_NOMOVE | + (uint)Win32.WinAPI.SWPPara.SWP_NOSIZE | + (uint)Win32.WinAPI.SWPPara.SWP_NOZORDER | + (uint)Win32.WinAPI.SWPPara.SWP_NOOWNERZORDER | + (uint)Win32.WinAPI.SWPPara.SWP_FRAMECHANGED); + } + + private void SetMdiClientLocation(MdiClient mdi) + { + mdi.BackColor = Color.White; + //mdi.Margin = new Padding(10); + //mdi.Dock = DockStyle.None; + + //mdi.Location = new Point(30, 40); + //mdi.Size = new Size(400, 260); + + } + + // used for child mdi form to notify its parent form that it's closed + /// + /// 当子窗体关闭时激发 + /// + /// + /// + protected void MdiChildClosed(object sender, FormClosedEventArgs e) + { + Form child = sender as Form; + if (child != null) + { + _lastClosedMdiChild = child; + _listClosedMdiChild.Add(child); + } + } + + // for mdi child form + /// + /// 子窗体可视化变化 + /// + /// + /// + protected void MdiChildVisibleChange(object sender, EventArgs e) + { + base.Invalidate(); + } + /// + /// 获取当前的子窗体列表 + /// + /// + public List GetCurrentMdiChildren() + { + List list = new List(); + if (_listClosedMdiChild != null) + { + foreach (Form f in MdiChildren) + { + if (!_listClosedMdiChild.Contains(f) && f.Visible) + list.Add(f); + } + } + return list; + } + + #endregion + + #endregion + + #region private method + + private void SetFormMinimizeSize() + { + int minW = 160; + int minH = 60; + + int w = BorderWidth * 2 + IconLeftMargin + IconSize.Width + + TextLeftMargin + MinBoxSize.Width + MaxBoxSize.Width + + CloseBoxSize.Width + ControlBoxSpace * 2 + + ControlBoxOffset.X + 12; + if (w < minW) + w = minW; + int h = BorderWidth * 2 + CaptionHeight + 8; + if (h < minH) + h = minH; + base.MinimumSize = new Size(w, h); + } + + private void SetShadowFormSize() + { + if (_shawdowForm == null || _shawdowForm.IsDisposed) + return; + if (base.WindowState == FormWindowState.Normal) + { + var size = base.Size; + size.Width += XTheme.ShadowWidth * 2; + size.Height += XTheme.ShadowWidth * 2; + if (_shawdowForm.Size != size) + { + _shawdowForm.Size = size; + // update size -- api: movewindow.... + } + } + } + + private void SetShadowFormLocation() + { + if (_shawdowForm == null || _shawdowForm.IsDisposed) + return; + if (base.WindowState == FormWindowState.Normal) + { + Point p = base.Location; + p.Offset(-XTheme.ShadowWidth, -XTheme.ShadowWidth); + if (_shawdowForm.Location != p) + { + _shawdowForm.Location = p; + // update location -- api: movewindow.... + } + } + } + + private void PrepareForNewTheme() + { + if (base.Region != null) + base.Region.Dispose(); + base.Region = null; + + if (ControlBox) + { + controlBoxManager.ResetBoxColor(); + controlBoxManager.FormResize(); + } + SetFormRegion(); + //Padding = new Padding(0); + base.BackColor = XTheme.FormBackColor; + base.OnSizeChanged(EventArgs.Empty); + SetFormMinimizeSize(); + if (XTheme.ShowShadow) + { + if (_shawdowForm == null || _shawdowForm.IsDisposed) + { + OnActivated(EventArgs.Empty); + } + } + else + { + if (_shawdowForm != null) + { + _shawdowForm.Close(); + _shawdowForm = null; + } + } + } + + private void SetFormRegion() + { + if (base.Region != null) + base.Region.Dispose(); + + Rectangle rect = new Rectangle(Point.Empty, base.Size); + GraphicsPath path; + + if (XTheme.UseDefaultTopRoundingFormRegion) + path = GraphicsPathHelper.CreateTopRoundedPathForFormRegion(rect); + else + path = GraphicsPathHelper.CreateRoundedRect(rect, Radius, Round, false); + + this.Region = new Region(path); + } + + //private GraphicsPath CreateRoundedFormRect(bool correction) + //{ + // Rectangle rect = new Rectangle(Point.Empty, this.Size); + // return GraphicsPathHelper.CreateRoundedRect(rect, Radius, Round, correction); + //} + + /// + /// 判断所接收到的 wm_nc-calc-size 消息是否指示窗体即将最小化 + /// + private bool IsAboutToMinimize(Win32.WinAPI.RECT rect) + { + if (rect.Left == -32000 && rect.Top == -32000) + return true; + else + return false; + } + + /// + /// 判断所接收到的 wm_nc-calc-size 消息是否指示窗体即将最大化 + /// + private bool IsAboutToMaximize(Win32.WinAPI.RECT rect) + { + /* + * 判断的方法是,只要窗体的左右、上下都延伸到了屏幕工作区之外, + * 并且左和右、上和下都延伸相同的量,就认为窗体是要进行最大化 + */ + + int left = rect.Left; + int top = rect.Top; + int width = rect.Right - rect.Left; + int height = rect.Bottom - rect.Top; + + if (left < 0 && top < 0) + { + Rectangle workingArea = Screen.GetWorkingArea(this); + if (width == (workingArea.Width + (-left) * 2) + && height == (workingArea.Height + (-top) * 2)) + return true; + } + return false; + } + + private void DrawFormBackground(Graphics g) + { + SmoothingMode oldMode = g.SmoothingMode; + if (Round != RoundStyle.None) + g.SmoothingMode = SmoothingMode.AntiAlias; + + using (SolidBrush sb = new SolidBrush(XTheme.FormBackColor)) + { + using (GraphicsPath path = GraphicsPathHelper.CreateRoundedRect( + ClientRectangle, Radius, Round, false)) + { + g.FillPath(sb, path); + } + } + g.SmoothingMode = oldMode; + } + + private void DrawCaptionBackground(Graphics g) + { + using (LinearGradientBrush lb = new LinearGradientBrush( + CaptionRectToDraw, + XTheme.CaptionBackColorTop, + XTheme.CaptionBackColorBottom, + LinearGradientMode.Vertical)) + { + g.FillRectangle(lb, CaptionRectToDraw); + } + } + + private void DrawFormIconAndText(Graphics g) + { + if (ShowIcon && Icon != null && XTheme.DrawCaptionIcon) + { + g.DrawIcon(this.Icon, IconRect); + } + + if (!string.IsNullOrEmpty(Text) && XTheme.DrawCaptionText) + { + TextRenderer.DrawText( + g, + this.Text, + SystemFonts.CaptionFont, + TextRect, + XTheme.CaptionTextColor, + (XTheme.CaptionTextCenter ? TextFormatFlags.HorizontalCenter : TextFormatFlags.Left) | + TextFormatFlags.VerticalCenter | + TextFormatFlags.EndEllipsis); + } + } + + private void DrawFormBorder(Graphics g) + { + int width = BorderWidth; + Rectangle rect = ClientRectangle; + + SmoothingMode oldMode = g.SmoothingMode; + if (Round != RoundStyle.None) + g.SmoothingMode = SmoothingMode.AntiAlias; + + // outter border + if (width > 0) + { + using (Pen p = new Pen(XTheme.FormBorderOutterColor)) + { + using (GraphicsPath path = GraphicsPathHelper.CreateRoundedRect( + rect, Radius, Round, true)) + { + g.DrawPath(p, path); + } + } + } + width--; + + // inner border + if (width > 0) + { + using (Pen p = new Pen(XTheme.FormBorderInnerColor)) + { + rect.Inflate(-1, -1); + using (GraphicsPath path = GraphicsPathHelper.CreateRoundedRect( + rect, Radius, Round, true)) + { + g.DrawPath(p, path); + } + } + } + width--; + + g.SmoothingMode = oldMode; + + // other inside border + using (Pen p = new Pen(XTheme.FormBorderInmostColor)) + { + while (width > 0) + { + rect.Inflate(-1, -1); + g.DrawRectangle(p, rect); + width--; + } + } + } + + /// + /// to make the client area to have 3D view + /// + private void DrawInsetClientRect(Graphics g) + { + int x = BorderWidth; + int y = BorderWidth + CaptionHeight; + int w = ClientSize.Width - BorderWidth * 2; + int h = ClientSize.Height - BorderWidth * 2 - CaptionHeight; + Rectangle clientRect = new Rectangle(x, y, w, h); + clientRect.Width--; + clientRect.Height--; + + Color inner = ColorHelper.GetDarkerColor(this.BackColor, 20); + clientRect.Inflate(1, 1); + using (Pen p1 = new Pen(inner)) + { + g.DrawRectangle(p1, clientRect); + } + + Color outter = Color.FromArgb(80, 255, 255, 255); + clientRect.Inflate(1, 1); + using (Pen p2 = new Pen(outter)) + { + g.DrawRectangle(p2, clientRect); + } + } + + #endregion + + #region your Win-Message handler method + + private bool WmNcActivate(ref Message m) + { + // something here + m.Result = Win32.WinAPI.TRUE; + return true; + } + + private bool WmNcCalcSize(ref Message m) + { + if (m.WParam == new IntPtr(1)) + { + Win32.WinAPI.NCCALCSIZE_PARAMS info = (Win32.WinAPI.NCCALCSIZE_PARAMS) + Marshal.PtrToStructure(m.LParam, typeof(Win32.WinAPI.NCCALCSIZE_PARAMS)); + if (IsAboutToMaximize(info.rectNewForm)) + { + Rectangle workingRect = Screen.GetWorkingArea(this); + info.rectNewForm.Left = workingRect.Left - BorderWidth; + info.rectNewForm.Top = workingRect.Top - BorderWidth; + info.rectNewForm.Right = workingRect.Right + BorderWidth; + info.rectNewForm.Bottom = workingRect.Bottom + BorderWidth; + Marshal.StructureToPtr(info, m.LParam, false); + } + } + return true; + } + + private bool WmNcHitTest(ref Message m) + { + int para = m.LParam.ToInt32(); + //var point = MousePosition; + //int x0 = Win32.WinAPI.LOWORD(para); + //int y0 = Win32.WinAPI.HIWORD(para); + Point p = PointToClient(MousePosition); + + if (Resizable) + { + if (TopLeftRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTTOPLEFT); + return true; + } + + if (TopRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTTOP); + return true; + } + + if (TopRightRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTTOPRIGHT); + return true; + } + + if (LeftRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTLEFT); + return true; + } + + if (RightRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTRIGHT); + return true; + } + + if (BottomLeftRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTBOTTOMLEFT); + return true; + } + + if (BottomRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTBOTTOM); + return true; + } + + if (BottomRightRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTBOTTOMRIGHT); + return true; + } + } + + if (IconRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTSYSMENU); + return true; + } + + if (CloseBoxRect.Contains(p) || MaxBoxRect.Contains(p) || MinBoxRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTCLIENT); + return true; + } + + if (IsMdiContainer && _mdiBarController != null) + { + if (_mdiBarController.HitTestBounds.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTCLIENT); + return true; + } + } + + if (CaptionRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTCAPTION); + return true; + } + + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTCLIENT); + return true; + } + + #endregion + + #region override method + /// + /// 消息 + /// + /// + protected override void WndProc(ref Message m) + { + bool alreadyHandled = false; + + switch (m.Msg) + { + case (int)Win32.WinAPI.WindowMessages.WM_NCCALCSIZE: + alreadyHandled = WmNcCalcSize(ref m); + break; + case (int)Win32.WinAPI.WindowMessages.WM_NCHITTEST: + alreadyHandled = WmNcHitTest(ref m); + break; + + case (int)Win32.WinAPI.WindowMessages.WM_NCACTIVATE: + alreadyHandled = WmNcActivate(ref m); + break; + + case (int)Win32.WinAPI.WindowMessages.WM_NCPAINT: + alreadyHandled = true; + break; + + default: + break; + } + + if (!alreadyHandled) + base.WndProc(ref m); + } + /// + /// 画UI + /// + /// + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + + DrawFormBackground(e.Graphics); + DrawCaptionBackground(e.Graphics); + DrawFormBorder(e.Graphics); + DrawFormIconAndText(e.Graphics); + + if (XTheme.SetClientInset) + DrawInsetClientRect(e.Graphics); + + if (ControlBox) + controlBoxManager.DrawBoxes(e.Graphics); + + if (IsMdiContainer && _mdiBarController != null) + _mdiBarController.RenderTheBar(e.Graphics); + } + /// + /// 在画背景时激发 + /// + /// + protected override void OnPaintBackground(PaintEventArgs e) + { + //base.OnPaintBackground(e); + } + + /// + /// 重写该方法解决窗体每次还原都会变大的问题 + /// + protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) + { + if (base.WindowState == FormWindowState.Normal) + { + if (this.Size == this.ClientSize) + { + //if (width == (this.Size.Width + SystemInformation.FrameBorderSize.Width * 2)) + if (width == (this.Size.Width + 4 * 2) || width == (this.Size.Width + 8 * 2)) + { + width = this.Size.Width; + height = this.Size.Height; + + } + } + } + base.SetBoundsCore(x, y, width, height, specified); + } + + /// + /// 重写该方法解决在VS设计器中,每次保存一个新的尺寸,再打开尺寸会变大的问题 + /// + protected override void SetClientSizeCore(int x, int y) + { + //MessageBox.Show("before SetClientSizeCore,size:" + + // base.Size.ToString() + ", clisize:" + base.ClientSize.ToString() + // + ", x:" + x.ToString() + ", y:" + y.ToString()); + + //if (base.WindowState == FormWindowState.Normal && DesignMode) + //{ + // if (base.Size != base.ClientSize) + // { + // int diffx = Size.Width - ClientSize.Width; + // int diffy = Size.Height - ClientSize.Height; + // if (diffx == 4 * 2 || diffx == 8 * 2) + // { + // x -= diffx; + // y -= diffy; + // } + // } + //} + base.SetClientSizeCore(x, y); + + //MessageBox.Show(base.SizeFromClientSize(new Size(x,y)).ToString()); + + //MessageBox.Show("after SetClientSizeCore,size:" + + // base.Size.ToString() + ", clisize:" + base.ClientSize.ToString() + // + ", x:" + x.ToString() + ", y:" + y.ToString()); + + } + /// + /// 创建控件时激发 + /// + protected override void OnCreateControl() + { + base.OnCreateControl(); + SetFormRegion(); + } + /// + /// 窗体可见变化时激发 + /// + /// + protected override void OnVisibleChanged(EventArgs e) + { + base.OnVisibleChanged(e); + if (_shawdowForm != null) + _shawdowForm.Visible = base.Visible; + } + + /// + /// 大小改变时激发 + /// + /// + protected override void OnSizeChanged(EventArgs e) + { + base.OnSizeChanged(e); + SetFormRegion(); + + if (ControlBox) + controlBoxManager.FormResize(); + + if (XTheme.ShowShadow && _shawdowForm != null + && !_shawdowForm.IsDisposed) + { + if (base.WindowState == FormWindowState.Normal) + { + _shawdowForm.Visible = true; + SetShadowFormSize(); + } + else + { + _shawdowForm.Visible = false; + } + } + + } + /// + /// 在位置变化时激发 + /// + /// + protected override void OnLocationChanged(EventArgs e) + { + base.OnLocationChanged(e); + + if (XTheme.ShowShadow && _shawdowForm != null + && !_shawdowForm.IsDisposed && _shawdowForm.Visible) + SetShadowFormLocation(); + } + /// + /// 窗体激活 + /// + /// + protected override void OnActivated(EventArgs e) + { + base.OnActivated(e); + if (XTheme.ShowShadow && !base.IsMdiChild) + { + if (_shawdowForm == null) + { + _shawdowForm = new GMShadow(this); + SetShadowFormSize(); + SetShadowFormLocation(); + _shawdowForm.Show(this); + SetShadowFormSize(); + SetShadowFormLocation(); + + _shawdowForm.TopMost = base.TopMost; + + var size = base.MinimumSize; + size.Width += ShadowWidth * 2; + size.Height += ShadowWidth * 2; + _shawdowForm.MinimumSize = size; + + if (XTheme.UseShadowToResize) + _shawdowForm.BeginToResizeOwner(); + } + } + } + /// + /// 窗体关闭后激发 + /// + /// + protected override void OnFormClosed(FormClosedEventArgs e) + { + if (_shawdowForm != null && !_shawdowForm.IsDisposed) + _shawdowForm.Close(); + + base.OnFormClosed(e); + } + /// + /// 加载时 + /// + /// + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + + if (base.IsMdiContainer) + { + SetMdiClient(); + _listClosedMdiChild = new List(); + _mdiBarController = new MdiBarController(this); + _mdiBarController.TabCloseButtonClick += new EventHandler(OnMdiTabCloseButtonClick); + _mdiBarController.NewTabButtonClick +=new EventHandler(OnMdiNewTabButtonClick); + OnMdiBarCreated(this, EventArgs.Empty); + } + } + /// + /// 在子窗体激活时激发 + /// + /// + protected override void OnMdiChildActivate(EventArgs e) + { + base.OnMdiChildActivate(e); + Invalidate(); + } + /// + /// 标签菜单 + /// + public ContextMenuStrip TabContextMenuStrip { get; set; } = null; + /// + /// 窗体上移动鼠标时激发 + /// + /// + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + if (ControlBox) + controlBoxManager.MouseOperation(e.Location, MouseOperationType.Move); + if (IsMdiContainer && _mdiBarController != null) + _mdiBarController.MouseOperation(e.Location, MouseOperationType.Move); + } + /// + /// 获取当前点击的标签项 + /// + public Form ClickTab { get; set; } = null; + /// + /// 在窗体上按下鼠标时激发 + /// + /// + protected override void OnMouseDown(MouseEventArgs e) + { + base.OnMouseDown(e); + + if (e.Button != System.Windows.Forms.MouseButtons.Left) + { + return; + } + + if (ControlBox) + controlBoxManager.MouseOperation(e.Location, MouseOperationType.Down); + if (IsMdiContainer && _mdiBarController != null) + _mdiBarController.MouseOperation(e.Location, MouseOperationType.Down); + } + /// + /// 在窗体上放开鼠标时激发 + /// + /// + protected override void OnMouseUp(MouseEventArgs e) + { + base.OnMouseUp(e); + + if (e.Button != System.Windows.Forms.MouseButtons.Left) + { + if (e.Button == System.Windows.Forms.MouseButtons.Right) + { + if (TabContextMenuStrip != null) + { + foreach (MdiGMTabItem tab in _mdiBarController._listTabItems) + { + if (!tab.IsHidden) + { + if (tab.Bounds.Contains(e.Location) && !tab.CloseBtnRect.Contains(e.Location)) + { + ClickTab = tab.Form; + TabContextMenuStrip.Show(PointToScreen(e.Location)); + break; + } + } + } + + } + } + return; + } + + if (e.Clicks > 1) + return; + + if (ControlBox) + controlBoxManager.MouseOperation(e.Location, MouseOperationType.Up); + if (IsMdiContainer && _mdiBarController != null) + _mdiBarController.MouseOperation(e.Location, MouseOperationType.Up); + } + /// + /// 在鼠标离开窗体时激发 + /// + /// + protected override void OnMouseLeave(EventArgs e) + { + base.OnMouseLeave(e); + if (ControlBox) + controlBoxManager.MouseOperation(Point.Empty, MouseOperationType.Leave); + if (IsMdiContainer && _mdiBarController != null) + _mdiBarController.MouseOperation(Point.Empty, MouseOperationType.Leave); + } + + #endregion + + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Forms/GMShadow.Designer.cs b/Source/ryControls/Gdu.WinFormUI/Forms/GMShadow.Designer.cs new file mode 100644 index 0000000..894b1db --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Forms/GMShadow.Designer.cs @@ -0,0 +1,47 @@ +namespace MGdu.WinFormUI +{ + partial class GMShadow + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // GMShadow + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 261); + this.Name = "GMShadow"; + this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; + this.Text = "GMShadow"; + this.ResumeLayout(false); + + } + + #endregion + } +} \ No newline at end of file diff --git a/Source/ryControls/Gdu.WinFormUI/Forms/GMShadow.cs b/Source/ryControls/Gdu.WinFormUI/Forms/GMShadow.cs new file mode 100644 index 0000000..10c0973 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Forms/GMShadow.cs @@ -0,0 +1,395 @@ +/* + * 本代码受中华人民共和国著作权法保护,作者仅授权下载代码之人在学习和交流范围内 + * 自由使用与修改代码;欲将代码用于商业用途的,请与作者联系。 + * 使用本代码请保留此处信息。作者联系方式:ping3108@163.com, 欢迎进行技术交流 + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +using MGdu.WinFormUI.Win32; +using MGdu.WinFormUI.MyGraphics; + +namespace MGdu.WinFormUI +{ + internal partial class GMShadow : Form + { + private GMForm _owner; + private bool _timeToResizeOwner; + + public GMShadow(GMForm owner) + { + _owner = owner; + _timeToResizeOwner = false; + InitializeComponent(); + FormIni(); + } + + public void BeginToResizeOwner() + { + _timeToResizeOwner = true; + } + + private void FormIni() + { + base.FormBorderStyle = FormBorderStyle.None; + base.WindowState = FormWindowState.Normal; + base.ShowInTaskbar = false; + SetStyle( + ControlStyles.UserPaint | + ControlStyles.AllPaintingInWmPaint | + ControlStyles.OptimizedDoubleBuffer | + ControlStyles.ResizeRedraw | + ControlStyles.DoubleBuffer, true); + UpdateStyles(); + base.AutoScaleMode = AutoScaleMode.None; + } + + protected override CreateParams CreateParams + { + get + { + CreateParams cp = base.CreateParams; + cp.ExStyle |= (int)Win32.WinAPI.WindowStyleEx.WS_EX_LAYERED; + return cp; + } + } + + private void SetFormReion() + { + if (base.Region != null) + base.Region.Dispose(); + + using (GraphicsPath path = GraphicsPathHelper.CreateRoundedRect( + new Rectangle(Point.Empty, base.Size), 16, RoundStyle.All, false)) + { + this.Region = new Region(path); + } + } + + private void SetOwnerSize() + { + var size = base.Size; + size.Width -= ShadowWidth * 2; + size.Height -= ShadowWidth * 2; + if (_owner.Size != size) + { + _owner.Size = size; + _owner.Update(); + } + } + + private void SetOwnerLocation() + { + Point location = base.Location; + location.Offset(ShadowWidth, ShadowWidth); + if (_owner.Location != location) + { + _owner.Location = location; + _owner.Update(); + } + } + + #region properties from owner + + private int ShadowWidth + { + get { return _owner.XTheme.ShadowWidth; } + } + + private bool UseShadowToResize + { + get { return _owner.XTheme.UseShadowToResize; } + } + + private Color ShadowColor + { + get { return _owner.XTheme.ShadowColor; } + } + + private int ShadowAValueDark + { + get { return _owner.XTheme.ShadowAValueDark; } + } + + private int ShadowAValueLight + { + get { return _owner.XTheme.ShadowAValueLight; } + } + + + #endregion + + #region resize rect region + + private Rectangle TopLeftRect + { + get + { + return new Rectangle(0, 0, ShadowWidth, ShadowWidth); + } + } + + private Rectangle TopRect + { + get + { + return new Rectangle( + ShadowWidth, + 0, + this.Size.Width - ShadowWidth * 2, + ShadowWidth); + } + } + + private Rectangle TopRightRect + { + get + { + return new Rectangle( + this.Size.Width - ShadowWidth, + 0, + ShadowWidth, + ShadowWidth); + } + } + + private Rectangle LeftRect + { + get + { + return new Rectangle( + 0, + ShadowWidth, + ShadowWidth, + this.Size.Height - ShadowWidth * 2); + } + } + + private Rectangle RightRect + { + get + { + return new Rectangle( + this.Size.Width - ShadowWidth, + ShadowWidth, + ShadowWidth, + this.Size.Height - ShadowWidth * 2); + } + } + + private Rectangle BottomLeftRect + { + get + { + return new Rectangle( + 0, + this.Size.Height - ShadowWidth, + ShadowWidth, + ShadowWidth); + } + } + + private Rectangle BottomRect + { + get + { + return new Rectangle( + ShadowWidth, + this.Size.Height - ShadowWidth, + this.Size.Width - ShadowWidth * 2, + ShadowWidth); + } + } + + private Rectangle BottomRightRect + { + get + { + return new Rectangle( + this.Size.Width - ShadowWidth, + this.Size.Height - ShadowWidth, + ShadowWidth, + ShadowWidth); + } + } + + #endregion + + private void DrawShadow(Graphics g) + { + int aDark = ShadowAValueDark; + int aLight = ShadowAValueLight; + if (aDark < 0) + aDark = 0; + if (aDark > 180) + aDark = 180; + if (aLight < 0) + aLight = 0; + if (aLight > 180) + aLight = 180; + if (aLight > aDark) + { + int t = aLight; + aLight = aDark; + aDark = t; + } + + int diff = (aDark - aLight) / ShadowWidth; + Rectangle rect = base.ClientRectangle; + rect.Width--; + rect.Height--; + g.SmoothingMode = SmoothingMode.AntiAlias; + for (int i = 0; i < ShadowWidth; i++) + { + using (Pen p = new Pen(Color.FromArgb(aLight + diff * i, ShadowColor))) + { + g.DrawRectangle(p, rect); + } + rect.Inflate(-1, -1); + } + } + + internal void RefleshLayeredForm() + { + Bitmap formBitMap = new Bitmap(base.Width, base.Height); + Graphics g = Graphics.FromImage(formBitMap); + + DrawShadow(g); + + Win32.WinAPI.POINT ptSrc = new Win32.WinAPI.POINT(0, 0); + Win32.WinAPI.POINT ptWinPos = new Win32.WinAPI.POINT(base.Left, base.Top); + Win32.WinAPI.SIZE szWinSize = new Win32.WinAPI.SIZE(Width, Height); + byte biAlpha = 0xFF; + Win32.WinAPI.BLENDFUNCTION stBlend = new Win32.WinAPI.BLENDFUNCTION( + (byte)Win32.WinAPI.BlendOp.AC_SRC_OVER, 0, biAlpha, (byte)Win32.WinAPI.BlendOp.AC_SRC_ALPHA); + + IntPtr gdiBitMap = IntPtr.Zero; + IntPtr memoryDC = IntPtr.Zero; + IntPtr preBits = IntPtr.Zero; + IntPtr screenDC = IntPtr.Zero; + + try + { + screenDC = Win32.WinAPI.GetDC(IntPtr.Zero); + memoryDC = Win32.WinAPI.CreateCompatibleDC(screenDC); + + gdiBitMap = formBitMap.GetHbitmap(Color.FromArgb(0)); + + preBits = Win32.WinAPI.SelectObject(memoryDC, gdiBitMap); + Win32.WinAPI.UpdateLayeredWindow(base.Handle + , screenDC + , ref ptWinPos + , ref szWinSize + , memoryDC + , ref ptSrc + , 0 + , ref stBlend + , (uint)Win32.WinAPI.ULWPara.ULW_ALPHA); + } + finally + { + if (gdiBitMap != IntPtr.Zero) + { + Win32.WinAPI.SelectObject(memoryDC, preBits); + Win32.WinAPI.DeleteObject(gdiBitMap); + } + + Win32.WinAPI.DeleteDC(memoryDC); + Win32.WinAPI.ReleaseDC(IntPtr.Zero, screenDC); + g.Dispose(); + formBitMap.Dispose(); + } + } + + private void WmNcHitTest(ref Message m) + { + int para = m.LParam.ToInt32(); + int x0 = Win32.WinAPI.LOWORD(para); + int y0 = Win32.WinAPI.HIWORD(para); + Point p = PointToClient(new Point(x0, y0)); + + if (UseShadowToResize) + { + if (TopLeftRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTTOPLEFT); + return ; + } + + if (TopRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTTOP); + return ; + } + + if (TopRightRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTTOPRIGHT); + return ; + } + + if (LeftRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTLEFT); + return ; + } + + if (RightRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTRIGHT); + return ; + } + + if (BottomLeftRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTBOTTOMLEFT); + return ; + } + + if (BottomRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTBOTTOM); + return ; + } + + if (BottomRightRect.Contains(p)) + { + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTBOTTOMRIGHT); + return ; + } + } + + m.Result = new IntPtr((int)Win32.WinAPI.NCHITTEST.HTCLIENT); + return ; + } + + protected override void WndProc(ref Message m) + { + if (m.Msg == (int)Win32.WinAPI.WindowMessages.WM_NCHITTEST) + { + WmNcHitTest(ref m); + return; + } + base.WndProc(ref m); + } + + protected override void OnSizeChanged(EventArgs e) + { + base.OnSizeChanged(e); + RefleshLayeredForm(); + SetFormReion(); + if (UseShadowToResize && _timeToResizeOwner && _owner.WindowState == FormWindowState.Normal) + SetOwnerSize(); + } + + protected override void OnLocationChanged(EventArgs e) + { + base.OnLocationChanged(e); + if (UseShadowToResize && _timeToResizeOwner && _owner.WindowState == FormWindowState.Normal) + SetOwnerLocation(); + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Forms/GMShadow.resx b/Source/ryControls/Gdu.WinFormUI/Forms/GMShadow.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Forms/GMShadow.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Source/ryControls/Gdu.WinFormUI/Forms/MdiBarController.cs b/Source/ryControls/Gdu.WinFormUI/Forms/MdiBarController.cs new file mode 100644 index 0000000..18538be --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Forms/MdiBarController.cs @@ -0,0 +1,1367 @@ +/* + * 本代码受中华人民共和国著作权法保护,作者仅授权下载代码之人在学习和交流范围内 + * 自由使用与修改代码;欲将代码用于商业用途的,请与作者联系。 + * 使用本代码请保留此处信息。作者联系方式:ping3108@163.com, 欢迎进行技术交流 + */ + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +using MGdu.WinFormUI.MyGraphics; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + /// + /// 该类处理mdi-bar的绘制及鼠标事件管理 + /// + internal class MdiBarController + { + #region private var + + GMForm _owner; + public List _listTabItems { get; private set; } + + // 有时候可能有很多tab,不能全部显示,那么就用两个变量来标识 + // 是第几个到第几个tab被显示出来了。 + int _beginShowIndex; + int _endShowIndex; + + int _activeTabIndex; + + // 有多少tab被隐藏了 + int _hiddenTabsCount; + + Point _lastMouseUpLocation; + + WLButton _newTabBtn; + WLButton _listAllBtn; + + EventHandler _newTabBtnClick; + EventHandler _tabCloseBtnClick; + + ContextMenuStrip _menuPopup; + private Rectangle _hitTestBounds; + + #endregion + + #region event & event handler + + public event EventHandler NewTabButtonClick + { + add { _newTabBtnClick = value; } + remove { _newTabBtnClick = null; } + } + + public event EventHandler TabCloseButtonClick + { + add { _tabCloseBtnClick = value; } + remove { _tabCloseBtnClick = null; } + } + + private void OnNewTabBtnClick(object sender, EventArgs e) + { + _newTabBtnClick?.Invoke(this, EventArgs.Empty); + } + + private void OnTabCloseBtnClick(object sender, EventArgs e) + { + if (sender is Form f) + { + _tabCloseBtnClick?.Invoke(f, EventArgs.Empty); + } + } + + private void OnListAllBtnClick(object sender, EventArgs e) + { + if (_listTabItems.Count < 1) + return; + + foreach (MdiGMTabItem tab in _listTabItems) + { + if (tab.IsFormActive) + { + tab.MenuItemPop.Checked = true; + tab.MenuItemPop.Image = null; + } + else + { + tab.MenuItemPop.Checked = false; + tab.MenuItemPop.Image = tab.Form.Icon.ToBitmap(); + } + tab.MenuItemPop.Text = tab.Form.Text; + + if (!tab.IsHidden) + tab.MenuItemPop.Font = new Font(tab.MenuItemPop.Font, FontStyle.Bold); + else + tab.MenuItemPop.Font = new Font(tab.MenuItemPop.Font, FontStyle.Regular); + } + _menuPopup.Show(_owner, ListAllBtnBounds.Left, ListAllBtnBounds.Bottom); + } + + private void OnActivateChild(Form child) + { + if (child != _owner.ActiveMdiChild) + { + if (_owner.XTheme.Mdi_UseMsgToActivateChild) + _owner.ActivateMdiChildForm(child); + else + child.Activate(); + } + } + + private void OnPopMenuItemClick(object sender, EventArgs e) + { + if (sender is ToolStripMenuItem ctl) + { + if (ctl.Tag is Form f) + { + OnActivateChild(f); + } + } + } + + #endregion + + #region Constructor & initial + + public MdiBarController(GMForm owner) + { + _owner = owner; + _listTabItems = new List(); + _newTabBtn = new WLButton(owner); + _listAllBtn = new WLButton(owner); + + // ini _newtabbtn + _newTabBtn.ColorTable = NewTabBtnColor; + _newTabBtn.Click += new EventHandler(OnNewTabBtnClick); + _newTabBtn.ForePathGetter = new ButtonForePathGetter( + MGdu.WinFormUI.MyGraphics.GraphicsPathHelper.CreatePlusFlag); + + _listAllBtn.ColorTable = ListAllBtnColor; + _listAllBtn.Click +=new EventHandler(OnListAllBtnClick); + _listAllBtn.ForePathGetter = new ButtonForePathGetter( + MGdu.WinFormUI.MyGraphics.GraphicsPathHelper.CreateDownTriangleFlag); + _listAllBtn.ForePathSize = new Size(10, 9); + _listAllBtn.ForeFont = new Font("微软雅黑", 8); + + _menuPopup = new ContextMenuStrip(); + } + + #endregion + + #region editable properties from thmem info + + /// + /// use left,top,right to location the bar in owner form, + /// the margin is from Form.ClientRectangle + /// + public Padding Margin + { + get { return _owner.XTheme.Mdi_BarMargin; } + } + + /// + /// 整个标签栏高度,包含标签栏底部区域、标签、标签顶部空隙 + /// + public int BarHeight + { + get { return BarBottomRegionHeight + Math.Max(TabHeight, TabHeightActive) + TabTopSpace; } + } + + /// + /// 标签栏底部区域的高度 + /// + public int BarBottomRegionHeight + { + get { return _owner.XTheme.Mdi_BarBottomRegionHeight; } + } + /// + /// 是否显示标签栏边框 + /// + public bool DrawBarBorder + { + get { return _owner.XTheme.Mdi_DrawBarBorder; } + } + /// + /// 是否显示标签栏背景 + /// + public bool DrawBarBackgound + { + get { return _owner.XTheme.Mdi_DrawBarBackground; } + } + + /// + ///标签栏左内边距 + /// + public int BarLeftPadding + { + get { return _owner.XTheme.Mdi_BarLeftPadding; } + } + /// + /// 标签栏右内边距 + /// + public int BarRightPadding + { + get { return _owner.XTheme.Mdi_BarRightPadding; } + } + /// + /// 标签高度 + /// + public int TabHeight + { + get { return _owner.XTheme.Mdi_TabHeight; } + } + /// + /// 激活的标签高度 + /// + public int TabHeightActive + { + get { return _owner.XTheme.Mdi_TabHeightActive; } + } + + /// + /// tab顶部与bar顶部的空间,这个值用来计算 BarHeight + /// + public int TabTopSpace + { + get { return _owner.XTheme.Mdi_TabTopSpace; } + } + + /// + /// 每个标签的左右边界可以不是垂直的,而是都有一个斜度 + /// + public int TabSlopeWidth + { + get { return _owner.XTheme.Mdi_TabSlopeWidth; } + } + + /// + /// tab与tab之间的距离,用负值可以使tab有重叠的效果 + /// + public int TabAndTabSpace + { + get { return _owner.XTheme.Mdi_TabAndTabSpace; } + } + /// + /// 标签是否显示图标 + /// + public bool ShowTabIcon + { + get { return _owner.XTheme.Mdi_ShowTabIcon; } + } + /// + /// 是否显示标签关闭按钮 + /// + public bool ShowTabCloseIcon + { + get { return _owner.XTheme.Mdi_ShowTabCloseIcon; } + } + /// + /// 标签图标大小 + /// + public Size IconSize + { + get { return ShowTabIcon ? new Size(16, 16) : Size.Empty; } + } + /// + /// 标签图标距离左边的距离 + /// + public int IconLeftSpace + { + get { return TabSlopeWidth + (ShowTabIcon ? 2 : 0); } + } + /// + /// 标签文字距离左边的距离 + /// + public int TextLeftSpace + { + get { return 2; } + } + /// + /// 标签关闭按钮的大小 + /// + public Size TabCloseBtnSize + { + get { return new Size(16, 16); } + } + /// + /// 标签关闭按钮距离右边的距离 + /// + public int TabCloseBtnRightSpace + { + get { return TabSlopeWidth + 2; } + } + /// + /// 是否显示新建标签按钮 + /// + public bool ShowNewTabBtn + { + get { return _owner.XTheme.Mdi_ShowNewTabBtn; } + } + /// + /// 新建标签按钮的大小 + /// + public Size NewTabBtnSize + { + get { return _owner.XTheme.Mdi_NewTabBtnSize; } + } + + public Rectangle NewTabBtnBounds + { + get; + set; + } + /// + /// 新建标签距离左边的距离 + /// + public int NewTabBtnLeftSpace + { + get { return _owner.XTheme.Mdi_NewTabBtnLeftSpace; } + } + + /// + /// 按钮与Bar底部的距离 + /// + public int NewTabBtnBottomSpace + { + get { return _owner.XTheme.Mdi_NewTabBtnBottomSpace; } + } + + public Rectangle ListAllBtnBounds { get; set; } + + public Size ListAllBtnSize + { + get { return _owner.XTheme.Mdi_ListAllBtnSize; } + } + + public int ListAllBtnLeftSpace + { + get { return _owner.XTheme.Mdi_ListAllBtnLeftSpace; } + } + + public int ListAllBtnBottomSpace + { + get { return _owner.XTheme.Mdi_ListAllBtnBottomSpace; } + } + + public BarButtonAlignmentType ListAllBtnAlign + { + get { return _owner.XTheme.Mdi_ListAllBtnAlign; } + } + + public bool AlwaysShowListAllBtn + { get { return _owner.XTheme.Mdi_AlwaysShowListAllBtn; } } + + /// + /// 一个tab允许的最小宽度 + /// + public int TabMinWidth + { + get + { + return Math.Max(TabSlopeWidth * 2 + IconLeftSpace + IconSize.Width + + TabCloseBtnRightSpace + TabCloseBtnSize.Width + 36, + _owner.XTheme.Mdi_TabMinWidth); + } + } + + /// + /// 一个tab允许的最大显示宽度 + /// + public int TabMaxWidth + { + get { return _owner.XTheme.Mdi_TabMaxWidth; } + } + /// + /// 标签正常宽度 + /// + public int TabNormalWidth + { + get { return _owner.XTheme.Mdi_TabNormalWidth; } + } + + #region bar & tab color + + public Color BarBorderColor + { + get { return _owner.XTheme.Mdi_BarBorderColor; } + } + + public Color BarBackColor + { + get { return _owner.XTheme.Mdi_BarBackColor; } + } + + public Color TabOutterBorderColor + { + get { return _owner.XTheme.Mdi_TabOutterBorderColor; } + } + + public Color TabInnerBorderColor + { + get { return _owner.XTheme.Mdi_TabInnerBorderColor; } + } + public bool TabShowBorder + { + get { return _owner.XTheme.Mdi_TabShowBorder; } + } + public Color TabActiveBackColorTop + { + get { return _owner.XTheme.Mdi_TabActiveBackColorTop; } + } + + public Color TabActiveBackColorBottom + { + get { return _owner.XTheme.Mdi_TabActiveBackColorBottom; } + } + + public Color TabDeactiveBackColorTop + { + get { return _owner.XTheme.Mdi_TabDeactiveBackColorTop; } + } + + public Color TabDeactiveBackColorBottom + { + get { return _owner.XTheme.Mdi_TabDeactiveBackColorBottom; } + } + + public Color BarBottomRegionBackColor + { + get { return _owner.XTheme.Mdi_BarBottomRegionBackColor; } + } + public Color TabActiveForeColor + { + get { return _owner.XTheme.Mdi_TabActiveForeColor; } + } + public Color TabDeactiveForeColor + { + get { return _owner.XTheme.Mdi_TabDeactiveForeColor; } + } + #endregion + + #region tab btn color + + public ButtonColorTable NewTabBtnColor + { + get { return _owner.XTheme.Mdi_NewTabBtnColor; } + } + + public ButtonColorTable ListAllBtnColor + { + get { return _owner.XTheme.Mdi_ListAllBtnColor; } + } + + public ButtonColorTable TabCloseBtnColor + { + get { return ButtonColorTable.GetDefaultCloseBtnColor(); } + } + + #endregion + + #endregion + + #region Calculated Properties + + public int BarWidth + { + get { return _owner.ClientSize.Width - Margin.Left - Margin.Right; } + } + + public Rectangle Bounds + { + get + { + return new Rectangle( + _owner.ClientRectangle.Left + Margin.Left, + _owner.ClientRectangle.Top + Margin.Top, + BarWidth, + BarHeight); + } + } + + public Rectangle BarBottomRegionBounds + { + get + { + return new Rectangle( + Bounds.Left, + Bounds.Top + (Bounds.Height - BarBottomRegionHeight), + BarWidth, + BarBottomRegionHeight); + } + } + + public Rectangle HitTestBounds + { + get { return _hitTestBounds; } + } + + #endregion + + #region private method + + private MdiGMTabItem CreateNewTab(Form f) + { + MdiGMTabItem tab = new MdiGMTabItem(this); + tab.Form = f; + tab.CloseBtn = new WLButton(_owner) + { + ColorTable = TabCloseBtnColor, + BorderType = ButtonBorderType.Ellipse, + DrawForePathTwice = true, + //tab.CloseBtn.DrawLightGlass = true; + ClickSendBackOject = f, + ForePathGetter = new + ButtonForePathGetter(MGdu.WinFormUI.MyGraphics.GraphicsPathHelper.CreateSingleLineCloseFlag) + }; + tab.CloseBtn.Click += new EventHandler(OnTabCloseBtnClick); + + // menu item + tab.MenuItemPop = new ToolStripMenuItem(); + tab.MenuItemPop.Tag = f; + tab.MenuItemPop.Click += new EventHandler(OnPopMenuItemClick); + _menuPopup.Items.Add(tab.MenuItemPop); + return tab; + } + + /// + /// 同步_listTabItems与mdi主窗体实际存在的子form + /// + private void CheckTabItemsWithOwnerMdiForm() + { + List listCurrent = _owner.GetCurrentMdiChildren(); + List newForm = new List(); + + foreach (MdiGMTabItem tab in _listTabItems) + tab.IsStillValid = false; + + foreach (Form f in listCurrent) + { + MdiGMTabItem tab; + if (IsTabItemsContaining(f, out tab)) + tab.IsStillValid = true; + else + newForm.Add(f); + } + + // remove the closed form tab + for (int i = _listTabItems.Count - 1; i >= 0; i--) + if (!_listTabItems[i].IsStillValid) + { + _menuPopup.Items.Remove(_listTabItems[i].MenuItemPop); + _listTabItems[i].MenuItemPop.Dispose(); + _listTabItems.RemoveAt(i); + } + + // create tabs for newly added forms + foreach (Form f in newForm) + { + _listTabItems.Add(CreateNewTab(f)); + } + + // find the active tab + int j = 0; + foreach (MdiGMTabItem tab in _listTabItems) + { + if (tab.Form == _owner.ActiveMdiChild) + { + _activeTabIndex = j; + tab.IsFormActive = true; + } + else + tab.IsFormActive = false; + j++; + } + } + + private bool IsTabItemsContaining(Form f, out MdiGMTabItem theTab) + { + theTab = null; + foreach (MdiGMTabItem tab in _listTabItems) + { + if (f == tab.Form) + { + theTab = tab; + return true; + } + } + return false; + } + + /// + /// 为每个tab分配空间,如果tab数目太多,则有些会被隐藏 + /// + private void CalculateSpaceForEachTab() + { + int beginOld = _beginShowIndex; + int endOld = _endShowIndex; + _beginShowIndex = 0; + _endShowIndex = _listTabItems.Count - 1; + _hiddenTabsCount = 0; + + int availableWidth = BarWidth - BarLeftPadding - BarRightPadding; + if (ShowNewTabBtn) + availableWidth -= (NewTabBtnSize.Width + NewTabBtnLeftSpace); + if (AlwaysShowListAllBtn) + availableWidth -= (ListAllBtnSize.Width + ListAllBtnLeftSpace * 2); + //int tabCount = _listTabItems.Count; + + int widthAll = 0; + int tabShorterThanNormalCount = 0; + int tabLongerThanMinWidthCount = 0; + int index = 0; + foreach (MdiGMTabItem tab in _listTabItems) + { + tab.FinalWidth = tab.GetFullShowTabWidth(); + widthAll += (tab.FinalWidth + (index > 0 ? TabAndTabSpace : 0)); + if (tab.FinalWidth < TabNormalWidth) + tabShorterThanNormalCount++; + if (tab.FinalWidth > TabMinWidth && index != _activeTabIndex) + tabLongerThanMinWidthCount++; + index++; + } + + if (widthAll <= availableWidth) + { + #region 1. 能以全文本方法显示所有 + int extraWidth = availableWidth - widthAll; + + //把剩余的空间分配给那些还没有达到normal宽度的tab + index=0; + while (extraWidth > 0 && tabShorterThanNormalCount > 0) + { + if (_listTabItems[index].FinalWidth < TabNormalWidth) + { + if (extraWidth > 2) + { + _listTabItems[index].FinalWidth += 2; + extraWidth -= 2; + } + else + { + _listTabItems[index].FinalWidth += extraWidth; + extraWidth = 0; + } + if (_listTabItems[index].FinalWidth >= TabNormalWidth) + tabShorterThanNormalCount--; + } + index++; + if (index >= _listTabItems.Count) + index = 0; + } + return; + #endregion + } + + + // 空间有限不能以全文本方式显示所有tab,则统一缩小非active的tab + int neededWidth = widthAll - availableWidth; + + #region 缩小非active tab,直到其达到tabminwidth + // 统一缩小非active-tab,看是否能在所有tab达到min宽度前腾出空间 + index = 0; + while (neededWidth > 0 && tabLongerThanMinWidthCount > 0) + { + if (_listTabItems[index].FinalWidth > TabMinWidth && index != _activeTabIndex) + { + int diff = _listTabItems[index].FinalWidth - TabMinWidth; + if (diff > 2) + { + _listTabItems[index].FinalWidth -= 2; + neededWidth -= 2; + } + else + { + _listTabItems[index].FinalWidth = TabMinWidth; + neededWidth -= diff; + } + if (_listTabItems[index].FinalWidth <= TabMinWidth) + tabLongerThanMinWidthCount--; + } + index++; + if (index >= _listTabItems.Count) + index = 0; + } + #endregion + + if (neededWidth <= 0) + { + // 2. 缩小非actvie-tab后,可以全部显示 + return; + } + + if ((_listTabItems[_activeTabIndex].FinalWidth > TabNormalWidth)) + { + // 若active-tab的宽度大于normal,则逐渐减小到normal + int width = _listTabItems[_activeTabIndex].FinalWidth; + while (width > TabNormalWidth && neededWidth > 0) + { + width--; + neededWidth--; + } + _listTabItems[_activeTabIndex].FinalWidth = width; + if (neededWidth <= 0) + { + // 3. 缩小active-tab达到normal宽度后,可以显示全部标签 + return; + } + + } + + #region 4. 隐藏相应的tab + if (!AlwaysShowListAllBtn) + { + availableWidth -= (ListAllBtnSize.Width + ListAllBtnLeftSpace * 2); + neededWidth += (ListAllBtnSize.Width + ListAllBtnLeftSpace * 2); + } + if (availableWidth < _listTabItems[_activeTabIndex].FinalWidth) + { + _listTabItems[_activeTabIndex].FinalWidth = availableWidth; + if (availableWidth < (TabCloseBtnSize.Width + TabSlopeWidth * 2)) + _listTabItems[_activeTabIndex].FinalWidth = TabCloseBtnSize.Width + TabSlopeWidth * 2; + } + _hiddenTabsCount = neededWidth / (TabMinWidth + TabAndTabSpace); + if ((neededWidth % (TabMinWidth + TabAndTabSpace)) != 0) + _hiddenTabsCount++; + if (_hiddenTabsCount >= _listTabItems.Count) + _hiddenTabsCount = _listTabItems.Count - 1; + + //先看一下之前所隐藏的tab数是否与将要隐藏的tab数一致,如果一致, + //且不影响active的显示,则不需要改变之前所隐藏的tab + //若不行,则简单点,先隐藏右边,不够的再隐藏左边 + #region 设置哪些tabs被隐藏 + int showTabCount = endOld - beginOld + 1; + if ((_listTabItems.Count - _hiddenTabsCount) == showTabCount) + { + if (endOld > _listTabItems.Count - 1) + { + endOld = _listTabItems.Count - 1; + beginOld = endOld - showTabCount + 1; + } + + if (beginOld <= _activeTabIndex && endOld >= _activeTabIndex) + { + _beginShowIndex = beginOld; + _endShowIndex = endOld; + } + else + { + //平移一下,使_actvieTabIndex包含其中 + if (_activeTabIndex < beginOld) + { + _beginShowIndex = _activeTabIndex; + _endShowIndex = _activeTabIndex + showTabCount - 1; + } + else + { + _endShowIndex = _activeTabIndex; + _beginShowIndex = _activeTabIndex - showTabCount + 1; + } + } + } + else + { + //先隐藏右边,不够的再隐藏左边 + int tabCntAfterActive = _listTabItems.Count - (_activeTabIndex + 1); + if (tabCntAfterActive >= _hiddenTabsCount) + { + _beginShowIndex = 0; + _endShowIndex = _listTabItems.Count - 1 - _hiddenTabsCount; + } + else + { + _beginShowIndex = _hiddenTabsCount - tabCntAfterActive; + _endShowIndex = _activeTabIndex; + } + } + #endregion + + // 再次把多出的空间重新分配给能显示的tab + int remainWidth = _hiddenTabsCount * (TabMinWidth + TabAndTabSpace) - neededWidth; + if (remainWidth > (_endShowIndex - _beginShowIndex + 1) * 3) + { + int average = remainWidth / (_endShowIndex - _beginShowIndex + 1); + for (int i = _beginShowIndex; i <= _endShowIndex; i++) + _listTabItems[i].FinalWidth += average; + } + + #endregion + } + + private void SetTabsVisibility() + { + for (int i = 0; i < _listTabItems.Count; i++) + { + if (i >= _beginShowIndex && i <= _endShowIndex) + _listTabItems[i].IsHidden = false; + else + _listTabItems[i].IsHidden = true; + } + } + + private void SetTabsAndBarButtonBounds() + { + if (ListAllBtnAlign == BarButtonAlignmentType.Left) + { + SetListAllBtnBounds(); + SetEachTabBounds(); + SetNewTabBtnBounds(); + } + else + { + SetEachTabBounds(); + SetNewTabBtnBounds(); + SetListAllBtnBounds(); + } + + SetHitTestBounds(); + } + + private void SetHitTestBounds() + { + int right = Bounds.Right - BarRightPadding; + + if(ListAllBtnAlign != BarButtonAlignmentType.Left && + (AlwaysShowListAllBtn || _hiddenTabsCount>0)) + { + right = ListAllBtnBounds.Right; + } + else if (ShowNewTabBtn) + { + right = NewTabBtnBounds.Right; + } + else if (_listTabItems.Count > 0 && _endShowIndex < _listTabItems.Count) + { + right = _listTabItems[_endShowIndex].Bounds.Right; + } + + int left = Bounds.Left + BarLeftPadding; + int width = right - left; + + _hitTestBounds = new Rectangle(left, Bounds.Top, width, Bounds.Height); + } + + private void SetEachTabBounds() + { + int x = Bounds.X + BarLeftPadding; + if (ListAllBtnAlign == BarButtonAlignmentType.Left) + { + if (AlwaysShowListAllBtn || _hiddenTabsCount > 0) + { + x = ListAllBtnBounds.Right + ListAllBtnLeftSpace; + } + } + if (_listTabItems.Count > 0) + { + for (int i = _beginShowIndex; i <= _endShowIndex; i++) + { + int height = _listTabItems[i].IsFormActive ? TabHeightActive : TabHeight; + int y = Bounds.Bottom - BarBottomRegionHeight - height; + int w = _listTabItems[i].FinalWidth; + _listTabItems[i].Bounds = new Rectangle(x, y, w, height); + x += (w + TabAndTabSpace); + } + } + } + + private void SetNewTabBtnBounds() + { + int tabsCount = _listTabItems.Count; + int x; + if (tabsCount > 0 && _endShowIndex < tabsCount) + { + x = _listTabItems[_endShowIndex].Bounds.Right + NewTabBtnLeftSpace; + if (x > (Bounds.Right - BarRightPadding - NewTabBtnSize.Width)) + x = Bounds.Right - BarRightPadding - NewTabBtnSize.Width; + if (x < Bounds.Left + BarLeftPadding) + x = Bounds.Left + BarLeftPadding; + } + else + { + x = Bounds.Left + BarLeftPadding; + if (ListAllBtnAlign == BarButtonAlignmentType.Left) + x = ListAllBtnBounds.Right + ListAllBtnLeftSpace; + } + int y = Bounds.Bottom - NewTabBtnBottomSpace - NewTabBtnSize.Height; + var size = ShowNewTabBtn ? NewTabBtnSize : Size.Empty; + if (size.Width > Bounds.Width) + size.Width = Bounds.Width; + NewTabBtnBounds = new Rectangle(new Point(x, y), size); + } + + private void SetListAllBtnBounds() + { + int x; + if (ListAllBtnAlign == BarButtonAlignmentType.Left) + { + x = Bounds.X + BarLeftPadding; + } + else + { + x = NewTabBtnBounds.Right; + if (ShowNewTabBtn || _listTabItems.Count > 0) + x += ListAllBtnLeftSpace; + if (x > (Bounds.Right - BarRightPadding - ListAllBtnSize.Width)) + x = Bounds.Right - BarRightPadding - ListAllBtnSize.Width; + } + int y = Bounds.Bottom - ListAllBtnBottomSpace - ListAllBtnSize.Height; + var size = ((_hiddenTabsCount>0 || AlwaysShowListAllBtn) ? ListAllBtnSize : Size.Empty); + if (size.Width > Bounds.Width) + size.Width = Bounds.Width; + ListAllBtnBounds = new Rectangle(new Point(x, y), size); + } + + private void RenderEachBarItem(Graphics g) + { + Region oldClip = g.Clip; + Region newClip = new Region(Bounds); + g.Clip = newClip; + SmoothingMode oldMode = g.SmoothingMode; + g.SmoothingMode = SmoothingMode.AntiAlias; + + DrawBarBorderAndBackground(g); + DrawEachTabItem(g); + DrawOtherBarButtons(g); + DrawBarBottomRegion(g); + + g.SmoothingMode = oldMode; + g.Clip = oldClip; + newClip.Dispose(); + } + + private void DrawBarBorderAndBackground(Graphics g) + { + Rectangle rect = Bounds; + if (DrawBarBackgound) + { + using (SolidBrush sb = new SolidBrush(BarBackColor)) + { + g.FillRectangle(sb, rect); + } + } + if (DrawBarBorder) + { + rect.Width--; + rect.Height--; + using (Pen p = new Pen(BarBorderColor)) + { + g.DrawRectangle(p, rect); + } + } + } + + private void DrawBarBottomRegion(Graphics g) + { + // bottom region + using (SolidBrush sb = new SolidBrush(BarBottomRegionBackColor)) + { + using (NewSmoothModeGraphics newGP = new NewSmoothModeGraphics(g, SmoothingMode.HighSpeed)) + { + g.FillRectangle(sb, BarBottomRegionBounds); + } + } + } + + private void DrawOtherBarButtons(Graphics g) + { + // new-tab-btn + if (ShowNewTabBtn) + { + _newTabBtn.Bounds = NewTabBtnBounds; + _newTabBtn.DrawButton(g); + } + + // list-all-btn + if (_hiddenTabsCount > 0 || AlwaysShowListAllBtn) + { + _listAllBtn.Bounds = ListAllBtnBounds; + if (_hiddenTabsCount == 0) + _listAllBtn.Text = string.Empty; + else + _listAllBtn.Text = _hiddenTabsCount.ToString(); + _listAllBtn.DrawButton(g); + } + } + + private void DrawEachTabItem(Graphics g) + { + foreach (MdiGMTabItem tab in _listTabItems) + { + if (!tab.IsHidden && !tab.IsFormActive) + RenderTabItem(g, tab); + } + // active-tab last + if (_listTabItems.Count > 0) + RenderTabItem(g, _listTabItems[_activeTabIndex]); + } + + private void RenderTabItem(Graphics g, MdiGMTabItem tab) + { + Rectangle rect = tab.Bounds; + Region oldRegion = g.Clip; + Region newRegion = new Region(rect); + g.Clip = newRegion; + + // fill backgroung + Color backTop,backBottom; + if (tab.IsFormActive) + { + backTop = TabActiveBackColorTop; + backBottom = TabActiveBackColorBottom; + } + else + { + backTop = TabDeactiveBackColorTop; + backBottom = TabDeactiveBackColorBottom; + } + + // background + using (LinearGradientBrush lb = new LinearGradientBrush( + rect, backTop, backBottom, LinearGradientMode.Vertical)) + { + using (GraphicsPath path = PathGetter.GetTabBorderPath(rect, TabSlopeWidth)) + { + g.FillPath(lb, path); + } + } + + // icon + if (ShowTabIcon && tab.Form.Icon != null) + { + if (tab.IconRect.Right < tab.Bounds.Right) + g.DrawIcon(tab.Form.Icon, tab.IconRect); + } + if (tab.IsFormActive) + { + // text + TextRenderer.DrawText(g, tab.Form.Text, tab.Form.Font, tab.TextRect,TabActiveForeColor, + TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis); + } + else + { + TextRenderer.DrawText(g, tab.Form.Text, tab.Form.Font, tab.TextRect, TabDeactiveForeColor, + TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis); + } + // outter border + rect.Width--; + rect.Height--; + if (TabShowBorder) + { + using (Pen p = new Pen(TabOutterBorderColor)) + { + if (tab.IsFormActive) + { + Rectangle rectTab = tab.Bounds; + Rectangle rectBottom = BarBottomRegionBounds; + Point p1 = new Point(rectBottom.X, rectBottom.Y - 1); + Point p2 = new Point(rectTab.X, rectTab.Bottom - 1); + Point p3 = new Point(rectTab.X + TabSlopeWidth, rectTab.Y); + Point p4 = new Point(rectTab.Right - 1 - TabSlopeWidth, rectTab.Y); + Point p5 = new Point(rectTab.Right - 1, rectTab.Bottom - 1); + Point p6 = new Point(rectBottom.Right - 1, rectBottom.Y - 1); + g.Clip = oldRegion; + //g.DrawLines(p, new Point[] { p1, p2, p3, p4, p5, p6 }); + g.Clip = newRegion; + } + else + { + using (GraphicsPath path = PathGetter.GetTabBorderPath(rect, TabSlopeWidth)) + { + //g.DrawPath(p, path); + } + } + } + } + // inner border + rect.Inflate(-1, -1); + rect.Height++; // 为了使bar-bottom-region 与 active-tab 的连线能覆盖非 active-tab 的底部的线 + if (TabShowBorder) + { + using (Pen p = new Pen(TabInnerBorderColor)) + { + using (GraphicsPath path = PathGetter.GetTabBorderPath(rect, TabSlopeWidth)) + { + g.DrawPath(p, path); + } + } + } + // do not let the active-tab to have bottom-line + if (tab.IsFormActive) + { + Rectangle rtmp = tab.Bounds; + Point p1 = new Point(rtmp.Left + 1, rtmp.Bottom - 1); + Point p2 = new Point(rtmp.Right - 2, rtmp.Bottom - 1); + using (Pen pen = new Pen(backBottom)) + { + g.DrawLine(pen, p1, p2); + } + } + if (ShowTabCloseIcon) + { + //close btn + tab.CloseBtn.Bounds = tab.CloseBtnRect; + tab.CloseBtn.DrawButton(g); + } + g.Clip = oldRegion; + newRegion.Dispose(); + } + + #region mouse operation + + private void MouseOperationDown(Point location) + { + foreach (MdiGMTabItem tab in _listTabItems) + { + if (!tab.IsHidden) + { + if (tab.Bounds.Contains(location) && !tab.CloseBtnRect.Contains(location)) + { + tab.Capture = true; + break; + } + } + } + } + + private void MouseOperationUp(Point location) + { + foreach (MdiGMTabItem tab in _listTabItems) + { + if (!tab.IsHidden) + { + if (tab.Capture && tab.Bounds.Contains(location)) + { + tab.Capture = false; + OnActivateChild(tab.Form); + //break; + } + } + tab.Capture = false; + } + } + + #endregion + + #endregion + + #region public method + + /// + /// 重绘整个标签栏 + /// + /// + public void RenderTheBar(Graphics g) + { + // 先把已关闭的form对应的tab删除,对新加的form则为其创建相应tab + CheckTabItemsWithOwnerMdiForm(); + + if (_listTabItems.Count > 0) + { + // 按照指定方式为每个tab分配空间 + CalculateSpaceForEachTab(); + SetTabsVisibility(); + } + + SetTabsAndBarButtonBounds(); + + RenderEachBarItem(g); + + if (ShowNewTabBtn) + { + if (_lastMouseUpLocation != Point.Empty) + { + //gdu debug: currently we need this to set the btn back to normal + if (!NewTabBtnBounds.Contains(_lastMouseUpLocation) + && _newTabBtn.State == GMButtonState.Hover) + _newTabBtn.MouseOperation(_lastMouseUpLocation, MouseOperationType.Move); + } + } + } + + /// + /// 处理鼠标事件。该方法会触发一些click事件,重刷一些按钮等 + /// + /// + /// + public void MouseOperation(Point location, MouseOperationType type) + { + //if (type == MouseOperationType.Up) + _lastMouseUpLocation = location; + //else + // _lastMouseUpLocation = Point.Empty; + + if (ShowNewTabBtn) + _newTabBtn.MouseOperation(location, type); + if (_hiddenTabsCount > 0 || AlwaysShowListAllBtn) + _listAllBtn.MouseOperation(location, type); + foreach (MdiGMTabItem tab in _listTabItems) + { + if (!tab.IsHidden) + { + if (ShowTabCloseIcon) + { tab.CloseBtn.MouseOperation(location, type); } + } + } + + switch (type) + { + case MouseOperationType.Down: + MouseOperationDown(location); + break; + + case MouseOperationType.Up: + MouseOperationUp(location); + break; + } + } + + #endregion + } + + /// + /// 该类表示一个单独的标签项 + /// + internal class MdiGMTabItem + { + + #region 内部变量 + + #endregion + + // mdi bar which this tab item is belong to + MdiBarController _barContainer; + + public MdiGMTabItem(MdiBarController barContainer) + { + _barContainer = barContainer; + IsStillValid = true; + } + + /// + /// 该标签所对应的窗体 + /// + public Form Form { get; set; } + + public bool IsFormActive { get; set; } + + /// + /// 最终分配到的整个tab的宽度 + /// + public int FinalWidth { get; set; } + + /// + /// 表示所对应的form是否仍未被关闭 + /// + public bool IsStillValid { get; set; } + + public Rectangle Bounds { get; set; } + + public WLButton CloseBtn { get; set; } + + public bool Capture { get; set; } + + /// + /// 是否因空间不足而被隐藏 + /// + public bool IsHidden { get; set; } + + public ToolStripMenuItem MenuItemPop { get; set; } + + public Rectangle IconRect + { + get + { + return new Rectangle( + Bounds.Left + _barContainer.IconLeftSpace, + Bounds.Top + (Bounds.Height - _barContainer.IconSize.Height) / 2, + _barContainer.IconSize.Width, + _barContainer.IconSize.Height); + } + } + + public Rectangle TextRect + { + get + { + int x = IconRect.Right + _barContainer.TextLeftSpace; + int w = CloseBtnRect.Left - x; + if (w < 0) + w = 0; + return new Rectangle(x, Bounds.Top, w, Bounds.Height); + } + } + + public Rectangle CloseBtnRect + { + get + { + return new Rectangle( + Bounds.Right - _barContainer.TabCloseBtnRightSpace - _barContainer.TabCloseBtnSize.Width, + Bounds.Top + (Bounds.Height - _barContainer.TabCloseBtnSize.Height) / 2, + _barContainer.TabCloseBtnSize.Width, + _barContainer.TabCloseBtnSize.Height); + } + } + + /// + /// 返回全部显示该标签文本所需的长度 + /// + /// + private int GetFullTextLength() + { + if (string.IsNullOrEmpty(Form.Text)) + return 0; + return TextRenderer.MeasureText(Form.Text, Form.Font).Width; + } + + /// + /// 返回显示全部文本时该tab所需的宽度,该宽度不超过bar-container + /// 规定的tabmaxwidth + /// + /// + public int GetFullShowTabWidth() + { + int w = _barContainer.TabSlopeWidth * 2 + _barContainer.IconSize.Width + + _barContainer.IconLeftSpace + _barContainer.TabCloseBtnSize.Width + + _barContainer.TabCloseBtnRightSpace + GetFullTextLength(); + if (w > _barContainer.TabMaxWidth) + w = _barContainer.TabMaxWidth; + return w; + } + } + + public enum BarButtonAlignmentType + { + /// + /// 居左 + /// + Left, + /// + /// 显示在最后一个标签后面 + /// + AfterLastTab, + } + + internal static class PathGetter + { + public static GraphicsPath GetTabBorderPath(Rectangle rect, int slopeWidth) + { + GraphicsPath path = new GraphicsPath(); + + Point p1 = new Point(rect.X + slopeWidth, rect.Y); + Point p2 = new Point(rect.Right - slopeWidth, rect.Y); + Point p3 = new Point(rect.Right, rect.Bottom); + Point p4 = new Point(rect.X, rect.Bottom); + + path.AddLine(p1, p2); + path.AddLine(p3, p4); + path.CloseFigure(); + + return path; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Forms/ThemeFormBase.cs b/Source/ryControls/Gdu.WinFormUI/Forms/ThemeFormBase.cs new file mode 100644 index 0000000..2f79c59 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Forms/ThemeFormBase.cs @@ -0,0 +1,575 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +using MGdu.WinFormUI.MyGraphics; + +namespace MGdu.WinFormUI +{ + /// + /// 该类封装设置一个主题所需的信息,可以继承该类实现不同的主题 + /// + public class ThemeFormBase + { + #region about theme + + /// + /// 主题名称,用于标识主题,对主题进行简单描述 + /// + public string ThemeName { protected set; get; } + + #endregion + + #region public info + + // form shape about + + /// + /// 窗体边界大小,鼠标移动到该边界将变成指针形状,拖动可改变窗体大小 + /// + public int SideResizeWidth { get; set; } + + /// + /// 窗体边框大小 + /// + public int BorderWidth { get; set; } + + /// + /// 窗体标题栏高度 + /// + public int CaptionHeight { get; set; } + + /// + /// 标题栏图标与窗体左边框的距离 + /// + public int IconLeftMargin { get; set; } + + /// + /// 标题栏图标尺寸 + /// + public Size IconSize { get; set; } + + /// + /// 标题栏文本左边距 + /// + public int TextLeftMargin { get; set; } + + /// + /// 控制按钮(关闭按钮)相对于窗体右上角的偏移量 + /// + public Point ControlBoxOffset { get; set; } + + /// + /// 窗体关闭按钮的尺寸 + /// + public Size CloseBoxSize { get; set; } + + /// + /// 窗体最大化/还原按钮的大小 + /// + public Size MaxBoxSize { get; set; } + + /// + /// 窗体最小化按钮的大小 + /// + public Size MinBoxSize { get; set; } + + /// + /// 关闭/最大化/最小化按钮之间的距离,可以设置成负值使它们重叠 + /// + public int ControlBoxSpace { get; set; } + + /// + /// 窗体圆角程度 + /// + public int Radius { get; set; } + + /// + /// 窗体圆角样式 + /// + public RoundStyle RoundedStyle { get; set; } + + /// + /// 是否使用默认的圆角样式,该样式为左上角和右上角圆角, + /// 最好在窗体边框较粗时才使用该样式 + /// + public bool UseDefaultTopRoundingFormRegion { get; set; } + + /// + /// 是否在标题栏上绘制图标 + /// + public bool DrawCaptionIcon { get; set; } + + /// + /// 是否在标题栏上绘制文本 + /// + public bool DrawCaptionText { get; set; } + + // form shadow + + /// + /// 是否显示窗体阴影 + /// + public bool ShowShadow { get; set; } + + /// + /// 窗体阴影大小 + /// + public int ShadowWidth { get; set; } + + /// + /// 拖动窗体阴影是否可以改变窗体大小 + /// + public bool UseShadowToResize { get; set; } + + /// + /// 阴影的颜色,可以设置成其他颜色而不一定是黑色 + /// + public Color ShadowColor { get; set; } + + /// + /// 阴影从里到外是逐渐变浅的,这个值设置深色部分的透明度,ARGB中的A值 + /// + public int ShadowAValueDark { get; set; } + + /// + /// 阴影从里到外是逐渐变浅的,这个值设置浅色部分的透明度,ARGB中的A值 + /// + public int ShadowAValueLight { get; set; } + + // form other + + /// + /// 是否在客户区边界画线使其看起来有立体感 + /// + public bool SetClientInset { get; set; } + + /// + /// 窗体标题栏文字是否居中显示 + /// + public bool CaptionTextCenter { get; set; } + + // form color + + /// + /// 窗体边框最外一像素的颜色 + /// + public Color FormBorderOutterColor { get; set; } + + /// + /// 窗体边框第二最外像素的颜色 + /// + public Color FormBorderInnerColor { get; set; } + + /// + /// 窗体边框其他部分颜色,如果窗体边框大小大于2,则其他像素将用此颜色画出 + /// + public Color FormBorderInmostColor { get; set; } + + /// + /// 标题栏颜色是从上到下渐变的,这个值设置上边的颜色值 + /// + public Color CaptionBackColorTop { get; set; } + + /// + /// 标题栏颜色是从上到下渐变的,这个值设置下边的颜色值 + /// + public Color CaptionBackColorBottom { get; set; } + + /// + /// 标题栏文字颜色 + /// + public Color CaptionTextColor { get; set; } + + /// + /// 窗体背景颜色,该值将覆盖窗体自带的BackColor属性值 + /// + public Color FormBackColor { get; set; } + + // control-box color table + /// + /// 窗体关闭按钮的颜色集合 + /// + public ButtonColorTable CloseBoxColor { get; set; } + + /// + /// 窗体最大化/还原按钮的颜色集合 + /// + public ButtonColorTable MaxBoxColor { get; set; } + + /// + /// 窗体最小化按钮的颜色集合 + /// + public ButtonColorTable MinBoxColor { get; set; } + + // control-box image + /// + /// 默认状态下关闭按钮背景图片 + /// + public Image CloseBoxBackImageNormal { get; set; } + /// + /// 鼠标移过去时关闭按钮背景图片 + /// + public Image CloseBoxBackImageHover { get; set; } + /// + /// 鼠标按下时关闭按钮背景图片 + /// + public Image CloseBoxBackImagePressed { get; set; } + /// + /// 默认状态下最大化按钮背景图片 + /// + public Image MaxBoxBackImageNormal { get; set; } + /// + /// 鼠标移过去时最大化按钮背景图片 + /// + public Image MaxBoxBackImageHover { get; set; } + /// + /// 鼠标按下时最大化按钮背景图片 + /// + public Image MaxBoxBackImagePressed { get; set; } + /// + /// 默认状态下恢复按钮背景图片 + /// + public Image ResBoxBackImageNormal { get; set; } + /// + /// 鼠标移过去时恢复按钮背景图片 + /// + public Image ResBoxBackImageHover { get; set; } + /// + /// 鼠标按下时恢复按钮背景图片 + /// + public Image ResBoxBackImagePressed { get; set; } + /// + /// 默认状态下最小化按钮背景图片 + /// + public Image MinBoxBackImageNormal { get; set; } + /// + /// 鼠标移过去时最小化按钮背景图片 + /// + public Image MinBoxBackImageHover { get; set; } + /// + /// 鼠标按下时最小化按钮背景图片 + /// + public Image MinBoxBackImagePressed { get; set; } + + #endregion + + #region mdi support + + // bar overall --------------------------------------------------------------- + /// + /// 是否用SendMessage的方式切换子窗体,以避免子窗体切换时产生的闪烁 + /// + public bool Mdi_UseMsgToActivateChild { get; set; } + + /// + /// Mdi-Bar与窗体左、上、右边界的距离,只用到这三个值,Bottom值没用到。 + /// 用这三个值来确定Mdi-Bar的宽度及其在窗体中的位置 + /// + public Padding Mdi_BarMargin { get; set; } + + /// + /// 内部左边空白,第一个标签将从这个空白距离之后开始 + /// + public int Mdi_BarLeftPadding { get; set; } + + /// + /// 标签栏内部右边空白 + /// + public int Mdi_BarRightPadding { get; set; } + /// + /// 标签栏背景颜色 + /// + public Color Mdi_BarBackColor { get; set; } + /// + /// 标签栏边框颜色 + /// + public Color Mdi_BarBorderColor { get; set; } + /// + /// 标签栏背景图片 + /// + public bool Mdi_DrawBarBackground { get; set; } + /// + /// 是否显示标签栏边框 + /// + public bool Mdi_DrawBarBorder { get; set; } + + // bar bottom region-------------------------------------------------------------- + /// + /// 标签栏下边区域的背景颜色 + /// + public Color Mdi_BarBottomRegionBackColor { get; set; } + /// + /// 标签栏下边区域的高度 + /// + public int Mdi_BarBottomRegionHeight { get; set; } + + + // tab ---------------------------------------------------------------------------- + /// + /// 标签高度 + /// + public int Mdi_TabHeight { get; set; } + + /// + /// 被选中的标签高度,可以设置成与TabHeight不一样的值,以突出显示被选中状态 + /// + public int Mdi_TabHeightActive { get; set; } + + /// + /// 标签之间的距离,设成负值可以使标签有重叠的效果 + /// + public int Mdi_TabAndTabSpace { get; set; } + + /// + /// 标签的最大宽度,任何情况下标签都不能超过这个宽度 + /// + public int Mdi_TabMaxWidth { get; set; } + + /// + /// 标签正常宽度,如果标签需要很短的宽度(比如20像素)就可以显示完上面的文字, + /// 但是Mdi-Bar上有足够的空间时,标签会以正常宽度(比如100像素)显示 + /// + public int Mdi_TabNormalWidth { get; set; } + + /// + /// 标签最小宽度,当标签小于这个宽度时将被隐藏 + /// + public int Mdi_TabMinWidth { get; set; } + + /// + /// 标签梯度大小,标签可以不以矩形方式显示,而是有一个梯度/斜度。 + /// + public int Mdi_TabSlopeWidth { get; set; } + + /// + /// 标签顶部空白,这个值用于参与计算Mdi-Bar高度,计算方式为: + /// Mdi-Bar Height = BottomRegionHeight + TabHeight + TabTopSpace + /// + public int Mdi_TabTopSpace { get; set; } + + /// + /// 标签上是否显示子窗体图标 + /// + public bool Mdi_ShowTabIcon { get; set; } + /// + /// 标签上是否显示子窗体关闭图标 + /// + public bool Mdi_ShowTabCloseIcon { get; set; } = true; + /// + /// 选中状态的标签的上部背景色,与下部背景色不同时,标签背景色就有渐变效果 + /// + public Color Mdi_TabActiveBackColorTop { get; set; } + /// + /// 选中状态的标签的下部背景色,与上部背景色不同时,标签背景色就有渐变效果 + /// + public Color Mdi_TabActiveBackColorBottom { get; set; } + /// + /// 标签激活时字体颜色 + /// + public Color Mdi_TabActiveForeColor { get; set; } = Color.Black; + /// + /// 非选中状态的标签的字体颜色 + /// + public Color Mdi_TabDeactiveForeColor { get; set; } = Color.Black; + + /// + /// 非选中状态的标签的上部背景色 + /// + public Color Mdi_TabDeactiveBackColorTop { get; set; } + /// + /// 非选中状态的标签的下部背景色 + /// + public Color Mdi_TabDeactiveBackColorBottom { get; set; } + + /// + /// 标签外边框颜色 + /// + public Color Mdi_TabOutterBorderColor { get; set; } + + /// + /// 标签内边框颜色,这个颜色一般具有一定的透明度 + /// + public Color Mdi_TabInnerBorderColor { get; set; } + /// + /// 是否显示标签边框 + /// + public bool Mdi_TabShowBorder { get; set; } = true; + // new tab btn --------------------------------------------------------------- + /// + /// 是否显示默认的新建标签按钮(NewTabBtn) + /// + public bool Mdi_ShowNewTabBtn { get; set; } + + /// + /// NewTabBtn与下边框的距离,这个值用来定位按钮的Y坐标 + /// + public int Mdi_NewTabBtnBottomSpace { get; set; } + /// + /// 新建标签按钮与左边框的距离,这个值用来定位按钮的X坐标 + /// + public int Mdi_NewTabBtnLeftSpace { get; set; } + /// + /// 新建标签按钮大小 + /// + public Size Mdi_NewTabBtnSize { get; set; } + /// + /// 按钮颜色集合 + /// + public ButtonColorTable Mdi_NewTabBtnColor { get; set; } + + // list-all-btn ---------------------------------------------------------- + /// + /// 是否一直显示ListAllBtn,即使在没有标签被隐藏的情况下 + /// + public bool Mdi_AlwaysShowListAllBtn { get; set; } + /// + ///《显示全部标签》按钮的位置 + /// + public BarButtonAlignmentType Mdi_ListAllBtnAlign { get; set; } + /// + /// 《显示全部标签》按钮与下边框的距离,这个值用来定位按钮的Y坐标 + /// + public int Mdi_ListAllBtnBottomSpace { get; set; } + /// + /// 《显示全部标签》按钮与左边框的距离,这个值用来定位按钮的X坐标 + /// + public int Mdi_ListAllBtnLeftSpace { get; set; } + /// + /// 《显示全部标签》按钮的颜色 + /// + public ButtonColorTable Mdi_ListAllBtnColor { get; set; } + /// + /// 《显示全部标签》按钮的大小 + /// + public Size Mdi_ListAllBtnSize { get; set; } + + #endregion + /// + /// 皮肤主题 + /// + public ThemeFormBase() + { + // about theme + ThemeName = "Base Default Theme"; + + // form shape + SideResizeWidth = 1; + BorderWidth = 1; + CaptionHeight = 26; + IconLeftMargin = 2; + IconSize = new Size(16, 16); + TextLeftMargin = 2; + ControlBoxOffset = new Point(1, 1); + ControlBoxSpace = 2; + Radius = 8; + RoundedStyle = RoundStyle.None; + UseDefaultTopRoundingFormRegion = true; + DrawCaptionIcon = true; + DrawCaptionText = true; + + // form shadow + ShowShadow = false; + ShadowWidth = 1; + ShadowColor = Color.Black; + ShadowAValueDark = 80; + ShadowAValueLight = 0; + UseShadowToResize = false; + + // form color + //FormBorderInmostColor = FormBorderInnerColor = FormBorderOutterColor + // = ColorHelper.GetLighterColor(Color.FromArgb(75, 159, 216), 10); + //CaptionBackColorBottom = CaptionBackColorTop + // = ColorHelper.GetLighterColor(Color.FromArgb(75, 159, 216), 10); + //CaptionTextColor = Color.Black; + //FormBackColor = SystemColors.Control; + CaptionBackColorTop = Color.FromArgb(51, 76, 95); + CaptionBackColorBottom = Color.FromArgb(51, 76, 95); + FormBackColor = Color.FromArgb(242, 242, 242); + CaptionTextColor = Color.White; + FormBorderOutterColor = FormBorderInnerColor = Color.FromArgb(230, 230, 230); + FormBorderInmostColor = Color.FromArgb(248, 248, 248); + + // form other + SetClientInset = true; + CaptionTextCenter = false; + + // control box color + CloseBoxSize = MaxBoxSize = MinBoxSize = new Size(30, 23); + ButtonColorTable closeTable = new ButtonColorTable(); + closeTable.ForeColorNormal = closeTable.ForeColorHover + = closeTable.ForeColorPressed = Color.FromArgb(249, 240, 223); + closeTable.BackColorHover = Color.FromArgb(217, 71, 71); + closeTable.BackColorPressed = Color.FromArgb(188, 52, 52); + CloseBoxColor = closeTable; + Mdi_ShowTabCloseIcon = false; + ButtonColorTable minTable = new ButtonColorTable(); + minTable.ForeColorNormal = minTable.ForeColorHover + = minTable.ForeColorPressed = Color.FromArgb(249, 240, 223); + minTable.BackColorHover = Color.FromArgb(67, 139, 221); + minTable.BackColorPressed = Color.FromArgb(50, 125, 210); + MinBoxColor = MaxBoxColor = minTable; + Mdi_ShowNewTabBtn = false; + + //CloseBoxColor = ButtonColorTable.GetDevWhiteThemeCloseBtnColor(); + //MaxBoxColor = ButtonColorTable.GetDevWhiteThemeMinMaxBtnColor(); + //MinBoxColor = MaxBoxColor; + + #region mdi support + + // bar overall + Mdi_UseMsgToActivateChild = true; + Mdi_BarMargin = new Padding(6, 38, 100, 0); + Mdi_BarLeftPadding = 3; + Mdi_BarRightPadding = 100; + Mdi_BarBackColor = Color.LightSkyBlue; + Mdi_BarBorderColor = Color.Red; + Mdi_DrawBarBackground = false; + Mdi_DrawBarBorder = false; + + // bar bottom region + Mdi_BarBottomRegionBackColor = Color.White; + Mdi_BarBottomRegionHeight = 3; + + // tab + Mdi_TabHeight = 26; + Mdi_TabHeightActive = Mdi_TabHeight; + Mdi_TabSlopeWidth = 8; + Mdi_TabAndTabSpace = -Mdi_TabSlopeWidth; + Mdi_TabTopSpace = 2; + Mdi_TabMaxWidth = 360; + Mdi_TabNormalWidth = 180; + Mdi_TabMinWidth = 90; + Mdi_ShowTabIcon = true; + + Mdi_TabOutterBorderColor = Color.Gray; + Mdi_TabInnerBorderColor = Color.FromArgb(180, Color.White); + Mdi_TabActiveBackColorTop = Color.White; + Mdi_TabActiveBackColorBottom = Color.FromArgb(248, 248, 248); + Mdi_TabDeactiveBackColorTop = Color.FromArgb(230, 230, 230); + Mdi_TabDeactiveBackColorBottom = Color.FromArgb(230, 230, 230); + + // new tab btn + Mdi_ShowNewTabBtn = true; + Mdi_NewTabBtnBottomSpace = 1; + Mdi_NewTabBtnLeftSpace = 4; + Mdi_NewTabBtnSize = new Size(24, 24); + + ButtonColorTable NewTabBtnTable = new ButtonColorTable(); + NewTabBtnTable.ForeColorNormal = NewTabBtnTable.ForeColorHover + = NewTabBtnTable.ForeColorPressed = Color.Gray; + NewTabBtnTable.BackColorHover = Color.White; + NewTabBtnTable.BackColorPressed = Color.WhiteSmoke; + Mdi_NewTabBtnColor = NewTabBtnTable; + // list all btn + Mdi_AlwaysShowListAllBtn = false; + Mdi_ListAllBtnAlign = BarButtonAlignmentType.Left; + Mdi_ListAllBtnBottomSpace = Mdi_BarBottomRegionHeight + 4; + Mdi_ListAllBtnLeftSpace = 4; + Mdi_ListAllBtnSize = new Size(36, 18); + Mdi_ListAllBtnColor = NewTabBtnTable; + #endregion + + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/GMControls/Common/GMBarControlBase.cs b/Source/ryControls/Gdu.WinFormUI/GMControls/Common/GMBarControlBase.cs new file mode 100644 index 0000000..08c8a23 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/GMControls/Common/GMBarControlBase.cs @@ -0,0 +1,112 @@ +using System; +using System.Drawing; +using System.Windows.Forms; +using System.ComponentModel; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public abstract class GMBarControlBase : Control + { + public GMBarControlBase() + { + base.SetStyle(ControlStyles.UserPaint | + ControlStyles.ResizeRedraw | + ControlStyles.AllPaintingInWmPaint | + ControlStyles.SupportsTransparentBackColor | + ControlStyles.OptimizedDoubleBuffer, true); + base.TabStop = false; + } + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public override string Text + { + get + { + return base.Text; + } + set + { + base.Text = value; + } + } + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public override RightToLeft RightToLeft + { + get + { + return base.RightToLeft; + } + set + { + base.RightToLeft = value; + } + } + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public override Image BackgroundImage + { + get + { + return base.BackgroundImage; + } + set + { + base.BackgroundImage = value; + } + } + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public override ImageLayout BackgroundImageLayout + { + get + { + return base.BackgroundImageLayout; + } + set + { + base.BackgroundImageLayout = value; + } + } + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public override System.Drawing.Color ForeColor + { + get + { + return base.ForeColor; + } + set + { + base.ForeColor = value; + } + } + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public override Color BackColor + { + get + { + return base.BackColor; + } + set + { + base.BackColor = value; + } + } + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public override Font Font + { + get + { + return base.Font; + } + set + { + base.Font = value; + } + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/GMControls/Common/GMControlType.cs b/Source/ryControls/Gdu.WinFormUI/GMControls/Common/GMControlType.cs new file mode 100644 index 0000000..caabfa6 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/GMControls/Common/GMControlType.cs @@ -0,0 +1,25 @@ +using System; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public enum GMControlType + { + Button, + RadioButton, + CheckBox, + RollingBar, + ProgressBar, + TrackBar, + ScrollBar, + + GMTabStrip, + + ListBox, + ComboBox, + + TreeView, + ListView, + GMGrid, + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/GMControls/Common/IGMControl.cs b/Source/ryControls/Gdu.WinFormUI/GMControls/Common/IGMControl.cs new file mode 100644 index 0000000..5d267fd --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/GMControls/Common/IGMControl.cs @@ -0,0 +1,10 @@ +using System; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public interface IGMControl + { + GMControlType ControlType { get; } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/GMControls/ProgressBar/GMProgessBarThemeBase.cs b/Source/ryControls/Gdu.WinFormUI/GMControls/ProgressBar/GMProgessBarThemeBase.cs new file mode 100644 index 0000000..6ab9065 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/GMControls/ProgressBar/GMProgessBarThemeBase.cs @@ -0,0 +1,51 @@ +using System; +using System.Drawing; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class GMProgessBarThemeBase : IDisposable + { + public Color BackColor { get; set; } + public Color BorderColor { get; set; } + public Color InnerBorderColor { get; set; } + public Color CoveredColor { get; set; } + public Color LeadingEdgeColor { get; set; } + + public bool DrawInnerBorder { get; set; } + public bool DrawLeadingEdge { get; set; } + public bool DrawBackColorGlass { get; set; } + public bool DrawCoveredColorGlass { get; set; } + + public int BorderRadius { get; set; } + public Color ForeColor { get; set; } + public Font ForeFont { get; set; } + + public GMProgessBarThemeBase() + { + BackColor = Color.White; + InnerBorderColor = Color.White; + BorderColor = Color.FromArgb(171, 171, 171); + CoveredColor = Color.FromArgb(0, 114, 198); + + DrawInnerBorder = true; + DrawLeadingEdge = false; + DrawBackColorGlass = false; + DrawCoveredColorGlass = false; + + BorderRadius = 0; + ForeColor = Color.Black; + ForeFont = new Font("微软雅黑", 9); + } + + #region IDisposable + + public void Dispose() + { + if (ForeFont != null && !ForeFont.IsSystemFont) + ForeFont.Dispose(); + } + + #endregion + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/GMControls/ProgressBar/GMProgressBar.cs b/Source/ryControls/Gdu.WinFormUI/GMControls/ProgressBar/GMProgressBar.cs new file mode 100644 index 0000000..11b8cbc --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/GMControls/ProgressBar/GMProgressBar.cs @@ -0,0 +1,409 @@ +/* + * 本代码受中华人民共和国著作权法保护,作者仅授权下载代码之人在学习和交流范围内 + * 自由使用与修改代码;欲将代码用于商业用途的,请与作者联系。 + * 使用本代码请保留此处信息。作者联系方式:ping3108@163.com, 欢迎进行技术交流 + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.ComponentModel; +using System.Windows.Forms; + +using MGdu.WinFormUI.MyGraphics; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + [ToolboxItem(true)] + public class GMProgressBar : GMBarControlBase, IGMControl + { + + #region 构造函数及初始化 + + public GMProgressBar() + { + + } + + #endregion + + #region private var + + string text = "0%"; + + #endregion + + #region IGMControl实现 + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public GMControlType ControlType + { + get { return GMControlType.ProgressBar; } + } + + #endregion + + #region 新增的公开属性 + + int _percentage = 0; + bool _showPercentageText = true; + GMProgessBarThemeBase _xtheme; + ProgressBarShapeStyle _shap = ProgressBarShapeStyle.Rectangle; + + [DefaultValue(0), Description("0-100之间的整数值,表示当前进度")] + public int Percentage + { + get + { + return _percentage; + } + set + { + if (_percentage != value) + { + if (value < 0) + value = 0; + if (value > 100) + value = 100; + _percentage = value; + text = _percentage.ToString() + "%"; + Invalidate(); + } + } + } + + [DefaultValue(true)] + public bool ShowPercentageText + { + get + { + return _showPercentageText; + } + set + { + if (_showPercentageText != value) + { + _showPercentageText = value; + Invalidate(); + } + } + } + + [Description("表示进度条是长方形的还是圆形的"),DefaultValue(typeof(ProgressBarShapeStyle),"0")] + public ProgressBarShapeStyle Shape + { + get + { + return _shap; + } + set + { + if (_shap != value) + { + _shap = value; + Invalidate(); + } + } + } + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public GMProgessBarThemeBase XTheme + { + get + { + return _xtheme; + } + set + { + _xtheme = value; + Invalidate(); + } + } + + #endregion + + #region 可用XTheme配置的属性 + + protected virtual Color GMBackColor + { + get + { + if (_xtheme == null) + return Color.White; + else + return _xtheme.BackColor; + } + } + + protected virtual Color InnerBorderColor + { + get + { + if (_xtheme == null) + return Color.White; + else + return _xtheme.InnerBorderColor; + } + } + + protected virtual Color BorderColor + { + get + { + if (_xtheme == null) + return Color.FromArgb(171, 171, 171); + else + return _xtheme.BorderColor; + } + } + + protected virtual Color CoveredColor + { + get + { + if (_xtheme == null) + return Color.FromArgb(0, 114, 198); + else + return _xtheme.CoveredColor; + } + } + + protected virtual Color LeadingEdgeColor + { + get + { + if (_xtheme == null) + return Color.Empty; + else + return _xtheme.LeadingEdgeColor; + } + } + + protected virtual bool DrawInnerBorder + { + get + { + if (_xtheme == null) + return true; + else + return _xtheme.DrawInnerBorder; + } + } + + protected virtual bool DrawLeadingEdge + { + get + { + if (_xtheme == null) + return false; + else + return _xtheme.DrawLeadingEdge; + } + } + + protected virtual bool DrawBackColorGlass + { + get + { + if (_xtheme == null) + return false; + else + return _xtheme.DrawBackColorGlass; + } + } + + protected virtual bool DrawCoveredColorGlass + { + get + { + if (_xtheme == null) + return false; + else + return _xtheme.DrawCoveredColorGlass; + } + } + + protected virtual int BorderRadius + { + get + { + if (_xtheme == null) + return 0; + else + return _xtheme.BorderRadius; + } + } + + protected virtual Color GMForeColor + { + get + { + if (_xtheme == null) + return base.ForeColor; + else + return _xtheme.ForeColor; + } + } + + protected virtual Font ForeFont + { + get + { + if (_xtheme == null) + return base.Font; + else + return _xtheme.ForeFont; + } + } + + #endregion + + #region 计算出的各元素区域 + + private Rectangle CoveredRect + { + get + { + Point location = ClientRectangle.Location; + int maxWidth, height, width; + if (DrawInnerBorder) + { + maxWidth = base.Width - 4; + height = base.Height - 4; + location.Offset(2, 2); + } + else + { + maxWidth = base.Width - 2; + height = base.Height - 2; + location.Offset(1, 1); + } + width = (int)((float)maxWidth * (float)Percentage / 100f); + return new Rectangle(location, new Size(width, height)); + } + } + + #endregion + + #region 内部绘图 + + protected virtual void PaintThisBar(Graphics g) + { + BasicBlockPainter.RenderFlatBackground(g, ClientRectangle, GMBackColor, + ButtonBorderType.Rectangle, BorderRadius, RoundStyle.All); + if (DrawBackColorGlass) + BasicBlockPainter.RenderRectangleGlass(g, ClientRectangle, BorderRadius, RoundStyle.All, + RectangleGlassPosition.Bottom, 270f, 0.5f, Color.White, 100, 20); + Rectangle rectCover = CoveredRect; + if (rectCover.Width > 0) + { + rectCover.Inflate(1, 1); + BasicBlockPainter.RenderFlatBackground(g, rectCover, CoveredColor, + ButtonBorderType.Rectangle, BorderRadius, RoundStyle.All); + if (DrawCoveredColorGlass) + BasicBlockPainter.RenderRectangleGlass(g, rectCover, BorderRadius, RoundStyle.All, + RectangleGlassPosition.Top, 90.001f); + } + if (DrawLeadingEdge && Percentage != 100) + { + rectCover.Inflate(-1, -1); + Point p1 = new Point(rectCover.Right - 1 + 1, rectCover.Y); + Point p2 = new Point(rectCover.Right - 1 + 1, rectCover.Bottom - 1); + using (Pen p = new Pen(LeadingEdgeColor)) + { + g.DrawLine(p, p1, p2); + } + } + if (ShowPercentageText) + { + TextRenderer.DrawText(g, text, ForeFont, ClientRectangle, ForeColor, + TextFormatFlags.HorizontalCenter | + TextFormatFlags.VerticalCenter); + } + Rectangle rectBorder = ClientRectangle; + BasicBlockPainter.RenderBorder(g, rectBorder, BorderColor, ButtonBorderType.Rectangle, + BorderRadius, RoundStyle.All); + if (DrawInnerBorder) + { + rectBorder.Inflate(-1, -1); + BasicBlockPainter.RenderBorder(g, rectBorder, InnerBorderColor, ButtonBorderType.Rectangle, + BorderRadius, RoundStyle.All); + } + } + + protected virtual void PaintThisBarInCircleShape(Graphics g) + { + Rectangle rect; + + if (base.Width < base.Height) + { + rect = new Rectangle(0, (Height - Width) / 2, Width, Width); + } + else + { + rect = new Rectangle((Width - Height) / 2, 0, Height, Height); + } + + g.FillRectangle(Brushes.Transparent, ClientRectangle); + + SimpleObjectPainter.RenderCircleProgressBar( + g, + rect, + CoveredColor, + BorderColor, + GMBackColor, + DrawInnerBorder, + 270, + Percentage, + ShowPercentageText, + ForeFont); + } + + #endregion + + #region 重写基类方法 + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + if (Shape == ProgressBarShapeStyle.Circle) + { + PaintThisBarInCircleShape(e.Graphics); + } + else + { + PaintThisBar(e.Graphics); + } + } + + [Browsable(true)] + public override System.Drawing.Color ForeColor + { + get + { + return base.ForeColor; + } + set + { + base.ForeColor = value; + } + } + + [Browsable(true)] + public override Font Font + { + get + { + return base.Font; + } + set + { + base.Font = value; + } + } + + #endregion + + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/GMControls/ProgressBar/ProgressBarShapeStyle.cs b/Source/ryControls/Gdu.WinFormUI/GMControls/ProgressBar/ProgressBarShapeStyle.cs new file mode 100644 index 0000000..f065350 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/GMControls/ProgressBar/ProgressBarShapeStyle.cs @@ -0,0 +1,11 @@ +using System; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public enum ProgressBarShapeStyle + { + Rectangle, + Circle, + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/GMControls/RollingBar/GMRollingBar.cs b/Source/ryControls/Gdu.WinFormUI/GMControls/RollingBar/GMRollingBar.cs new file mode 100644 index 0000000..f81466e --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/GMControls/RollingBar/GMRollingBar.cs @@ -0,0 +1,308 @@ +/* + * 本代码受中华人民共和国著作权法保护,作者仅授权下载代码之人在学习和交流范围内 + * 自由使用与修改代码;欲将代码用于商业用途的,请与作者联系。 + * 使用本代码请保留此处信息。作者联系方式:ping3108@163.com, 欢迎进行技术交流 + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.ComponentModel; +using System.Windows.Forms; + +using MGdu.WinFormUI.MyGraphics; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + [ToolboxItem(true)] + public class GMRollingBar : GMBarControlBase, IGMControl + { + + #region 构造函数及初始化 + + public GMRollingBar() + { + rollingTimer = new Timer(); + rollingTimer.Tick += new EventHandler(rollingTimer_Tick); + rollingTimer.Interval = _refleshFrequency; + rollingTimer.Enabled = false; + } + + #endregion + + #region private var + + float currentAngle = 0f; + + Timer rollingTimer; + + #endregion + + #region IGMControl实现 + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public GMControlType ControlType + { + get { return GMControlType.RollingBar; } + } + + #endregion + + #region 新增的公开属性 + + GMRollingBarThemeBase _xtheme; + RollingBarStyle _style; + int _refleshFrequency = 150; + + [DefaultValue(150)] + public int RefleshFrequency + { + get + { + return _refleshFrequency; + } + set + { + if (_refleshFrequency != value) + { + if (value < 1) + value = 150; + _refleshFrequency = value; + rollingTimer.Interval = _refleshFrequency; + } + } + } + + [DefaultValue(typeof(RollingBarStyle),"0")] + public RollingBarStyle Style + { + get + { + return _style; + } + set + { + if (_style != value) + { + _style = value; + Invalidate(); + } + } + } + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public GMRollingBarThemeBase XTheme + { + get + { + return _xtheme; + } + set + { + _xtheme = value; + Invalidate(); + } + } + + #endregion + + #region 公开的方法 + + public void StartRolling() + { + if (rollingTimer.Enabled) + return; + rollingTimer.Enabled = true; + } + + public void StopRolling() + { + rollingTimer.Enabled = false; + } + + #endregion + + #region 可用XTheme配置的属性 + + protected virtual int Radius1 + { + get + { + if (_xtheme == null) + return 10; + else + return _xtheme.Radius1; + } + } + + protected virtual int Radius2 + { + get + { + if (_xtheme == null) + return 24; + else + return _xtheme.Radius2; + } + } + + protected virtual int SpokeNum + { + get + { + if (_xtheme == null) + return 12; + else + return _xtheme.SpokeNum; + } + } + + protected virtual float PenWidth + { + get + { + if (_xtheme == null) + return 2; + else + return _xtheme.PenWidth; + } + } + + protected virtual Color BaseColor + { + get + { + if (_xtheme == null) + return Color.Red; + else + return _xtheme.BaseColor; + } + } + + protected virtual Color GMBackColor + { + get + { + if (_xtheme == null) + return Color.Transparent; + else + return _xtheme.BackColor; + } + } + + #endregion + + #region 内部方法 + + private void rollingTimer_Tick(object sender, EventArgs e) + { + base.Invalidate(); + } + + #endregion + + #region 内部绘图 + + protected virtual void PaintThisRollingBar(Graphics g) + { + switch (Style) + { + case RollingBarStyle.Default: + PaintDefault(g); + break; + + case RollingBarStyle.ChromeOneQuarter: + PaintChromeOneQuarter(g); + break; + + case RollingBarStyle.DiamondRing: + PaintDiamondRing(g); + break; + + case RollingBarStyle.BigGuyLeadsLittleGuys: + PaintTheseGuys(g); + break; + } + } + + private void IncreaseCurrentAngle(int spokeNum) + { + if (rollingTimer.Enabled) + { + currentAngle += 360f / spokeNum; + if (currentAngle > 360f) + currentAngle -= 360f; + } + } + + private void PaintDefault(Graphics g) + { + IncreaseCurrentAngle(SpokeNum); + + RollingBarPainter.RenderDefault( + g, + ClientRectangle, + GMBackColor, + currentAngle, + Radius1, + Radius2, + SpokeNum, + PenWidth, + ColorHelper.GetLighterArrayColors(BaseColor, SpokeNum)); + } + + private void PaintChromeOneQuarter(Graphics g) + { + IncreaseCurrentAngle(10); + + RollingBarPainter.RenderChromeOneQuarter( + g, + ClientRectangle, + GMBackColor, + currentAngle, + Radius1, + BaseColor); + } + + private void PaintDiamondRing(Graphics g) + { + IncreaseCurrentAngle(12); + + RollingBarPainter.RenderDiamondRing( + g, + ClientRectangle, + GMBackColor, + currentAngle, + Radius1, + BaseColor, + _xtheme == null ? Color.White : _xtheme.DiamondColor); + } + + private void PaintTheseGuys(Graphics g) + { + IncreaseCurrentAngle(10); + + RollingBarPainter.RenderTheseGuys( + g, + ClientRectangle, + GMBackColor, + currentAngle, + Radius1, + BaseColor); + } + + #endregion + + #region 重写基类方法 + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + PaintThisRollingBar(e.Graphics); + } + + #endregion + + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/GMControls/RollingBar/GMRollingBarThemeBase.cs b/Source/ryControls/Gdu.WinFormUI/GMControls/RollingBar/GMRollingBarThemeBase.cs new file mode 100644 index 0000000..95f749b --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/GMControls/RollingBar/GMRollingBarThemeBase.cs @@ -0,0 +1,28 @@ +using System; +using System.Drawing; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class GMRollingBarThemeBase + { + public int Radius1 { get; set; } + public int Radius2 { get; set; } + public int SpokeNum { get; set; } + public float PenWidth { get; set; } + public Color BackColor { get; set; } + public Color BaseColor { get; set; } + public Color DiamondColor { get; set; } + + public GMRollingBarThemeBase() + { + Radius1 = 10; + Radius2 = 24; + SpokeNum = 12; + PenWidth = 2; + BackColor = Color.Transparent; + BaseColor = Color.Red; + DiamondColor = Color.White; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/GMControls/RollingBar/RollingBarStyle.cs b/Source/ryControls/Gdu.WinFormUI/GMControls/RollingBar/RollingBarStyle.cs new file mode 100644 index 0000000..512ff58 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/GMControls/RollingBar/RollingBarStyle.cs @@ -0,0 +1,14 @@ +using System; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public enum RollingBarStyle + { + Default, + ChromeOneQuarter, + DiamondRing, + BigGuyLeadsLittleGuys, + //FiveRunningFools, + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/GMControls/ScrollBar/GMHScrollBar.cs b/Source/ryControls/Gdu.WinFormUI/GMControls/ScrollBar/GMHScrollBar.cs new file mode 100644 index 0000000..21457da --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/GMControls/ScrollBar/GMHScrollBar.cs @@ -0,0 +1,136 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + [ToolboxItem(true)] + public class GMHScrollBar : GMScrollBarBase + { + + #region 重写/实现属性 + + protected override int ScrollBarLength + { + get + { + return base.Size.Width; + } + } + + //现在发现这个属性其实没有必要重写 + protected override int MiddleButtonBeginPositionDot + { + get + { + int sideBtnLen = ShowSideButtons ? base.SideButtonLength : 0; + return base.InnerPaddingWidth + sideBtnLen + + base.MiddleButtonOutterSpace1; + } + } + + protected override Rectangle SideButton1Rect + { + get + { + int width, height; + if (ShowSideButtons) + { + height = base.Size.Height - InnerPaddingWidth * 2; + width = base.SideButtonLength; + + int len = ScrollBarLength - InnerPaddingWidth * 2; + if (len < 0) + len = 0; + if (len < SideButtonLength * 2) + width = len / 2; + } + else + { + width = height = 0; + } + return new Rectangle(base.InnerPaddingWidth, + base.InnerPaddingWidth, width, height); + } + } + + protected override Rectangle SideButton2Rect + { + get + { + Rectangle rect1 = SideButton1Rect; + return new Rectangle(Size.Width - InnerPaddingWidth - rect1.Width, + InnerPaddingWidth, rect1.Width, rect1.Height); + + } + } + + protected override Rectangle MiddleButtonRect + { + get + { + return new Rectangle(this.MiddleButtonCurrentPositionDot, + InnerPaddingWidth + MiddleButtonOutterSpace2, + base.MiddleButtonLength, + Size.Height - InnerPaddingWidth * 2 - MiddleButtonOutterSpace2 * 2 + ); + } + } + + protected override Rectangle BeforeMdlBtnRect + { + get + { + return new Rectangle(MiddleButtonBeginPositionDot, + InnerPaddingWidth, + MiddleButtonCurrentPositionDot - MiddleButtonBeginPositionDot, + Size.Height - InnerPaddingWidth * 2); + } + } + + protected override Rectangle AfterMdlBtnRect + { + get + { + int top = InnerPaddingWidth; + int left = MiddleButtonRect.Bottom; + int height = Size.Height - top * 2; + int width = SideButton2Rect.Left - left - MiddleButtonOutterSpace1; + if (!ShowSideButtons) + width += SideButtonLength; + return new Rectangle(left, top, width, height); + } + } + + protected override ForePathRatoteDirection SideButton1RotateInfo + { + get + { + return ForePathRatoteDirection.Left; + } + } + + protected override ForePathRatoteDirection SideButton2RotateInfo + { + get { return ForePathRatoteDirection.Right; } + } + + protected override bool IsVerticalBar + { + get { return false; } + } + + #endregion + + #region 构造函数 + + public GMHScrollBar() + { + } + + #endregion + + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/GMControls/ScrollBar/GMScrollBarBase.cs b/Source/ryControls/Gdu.WinFormUI/GMControls/ScrollBar/GMScrollBarBase.cs new file mode 100644 index 0000000..9aaf287 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/GMControls/ScrollBar/GMScrollBarBase.cs @@ -0,0 +1,1084 @@ +/* + * 本代码受中华人民共和国著作权法保护,作者仅授权下载代码之人在学习和交流范围内 + * 自由使用与修改代码;欲将代码用于商业用途的,请与作者联系。 + * 使用本代码请保留此处信息。作者联系方式:ping3108@163.com, 欢迎进行技术交流 + */ + +using System; +using System.Windows.Forms; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.ComponentModel; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + [ToolboxItem(false), DefaultEvent("ValueChanged")] + public abstract class GMScrollBarBase: GMBarControlBase, IGMControl + { + #region 类内部专用变量 + + const int MIN_MIDDLEBUTTON_LENGTH = 10; + + const int TIMER_INTERVAL_SLOW = 400; + const int TIMER_INTERVAL_FAST = 50; + bool isMouseDownInMiddleButton; + CutePointAndValuePresenter presenter; + + bool isMouseDownInSideButton; + LocationResult sideButtonDownWhere; + Point sideButtonDownPoint; + Point middleButtonMovePoint; + + Timer mouseDownTimer; + + bool middleButtonVisible; + + WLButton wlSideButton1; + WLButton wlSideButton2; + WLButton wlMiddleButton; + + private static readonly object EVENT_VALUECHANGED; + private static readonly object EVENT_THEMECHANGED; + + #endregion + + #region 内部专用属性 + + private int BlankSpaceLength + { + get + { + int sideBtnLen = ShowSideButtons ? SideButtonLength * 2 : 0; + return ScrollBarLength - InnerPaddingWidth * 2 - sideBtnLen - + MiddleButtonOutterSpace1 * 2; + } + } + + private int ActualMovableSpaceLength + { + get + { + return BlankSpaceLength - MiddleButtonLength + 1; + } + } + + #endregion + + #region 内部私有方法 + + private LocationResult CheckLocation(Point p) + { + if(SideButton1Rect.Contains(p)) + { + return LocationResult.SideButton1; + } + if(SideButton2Rect.Contains(p)) + { + return LocationResult.SideButton2; + } + if(MiddleButtonRect.Contains(p) && middleButtonVisible) + { + return LocationResult.MiddleButton; + } + if(BeforeMdlBtnRect.Contains(p)) + { + return LocationResult.BeforeMiddleButton; + } + if (AfterMdlBtnRect.Contains(p)) + { + return LocationResult.AfterMiddleButton; + } + return LocationResult.NoWhere; + } + + private void DoOnMouseDown(Point p) + { + LocationResult where = CheckLocation(p); + if (where == LocationResult.MiddleButton) + { + isMouseDownInMiddleButton = true; + middleButtonMovePoint = p; + wlMiddleButton.State = GMButtonState.Pressed; + } + else if (where != LocationResult.NoWhere) + { + isMouseDownInSideButton = true; + sideButtonDownWhere = where; + sideButtonDownPoint = p; + MouseDownSideButton(where); + mouseDownTimer.Enabled = true; + } + } + + private void MouseDownSideButton(LocationResult where) + { + int delta = 0; + switch (where) + { + case LocationResult.SideButton1: + delta = - SmallChange; + wlSideButton1.State = GMButtonState.Pressed; + break; + case LocationResult.SideButton2: + wlSideButton2.State = GMButtonState.Pressed; + delta = SmallChange; + break; + case LocationResult.AfterMiddleButton: + delta = LargeChange; + break; + case LocationResult.BeforeMiddleButton: + delta = - LargeChange; + break; + } + if (delta != 0) + { + ValueAdd(delta); + } + } + + private void DealMouseMoveWhenDownInSideButton(Point p) + { + sideButtonDownPoint = p; + } + + private void DealMouseMoveWhenDownInMiddleButton(Point p) + { + if (IsVerticalBar) + { + if (p.Y < MiddleButtonBeginPositionDot || p.Y > (MiddleButtonMaxPositionDot + MiddleButtonLength)) + return; + int delta = p.Y - middleButtonMovePoint.Y; + if (delta != 0) + this.DealMiddleButtonMove(delta); + middleButtonMovePoint = p; + } + else + { + if (p.X < MiddleButtonBeginPositionDot || p.X > (MiddleButtonMaxPositionDot + MiddleButtonLength)) + return; + int delta = p.X - middleButtonMovePoint.X; + if (delta != 0) + this.DealMiddleButtonMove(delta); + middleButtonMovePoint = p; + } + } + + private void MouseDownTimerHandler(object sender, EventArgs e) + { + if (mouseDownTimer.Interval != TIMER_INTERVAL_FAST) + mouseDownTimer.Interval = TIMER_INTERVAL_FAST; + if (sideButtonDownWhere == CheckLocation(sideButtonDownPoint)) + { + MouseDownSideButton(sideButtonDownWhere); + } + } + + private void ValueAdd(int amount) + { + int value = Value; + value += amount; + if (value < Minimum) + value = Minimum; + if (value > Maximum) + value = Maximum; + Value = value; + } + + private void UpdateScrollInfo() + { + if (presenter == null) + return; + + int valueCount = Maximum - Minimum + 1; + int pointCount = ActualMovableSpaceLength; + if (valueCount != presenter.ValueCount || pointCount != presenter.PointCount) + { + presenter.SetPointAndValueCount(pointCount, valueCount); + ResetMiddleButtonPosition(); + base.Invalidate(); + } + } + + private void ResetMiddleButtonPosition() + { + int beginDot = MiddleButtonBeginPositionDot; + int p1, p2; + presenter.GetPointIndexFromValueIndex(Value - Minimum, out p1, out p2); + p1 += beginDot; + p2 += beginDot; + if (MiddleButtonCurrentPositionDot >= p1 && MiddleButtonCurrentPositionDot <= p2) + return; + if (Value == Maximum) + MiddleButtonCurrentPositionDot = p2; + else + MiddleButtonCurrentPositionDot = p1; + Invalidate(); + } + + private bool HasEnoughRoomForMiddleButton() + { + int lenForMBtn = ScrollBarLength - InnerPaddingWidth * 2 - + MiddleButtonOutterSpace1 * 2; + if (ShowSideButtons) + lenForMBtn -= SideButtonLength * 2; + return (lenForMBtn > MIN_MIDDLEBUTTON_LENGTH); + } + + private void DoOnResize() + { + + middleButtonVisible = HasEnoughRoomForMiddleButton() && base.Enabled; + + wlSideButton1.Bounds = SideButton1Rect; + wlSideButton2.Bounds = SideButton2Rect; + wlMiddleButton.Bounds = MiddleButtonRect; + + this.UpdateScrollInfo(); + } + + private void UpdateInfoToSideMiddleButton() + { + SetSideMdlBtnInfo(); + DoOnResize(); + Invalidate(); + } + + private void SetSideMdlBtnInfo() + { + wlSideButton1.ColorTable = SideButtonColorTable; + wlSideButton2.ColorTable = SideButtonColorTable; + wlMiddleButton.ColorTable = MiddleButtonColorTable; + wlSideButton1.ForePathGetter = SideButtonForePathGetter; + wlSideButton2.ForePathGetter = SideButtonForePathGetter; + wlSideButton1.ForePathSize = SideButtonForePathSize; + wlSideButton2.ForePathSize = SideButtonForePathSize; + + wlSideButton1.HowForePathRender = HowSideButtonForePathDraw; + wlSideButton2.HowForePathRender = HowSideButtonForePathDraw; + + wlSideButton1.BorderType = wlSideButton2.BorderType = + (_xtheme == null ? ButtonBorderType.Rectangle : _xtheme.SideButtonBorderType); + wlSideButton1.Radius = wlSideButton2.Radius = + (_xtheme == null ? 0 : _xtheme.SideButtonRadius); + wlMiddleButton.Radius = (_xtheme == null ? 0 : _xtheme.MiddleButtonRadius); + } + + private void SetButtonState(Point p, GMButtonState newState) + { + wlMiddleButton.State = wlSideButton2.State = wlSideButton1.State = GMButtonState.Normal; + switch (CheckLocation(p)) + { + case LocationResult.MiddleButton: + wlMiddleButton.State = newState; + break; + case LocationResult.SideButton1: + wlSideButton1.State = newState; + break; + case LocationResult.SideButton2: + wlSideButton2.State = newState; + break; + } + } + + private void DealMiddleButtonMove(int moveDelta) + { + MiddleButtonCurrentPositionDot += moveDelta; + int v1, v2; + int locIndex = MiddleButtonCurrentPositionDot - MiddleButtonBeginPositionDot; + presenter.GetValueIndexFromPointIndex(locIndex, out v1, out v2); + if (MiddleButtonCurrentPositionDot == MiddleButtonMaxPositionDot) + { + Value = Minimum + v2; + } + else if (MiddleButtonCurrentPositionDot == MiddleButtonBeginPositionDot) + { + Value = Minimum + v1; + } + else + { + Value = Minimum + v1 + (v2 - v1) / 2; + } + } + + #endregion + + #region 内部绘图 + + private void PaintScrollBar(Graphics g) + { + if (DrawBackground) + { + RenderBackground(g); + } + + if (middleButtonVisible) + { + wlMiddleButton.Bounds = MiddleButtonRect; + wlMiddleButton.DrawButton(g); + } + + if (ShowSideButtons) + { + wlSideButton1.DrawButton(g); + wlSideButton2.DrawButton(g); + } + + if (DrawBorder) + { + RenderBorders(g); + } + } + + private void RenderBackground(Graphics g) + { + using (SolidBrush sb = new SolidBrush(GMBackColor)) + { + g.FillRectangle(sb, ClientRectangle); + } + } + + private void RenderMiddleButton(Graphics g) + { + Rectangle rect = MiddleButtonRect; + rect.Width--; rect.Height--; + g.DrawRectangle(Pens.Black, rect); + } + + private void RenderBorders(Graphics g) + { + Rectangle rect = ClientRectangle; + rect.Width--; + rect.Height--; + using (Pen p = new Pen(BorderColor)) + { + g.DrawRectangle(p, rect); + } + } + + private void MiddleButtonExtraPaint(object sender, PaintEventArgs e) + { + if (!DrawLinesInMiddleButton) + return; + int linesLen = 8; + if (MiddleButtonLength < (linesLen + MiddleBtnLineOutterSpace1 * 2)) + return; + + Pen p1 = new Pen(MiddleButtonLine1Color); + Pen p2 = new Pen(MiddleButtonLine2Color); + Rectangle rect = e.ClipRectangle; + + if (IsVerticalBar) + { + int x1 = rect.Left + MiddleBtnLineOutterSpace2; + int x2 = rect.Right - MiddleBtnLineOutterSpace2 - 1; + int y = rect.Top + (rect.Height - linesLen) / 2; + for (int i = 0; i < 3; i++) + { + e.Graphics.DrawLine(p1, x1, y, x2, y); + e.Graphics.DrawLine(p2, x1, y+1, x2, y+1); + + y += 3; + } + } + else + { + int x = rect.Left + (rect.Width - linesLen) / 2; + int y1 = rect.Top + MiddleBtnLineOutterSpace2; + int y2 = rect.Bottom - MiddleBtnLineOutterSpace2 - 1; + for (int i = 0; i < 3; i++) + { + e.Graphics.DrawLine(p1, x, y1, x, y2); + e.Graphics.DrawLine(p2, x+1, y1, x+1, y2); + x += 3; + } + } + + p1.Dispose(); + p2.Dispose(); + } + + #endregion + + #region 可通过XTheme配置的属性 + + protected int InnerPaddingWidth + { + get + { + if (_xtheme == null) + return 0; + else + return _xtheme.InnerPaddingWidth; + } + } + + protected int MiddleButtonOutterSpace1 + { + get + { + if (_xtheme == null) + return 1; + else + return _xtheme.MiddleButtonOutterSpace1; + } + } + + protected int MiddleButtonOutterSpace2 + { + get + { + if (_xtheme == null) + return 0; + else + return _xtheme.MiddleButtonOutterSpace2; + } + } + + protected int SideButtonLength + { + get + { + if (_xtheme == null) + return 16; + else + return _xtheme.SideButtonLength; + } + } + + protected bool DrawBackground + { + get + { + if (_xtheme == null) + return true; + else + return _xtheme.DrawBackground; + } + } + + protected bool DrawBorder + { + get + { + if (_xtheme == null) + return false; + else + return _xtheme.DrawBorder; + } + } + + protected bool DrawInnerBorder + { + get + { + if (_xtheme == null) + return false; + else + return _xtheme.DrawInnerBorder; + } + } + + protected bool ShowSideButtons + { + get + { + if (_xtheme == null) + return true; + else + return _xtheme.ShowSideButtons; + } + } + + protected Color GMBackColor + { + get + { + if (_xtheme == null) + return Color.FromArgb(227, 227, 227); + else + return _xtheme.BackColor; + } + } + + protected Color BorderColor + { + get + { + if (_xtheme == null) + return Color.FromArgb(248, 248, 248); + else + return _xtheme.BorderColor; + } + } + + protected Color InnerBorderColor + { + get + { + if (_xtheme == null) + return Color.Empty; + else + return _xtheme.InnerBorderColor; + } + } + + protected Size SideButtonForePathSize + { + get + { + if (_xtheme == null) + return new Size(7, 7); + else + return _xtheme.SideButtonForePathSize; + } + } + + protected ButtonForePathGetter SideButtonForePathGetter + { + get + { + if (_xtheme == null) + return new ButtonForePathGetter( + MGdu.WinFormUI.MyGraphics.GraphicsPathHelper.Create7x4In7x7DownTriangleFlag); + else + return _xtheme.SideButtonForePathGetter; + } + } + + protected ButtonColorTable SideButtonColorTable + { + get + { + if (_xtheme == null) + return GetDefaultSideMdlBtnColor(); + else + return _xtheme.SideButtonColorTable; + } + } + + protected ButtonColorTable MiddleButtonColorTable + { + get + { + if (_xtheme == null) + return GetDefaultSideMdlBtnColor(); + else + return _xtheme.MiddleButtonColorTable; + } + } + + protected ForePathRenderMode HowSideButtonForePathDraw + { + get + { + if (_xtheme == null) + return ForePathRenderMode.Draw ; + else + return _xtheme.HowSideButtonForePathDraw; + } + } + + protected bool DrawLinesInMiddleButton + { + get + { + if (_xtheme == null) + return true; + else + return _xtheme.DrawLinesInMiddleButton; + } + } + + protected Color MiddleButtonLine1Color + { + get + { + if (_xtheme == null) + return Color.FromArgb(89, 89, 89); + else + return _xtheme.MiddleButtonLine1Color; + } + } + + protected Color MiddleButtonLine2Color + { + get + { + if (_xtheme == null) + return Color.FromArgb(182, 182, 182); + else + return _xtheme.MiddleButtonLine2Color; + } + } + + protected int MiddleBtnLineOutterSpace1 + { + get + { + if (_xtheme == null) + return 4; + else + return _xtheme.MiddleBtnLineOutterSpace1; + } + } + + protected int MiddleBtnLineOutterSpace2 + { + get + { + if (_xtheme == null) + return 4; + else + return _xtheme.MiddleBtnLineOutterSpace2; + } + } + + private ButtonColorTable GetDefaultSideMdlBtnColor() + { + ButtonColorTable table = new ButtonColorTable(); + + table.BorderColorNormal = Color.FromArgb(151, 151, 151); + table.BorderColorHover = Color.FromArgb(53, 111, 155); + table.BorderColorPressed = Color.FromArgb(60, 127, 177); + + table.BackColorNormal = Color.FromArgb(217, 218, 219); + table.BackColorHover = Color.FromArgb(169, 219, 246); + table.BackColorPressed = Color.FromArgb(111, 202, 240); + + table.ForeColorNormal = Color.FromArgb(73, 73, 73); + table.ForeColorHover = Color.FromArgb(32, 106, 145); + table.ForeColorPressed = Color.FromArgb(15, 38, 50); + table.ForeColorDisabled = SystemColors.ControlDarkDark; + + table.BackColorDisabled = SystemColors.ControlDark; + + return table; + } + + #endregion + + #region 子类可访问的Protected属性, 可重写的protected方法 + + protected int MiddleButtonLength + { + get + { + return Math.Max(MIN_MIDDLEBUTTON_LENGTH, + BlankSpaceLength * MiddleButtonLengthPercentage / 100); + } + } + + protected int MiddleButtonMaxPositionDot + { + get + { + return MiddleButtonBeginPositionDot + ActualMovableSpaceLength - 1; + } + } + + int _middleButtonCurrentPositionDot; + protected int MiddleButtonCurrentPositionDot + { + get + { + return _middleButtonCurrentPositionDot; + } + set + { + if (_middleButtonCurrentPositionDot == value) + return; + if (value > MiddleButtonMaxPositionDot) + _middleButtonCurrentPositionDot = MiddleButtonMaxPositionDot; + else if (value < MiddleButtonBeginPositionDot) + _middleButtonCurrentPositionDot = MiddleButtonBeginPositionDot; + else + _middleButtonCurrentPositionDot = value; + + Invalidate(); + } + } + + /// + /// 引发 ValueChanged 事件 + /// + /// + protected virtual void OnValueChanged(EventArgs e) + { + EventHandler handler = (EventHandler)base.Events[EVENT_VALUECHANGED]; + if (handler != null) + { + handler(this, e); + } + } + + /// + /// 引发 ThemeChanged 事件 + /// + /// + protected virtual void OnThemeChanged(EventArgs e) + { + EventHandler handler = (EventHandler)base.Events[EVENT_THEMECHANGED]; + if (handler != null) + { + handler(this, e); + } + } + + #endregion + + #region 留给子类(HScrollBar, VScrollBar)重写的属性 + + protected abstract int ScrollBarLength { get; } + protected abstract int MiddleButtonBeginPositionDot { get; } + protected abstract Rectangle SideButton1Rect { get; } + protected abstract Rectangle SideButton2Rect { get; } + protected abstract Rectangle MiddleButtonRect { get; } + protected abstract Rectangle BeforeMdlBtnRect { get; } + protected abstract Rectangle AfterMdlBtnRect { get; } + protected abstract ForePathRatoteDirection SideButton1RotateInfo { get; } + protected abstract ForePathRatoteDirection SideButton2RotateInfo { get; } + protected abstract bool IsVerticalBar { get; } + + #endregion + + #region IGMControl接口实现 + + [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)] + public GMControlType ControlType + { + get { return GMControlType.ScrollBar; } + } + + #endregion + + #region 控件事件 + + public event EventHandler ValueChanged + { + add + { + base.Events.AddHandler(EVENT_VALUECHANGED, value); + } + remove + { + base.Events.RemoveHandler(EVENT_VALUECHANGED, value); + } + } + + public event EventHandler ThemeChanged + { + add + { + base.Events.AddHandler(EVENT_THEMECHANGED, value); + } + remove + { + base.Events.RemoveHandler(EVENT_THEMECHANGED, value); + } + } + + #endregion + + #region 辅助公开属性的内部变量 + + int _maximum = 100; + int _minimum = 0; + int _value = 0; + int _smallChange = 1; + int _largeChange = 10; + int _middleButtonLengthPercentage = 10; + GMScrollBarThemeBase _xtheme; + + #endregion + + #region 公开属性 + + [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)] + public GMScrollBarThemeBase XTheme + { + get + { + return this._xtheme; + } + set + { + if (this._xtheme == value) + return; + this._xtheme = value; + UpdateInfoToSideMiddleButton(); + OnThemeChanged(EventArgs.Empty); + } + } + + [DefaultValue(0)] + public int Value + { + get + { + return this._value; + } + set + { + if (this._value == value) + return; + if (value < Minimum || value > Maximum) + throw new ArgumentOutOfRangeException("Value"); + + this._value = value; + ResetMiddleButtonPosition(); + OnValueChanged(EventArgs.Empty); + } + } + + [DefaultValue(0), RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)] + public int Minimum + { + get + { + return this._minimum; + } + set + { + if (this._minimum == value) + return; + + if (value > this._maximum) + this._maximum = value; + + if (this.Value < value) + this.Value = value; + + this._minimum = value; + this.UpdateScrollInfo(); + } + } + + [DefaultValue(100), RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)] + public int Maximum + { + get + { + return this._maximum; + } + set + { + if (this._maximum == value) + return; + + if (value < this._minimum) + this._minimum = value; + + if (this.Value > value) + this.Value = value; + + this._maximum = value; + this.UpdateScrollInfo(); + } + } + + public int SmallChange + { + get + { + return _smallChange; + } + set + { + _smallChange = value < 1 ? 1 : value; + } + } + + public int LargeChange + { + get + { + return _largeChange; + } + set + { + _largeChange = value < 1 ? 1 : value; + } + } + + public int MiddleButtonLengthPercentage + { + get + { + return this._middleButtonLengthPercentage; + } + set + { + if (this._middleButtonLengthPercentage == value) + return; + if (value >= 5 && value <= 90) + { + this._middleButtonLengthPercentage = value; + } + else + { + if (value < 5) + this._middleButtonLengthPercentage = 5; + if (value > 90) + this._middleButtonLengthPercentage = 90; + } + this.UpdateScrollInfo(); + } + } + + #endregion + + #region 构造函数及初始化 + + static GMScrollBarBase() + { + EVENT_VALUECHANGED = new object(); + EVENT_THEMECHANGED = new object(); + } + + public GMScrollBarBase() + : base() + { + presenter = new CutePointAndValuePresenter(); + ButtonsIni(); + mouseDownTimer = new Timer(); + mouseDownTimer.Enabled = false; + mouseDownTimer.Interval = TIMER_INTERVAL_SLOW; + mouseDownTimer.Tick += new EventHandler(MouseDownTimerHandler); + } + + private void ButtonsIni() + { + wlSideButton1 = new WLButton(this); + wlSideButton2 = new WLButton(this); + wlMiddleButton = new WLButton(this); + + wlSideButton1.RotateDirection = SideButton1RotateInfo; + wlSideButton2.RotateDirection = SideButton2RotateInfo; + + wlSideButton1.RoundedType = wlSideButton2.RoundedType = MyGraphics.RoundStyle.All; + wlMiddleButton.RoundedType = MyGraphics.RoundStyle.All; + + SetSideMdlBtnInfo(); + + wlMiddleButton.Paint += new PaintEventHandler(MiddleButtonExtraPaint); + } + + #endregion + + #region 重写方法 + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + PaintScrollBar(e.Graphics); + } + + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + DoOnResize(); + } + + protected override void OnMouseDown(MouseEventArgs e) + { + base.OnMouseDown(e); + if (e.Button == System.Windows.Forms.MouseButtons.Left) + { + DoOnMouseDown(e.Location); + } + } + + protected override void OnMouseUp(MouseEventArgs e) + { + base.OnMouseUp(e); + if (e.Button == System.Windows.Forms.MouseButtons.Left) + { + isMouseDownInMiddleButton = false; + isMouseDownInSideButton = false; + sideButtonDownWhere = LocationResult.NoWhere; + mouseDownTimer.Enabled = false; + mouseDownTimer.Interval = TIMER_INTERVAL_SLOW; + + SetButtonState(e.Location, GMButtonState.Hover); + } + } + + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + if (isMouseDownInSideButton) + { + DealMouseMoveWhenDownInSideButton(e.Location); + } + if (isMouseDownInMiddleButton) + { + DealMouseMoveWhenDownInMiddleButton(e.Location); + } + if (!isMouseDownInMiddleButton && !isMouseDownInSideButton) + { + SetButtonState(e.Location, GMButtonState.Hover); + } + } + + protected override void OnMouseLeave(EventArgs e) + { + base.OnMouseLeave(e); + wlMiddleButton.State = wlSideButton2.State = wlSideButton1.State = GMButtonState.Normal; + } + + protected override void OnEnabledChanged(EventArgs e) + { + base.OnEnabledChanged(e); + + wlSideButton2.Enabled = base.Enabled; + wlSideButton1.Enabled = base.Enabled; + + middleButtonVisible = HasEnoughRoomForMiddleButton() && base.Enabled; + Invalidate(); + } + + #endregion + + #region debug + + //debuggggggggggggggggggggggggggggggggg + //ccccccccccccccccccccccccccccccccccccc + public void DebugEntry() + { + Console.WriteLine("BlankSpaceLength: " + BlankSpaceLength.ToString()); + Console.WriteLine("MiddleButtonLength: " + MiddleButtonLength.ToString()); + Console.WriteLine("MiddleButtonRect: " + MiddleButtonRect.ToString()); + Console.WriteLine("ActualMovableSpaceLength: " + ActualMovableSpaceLength.ToString()); + + //XTheme.MiddleButtonOutterSpace1 = 2; + + Console.WriteLine("MiddleButtonOutterSpace1: " + XTheme.MiddleButtonOutterSpace1.ToString()); + + Console.WriteLine("InnerPaddingWidth: " + XTheme.InnerPaddingWidth.ToString()); + + } + + //debuggggggggggggggggggggggggggggggggggggggggggg + public CutePointAndValuePresenter GetPresenter() + { + return presenter; + } + + #endregion + + /// + /// 指示鼠标位于哪个区域 + /// + private enum LocationResult + { + NoWhere, + SideButton1, + SideButton2, + MiddleButton, + BeforeMiddleButton, + AfterMiddleButton + } + + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/GMControls/ScrollBar/GMScrollBarThemeBase.cs b/Source/ryControls/Gdu.WinFormUI/GMControls/ScrollBar/GMScrollBarThemeBase.cs new file mode 100644 index 0000000..a1e2f5d --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/GMControls/ScrollBar/GMScrollBarThemeBase.cs @@ -0,0 +1,116 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class GMScrollBarThemeBase : IDisposable + { + public int InnerPaddingWidth { get; set; } + public int MiddleButtonOutterSpace1 { get; set; } + public int MiddleButtonOutterSpace2 { get; set; } + public int SideButtonLength { get; set; } + public int BestUndirectLen { get; set; } + public bool DrawBackground { get; set; } + public bool DrawBorder { get; set; } + public bool DrawInnerBorder { get; set; } + public bool ShowSideButtons { get; set; } + public Color BackColor { get; set; } + public Color BorderColor { get; set; } + public Color InnerBorderColor { get; set; } + public Size SideButtonForePathSize { get; set; } + public ButtonForePathGetter SideButtonForePathGetter { get; set; } + public ButtonColorTable SideButtonColorTable { get; set; } + public ButtonColorTable MiddleButtonColorTable { get; set; } + public ForePathRenderMode HowSideButtonForePathDraw { get; set; } + + public bool DrawLinesInMiddleButton { get; set; } + public Color MiddleButtonLine1Color { get; set; } + public Color MiddleButtonLine2Color { get; set; } + public int MiddleBtnLineOutterSpace1 { get; set; } + public int MiddleBtnLineOutterSpace2 { get; set; } + + public int SideButtonRadius { get; set; } + public int MiddleButtonRadius { get; set; } + public ButtonBorderType SideButtonBorderType { get; set; } + + private void SetDefaultValue() + { + InnerPaddingWidth = 0; + MiddleButtonOutterSpace1 = 1; + MiddleButtonOutterSpace2 = 0; + SideButtonLength = 16; + BestUndirectLen = 15; + DrawBackground = true; + DrawBorder = false; + DrawInnerBorder = false; + ShowSideButtons = true; + //SideButtonCanDisabled = false; + BackColor = Color.FromArgb(227,227,227); + BorderColor = Color.FromArgb(248, 248, 248); + + SideButtonForePathSize = new Size(10, 9); + SideButtonForePathGetter = new ButtonForePathGetter( + MGdu.WinFormUI.MyGraphics.GraphicsPathHelper.Create7x4DownTriangleFlag); + + SideButtonColorTable = SideBtnColor(); + MiddleButtonColorTable = MdlBtnColor(); + + HowSideButtonForePathDraw = ForePathRenderMode.Draw; + + DrawLinesInMiddleButton = true; + MiddleBtnLineOutterSpace1 = 4; + MiddleBtnLineOutterSpace2 = 4; + MiddleButtonLine1Color = Color.FromArgb(89, 89, 89); + MiddleButtonLine2Color = Color.FromArgb(182, 182, 182); + + SideButtonRadius = MiddleButtonRadius = 0; + SideButtonBorderType = ButtonBorderType.Rectangle; + } + + private ButtonColorTable SideBtnColor() + { + ButtonColorTable table = MdlBtnColor(); + + table.ForeColorNormal = Color.FromArgb(73, 73, 73); + table.ForeColorHover = Color.FromArgb(32, 106, 145); + table.ForeColorPressed = Color.FromArgb(15, 38, 50); + table.ForeColorDisabled = SystemColors.ControlDarkDark; + + table.BackColorDisabled = SystemColors.ControlDark; + + return table; + } + + private ButtonColorTable MdlBtnColor() + { + ButtonColorTable table = new ButtonColorTable(); + + table.BorderColorNormal = Color.FromArgb(151, 151, 151); + table.BorderColorHover = Color.FromArgb(53, 111, 155); + table.BorderColorPressed = Color.FromArgb(60, 127, 177); + + table.BackColorNormal = Color.FromArgb(217, 218, 219); + table.BackColorHover = Color.FromArgb(169, 219, 246); + table.BackColorPressed = Color.FromArgb(111, 202, 240); + + return table; + } + + public GMScrollBarThemeBase() + { + SetDefaultValue(); + } + + #region IDisposable + + public void Dispose() + { + //if (SideButtonForePath != null) + // SideButtonForePath.Dispose(); + } + + #endregion + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/GMControls/ScrollBar/GMVScrollBar.cs b/Source/ryControls/Gdu.WinFormUI/GMControls/ScrollBar/GMVScrollBar.cs new file mode 100644 index 0000000..9927ab0 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/GMControls/ScrollBar/GMVScrollBar.cs @@ -0,0 +1,138 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + [ToolboxItem(true)] + public class GMVScrollBar : GMScrollBarBase + { + #region private var + + #endregion + + #region 重写/实现属性 + + protected override int ScrollBarLength + { + get + { + return base.Size.Height; + } + } + + protected override int MiddleButtonBeginPositionDot + { + get + { + int sizeBtnLen = ShowSideButtons ? base.SideButtonLength : 0; + return base.InnerPaddingWidth + sizeBtnLen + + base.MiddleButtonOutterSpace1; + } + } + + protected override Rectangle SideButton1Rect + { + get + { + int width, height; + if (ShowSideButtons) + { + width = base.Size.Width - InnerPaddingWidth * 2; + height = base.SideButtonLength; + + int len = ScrollBarLength - InnerPaddingWidth * 2; + if (len < 0) + len = 0; + if (len < SideButtonLength * 2) + height = len / 2; + } + else + { + width = height = 0; + } + return new Rectangle(base.InnerPaddingWidth, + base.InnerPaddingWidth, width, height); + } + } + + protected override Rectangle SideButton2Rect + { + get + { + Rectangle rect1 = SideButton1Rect; + return new Rectangle(InnerPaddingWidth, + Size.Height - InnerPaddingWidth - rect1.Height, + rect1.Width, rect1.Height); + + } + } + + protected override Rectangle MiddleButtonRect + { + get + { + return new Rectangle(InnerPaddingWidth + MiddleButtonOutterSpace2, + this.MiddleButtonCurrentPositionDot, + Size.Width - InnerPaddingWidth * 2 - MiddleButtonOutterSpace2 * 2, + base.MiddleButtonLength); + } + } + + protected override Rectangle BeforeMdlBtnRect + { + get + { + return new Rectangle(InnerPaddingWidth, + MiddleButtonBeginPositionDot, + Size.Width - InnerPaddingWidth * 2, + MiddleButtonCurrentPositionDot - MiddleButtonBeginPositionDot); + } + } + + protected override Rectangle AfterMdlBtnRect + { + get + { + int left = InnerPaddingWidth; + int top = MiddleButtonRect.Bottom; + int width = Size.Width - left * 2; + int height = SideButton2Rect.Top - top - MiddleButtonOutterSpace1; + if (!ShowSideButtons) + height += SideButtonLength; + return new Rectangle(left, top, width, height); + } + } + + protected override ForePathRatoteDirection SideButton1RotateInfo + { + get + { + return ForePathRatoteDirection.Up; + } + } + + protected override ForePathRatoteDirection SideButton2RotateInfo + { + get { return ForePathRatoteDirection.Down; } + } + + protected override bool IsVerticalBar + { + get { return true; } + } + + #endregion + + #region 构造函数 + + public GMVScrollBar() + { + } + + #endregion + + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/GMControls/TrackBar/CutePointAndValuePresenter.cs b/Source/ryControls/Gdu.WinFormUI/GMControls/TrackBar/CutePointAndValuePresenter.cs new file mode 100644 index 0000000..f0d18d0 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/GMControls/TrackBar/CutePointAndValuePresenter.cs @@ -0,0 +1,246 @@ +/* + * 本代码受中华人民共和国著作权法保护,作者仅授权下载代码之人在学习和交流范围内 + * 自由使用与修改代码;欲将代码用于商业用途的,请与作者联系。 + * 使用本代码请保留此处信息。作者联系方式:ping3108@163.com, 欢迎进行技术交流 + */ + +using System; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class CutePointAndValuePresenter + { + #region 内部变量 + + int eggCount = 10; + int markCount = 10; + bool fcp; + + double averageEggsInEachGab; + int firstMarkN; + int lastMarkN; + + #endregion + + #region 构造函数 + + public CutePointAndValuePresenter() + { + UpdateEggAndMarkInfo(); + } + + #endregion + + #region 公开的属性,方法 + + public int PointCount + { + get + { + return fcp ? eggCount : markCount; + } + } + + public int ValueCount + { + get + { + return fcp ? markCount : eggCount; + } + } + + public void SetPointAndValueCount(int pointCount, int valueCount) + { + if (pointCount < 1) + pointCount = 1; + if (valueCount < 1) + valueCount = 1; + if (pointCount >= valueCount) + { + fcp = true; + eggCount = pointCount; + markCount = valueCount; + } + else + { + fcp = false; + eggCount = valueCount; + markCount = pointCount; + } + UpdateEggAndMarkInfo(); + } + + public void GetPointIndexFromValueIndex(int vIndex, out int pIndexFrom, out int pIndexTo) + { + + if (fcp) + { + if (vIndex < 0 || vIndex > markCount - 1) + throw new ArgumentOutOfRangeException("vIndex"); + + GetEggsIndexFromMarkIndex(vIndex, out pIndexFrom, out pIndexTo); + } + else + { + if (vIndex < 0 || vIndex > eggCount - 1) + throw new ArgumentOutOfRangeException("vIndex"); + + GetMarkIndexFromEggIndex(vIndex, out pIndexFrom); + pIndexTo = pIndexFrom; + } + } + + public void GetValueIndexFromPointIndex(int pIndex, out int vIndexFrom, out int vIndexTo) + { + if (fcp) + { + if (pIndex < 0 || pIndex > eggCount - 1) + throw new ArgumentOutOfRangeException("pIndex"); + + GetMarkIndexFromEggIndex(pIndex, out vIndexFrom); + vIndexTo = vIndexFrom; + } + else + { + if (pIndex < 0 || pIndex > markCount - 1) + throw new ArgumentOutOfRangeException("pIndex"); + + GetEggsIndexFromMarkIndex(pIndex, out vIndexFrom, out vIndexTo); + } + } + + public void GetExactPointIndexFromValueIndex(int vIndex, out int pIndex) + { + int pIndex2; + GetPointIndexFromValueIndex(vIndex, out pIndex, out pIndex2); + int maxIndex = fcp ? markCount - 1 : eggCount - 1; + if (vIndex == maxIndex) + pIndex = pIndex2; + else if (vIndex != 0) + pIndex = (pIndex + pIndex2) / 2; + } + + public void GetExactValueIndexFromPointIndex(int pIndex, out int vIndex) + { + int vIndex2; + GetValueIndexFromPointIndex(pIndex, out vIndex, out vIndex2); + int maxIndex = fcp ? eggCount - 1 : markCount - 1; + if (pIndex == maxIndex) + vIndex = vIndex2; + else if (pIndex != 0) + vIndex = (vIndex + vIndex2) / 2; + } + + #endregion + + #region 内部函数 + + private int GetUpRoundedHalfValue(int a) + { + int t = a / 2; + if (a % 2 != 0) + t++; + return t; + } + + private int EggsCount(int markIndex) + { + return (markIndex + 1) + + (int)Math.Round(averageEggsInEachGab * ((double)markIndex + 0.5), MidpointRounding.AwayFromZero); + } + + private void UpdateEggAndMarkInfo() + { + if (markCount == 1) + { + firstMarkN = eggCount; + return; + } + if (markCount == 2) + { + firstMarkN = GetUpRoundedHalfValue(eggCount); + lastMarkN = eggCount / 2; + return; + } + + int remainEggs = eggCount - markCount; + int gabs = markCount - 1; + averageEggsInEachGab = (double)remainEggs / (double)gabs; + firstMarkN = EggsCount(0); + lastMarkN = eggCount - EggsCount(markCount - 2); + } + + private void GetEggsIndexFromMarkIndex(int markIndex, out int eggIndexFrom, out int eggIndexTo) + { + if (markIndex == 0) + { + eggIndexFrom = 0; + eggIndexTo = firstMarkN - 1; + return; + } + if (markIndex == markCount - 1) + { + eggIndexTo = eggCount - 1; + eggIndexFrom = eggIndexTo - lastMarkN + 1; + return; + } + eggIndexFrom = EggsCount(markIndex - 1); + eggIndexTo = EggsCount(markIndex) - 1; + } + + private void GetMarkIndexFromEggIndex(int eggIndex, out int markIndex) + { + if (eggIndex < firstMarkN) + { + markIndex = 0; + return; + } + if (eggIndex >= (eggCount - lastMarkN)) + { + markIndex = markCount - 1; + return; + } + + //double rst = ((double)eggIndex + averageEggsInEachGab * 0.5) / (1 + averageEggsInEachGab); + //markIndex = (int)rst; + + markIndex = (int)(((double)eggIndex + averageEggsInEachGab * 0.5) / (1 + averageEggsInEachGab)); + if (!IsRightEgg(markIndex, eggIndex)) + { + if (markIndex == 1) + markIndex++; + else if (markIndex == markCount - 2) + markIndex--; + else + { + if (IsRightEgg(markIndex - 1, eggIndex)) + markIndex--; + else if (IsRightEgg(markIndex + 1, eggIndex)) + markIndex++; + else + { + string msg = "Inner error in CutePointAndValuePresenter.GetMarkIndexFromEggIndex(), " + + "\r\n" + "can't find the correct markindex, please contact the author and " + + "report this error with the following data: " + "\r\n" + + "eggCount: " + eggCount.ToString() + "\r\n" + + "markCount: " + markCount.ToString() + "\r\n" + + "eggIndex: " + eggIndex.ToString(); + + throw new Exception(msg); + } + + } + } + } + + private bool IsRightEgg(int markIndex, int eggIndex) + { + int eggIndex1 = EggsCount(markIndex - 1); + int eggIndex2 = EggsCount(markIndex) - 1; + return (eggIndex1 <= eggIndex) && (eggIndex <= eggIndex2); + } + + #endregion + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/GMControls/TrackBar/GMTrackBar.cs b/Source/ryControls/Gdu.WinFormUI/GMControls/TrackBar/GMTrackBar.cs new file mode 100644 index 0000000..c148737 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/GMControls/TrackBar/GMTrackBar.cs @@ -0,0 +1,1546 @@ +/* + * 本代码受中华人民共和国著作权法保护,作者仅授权下载代码之人在学习和交流范围内 + * 自由使用与修改代码;欲将代码用于商业用途的,请与作者联系。 + * 使用本代码请保留此处信息。作者联系方式:ping3108@163.com, 欢迎进行技术交流 + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; +using System.ComponentModel; + +using MGdu.WinFormUI.MyGraphics; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + [ToolboxItem(true), DefaultEvent("ValueChanged")] + public class GMTrackBar : GMBarControlBase, IGMControl + { + + #region 构造函数及初始化 + + static GMTrackBar() + { + EVENT_VALUECHANGED = new object(); + EVENT_PAINTBUTTON = new object(); + EVENT_PAINTMAINLINE = new object(); + } + + public GMTrackBar() + { + ThumeButtonIni(); + presenter = new CutePointAndValuePresenter(); + base.TabStop = true; + } + + private void ThumeButtonIni() + { + thumbButton = new WLButton(this); + thumbButton.RestrictedBounds = false; + SetThumbButtonInfo(); + } + + private void SetThumbButtonInfo() + { + thumbButton.ColorTable = ThumbButtonColorTable; + thumbButton.BorderType = ThumbButtonBorderType; + } + + #endregion + + #region 控件事件相关 + + private static readonly object EVENT_VALUECHANGED; + private static readonly object EVENT_PAINTMAINLINE; + private static readonly object EVENT_PAINTBUTTON; + + /// + /// 控件Value值发生变化后引发 + /// + [Description("控件Value值发生变化后引发")] + public event EventHandler ValueChanged + { + add + { + base.Events.AddHandler(EVENT_VALUECHANGED, value); + } + remove + { + base.Events.RemoveHandler(EVENT_VALUECHANGED, value); + } + } + + /// + /// 控件绘制MainLine前引发, 可以设置Cancel参数来取消默认的绘制 + /// + [Description("控件绘制MainLine前引发, 可以设置Cancel参数来取消默认的绘制, 请把参数转化为 GMTrackBarPaintEventArgs")] + public event PaintEventHandler BeforePaintMainLine + { + add + { + base.Events.AddHandler(EVENT_PAINTMAINLINE, value); + } + remove + { + base.Events.RemoveHandler(EVENT_PAINTMAINLINE, value); + } + } + + /// + /// 控件绘制Button前引发 + /// + [Description("控件绘制ThumbButton前引发, 可以设置Cancel参数来取消默认的绘制, 请把参数转化为 GMTrackBarPaintEventArgs")] + public event PaintEventHandler BeforePaintButton + { + add + { + base.Events.AddHandler(EVENT_PAINTBUTTON, value); + } + remove + { + base.Events.RemoveHandler(EVENT_PAINTBUTTON, value); + } + } + + + /// + /// 引发 ValueChanged 事件 + /// + protected virtual void OnValueChanged(EventArgs e) + { + EventHandler handle = (EventHandler)base.Events[EVENT_VALUECHANGED]; + if (handle != null) + { + handle(this, e); + } + } + + /// + /// 引发 BeforePaintMainLine 事件 + /// + protected virtual void OnBeforePaintMainLine(PaintEventArgs e) + { + PaintEventHandler handle = (PaintEventHandler)base.Events[EVENT_PAINTMAINLINE]; + if (handle != null) + { + handle(this, e); + } + } + + /// + /// 引发 BeforePaintButton 事件 + /// + protected virtual void OnBeforePaintButton(PaintEventArgs e) + { + PaintEventHandler handle = (PaintEventHandler)base.Events[EVENT_PAINTBUTTON]; + if (handle != null) + { + handle(this, e); + } + } + + #endregion + + #region 公开的属性 + + int _value = 0; + int _minimum = 0; + int _maximum = 10; + int _smallChange = 1; + int _largeChange = 5; + int _tickFrequency = 1; + TickStyle _tickSide = TickStyle.None; + Orientation _barOrientation = Orientation.Horizontal; + GMTrackBarThemeBase _xtheme = null; + bool _drawFocusRect = false; + bool _autoSize = true; + + [DefaultValue(0)] + public int Value + { + get + { + return _value; + } + set + { + if (_value != value) + { + if (value > _maximum) + value = _maximum; + if (value < _minimum) + value = _minimum; + + _value = value; + ResetButtonPositionFromValue(); + OnValueChanged(EventArgs.Empty); + } + } + } + + [DefaultValue(0)] + public int Minimum + { + get + { + return _minimum; + } + set + { + if (_minimum != value) + { + if (value > _maximum) + _maximum = value; + if (_value < value) + _value = value; + _minimum = value; + UpdatePresenterAndRedraw(); + } + } + } + + [DefaultValue(10)] + public int Maximum + { + get + { + return _maximum; + } + set + { + if (_maximum != value) + { + if (value < _minimum) + _minimum = value; + if (_value > value) + _value = value; + _maximum = value; + UpdatePresenterAndRedraw(); + } + } + } + + [DefaultValue(1)] + public int SmallChange + { + get + { + return _smallChange; + } + set + { + _smallChange = value < 1 ? 1 : value; + } + } + + [DefaultValue(5)] + public int LargeChange + { + get + { + return _largeChange; + } + set + { + _largeChange = value < 1 ? 1 : value; + } + } + + [DefaultValue(1)] + public int TickFrequency + { + get + { + return _tickFrequency; + } + set + { + if (_tickFrequency != value) + { + _tickFrequency = value < 1 ? 1 : value; + if (_tickSide != TickStyle.None) + Invalidate(); + } + } + } + + [DefaultValue(0)] + public TickStyle TickSide + { + get + { + return _tickSide; + } + set + { + if (_tickSide != value) + { + _tickSide = value; + DoWhenResize(); + Invalidate(); + } + } + } + + [DefaultValue(0)] + public Orientation BarOrientation + { + get + { + return _barOrientation; + } + set + { + if (_barOrientation != value) + { + _barOrientation = value; + DoWhenBarOrientationChanged(); + } + } + } + + [DefaultValue(true), Browsable(true)] + public override bool AutoSize + { + get + { + return _autoSize; + } + set + { + if (_autoSize != value) + { + _autoSize = value; + + if (_barOrientation == Orientation.Horizontal) + { + base.SetStyle(ControlStyles.FixedHeight, _autoSize); + base.SetStyle(ControlStyles.FixedWidth, false); + } + else + { + base.SetStyle(ControlStyles.FixedWidth, _autoSize); + base.SetStyle(ControlStyles.FixedHeight, false); + } + + DoWhenAutoSizeChanged(); + } + } + } + + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public GMTrackBarThemeBase XTheme + { + get + { + return _xtheme; + } + set + { + if (_xtheme != value) + { + _xtheme = value; + DoWhenXThemeChanged(); + } + } + } + + [DefaultValue(false)] + public bool DrawFocusRect + { + get + { + return _drawFocusRect; + } + set + { + _drawFocusRect = value; + Invalidate(); + } + } + + #endregion + + #region 公开的方法 + + /// + /// 将Value值加一个LargeChange量 + /// + public void DoLargeUp() + { + ValueAdd(LargeChange); + } + + /// + /// 将Value值减一个LargeChange量 + /// + public void DoLargeDown() + { + ValueAdd(-LargeChange); + } + + /// + /// 将Value值加一个SmallChange量 + /// + public void DoSmallUp() + { + ValueAdd(SmallChange); + } + + /// + /// 将Value值减一个SmallChange量 + /// + public void DoSmallDown() + { + ValueAdd(-SmallChange); + } + + #endregion + + #region 可通过XTheme配置的内部 look and feel 属性 + + protected virtual int ButtonLength1 + { + get + { + if (_xtheme == null) + return 8; + else + return _xtheme.ButtonLength1; + } + } + + protected virtual int ButtonLength2 + { + get + { + if (_xtheme == null) + return 18; + else + return _xtheme.ButtonLength2; + } + } + + protected virtual int ButtonOutterSpace1 + { + get + { + if (_xtheme == null) + return 4; + else + return _xtheme.ButtonOutterSpace1; + } + } + + protected virtual int ButtonOutterSpace2 + { + get + { + if (_xtheme == null) + return 2; + else + return _xtheme.ButtonOutterSpace2; + } + } + + protected virtual int MainLineLength + { + get + { + if (_xtheme == null) + return 4; + else + return _xtheme.MainLineLength; + } + } + + protected virtual int TickLineLength + { + get + { + if (_xtheme == null) + return 3; + else + return _xtheme.TickLineLength; + } + } + + protected virtual int TickLineSpaceWithButton + { + get + { + if (_xtheme == null) + return 2; + else + return _xtheme.TickLineSpaceWithButton; + } + } + + protected virtual int TickLineSpaceWithBorder + { + get + { + if (_xtheme == null) + return 6; + else + return _xtheme.TickLineSpaceWithBorder; + } + } + + protected virtual int BorderWidth + { + get + { + if (_xtheme == null) + return 1; + else + return _xtheme.BorderWidth; + } + } + + protected virtual bool DrawBackground + { + get + { + if (_xtheme == null) + return true; + else + return _xtheme.DrawBackground; + } + } + + protected virtual bool DrawBorder + { + get + { + if (_xtheme == null) + return false; + else + return _xtheme.DrawBorder; + } + } + + protected virtual bool DrawInnerBorder + { + get + { + if (_xtheme == null) + return false; + else + return _xtheme.DrawInnerBorder; + } + } + + protected virtual Color GMBackColor + { + get + { + if (_xtheme == null) + return Color.Transparent; + else + return _xtheme.BackColor; + } + } + + protected virtual Color BorderColor + { + get + { + if (_xtheme == null) + return Color.LightGray; + else + return _xtheme.BorderColor; + } + } + + protected virtual Color InnerBorderColor + { + get + { + if (_xtheme == null) + return Color.Empty; + else + return _xtheme.InnerBorderColor; + } + } + + protected virtual Color TickLineColor + { + get + { + if (_xtheme == null) + return Color.FromArgb(185,185,185); + else + return _xtheme.TickLineColor; + } + } + + protected virtual Color MainLineRange1BackColor + { + get + { + if (_xtheme == null) + return Color.LightGray; + else + return _xtheme.MainLineRange1BackColor; + } + } + + protected virtual Color MainLineRange2BackColor + { + get + { + if (_xtheme == null) + return Color.White; + else + return _xtheme.MainLineRange2BackColor; + } + } + + protected virtual Color MainLineBorderColor + { + get + { + if (_xtheme == null) + return Color.FromArgb(0,114,198); + else + return _xtheme.MainLineBorderColor; + } + } + + protected virtual bool MainLineDrawBorder + { + get + { + if (_xtheme == null) + return true; + else + return _xtheme.MainLineDrawBorder; + } + } + + protected virtual int MainLineRadius + { + get + { + if (_xtheme == null) + return 0; + else + return _xtheme.MainLineRadius; + } + } + + protected virtual ButtonColorTable ThumbButtonColorTable + { + get + { + if (_xtheme == null) + return DefaultThumbColor(); + else + return _xtheme.ThumbButtonColorTable; + } + } + + protected virtual ButtonBorderType ThumbButtonBorderType + { + get + { + if (_xtheme == null) + return ButtonBorderType.Rectangle; + else + return _xtheme.ThumbButtonBorderType; + } + } + + protected virtual ButtonColorTable DefaultThumbColor() + { + ButtonColorTable table = new ButtonColorTable(); + table.BorderColorNormal = table.BorderColorHover = table.BorderColorPressed = + Color.FromArgb(0, 114, 198); + table.BackColorNormal = Color.White; + table.BackColorHover = Color.FromArgb(177, 214, 240); + table.BackColorPressed = ColorHelper.GetDarkerColor(table.BackColorHover, 16); + return table; + } + + #endregion + + #region 内部使用的变量 + + CutePointAndValuePresenter presenter; + + bool isMouseDownInButton; + + WLButton thumbButton; + + #endregion + + #region 内部函数, 属性 + + int _buttonCurrentPositionDot; + + private int ButtonCurrentPositionDot + { + get + { + return _buttonCurrentPositionDot; + } + set + { + if (_buttonCurrentPositionDot != value) + { + if (_barOrientation == Orientation.Horizontal) + { + if (value < BBDot) + _buttonCurrentPositionDot = BBDot; + else if (value > BMDot) + _buttonCurrentPositionDot = BMDot; + else + _buttonCurrentPositionDot = value; + } + else + { + if (value > BBDot) + _buttonCurrentPositionDot = BBDot; + else if (value < BMDot) + _buttonCurrentPositionDot = BMDot; + else + _buttonCurrentPositionDot = value; + } + if (thumbButton != null) + thumbButton.Bounds = BTR; + } + } + } + + private void DoWhenResize() + { + SetFittedSize(); + thumbButton.Bounds = BTR; + UpdatePresenterAndRedraw(); + } + + private void DoWhenMouseDownInMainLine(Point p) + { + DoWhenMouseMoveInButton(p); + } + + private void DoWhenMouseMoveInButton(Point p) + { + int begin = BBDot; + int max = BMDot; + + if (_barOrientation == Orientation.Horizontal) + p.Offset(-ButtonLength1 / 2, 0); + else + p.Offset(0, -ButtonLength1 / 2); + + if (_barOrientation == Orientation.Horizontal) + { + int pos = p.X; + if (pos < (begin - 100) || pos > (max + 100)) + return; + if (pos < begin) + pos = begin; + if (pos > max) + pos = max; + + int v1, v2; + int locIndex = pos - begin; + presenter.GetValueIndexFromPointIndex(locIndex, out v1, out v2); + if (_value < v1 || _value > v2) + { + if (pos == begin) + Value = Minimum + v1; + else if (pos == max) + Value = Minimum + v2; + else + Value = Minimum + (v1 + v2) / 2; + } + } + else + { + int pos = p.Y; + if (pos < (max - 100) || pos > (begin + 100)) + return; + if (pos < max) + pos = max; + if (pos > begin) + pos = begin; + pos = (begin + max) - pos; + int v1, v2; + int locIndex = pos - max; + presenter.GetValueIndexFromPointIndex(locIndex, out v1, out v2); + if (_value < v1 || _value > v2) + { + if (pos == begin) + Value = Minimum + v2; + else if (pos == max) + Value = Minimum + v1; + else + Value = Minimum + (v1 + v2) / 2; + } + } + } + + private void UpdatePresenterAndRedraw() + { + int pointCount = RemainPointCount; + int valueCount = Maximum - Minimum + 1; + if (pointCount != presenter.PointCount || valueCount != presenter.ValueCount) + { + presenter.SetPointAndValueCount(pointCount, valueCount); + + ResetButtonPositionFromValue(); + Invalidate(); + } + } + + private void ResetButtonPositionFromValue() + { + int newPos = GetDotFromValue(Value); + if (newPos != ButtonCurrentPositionDot) + { + ButtonCurrentPositionDot = newPos; + Invalidate(); + } + } + + private int GetDotFromValue(int value) + { + int p1, p2; + int valueIndex = value - Minimum; + presenter.GetPointIndexFromValueIndex(valueIndex, out p1, out p2); + + int targetPos; + if (value == Minimum) + targetPos = p1; + else if (value == Maximum) + targetPos = p2; + else + targetPos = (p1 + p2) / 2; + + if (_barOrientation == Orientation.Horizontal) + targetPos += BBDot; + else + { + targetPos += BMDot; + targetPos = (BMDot + BBDot) - targetPos; + } + return targetPos; + } + + private void ValueAdd(int amount) + { + if (Value == Minimum && amount <= 0) + return; + if (Value == Maximum && amount >= 0) + return; + int v = Value; + v += amount; + if (v < Minimum) + v = Minimum; + if (v > Maximum) + v = Maximum; + Value = v; + } + + private void SetFittedSize() + { + if (AutoSize) + { + int bestLen = BestFittedLength; + if (_barOrientation == Orientation.Horizontal) + { + if (base.Height != bestLen) + base.Height = bestLen; + } + else + { + if (base.Width != bestLen) + base.Width = bestLen; + } + } + } + + private void DoWhenBarOrientationChanged() + { + var newSize = new Size(base.Height, base.Width); + + base.Size = newSize; + ResetButtonPositionFromValue(); + UpdatePresenterAndRedraw(); + Invalidate(); + } + + private void DoWhenXThemeChanged() + { + SetThumbButtonInfo(); + DoWhenResize(); + Invalidate(); + } + + private void DoWhenAutoSizeChanged() + { + SetFittedSize(); + } + + #endregion + + #region 内部绘图 + + protected virtual void OnPaintGMTrackbar(Graphics g) + { + if (DrawBackground) + RenderBackground(g); + if (TickSide != TickStyle.None) + RenderTickLines(g); + RenderMainLine(g); + RenderButton(g); + if (DrawBorder) + RenderBorders(g); + RenderFocusRect(g); + } + + private void RenderBackground(Graphics g) + { + using (SolidBrush sb = new SolidBrush(GMBackColor)) + { + g.FillRectangle(sb, ClientRectangle); + } + } + + private void RenderFocusRect(Graphics g) + { + if (DrawFocusRect && base.Focused) + { + Rectangle rect = ClientRectangle; + rect.Width--; + rect.Height--; + rect.Inflate(-1, -1); + using (Pen p = new Pen(Color.Black)) + { + p.DashStyle = DashStyle.Dot; + g.DrawRectangle(p, rect); + } + } + } + + private void RenderBorders(Graphics g) + { + Rectangle rect = ClientRectangle; + rect.Width--; + rect.Height--; + using (Pen p = new Pen(BorderColor)) + { + g.DrawRectangle(p, rect); + } + if (DrawInnerBorder) + { + rect.Inflate(-1, -1); + using (Pen p2 = new Pen(InnerBorderColor)) + { + g.DrawRectangle(p2, rect); + } + } + } + + private void RenderMainLine(Graphics g) + { + GMTrackBarPaintEventArgs e = new GMTrackBarPaintEventArgs(g, + MainLineRectToDraw, MainLineRange1Rect, MainLineRange2Rect); + OnBeforePaintMainLine(e); + + if (!e.Cancel) + { + RenderMainLine(g, MainLineRange1Rect, MainLineRange1BackColor); + RenderMainLine(g, MainLineRange2Rect, MainLineRange2BackColor); + } + e.Dispose(); + } + + private void RenderMainLine(Graphics g, Rectangle rect, Color backColor) + { + SmoothingMode newMode = (MainLineRadius > 0) ? SmoothingMode.AntiAlias : SmoothingMode.HighSpeed; + RoundStyle style = (MainLineRadius > 0) ? RoundStyle.All : RoundStyle.None; + + using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, newMode)) + { + using (SolidBrush sb = new SolidBrush(backColor)) + { + using (GraphicsPath path = GraphicsPathHelper.CreateRoundedRect( + rect, MainLineRadius, style, false)) + { + g.FillPath(sb, path); + } + } + if (MainLineDrawBorder) + { + using (Pen p = new Pen(MainLineBorderColor)) + { + using (GraphicsPath path = GraphicsPathHelper.CreateRoundedRect( + rect, MainLineRadius, style, true)) + { + g.DrawPath(p, path); + } + } + } + } + } + + private void RenderButton(Graphics g) + { + GMTrackBarPaintEventArgs e = new GMTrackBarPaintEventArgs(g, BTR); + e.BtnState = thumbButton.State; + OnBeforePaintButton(e); + + if (!e.Cancel) + thumbButton.DrawButton(g); + e.Dispose(); + } + + private void RenderTickLines(Graphics g) + { + Pen p = new Pen(TickLineColor); + + if (TickSide == TickStyle.Both || TickSide == TickStyle.TopLeft) + { + if (_barOrientation == Orientation.Horizontal) + RenderTickLinesTopBottom(g, p, TickLinesRect1, true); + else + RenderTickLinesLeftRight(g, p, TickLinesRect1, true); + } + if (TickSide == TickStyle.Both || TickSide == TickStyle.BottomRight) + { + if (_barOrientation == Orientation.Horizontal) + RenderTickLinesTopBottom(g, p, TickLinesRect2, false); + else + RenderTickLinesLeftRight(g, p,TickLinesRect2, false); + } + + p.Dispose(); + } + + private void RenderTickLinesTopBottom(Graphics g, Pen p, Rectangle rect, bool isTop) + { + int y1 = rect.Top; + int y2 = rect.Bottom - 1; + int prex = -1; + int addExtra = ButtonLength1 / 2; + + int xfirst = GetDotFromValue(Minimum) + addExtra; + int xlast = GetDotFromValue(Maximum) + addExtra; + + for (int i = Minimum; i <= Maximum; i += TickFrequency) + { + int x = GetDotFromValue(i) + addExtra; + + if (x == xfirst || x == (xfirst + 1) || x == xlast || x == (xlast - 1)) + continue; + if (x == prex || x == (prex + 1)) + continue; + + g.DrawLine(p, x, y1, x, y2); + prex = x; + } + + // render the first and last points with a little longer line + if (isTop) + y1 -= 1; + else + y2 += 1; + g.DrawLine(p, xfirst, y1, xfirst, y2); + g.DrawLine(p, xlast, y1, xlast, y2); + } + + private void RenderTickLinesLeftRight(Graphics g, Pen p, Rectangle rect, bool isLeft) + { + int x1 = rect.Left; + int x2 = rect.Right - 1; + int prey = -1; + int addExtra = ButtonLength1 / 2; + + int yfirst = GetDotFromValue(Minimum) + addExtra; + int ylast = GetDotFromValue(Maximum) + addExtra; + + for (int i = Minimum; i <= Maximum; i += TickFrequency) + { + int y = GetDotFromValue(i) + addExtra; + + if (y == yfirst || y == yfirst - 1 || y == ylast || y == ylast + 1) + continue; + if (y == prey || y == (prey - 1)) + continue; + + g.DrawLine(p, x1, y, x2, y); + prey = y; + } + + // render the first and last points + if (isLeft) + x1 -= 1; + else + x2 += 1; + g.DrawLine(p, x1, yfirst, x2, yfirst); + g.DrawLine(p, x1, ylast, x2, ylast); + } + + #endregion + + #region 计算而得的内部只读属性 + + private int RemainPointCount + { + get + { + int count = 0; + + if (_barOrientation == Orientation.Horizontal) + { + count = Size.Width - BorderWidth * 2 - ButtonOutterSpace1 * 2 + - ButtonLength1 + 1; + } + else + { + count = Size.Height - BorderWidth * 2 - ButtonOutterSpace1 * 2 + - ButtonLength1 + 1; + } + + return count; + } + } + + private int BBDot + { + get + { + if (_barOrientation == Orientation.Horizontal) + return BorderWidth + ButtonOutterSpace1; + else + return Size.Height - 1 - BorderWidth - ButtonOutterSpace1 - ButtonLength1 + 1; + } + } + + private int BMDot + { + get + { + if (_barOrientation == Orientation.Horizontal) + return (Size.Width - 1) - BorderWidth - ButtonOutterSpace1 - ButtonLength1 + 1; + else + return BorderWidth + ButtonOutterSpace1; + } + } + + private int MainLineBegionDot + { + get + { + return BBDot + ButtonLength1 / 2; + } + } + + private int MainLineEndDot + { + get + { + return BMDot + ButtonLength1 / 2; + } + } + + private Rectangle BTR + { + get + { + + if (_barOrientation == Orientation.Horizontal) + { + int x = ButtonCurrentPositionDot; + int y = 0; + if (TickSide == TickStyle.Both || TickSide == TickStyle.TopLeft) + y = BorderWidth + TickLineSpaceWithBorder + TickLineLength + + TickLineSpaceWithButton + ButtonOutterSpace2; + else + y = BorderWidth + ButtonOutterSpace2; + return new Rectangle(x, y, ButtonLength1, ButtonLength2); + } + else + { + int x = 0; + if (TickSide == TickStyle.Both || TickSide == TickStyle.TopLeft) + x = BorderWidth + TickLineSpaceWithBorder + TickLineLength + + TickLineSpaceWithButton + ButtonOutterSpace2; + else + x = BorderWidth + ButtonOutterSpace2; + int y = ButtonCurrentPositionDot; + return new Rectangle(x, y, ButtonLength2, ButtonLength1); + } + } + } + + private Rectangle MainLineRect + { + get + { + Rectangle btnRect = BTR; + + if (_barOrientation == Orientation.Horizontal) + { + int h = MainLineLength; + int x = MainLineBegionDot; + int y = btnRect.Y + (btnRect.Height - h) / 2; + if ((btnRect.Height - h) % 2 != 0) + y++; + int w = MainLineEndDot - MainLineBegionDot + 1; + return new Rectangle(x, y, w, h); + } + else + { + int w = MainLineLength; + int x = btnRect.X + (btnRect.Width - w) / 2; + if ((btnRect.Width - w) % 2 != 0) + x++; + int y = MainLineEndDot; + int h = MainLineBegionDot - y + 1; + return new Rectangle(x, y, w, h); + } + } + } + + private Rectangle MainLineRectToDraw + { + get + { + Rectangle rect = MainLineRect; + + if (_barOrientation == Orientation.Horizontal) + rect.Inflate(2, 0); + else + rect.Inflate(0, 2); + + return rect; + } + } + + private Rectangle MainLineRectHitTest + { + get + { + Rectangle rect = MainLineRect; + int diff = (ButtonLength2 - MainLineLength) / 2; + if (_barOrientation == Orientation.Horizontal) + rect.Inflate(0, diff); + else + rect.Inflate(diff, 0); + return rect; + } + } + + private Rectangle TickLinesRect1 + { + get + { + int lineBegin = MainLineBegionDot; + int lineEnd = MainLineEndDot; + + if (_barOrientation == Orientation.Horizontal) + { + int x = lineBegin; + int y = BorderWidth + TickLineSpaceWithBorder; + int w = lineEnd - lineBegin + 1; + int h = 0; + if (TickSide == TickStyle.Both || TickSide == TickStyle.TopLeft) + h = TickLineLength; + return new Rectangle(x, y, w, h); + } + else + { + int x = BorderWidth + TickLineSpaceWithBorder; + int y = lineEnd; + int h = lineBegin - lineEnd + 1; + int w = 0; + if (TickSide == TickStyle.Both || TickSide == TickStyle.TopLeft) + w = TickLineLength; + return new Rectangle(x, y, w, h); + } + } + } + + private Rectangle TickLinesRect2 + { + get + { + Rectangle btnRect = BTR; + + if (_barOrientation == Orientation.Horizontal) + { + int x = MainLineBegionDot; + int y = btnRect.Bottom + ButtonOutterSpace2 + TickLineSpaceWithButton; + int w = MainLineEndDot - MainLineBegionDot + 1; + int h = 0; + if(TickSide == TickStyle.Both || TickSide == TickStyle.BottomRight) + h = TickLineLength; + return new Rectangle(x, y, w, h); + } + else + { + int x = btnRect.Right + ButtonOutterSpace2 + TickLineSpaceWithButton; + int y = MainLineEndDot; + int h = MainLineBegionDot - MainLineEndDot + 1; + int w = 0; + if (TickSide == TickStyle.Both || TickSide == TickStyle.BottomRight) + w = TickLineLength; + return new Rectangle(x, y, w, h); + } + } + } + + private Rectangle MainLineRange1Rect + { + get + { + Rectangle rect = MainLineRectToDraw; + int pos = ButtonCurrentPositionDot + ButtonLength1 / 2; + + if (_barOrientation == Orientation.Horizontal) + { + rect.Width = pos - 1 - rect.X + 1; + return rect; + } + else + { + return new Rectangle(rect.X, pos + 1, + rect.Width, rect.Bottom - pos - 1); + } + } + } + + private Rectangle MainLineRange2Rect + { + get + { + Rectangle rect = MainLineRectToDraw; + int pos = ButtonCurrentPositionDot + ButtonLength1 / 2; + + if (_barOrientation == Orientation.Horizontal) + { + return new Rectangle(pos + 1, rect.Y, rect.Right - pos - 1, rect.Height); + } + else + { + rect.Height = pos - 1 - rect.Y + 1; + return rect; + } + } + } + + private int BestFittedLength + { + get + { + int value = BorderWidth * 2 + ButtonOutterSpace2 * 2 + ButtonLength2; + if (TickSide == TickStyle.Both || TickSide == TickStyle.TopLeft) + value += TickLineSpaceWithBorder + TickLineLength + TickLineSpaceWithButton; + if (TickSide == TickStyle.Both || TickSide == TickStyle.BottomRight) + value += TickLineSpaceWithBorder + TickLineLength + TickLineSpaceWithButton; + return value; + } + } + + #endregion + + #region IGMControl实现 + + [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)] + public GMControlType ControlType + { + get { return GMControlType.TrackBar; } + } + + #endregion + + #region 重写基类方法 + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + OnPaintGMTrackbar(e.Graphics); + } + + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + DoWhenResize(); + } + + protected override void OnMouseDown(MouseEventArgs e) + { + base.OnMouseDown(e); + + if (e.Button == System.Windows.Forms.MouseButtons.Left) + { + if (TabStop) + base.Focus(); + + if (BTR.Contains(e.Location)) + { + isMouseDownInButton = true; + thumbButton.State = GMButtonState.Pressed; + } + else if(MainLineRectHitTest.Contains(e.Location)) + { + DoWhenMouseDownInMainLine(e.Location); + } + } + } + + protected override void OnMouseUp(MouseEventArgs e) + { + base.OnMouseUp(e); + if (e.Button == System.Windows.Forms.MouseButtons.Left) + { + isMouseDownInButton = false; + if (BTR.Contains(e.Location)) + thumbButton.State = GMButtonState.Hover; + else + thumbButton.State = GMButtonState.Normal; + } + } + + protected override void OnMouseLeave(EventArgs e) + { + base.OnMouseLeave(e); + thumbButton.State = GMButtonState.Normal; + } + + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + if (isMouseDownInButton) + { + DoWhenMouseMoveInButton(e.Location); + } + if (!base.Capture) + { + if(BTR.Contains(e.Location)) + thumbButton.State = GMButtonState.Hover; + else + thumbButton.State = GMButtonState.Normal; + } + } + + protected override bool IsInputKey(Keys keyData) + { + if ((keyData & Keys.Alt) == Keys.Alt) + { + return false; + } + switch ((keyData & Keys.KeyCode)) + { + case Keys.PageUp: + case Keys.PageDown: + case Keys.End: + case Keys.Home: + + case Keys.Down: + case Keys.Up: + case Keys.Left: + case Keys.Right: + return true; + } + return base.IsInputKey(keyData); + } + + protected override void OnEnter(EventArgs e) + { + base.OnEnter(e); + if (DrawFocusRect) + base.Invalidate(); + } + + protected override void OnLeave(EventArgs e) + { + base.OnLeave(e); + if (DrawFocusRect) + base.Invalidate(); + } + + protected override void OnKeyDown(KeyEventArgs e) + { + switch (e.KeyData) + { + case Keys.Left: + case Keys.Up: + if (_barOrientation == Orientation.Horizontal) + DoSmallDown(); + else + DoSmallUp(); + break; + case Keys.Down: + case Keys.Right: + if (_barOrientation == Orientation.Horizontal) + DoSmallUp(); + else + DoSmallDown(); + break; + case Keys.PageUp: + if (_barOrientation == Orientation.Horizontal) + DoLargeDown(); + else + DoLargeUp(); + break; + case Keys.PageDown: + if (_barOrientation == Orientation.Horizontal) + DoLargeUp(); + else + DoLargeDown(); + break; + case Keys.Home: + if (_barOrientation == Orientation.Horizontal) + Value = Minimum; + else + Value = Maximum; + break; + case Keys.End: + if (_barOrientation == Orientation.Horizontal) + Value = Maximum; + else + Value = Minimum; + break; + } + base.OnKeyDown(e); + } + + #endregion + + #region 内部类 + + public class GMTrackBarPaintEventArgs : PaintEventArgs + { + public Rectangle MainLineRange1Rect { get; private set; } + public Rectangle MainLineRange2Rect { get; private set; } + public bool Cancel { get; set; } + public GMButtonState BtnState { get; set; } + + public GMTrackBarPaintEventArgs(Graphics g, Rectangle clipRect) + : this(g, clipRect, Rectangle.Empty, Rectangle.Empty) + { + + } + + public GMTrackBarPaintEventArgs(Graphics g, Rectangle mainLineRect, + Rectangle range1Rect, Rectangle range2Rect) : base(g, mainLineRect) + { + MainLineRange1Rect = range1Rect; + MainLineRange2Rect = range2Rect; + Cancel = false; + BtnState = GMButtonState.Normal; + } + } + + #endregion + + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/GMControls/TrackBar/GMTrackBarThemeBase.cs b/Source/ryControls/Gdu.WinFormUI/GMControls/TrackBar/GMTrackBarThemeBase.cs new file mode 100644 index 0000000..714c7e8 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/GMControls/TrackBar/GMTrackBarThemeBase.cs @@ -0,0 +1,73 @@ +using System; +using System.Drawing; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class GMTrackBarThemeBase + { + #region 尺寸及间距调节 + + public int ButtonLength1 { get; set; } + public int ButtonLength2 { get; set; } + public int MainLineLength { get; set; } + public int ButtonOutterSpace1 { get; set; } + public int ButtonOutterSpace2 { get; set; } + public int TickLineLength { get; set; } + public int TickLineSpaceWithButton { get; set; } + public int TickLineSpaceWithBorder { get; set; } + + #endregion + + #region 边框及颜色设置 + + public int BorderWidth { get; set; } + public bool DrawBackground { get; set; } + public bool DrawBorder { get; set; } + public bool DrawInnerBorder { get; set; } + public Color BackColor { get; set; } + public Color BorderColor { get; set; } + public Color InnerBorderColor { get; set; } + public Color TickLineColor { get; set; } + + #endregion + + #region extra + + public ButtonColorTable ThumbButtonColorTable { get; set; } + public ButtonBorderType ThumbButtonBorderType { get; set; } + + public bool MainLineDrawBorder { get; set; } + public Color MainLineBorderColor { get; set; } + public int MainLineRadius { get; set; } + public Color MainLineRange1BackColor { get; set; } + public Color MainLineRange2BackColor { get; set; } + + #endregion + + public GMTrackBarThemeBase() + { + ButtonLength1 = 8; + ButtonLength2 = 18; + MainLineLength = 4; + ButtonOutterSpace1 = 4; + ButtonOutterSpace2 = 2; + TickLineLength = 3; + TickLineSpaceWithButton = 2; + TickLineSpaceWithBorder = 6; + + BorderWidth = 1; + DrawBackground = true; + DrawBorder = false; + DrawInnerBorder = false; + BackColor = Color.Transparent; + TickLineColor = Color.FromArgb(185, 185, 185); + + MainLineDrawBorder = true; + MainLineBorderColor = Color.FromArgb(0, 114, 198); + MainLineRadius = 0; + MainLineRange1BackColor = MainLineRange2BackColor = Color.White; + + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/MyGraphics/ColorHelper.cs b/Source/ryControls/Gdu.WinFormUI/MyGraphics/ColorHelper.cs new file mode 100644 index 0000000..80059d3 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/MyGraphics/ColorHelper.cs @@ -0,0 +1,77 @@ +/* + * 本代码受中华人民共和国著作权法保护,作者仅授权下载代码之人在学习和交流范围内 + * 自由使用与修改代码;欲将代码用于商业用途的,请与作者联系。 + * 使用本代码请保留此处信息。作者联系方式:ping3108@163.com, 欢迎进行技术交流 + */ + +using System; +using System.Text; +using System.Drawing; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI.MyGraphics +{ + public static class ColorHelper + { + public static Color GetLighterColor(Color baseColor, int percentage) + { + int r0 = baseColor.R; + int g0 = baseColor.G; + int b0 = baseColor.B; + + int r = r0 + (int)((255 - r0) * (percentage / 100f)); + int g = g0 + (int)((255 - g0) * (percentage / 100f)); + int b = b0 + (int)((255 - b0) * (percentage / 100f)); + + if (r > 255) + r = 255; + if (g > 255) + g = 255; + if (b > 255) + b = 255; + + return Color.FromArgb(baseColor.A, r, g, b); + } + + public static Color GetDarkerColor(Color baseColor, int percentage) + { + int r0 = baseColor.R; + int g0 = baseColor.G; + int b0 = baseColor.B; + + int r = r0 - (int)(r0 * (percentage / 100f)); + int g = g0 - (int)(g0 * (percentage / 100f)); + int b = b0 - (int)(b0 * (percentage / 100f)); + + if (r < 0) + r = 0; + if (g < 0) + g = 0; + if (b < 0) + b = 0; + + return Color.FromArgb(baseColor.A, r, g, b); + } + + public static Color[] GetLighterArrayColors(Color baseColor, int arrayLength, float maxPercentage) + { + if (maxPercentage < 2) + maxPercentage = 2f; + if (maxPercentage > 100) + maxPercentage = 100f; + + Color[] arrc = new Color[arrayLength]; + float average = maxPercentage / arrayLength; + for (int i = 0; i < arrayLength; i++) + { + arrc[arrayLength - i - 1] = GetLighterColor(baseColor, (int)(average * i)); + } + return arrc; + } + + public static Color[] GetLighterArrayColors(Color baseColor, int arrayLength) + { + return GetLighterArrayColors(baseColor, arrayLength, 100f); + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/MyGraphics/GraphicsPathHelper.cs b/Source/ryControls/Gdu.WinFormUI/MyGraphics/GraphicsPathHelper.cs new file mode 100644 index 0000000..1b9971c --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/MyGraphics/GraphicsPathHelper.cs @@ -0,0 +1,338 @@ +/* + * 本代码受中华人民共和国著作权法保护,作者仅授权下载代码之人在学习和交流范围内 + * 自由使用与修改代码;欲将代码用于商业用途的,请与作者联系。 + * 使用本代码请保留此处信息。作者联系方式:ping3108@163.com, 欢迎进行技术交流 + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI.MyGraphics +{ + + /// + /// 提供产生各种路径的静态方法,比如圆角路径、关闭按钮上的x路径、+号路径 + /// + public static class GraphicsPathHelper + { + public static GraphicsPath CreateRoundedRect(Rectangle rect, int radius, RoundStyle type, bool shorten) + { + GraphicsPath path = new GraphicsPath(); + + if (shorten) + { + rect.Width--; + rect.Height--; + } + + if (radius < 2) + type = RoundStyle.None; + + Rectangle rectTopLeft = new Rectangle(rect.X, rect.Y, radius, radius); + Rectangle rectTopRight = new Rectangle(rect.Right - radius, rect.Y, radius, radius); + Rectangle rectBottomLeft = new Rectangle(rect.X, rect.Bottom - radius, radius, radius); + Rectangle rectBottomRight = new Rectangle(rect.Right - radius, rect.Bottom - radius, radius, radius); + Point p1 = new Point(rect.X, rect.Y); + Point p2 = new Point(rect.Right, rect.Y); + Point p3 = new Point(rect.Right, rect.Bottom); + Point p4 = new Point(rect.X, rect.Bottom); + + switch (type) + { + case RoundStyle.None: + path.AddRectangle(rect); + break; + case RoundStyle.All: + path.AddArc(rectTopLeft, 180, 90); + path.AddArc(rectTopRight, 270, 90); + path.AddArc(rectBottomRight, 0, 90); + path.AddArc(rectBottomLeft, 90, 90); + break; + case RoundStyle.Top: + path.AddArc(rectTopLeft, 180, 90); + path.AddArc(rectTopRight, 270, 90); + path.AddLine(p3, p4); + break; + case RoundStyle.Bottom: + path.AddArc(rectBottomRight, 0, 90); + path.AddArc(rectBottomLeft, 90, 90); + path.AddLine(p1, p2); + break; + case RoundStyle.Left: + path.AddArc(rectBottomLeft, 90, 90); + path.AddArc(rectTopLeft, 180, 90); + path.AddLine(p2, p3); + break; + case RoundStyle.Right: + path.AddArc(rectTopRight, 270, 90); + path.AddArc(rectBottomRight, 0, 90); + path.AddLine(p4, p1); + break; + default: + break; + } + path.CloseFigure(); + return path; + } + + public static GraphicsPath CreateMinimizeFlagPath(Rectangle rect) + { + GraphicsPath path = new GraphicsPath(); + int x = rect.X + (rect.Width - 9) / 2; + int y = rect.Y + (rect.Height - 7) / 2; + Point p1 = new Point(x + 1, y + 5); + Point p2 = new Point(x + 7, y + 5); + Point p3 = new Point(x + 1, y + 6); + Point p4 = new Point(x + 7, y + 6); + path.AddLines(new Point[] { p1, p2, p3, p4 }); + return path; + } + + public static GraphicsPath CreateMaximizeFlagPath(Rectangle rect) + { + GraphicsPath path = new GraphicsPath(); + int x = rect.X + (rect.Width - 9) / 2; + int y = rect.Y + (rect.Height - 7) / 2; + Point p1 = new Point(x + 1, y + 1); + Point p2 = new Point(x + 7, y + 1); + path.AddRectangle(new Rectangle(new Point(x, y), new Size(8, 6))); + path.CloseFigure(); + path.AddLine(p1, p2); + return path; + } + + public static GraphicsPath CreateRestoreFlagPath(Rectangle rect) + { + GraphicsPath path = new GraphicsPath(); + int x = rect.X + (rect.Width - 11) / 2; + int y = rect.Y + (rect.Height - 9) / 2; + + Point p1 = new Point(x, y + 3); + Point p2 = new Point(x + 6, y + 3); + Point p3 = new Point(x + 6, y + 4); + Point p4 = new Point(x + 6, y + 8); + Point p5 = new Point(x, y + 8); + Point p6 = new Point(x, y + 4); + + Point p7 = new Point(x + 7, y + 5); + Point p8 = new Point(x + 9, y + 5); + Point p9 = new Point(x + 9, y + 1); + Point p10 = new Point(x + 3, y + 1); + Point p11 = new Point(x + 3, y + 2); + Point p12 = new Point(x + 3, y); + Point p13 = new Point(x + 9, y); + + path.AddLines(new Point[] { p1, p2, p4, p5, p6, p3, p2, p1 }); + path.CloseFigure(); + + path.AddLines(new Point[] { p7, p8, p9, p10, p11, p12, p13, p8, p7 }); + return path; + } + + public static GraphicsPath CreateCloseFlagPath(Rectangle rect) + { + GraphicsPath path = new GraphicsPath(); + + int x = rect.X + (rect.Width - 9) / 2; + int y = rect.Y + (rect.Height - 7) / 2; + + Point p1 = new Point(x + 1-1, y-1); + Point p2 = new Point(x + 7, y + 6); + Point p3 = new Point(x + 8, y + 6); + Point p4 = new Point(x + 2-1, y-1); + + Point p5 = new Point(x + 6+1, y-1); + Point p6 = new Point(x, y + 6); + Point p7 = new Point(x + 1, y + 6); + Point p8 = new Point(x + 7+1, y-1); + + path.AddLine(p1, p2); + path.AddLine(p3, p4); + path.CloseFigure(); + path.AddLine(p5, p6); + path.AddLine(p7, p8); + + return path; + } + + public static GraphicsPath CreateTopRoundedPathForFormRegion(Rectangle rect) + { + GraphicsPath path = new GraphicsPath(); + + Point pBL = new Point(rect.X, rect.Bottom); // bottom left + Point pBR = new Point(rect.Right, rect.Bottom); // bottom right + + int x = rect.X, y = rect.Y, r = rect.Right; + Point p1 = new Point(x, y + 4); + Point p2 = new Point(x + 1, y + 4); + Point p3 = new Point(x + 1, y + 2); + Point p4 = new Point(x + 2, y + 2); + Point p5 = new Point(x + 2, y + 1); + Point p6 = new Point(x + 4, y + 1); + Point p7 = new Point(x + 4, y); + + Point p8 = new Point(r - 4, y); + Point p9 = new Point(r - 4, y + 1); + Point p10 = new Point(r - 2, y + 1); + Point p11 = new Point(r - 2, y + 2); + Point p12 = new Point(r - 1, y + 2); + Point p13 = new Point(r - 1, y + 4); + Point p14 = new Point(r, y + 4); + + path.AddLines(new Point[] { p1, p2, p3, p4, p5, p6, p7 }); + path.AddLines(new Point[] { p8, p9, p10, p11, p12, p13, p14 }); + path.AddLine(pBR, pBL); + + path.CloseFigure(); + return path; + } + + public static GraphicsPath CreateSingleLineCloseFlag(Rectangle rect, int width) + { + GraphicsPath path = new GraphicsPath(); + + int x = rect.X + (rect.Width - width) / 2; + int y = rect.Y + (rect.Height - width) / 2; + + Point p1 = new Point(x, y); + Point p2 = new Point(x + width, y); + Point p3 = new Point(x + width, y + width); + Point p4 = new Point(x, y + width); + + path.AddLine(p1, p3); + path.CloseFigure(); + path.AddLine(p2, p4); + + return path; + } + + public static GraphicsPath CreateSingleLineCloseFlag(Rectangle rect) + { + return CreateSingleLineCloseFlag(rect, 6); + } + + public static GraphicsPath CreatePlusFlag(Rectangle rect, int width) + { + GraphicsPath path = new GraphicsPath(); + + if (width % 2 == 1) + width++; + + int x = rect.X + (rect.Width - width) / 2; + int y = rect.Y + (rect.Height - width) / 2; + + Point p1 = new Point(x + width / 2 - 1, y); + Point p2 = new Point(x + width / 2 - 1, y + width - 1); + Point p3 = new Point(x + width / 2, y + width - 1); + Point p4 = new Point(x + width / 2, y); + + Point p5 = new Point(x, y + width / 2 - 1); + Point p6 = new Point(x + width - 1, y + width / 2 - 1); + Point p7 = new Point(x + width - 1, y + width / 2); + Point p8 = new Point(x, y + width / 2); + + path.AddLines(new Point[] { p1, p2, p3, p4 }); + path.CloseFigure(); + path.AddLines(new Point[] { p5, p6, p7, p8 }); + + return path; + } + + public static GraphicsPath CreatePlusFlag(Rectangle rect) + { + return CreatePlusFlag(rect, 10); + } + + public static GraphicsPath CreateDownTriangleFlag(Rectangle rect) + { + GraphicsPath path = new GraphicsPath(); + + int x = rect.X + (rect.Width - 10) / 2; + int y = rect.Y + (rect.Height - 9) / 2; + + if (rect.Height % 2 == 0) + y++; + + Point p1 = new Point(x, y); + Point p2 = new Point(x + 9, y); + Point p3 = new Point(x + 9, y + 1); + Point p4 = new Point(x, y + 1); + + path.AddLines(new Point[] { p1, p2, p3, p4 }); + path.CloseFigure(); + + int x1 = x, y1 = y + 4, x2 = x + 9, y2 = y + 4; + for (int i = 1; i <= 5; i++) + { + if (i % 2 == 0) + path.AddLine(x2, y2, x1, y1); + else + path.AddLine(x1, y1, x2, y2); + x1++; + x2--; + y1++; + y2++; + } + + return path; + } + + public static GraphicsPath Create7x4DownTriangleFlag(Rectangle rect) + { + return CreateWxHDownTriangleFlag(rect, 7, 4); + } + + public static GraphicsPath Create9x5DownTriangleFlag(Rectangle rect) + { + return CreateWxHDownTriangleFlag(rect, 9, 5); + } + + private static GraphicsPath CreateWxHDownTriangleFlag(Rectangle rect, int w, int h) + { + GraphicsPath path = new GraphicsPath(); + + int x = rect.X + (rect.Width - w) / 2; + int y = rect.Y + (rect.Height - h) / 2; + + int x1 = x, x2 = x + w - 1; + + for (int i = 0; i < h; i++) + { + if (i % 2 == 0) + path.AddLine(x1, y, x2, y); + else + path.AddLine(x2, y, x1, y); + x1++; + x2--; + y++; + } + path.CloseFigure(); + return path; + } + + public static GraphicsPath Create7x4In7x7DownTriangleFlag(Rectangle rect) + { + GraphicsPath path = new GraphicsPath(); + + int x = rect.X + (rect.Width - 7) / 2; + int y = rect.Y + (rect.Height - 7) / 2 + 2; + + int x1 = x, x2 = x + 6; + + for (int i = 0; i < 4; i++) + { + if (i % 2 == 0) + path.AddLine(x1, y, x2, y); + else + path.AddLine(x2, y, x1, y); + x1++; + x2--; + y++; + } + path.CloseFigure(); + return path; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/MyGraphics/NewGraphics.cs b/Source/ryControls/Gdu.WinFormUI/MyGraphics/NewGraphics.cs new file mode 100644 index 0000000..9728bc0 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/MyGraphics/NewGraphics.cs @@ -0,0 +1,49 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI.MyGraphics +{ + public class NewSmoothModeGraphics : IDisposable + { + SmoothingMode _oldMode; + Graphics _graphics; + + public NewSmoothModeGraphics(Graphics g, SmoothingMode newMode) + { + _oldMode = g.SmoothingMode; + g.SmoothingMode = newMode; + _graphics = g; + } + + public void Dispose() + { + _graphics.SmoothingMode = _oldMode; + } + } + + public class NewClipGraphics : IDisposable + { + Region _oldClip; + Region _newClip; + Graphics _graphics; + bool _shouldDispose; + + public NewClipGraphics(Graphics g, Region newClip, bool disposeNewClip) + { + _oldClip = g.Clip; + _graphics = g; + _shouldDispose = disposeNewClip; + _newClip = newClip; + g.Clip = newClip; + } + + public void Dispose() + { + _graphics.Clip = _oldClip; + if (_shouldDispose) + _newClip.Dispose(); + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/MyGraphics/RoundStyle.cs b/Source/ryControls/Gdu.WinFormUI/MyGraphics/RoundStyle.cs new file mode 100644 index 0000000..513fe1a --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/MyGraphics/RoundStyle.cs @@ -0,0 +1,35 @@ +using System; + +namespace MGdu.WinFormUI.MyGraphics +{ + /// + /// 圆角样式 + /// + public enum RoundStyle + { + /// + /// 无 + /// + None, + /// + /// 所有 + /// + All, + /// + /// 上 + /// + Top, + /// + /// 下 + /// + Bottom, + /// + /// 左 + /// + Left, + /// + /// 右 + /// + Right + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Painter/BasicBlockPainter.cs b/Source/ryControls/Gdu.WinFormUI/Painter/BasicBlockPainter.cs new file mode 100644 index 0000000..a6c31e6 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Painter/BasicBlockPainter.cs @@ -0,0 +1,228 @@ +/* + * 本代码受中华人民共和国著作权法保护,作者仅授权下载代码之人在学习和交流范围内 + * 自由使用与修改代码;欲将代码用于商业用途的,请与作者联系。 + * 使用本代码请保留此处信息。作者联系方式:ping3108@163.com, 欢迎进行技术交流 + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +using MGdu.WinFormUI.MyGraphics; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class BasicBlockPainter + { + + #region static method + + public static void RenderFlatBackground(Graphics g, Rectangle rect, Color backColor, + ButtonBorderType borderType, int radius, RoundStyle roundType) + { + SmoothingMode newMode; + bool simpleRect = (borderType == ButtonBorderType.Rectangle && (roundType == RoundStyle.None || radius < 2)); + if (simpleRect) + { + newMode = SmoothingMode.HighSpeed; + } + else + { + newMode = SmoothingMode.AntiAlias; + rect.Width--; + rect.Height--; + } + using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, newMode)) + { + using (SolidBrush sb = new SolidBrush(backColor)) + { + if (simpleRect) + { + g.FillRectangle(sb, rect); + } + else if (borderType == ButtonBorderType.Ellipse) + { + g.FillEllipse(sb, rect); + } + else + { + using (GraphicsPath path = GraphicsPathHelper.CreateRoundedRect(rect, radius, roundType, false)) + { + g.FillPath(sb, path); + } + } + } + } + } + + public static void RenderBorder(Graphics g, Rectangle rect, Color borderColor, + ButtonBorderType borderType, int radius, RoundStyle roundType) + { + rect.Width--; + rect.Height--; + + bool simpleRect = (borderType == ButtonBorderType.Rectangle && (roundType == RoundStyle.None || radius < 2)); + SmoothingMode newMode = simpleRect ? SmoothingMode.HighSpeed : SmoothingMode.AntiAlias; + + using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, newMode)) + { + using (Pen p = new Pen(borderColor)) + { + if (simpleRect) + { + g.DrawRectangle(p, rect); + } + else if (borderType == ButtonBorderType.Ellipse) + { + g.DrawEllipse(p, rect); + } + else + { + using (GraphicsPath path = GraphicsPathHelper.CreateRoundedRect(rect, radius, roundType, false)) + { + g.DrawPath(p, path); + } + } + } + } + } + + #region rectangle glass + + public static void RenderRectangleGlass(Graphics g, Rectangle ownerRect, + int ownerRadius, RoundStyle ownerRoundTye, RectangleGlassPosition position, + float angle, float glassLengthFactor, Color glassColor, int alpha1, int alpha2) + { + if (!(glassLengthFactor > 0 && glassLengthFactor < 1)) + throw new ArgumentException("glassLengthFactor must be between 0 and 1, but not include 0 and 1. ", + "glassLengthFactor"); + + Rectangle rect = CalcGlassRect(ownerRect, position, glassLengthFactor); + RoundStyle round = CalcRoundStyle(position, ownerRadius, ownerRoundTye); + + //if (angle == 0 || angle == 90 || angle == 180 || angle == 270) + // angle++; + + bool simpleRect = (round == RoundStyle.None); + SmoothingMode newMode; + if (simpleRect) + { + newMode = SmoothingMode.HighSpeed; + } + else + { + newMode = SmoothingMode.AntiAlias; + rect.Width--; + rect.Height--; + } + + if (rect.Width < 1 || rect.Height < 1) + return; + + using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, newMode)) + { + using (LinearGradientBrush lb = new LinearGradientBrush(rect, + Color.FromArgb(alpha1, glassColor), Color.FromArgb(alpha2, glassColor), angle)) + { + if (simpleRect) + { + g.FillRectangle(lb, rect); + } + else + { + using (GraphicsPath path = GraphicsPathHelper.CreateRoundedRect(rect, + ownerRadius, round, false)) + { + g.FillPath(lb, path); + } + } + } + } + } + + private static Rectangle CalcGlassRect(Rectangle ownerRect, RectangleGlassPosition pos, float factor) + { + Point location = ownerRect.Location; + int width = ownerRect.Width; + int height = ownerRect.Height; + + switch (pos) + { + case RectangleGlassPosition.Fill: + break; + case RectangleGlassPosition.Top: + height = (int)(ownerRect.Height * factor); + break; + case RectangleGlassPosition.Bottom: + height = (int)(ownerRect.Height * factor); + location.Offset(0, ownerRect.Height - height); + break; + case RectangleGlassPosition.Left: + width = (int)(ownerRect.Width * factor); + break; + case RectangleGlassPosition.Right: + width = (int)(ownerRect.Width * factor); + location.Offset(ownerRect.Width - width, 0); + break; + } + return new Rectangle(location, new Size(width, height)); + } + + private static RoundStyle CalcRoundStyle(RectangleGlassPosition pos, int radius, RoundStyle ownerStyle) + { + if (radius < 2 || ownerStyle == RoundStyle.None) + return RoundStyle.None; + switch (pos) + { + case RectangleGlassPosition.Fill: + return ownerStyle; + case RectangleGlassPosition.Top: + if (ownerStyle == RoundStyle.All || ownerStyle == RoundStyle.Top) + return RoundStyle.Top; + else + return RoundStyle.None; + case RectangleGlassPosition.Bottom: + if (ownerStyle == RoundStyle.All || ownerStyle == RoundStyle.Bottom) + return RoundStyle.Bottom; + else + return RoundStyle.None; + case RectangleGlassPosition.Left: + if (ownerStyle == RoundStyle.All || ownerStyle == RoundStyle.Left) + return RoundStyle.Left; + else + return RoundStyle.None; + case RectangleGlassPosition.Right: + if (ownerStyle == RoundStyle.All || ownerStyle == RoundStyle.Right) + return RoundStyle.Right; + else + return RoundStyle.None; + default: + return RoundStyle.None; + } + } + + public static void RenderRectangleGlass(Graphics g, Rectangle ownerRect, int ownerRadius, RoundStyle ownerRoundTye) + { + RenderRectangleGlass(g, ownerRect, ownerRadius, ownerRoundTye, RectangleGlassPosition.Top, 90f); + } + + public static void RenderRectangleGlass(Graphics g, Rectangle ownerRect, int ownerRadius, RoundStyle ownerRoundTye, + RectangleGlassPosition position, float angle) + { + RenderRectangleGlass(g, ownerRect, ownerRadius, ownerRoundTye, position, angle, 0.5f); + } + + public static void RenderRectangleGlass(Graphics g, Rectangle ownerRect, int ownerRadius, RoundStyle ownerRoundTye, + RectangleGlassPosition position, float angle, float glassLengthFactor) + { + RenderRectangleGlass(g, ownerRect, ownerRadius, ownerRoundTye, + position, angle, glassLengthFactor, Color.White, 220, 60); + } + + #endregion + + #endregion + + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Painter/RectangleGlassPosition.cs b/Source/ryControls/Gdu.WinFormUI/Painter/RectangleGlassPosition.cs new file mode 100644 index 0000000..5987812 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Painter/RectangleGlassPosition.cs @@ -0,0 +1,15 @@ +using System; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + + public enum RectangleGlassPosition + { + Fill, + Top, + Right, + Left, + Bottom, + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Painter/RollingBarPainter.cs b/Source/ryControls/Gdu.WinFormUI/Painter/RollingBarPainter.cs new file mode 100644 index 0000000..252e00f --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Painter/RollingBarPainter.cs @@ -0,0 +1,149 @@ +/* + * 本代码受中华人民共和国著作权法保护,作者仅授权下载代码之人在学习和交流范围内 + * 自由使用与修改代码;欲将代码用于商业用途的,请与作者联系。 + * 使用本代码请保留此处信息。作者联系方式:ping3108@163.com, 欢迎进行技术交流 + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +using MGdu.WinFormUI.MyGraphics; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class RollingBarPainter + { + public static void RenderDefault(Graphics g, Rectangle rect, Color backColor, float startAngle, + int radius1, int radius2, int spokeNum, float penWidth, Color[] colorArray) + { + + if (spokeNum < 1) + throw new ArgumentException("spokeNum must bigger than 0", "spokeNum"); + if (spokeNum > colorArray.Length) + throw new ArgumentException("spokeNum must NOT bigger than the length of colorArray. ", "spokeNum"); + using (SolidBrush sb = new SolidBrush(backColor)) + { + using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.HighSpeed)) + { + g.FillRectangle(sb, rect); + } + } + Point NYPD = new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2); + PointF p1, p2; + p1 = new PointF(0f, 0f); + p2 = p1; + double cra = 2 * Math.PI / spokeNum; + startAngle = (float)(startAngle * 2 * Math.PI / 360f); + using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.AntiAlias)) + { + using (Pen p = new Pen(Color.White, penWidth)) + { + p.StartCap = LineCap.Round; + p.EndCap = LineCap.Round; + for (int i = 0; i < spokeNum; i++) + { + double angle = startAngle + cra * i; + p1.X = NYPD.X + (float)(radius1 / 2 * Math.Cos(angle)); + p1.Y = NYPD.Y + (float)(radius1 / 2 * Math.Sin(angle)); + p2.X = NYPD.X + (float)(radius2 / 2 * Math.Cos(angle)); + p2.Y = NYPD.Y + (float)(radius2 / 2 * Math.Sin(angle)); + p.Color = colorArray[i]; + g.DrawLine(p, p1, p2); + } + } + } + } + + public static void RenderChromeOneQuarter(Graphics g, Rectangle rect, Color backColor, + float startAngle, int radius, Color baseColor) + { + using (SolidBrush sb = new SolidBrush(backColor)) + { + using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.HighSpeed)) + { + g.FillRectangle(sb, rect); + } + } + Rectangle rectgc = new Rectangle( + rect.X + (rect.Width - radius) / 2, rect.Y + (rect.Height - radius) / 2, radius, radius); + using (Pen p = new Pen(baseColor, 3)) + { + p.StartCap = LineCap.Round; + p.EndCap = LineCap.Round; + using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.AntiAlias)) + { + g.DrawArc(p, rectgc, startAngle, 120); + } + } + } + + public static void RenderDiamondRing(Graphics g, Rectangle rect, Color backColor, float startAngle, + int radius, Color baseColor, Color diamondColor) + { + using (SolidBrush sb = new SolidBrush(backColor)) + { + using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.HighSpeed)) + { + g.FillRectangle(sb, rect); + } + } + Point NYPD = new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2); + startAngle = (float)(startAngle * 2 * Math.PI / 360f); + PointF pslute = PointF.Empty; + pslute.X = NYPD.X + (float)(Math.Cos(startAngle) * radius / 2); + pslute.Y = NYPD.Y + (float)(Math.Sin(startAngle) * radius / 2); + + Rectangle rectce = new Rectangle( + rect.X + (rect.Width - radius) / 2, rect.Y + (rect.Height - radius) / 2, radius, radius); + float width = 4f; + RectangleF rectpf = new RectangleF(pslute.X - width / 2, pslute.Y - width / 2, width, width); + using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.AntiAlias)) + { + using (Pen p = new Pen(baseColor)) + { + g.DrawEllipse(p, rectce); + } + using (SolidBrush sb = new SolidBrush(diamondColor)) + { + g.FillEllipse(sb, rectpf); + } + } + } + + public static void RenderTheseGuys(Graphics g, Rectangle rect, Color backColor, float startAngle, + int radius, Color baseColor) + { + using (SolidBrush sb = new SolidBrush(backColor)) + { + using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.HighSpeed)) + { + g.FillRectangle(sb, rect); + } + } + Point NYPD = new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2); + startAngle = (float)(startAngle * 2 * Math.PI / 360f); + PointF CIA = PointF.Empty; + double crs = 2 * Math.PI / 10; + RectangleF FBI = RectangleF.Empty; + float[] theFeds = new float[] { 5f, 4f, 3f, 2f, 2f }; + Color[] DoD = ColorHelper.GetLighterArrayColors(baseColor, 5, 50f); + using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.AntiAlias)) + { + using (SolidBrush sb = new SolidBrush(baseColor)) + { + for (int i = 0; i < 5; i++) + { + CIA.X = NYPD.X + (float)(Math.Cos(startAngle - i * crs) * radius / 2); + CIA.Y = NYPD.Y + (float)(Math.Sin(startAngle - i * crs) * radius / 2); + FBI = new RectangleF( + CIA.X - theFeds[i] / 2, CIA.Y - theFeds[i] / 2, theFeds[i], theFeds[i]); + sb.Color = DoD[4 - i]; + g.FillEllipse(sb, FBI); + } + } + } + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Painter/SimpleObjectPainter.cs b/Source/ryControls/Gdu.WinFormUI/Painter/SimpleObjectPainter.cs new file mode 100644 index 0000000..560f2a0 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Painter/SimpleObjectPainter.cs @@ -0,0 +1,85 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +using MGdu.WinFormUI.MyGraphics; + +namespace MGdu.WinFormUI +{ + /// + /// SimpleObject指的是只有一种状态(不像普通按钮一样有三种状态),并且其上的元素 + /// 布局比较简单的Object + /// + public class SimpleObjectPainter + { + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static void RenderCircleProgressBar(Graphics g, Rectangle rect, Color coveredColor, Color borderColor, + Color backColor, bool drawInnerBorder, int startAngle, int percentage, bool drawText, Font textFont) + { + using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.AntiAlias)) + { + Rectangle backup = rect; + rect.Width--; + rect.Height--; + + if (percentage < 0) + percentage = 0; + if (percentage > 360) + percentage = 360; + + SolidBrush brushBack = new SolidBrush(backColor); + Pen penBorder = new Pen(borderColor); + + // fill background + g.FillEllipse(brushBack, rect); + + // outter most circle + g.DrawEllipse(penBorder, rect); + + // pie covered region + rect.Inflate(-1, -1); + if (drawInnerBorder) + rect.Inflate(-1, -1); + using (SolidBrush sb = new SolidBrush(coveredColor)) + { + g.FillPie(sb, rect, startAngle, 360 * percentage / 100); + } + + // inner circle background + rect = backup; + rect.Inflate(-rect.Width / 4, -rect.Width / 4); + g.FillEllipse(brushBack, rect); + + // inner circle line + rect.Inflate(-1, -1); + if (drawInnerBorder) + rect.Inflate(-1, -1); + g.DrawEllipse(penBorder, rect); + + // text + if (drawText) + { + string text = percentage.ToString() + "%"; + TextRenderer.DrawText(g, text, textFont, backup, Color.Black, + TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter); + } + + brushBack.Dispose(); + penBorder.Dispose(); + } + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/Form/ThemeFormDevExpress.cs b/Source/ryControls/Gdu.WinFormUI/Theme/Form/ThemeFormDevExpress.cs new file mode 100644 index 0000000..d8944df --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/Form/ThemeFormDevExpress.cs @@ -0,0 +1,43 @@ +using System; +using System.Drawing; + +using MGdu.WinFormUI.MyGraphics; + +namespace MGdu.WinFormUI +{ + /// + /// DevExpress风格皮肤 + /// + public class ThemeFormDevExpress : ThemeFormBase + { + /// + /// DevExpress风格皮肤 + /// + public ThemeFormDevExpress() + : base() + { + ThemeName = "DevExpress Default"; + + BorderWidth = 2; + CaptionHeight = 30; + IconSize = new Size(16, 16); + ControlBoxOffset = new Point(8, 8); + ControlBoxSpace = 2; + SideResizeWidth = 4; + UseDefaultTopRoundingFormRegion = false; + + CaptionBackColorBottom = Color.White; + CaptionBackColorTop = Color.White; + + RoundedStyle = RoundStyle.None; + + FormBorderOutterColor = Color.FromArgb(0, 144, 198); + FormBorderInnerColor = Color.White; + SetClientInset = false; + + CaptionTextCenter = true; + CaptionTextColor = Color.FromArgb(102, 102, 102); + FormBackColor = Color.White; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/Form/ThemeFormNew.cs b/Source/ryControls/Gdu.WinFormUI/Theme/Form/ThemeFormNew.cs new file mode 100644 index 0000000..f8c420b --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/Form/ThemeFormNew.cs @@ -0,0 +1,41 @@ +using System; +using System.Drawing; + +using MGdu.WinFormUI.MyGraphics; + +namespace MGdu.WinFormUI +{ + /// + /// 新风格皮肤 + /// + public class ThemeFormNew : ThemeFormBase + { + /// + /// 新风格皮肤 + /// + public ThemeFormNew() + : base() + { + // about theme + ThemeName = "A New Look Theme"; + + UseDefaultTopRoundingFormRegion = false; + BorderWidth = 2; + CaptionHeight = 36; + IconSize = new Size(24, 24); + ControlBoxOffset = new Point(6, 9); + ControlBoxSpace = 2; + MaxBoxSize = MinBoxSize = CloseBoxSize = new Size(32, 18); + SideResizeWidth = 4; + + CaptionBackColorBottom = Color.LightSlateGray; + CaptionBackColorTop = ColorHelper.GetLighterColor(CaptionBackColorBottom, 40); + + RoundedStyle = RoundStyle.None; + + FormBorderOutterColor = Color.Black; + FormBorderInnerColor = Color.FromArgb(200, Color.White); + SetClientInset = false; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/Form/ThemeFormVS2013.cs b/Source/ryControls/Gdu.WinFormUI/Theme/Form/ThemeFormVS2013.cs new file mode 100644 index 0000000..761c334 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/Form/ThemeFormVS2013.cs @@ -0,0 +1,44 @@ +using System; +using System.Drawing; + +using MGdu.WinFormUI.MyGraphics; + +namespace MGdu.WinFormUI +{ + /// + /// 基础皮肤 + /// + public class ThemeFormVS2013 : ThemeFormBase + { + /// + /// VS2013风格皮肤 + /// + public ThemeFormVS2013() + : base() + { + ThemeName = "A VS2013 Look"; + + BorderWidth = 1; + CaptionHeight = 38; + IconSize = new Size(22, 22); + CloseBoxSize = MaxBoxSize = MinBoxSize = new Size(34, 27); + ControlBoxOffset = new Point(1, 1); + ControlBoxSpace = 1; + SideResizeWidth = 6; + UseDefaultTopRoundingFormRegion = false; + + CaptionBackColorBottom = CaptionBackColorTop = Color.FromArgb(214, 219, 233); + + RoundedStyle = RoundStyle.None; + + FormBorderOutterColor = Color.FromArgb(0, 0, 0); + SetClientInset = false; + + CaptionTextColor = Color.FromArgb(0, 0, 0); + FormBackColor = Color.FromArgb(42, 58, 86); + + CloseBoxColor = ButtonColorTable.GetColorTableVs2013Theme(); + MaxBoxColor = MinBoxColor = CloseBoxColor; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/ProgressBar/ThemeProgressBarBlue.cs b/Source/ryControls/Gdu.WinFormUI/Theme/ProgressBar/ThemeProgressBarBlue.cs new file mode 100644 index 0000000..3e95dee --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/ProgressBar/ThemeProgressBarBlue.cs @@ -0,0 +1,15 @@ +using System; +using System.Drawing; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class ThemeProgressBarBlue : ThemeProgressBarGreen + { + public ThemeProgressBarBlue() + { + CoveredColor = Color.FromArgb(181, 205, 242); + LeadingEdgeColor = Color.FromArgb(153, 163, 180); + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/ProgressBar/ThemeProgressBarGreen.cs b/Source/ryControls/Gdu.WinFormUI/Theme/ProgressBar/ThemeProgressBarGreen.cs new file mode 100644 index 0000000..189f95c --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/ProgressBar/ThemeProgressBarGreen.cs @@ -0,0 +1,24 @@ +using System; +using System.Drawing; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class ThemeProgressBarGreen : GMProgessBarThemeBase + { + public ThemeProgressBarGreen() + { + DrawInnerBorder = false; + DrawCoveredColorGlass = true; + DrawLeadingEdge = true; + DrawBackColorGlass = true; + + CoveredColor = Color.FromArgb(176, 229, 124); + BorderColor = Color.FromArgb(165, 178, 152); + LeadingEdgeColor = Color.FromArgb(188, 203, 173); + BackColor = Color.FromArgb(211, 220, 226); + + BorderRadius = 2; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/ProgressBar/ThemeProgressBarSoftGreen.cs b/Source/ryControls/Gdu.WinFormUI/Theme/ProgressBar/ThemeProgressBarSoftGreen.cs new file mode 100644 index 0000000..dc6e4fa --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/ProgressBar/ThemeProgressBarSoftGreen.cs @@ -0,0 +1,14 @@ +using System; +using System.Drawing; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class ThemeProgressBarSoftGreen : GMProgessBarThemeBase + { + public ThemeProgressBarSoftGreen() + { + CoveredColor = Color.FromArgb(23, 143, 54); + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/RollingBar/ThemeRollingBarChromeGreen.cs b/Source/ryControls/Gdu.WinFormUI/Theme/RollingBar/ThemeRollingBarChromeGreen.cs new file mode 100644 index 0000000..159b05b --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/RollingBar/ThemeRollingBarChromeGreen.cs @@ -0,0 +1,18 @@ +using System; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + /// + /// this theme is just for chrome one quarter style + /// + public class ThemeRollingBarChromeGreen : GMRollingBarThemeBase + { + public ThemeRollingBarChromeGreen() + { + Radius1 = 14; + BaseColor = System.Drawing.Color.LightSeaGreen; + BackColor = System.Drawing.Color.White; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/RollingBar/ThemeRollingBarCircleDots.cs b/Source/ryControls/Gdu.WinFormUI/Theme/RollingBar/ThemeRollingBarCircleDots.cs new file mode 100644 index 0000000..c55d189 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/RollingBar/ThemeRollingBarCircleDots.cs @@ -0,0 +1,19 @@ +using System; +using System.Drawing; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class ThemeRollingBarCircleDots : GMRollingBarThemeBase + { + public ThemeRollingBarCircleDots() + { + Radius1 = 12; + Radius2 = 14; + PenWidth = 4f; + SpokeNum = 9; + + BaseColor = Color.LightSeaGreen; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/RollingBar/ThemeRollingBarFullCircle.cs b/Source/ryControls/Gdu.WinFormUI/Theme/RollingBar/ThemeRollingBarFullCircle.cs new file mode 100644 index 0000000..1f8f412 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/RollingBar/ThemeRollingBarFullCircle.cs @@ -0,0 +1,19 @@ +using System; +using System.Drawing; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class ThemeRollingBarFullCircle : GMRollingBarThemeBase + { + public ThemeRollingBarFullCircle() + { + SpokeNum = 36; + Radius1 = 16; + Radius2 = 18; + PenWidth = 4; + + BaseColor = Color.DarkGray; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/RollingBar/ThemeRollingBarGuys.cs b/Source/ryControls/Gdu.WinFormUI/Theme/RollingBar/ThemeRollingBarGuys.cs new file mode 100644 index 0000000..ad7e9c2 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/RollingBar/ThemeRollingBarGuys.cs @@ -0,0 +1,16 @@ +using System; +using System.Drawing; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class ThemeRollingBarGuys : GMRollingBarThemeBase + { + public ThemeRollingBarGuys() + { + Radius1 = 18; + BackColor = Color.Transparent; + BaseColor = Color.Blue; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/RollingBar/ThemeRollingBarRing.cs b/Source/ryControls/Gdu.WinFormUI/Theme/RollingBar/ThemeRollingBarRing.cs new file mode 100644 index 0000000..4fcf912 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/RollingBar/ThemeRollingBarRing.cs @@ -0,0 +1,19 @@ +using System; +using System.Drawing; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + /// + /// for diamond ring style only + /// + public class ThemeRollingBarRing : GMRollingBarThemeBase + { + public ThemeRollingBarRing() + { + Radius1 = 18; + BaseColor = Color.Gold; + DiamondColor = Color.FromArgb(160, Color.Red); + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarChrome.cs b/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarChrome.cs new file mode 100644 index 0000000..b3c71e9 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarChrome.cs @@ -0,0 +1,67 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +using MGdu.WinFormUI.MyGraphics; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class ThemeScrollbarChrome : GMScrollBarThemeBase + { + public ThemeScrollbarChrome() + { + BackColor = Color.FromArgb(241, 241, 241); + DrawBorder = false; + DrawBackground = true; + + InnerPaddingWidth = 0; + MiddleButtonOutterSpace1 = 0; + MiddleButtonOutterSpace2 = 2; + + ShowSideButtons = true; + //SideButtonCanDisabled = true; + SideButtonLength = 17; + BestUndirectLen = 17; + + SideButtonColorTable = GetSideButtonColorTable(); + MiddleButtonColorTable = GetMiddleButtonColorTable(); + + SideButtonForePathSize = new Size(7, 7); + SideButtonForePathGetter = new ButtonForePathGetter( + GraphicsPathHelper.Create7x4In7x7DownTriangleFlag); + HowSideButtonForePathDraw = ForePathRenderMode.Draw; + + DrawLinesInMiddleButton = false; + } + + private ButtonColorTable GetSideButtonColorTable() + { + ButtonColorTable table = new ButtonColorTable(); + + table.ForeColorHover = table.ForeColorNormal = Color.FromArgb(80, 80, 80); + table.ForeColorPressed = Color.White; + table.ForeColorDisabled = Color.FromArgb(163, 163, 163); + + table.BackColorHover = Color.FromArgb(210, 210, 210); + table.BackColorPressed = Color.FromArgb(120, 120, 120); + + return table; + } + + private ButtonColorTable GetMiddleButtonColorTable() + { + ButtonColorTable table = new ButtonColorTable(); + + table.BorderColorNormal = Color.FromArgb(168, 168, 168); + table.BorderColorHover = Color.FromArgb(154, 154, 154); + table.BorderColorPressed = Color.FromArgb(120, 120, 120); + + table.BackColorNormal = Color.FromArgb(188, 188, 188); + table.BackColorHover = Color.FromArgb(170, 170, 170); + table.BackColorPressed = Color.FromArgb(141, 141, 141); + + return table; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarDevStyle.cs b/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarDevStyle.cs new file mode 100644 index 0000000..8b93714 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarDevStyle.cs @@ -0,0 +1,34 @@ +using System; +using System.Drawing; +using MGdu.WinFormUI.MyGraphics; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class ThemeScrollbarDevStyle : ThemeScrollbarVS2013 + { + public ThemeScrollbarDevStyle() + { + BestUndirectLen = 17; + BackColor = Color.FromArgb(245, 245, 247); + MiddleButtonOutterSpace2 = 5; + SideButtonLength = 17; + InnerPaddingWidth = 0; + SideButtonForePathGetter = new ButtonForePathGetter( + GraphicsPathHelper.Create7x4In7x7DownTriangleFlag); + SideButtonForePathSize = new Size(7, 7); + + SideButtonColorTable.ForeColorNormal = Color.FromArgb(128, 131, 143); + SideButtonColorTable.ForeColorHover = Color.FromArgb(32, 31, 53); + SideButtonColorTable.ForeColorPressed = Color.Black; + + MiddleButtonColorTable.BorderColorNormal = MiddleButtonColorTable.BorderColorHover = + MiddleButtonColorTable.BorderColorPressed = Color.FromArgb(169, 172, 181); + MiddleButtonColorTable.BackColorNormal = Color.FromArgb(217, 218, 223); + MiddleButtonColorTable.BackColorHover = Color.FromArgb(213, 224, 252); + MiddleButtonColorTable.BackColorPressed = Color.FromArgb(202, 203, 205); + + MiddleButtonRadius = 6; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarEllipse.cs b/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarEllipse.cs new file mode 100644 index 0000000..05a7f14 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarEllipse.cs @@ -0,0 +1,16 @@ +using System; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class ThemeScrollbarEllipse : GMScrollBarThemeBase + { + public ThemeScrollbarEllipse() + { + SideButtonBorderType = ButtonBorderType.Ellipse; + MiddleButtonOutterSpace2 = 1; + MiddleButtonRadius = 12; + SideButtonLength = BestUndirectLen; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarNoSideButtons.cs b/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarNoSideButtons.cs new file mode 100644 index 0000000..3402a6b --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarNoSideButtons.cs @@ -0,0 +1,42 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +using MGdu.WinFormUI.MyGraphics; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class ThemeScrollbarNoSideButtons : GMScrollBarThemeBase + { + public ThemeScrollbarNoSideButtons() + { + BackColor = Color.FromArgb(228, 237, 243); + DrawBorder = false; + DrawBackground = true; + + InnerPaddingWidth = 0; + MiddleButtonOutterSpace1 = 0; + MiddleButtonOutterSpace2 = 0; + + DrawLinesInMiddleButton = false; + ShowSideButtons = false; + + MiddleButtonColorTable = GetColorTable(); + + BestUndirectLen = 12; + } + + private ButtonColorTable GetColorTable() + { + ButtonColorTable table = new ButtonColorTable(); + + table.BackColorNormal = Color.FromArgb(190, 199, 209); + table.BackColorHover = Color.FromArgb(163, 176, 189); + table.BackColorPressed = Color.FromArgb(146, 162, 178); + table.BackColorDisabled = Color.FromArgb(210, 210, 210); + + return table; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarVS2013.cs b/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarVS2013.cs new file mode 100644 index 0000000..61aa9d5 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarVS2013.cs @@ -0,0 +1,55 @@ +using System; +using System.Drawing; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class ThemeScrollbarVS2013 : GMScrollBarThemeBase + { + public ThemeScrollbarVS2013() + { + DrawLinesInMiddleButton = false; + ShowSideButtons = true; + DrawBackground = true; + DrawBorder = false; + DrawInnerBorder = false; + + BackColor = Color.FromArgb(232, 232, 232); + InnerPaddingWidth = 0; + MiddleButtonOutterSpace1 = 0; + MiddleButtonOutterSpace2 = 4; + BestUndirectLen = 17; + SideButtonLength = 17; + + SideButtonColorTable = SideBtnColor(); + MiddleButtonColorTable = MdlBtnColor(); + + SideButtonForePathSize = new Size(9, 9); + SideButtonForePathGetter = new ButtonForePathGetter( + MGdu.WinFormUI.MyGraphics.GraphicsPathHelper.Create9x5DownTriangleFlag); + } + + private ButtonColorTable SideBtnColor() + { + ButtonColorTable table = new ButtonColorTable(); + + table.ForeColorNormal = Color.FromArgb(134, 137, 153); + table.ForeColorHover = Color.FromArgb(28, 151, 234); + table.ForeColorPressed = Color.FromArgb(0, 122, 204); + table.ForeColorDisabled = Color.LightGray; + + return table; + } + + private ButtonColorTable MdlBtnColor() + { + ButtonColorTable table = new ButtonColorTable(); + + table.BackColorNormal = Color.FromArgb(208, 209, 215); + table.BackColorHover = Color.FromArgb(136, 136, 136); + table.BackColorPressed = Color.FromArgb(106, 106, 106); + + return table; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarXMPBlack.cs b/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarXMPBlack.cs new file mode 100644 index 0000000..d93a1d4 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/ScrollBar/ThemeScrollbarXMPBlack.cs @@ -0,0 +1,63 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +using MGdu.WinFormUI.MyGraphics; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class ThemeScrollbarXMPBlack : GMScrollBarThemeBase + { + public ThemeScrollbarXMPBlack() + { + BackColor = Color.FromArgb(64, 64, 64); + BorderColor = Color.FromArgb(17, 17, 17); + DrawBackground = true; + DrawBorder = true; + + InnerPaddingWidth = 1; + MiddleButtonOutterSpace1 = 0; + MiddleButtonOutterSpace2 = 1; + SideButtonLength = 14; + BestUndirectLen = 14; + + SideButtonForePathSize = new Size(7, 7); + SideButtonForePathGetter = new ButtonForePathGetter( + GraphicsPathHelper.Create7x4In7x7DownTriangleFlag); + + MiddleButtonColorTable = GetMiddleButtonColorTable(); + SideButtonColorTable = GetSideButtonColorTable(); + + DrawLinesInMiddleButton = true; + MiddleButtonLine1Color = Color.FromArgb(42, 42, 42); + MiddleButtonLine2Color = Color.FromArgb(95, 95, 95); + + MiddleBtnLineOutterSpace1 = 2; + MiddleBtnLineOutterSpace2 = 2; + } + + private ButtonColorTable GetMiddleButtonColorTable() + { + ButtonColorTable table = new ButtonColorTable(); + + table.BackColorNormal = Color.FromArgb(117, 117, 117); + table.BackColorHover = Color.FromArgb(129, 129, 129); + table.BackColorPressed = Color.FromArgb(140, 140, 140); + + return table; + } + + private ButtonColorTable GetSideButtonColorTable() + { + ButtonColorTable table = new ButtonColorTable(); + + table.ForeColorNormal = Color.FromArgb(120, 120, 120); + table.ForeColorHover = Color.FromArgb(140, 140, 140); + table.ForeColorPressed = Color.FromArgb(160, 160, 160); + table.ForeColorDisabled = Color.FromArgb(89, 89, 89); + + return table; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/TrackBar/ThemeTrackBarMetropolis.cs b/Source/ryControls/Gdu.WinFormUI/Theme/TrackBar/ThemeTrackBarMetropolis.cs new file mode 100644 index 0000000..939cf01 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/TrackBar/ThemeTrackBarMetropolis.cs @@ -0,0 +1,33 @@ +using System; +using System.Drawing; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class ThemeTrackBarMetropolis : GMTrackBarThemeBase + { + public ThemeTrackBarMetropolis() + { + MainLineDrawBorder = false; + MainLineRange1BackColor = Color.FromArgb(247, 138, 9); + //MainLineRange1BackColor = Color.FromArgb(55, 58, 61); + MainLineRange2BackColor = Color.FromArgb(157, 157, 157); + + MainLineLength = 3; + + ButtonLength1 = 5; + ButtonLength2 = 10; + + ThumbButtonColorTable = GetColorTable(); + } + + private ButtonColorTable GetColorTable() + { + ButtonColorTable table = new ButtonColorTable(); + table.BackColorNormal = Color.FromArgb(55, 58, 61); + table.BackColorHover = Color.Black; + table.BackColorPressed = Color.FromArgb(130, 130, 130); + return table; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/TrackBar/ThemeTrackBarTTPlayer.cs b/Source/ryControls/Gdu.WinFormUI/Theme/TrackBar/ThemeTrackBarTTPlayer.cs new file mode 100644 index 0000000..686dac9 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/TrackBar/ThemeTrackBarTTPlayer.cs @@ -0,0 +1,36 @@ +using System; +using System.Drawing; +//忽略没有注释警告 +#pragma warning disable 1591 +namespace MGdu.WinFormUI +{ + public class ThemeTrackBarTTPlayer : GMTrackBarThemeBase + { + public ThemeTrackBarTTPlayer() + { + ButtonLength1 = ButtonLength2 = 12; + ButtonOutterSpace2 = 6; + MainLineLength = 4; + + DrawBackground = true; + BackColor = Color.FromArgb(49, 76, 111); + + MainLineDrawBorder = false; + MainLineRadius = 2; + MainLineRange1BackColor = Color.FromArgb(154, 207, 242); + MainLineRange2BackColor = Color.FromArgb(66, 114, 176); + + ThumbButtonBorderType = ButtonBorderType.Ellipse; + ThumbButtonColorTable = GetColorTable(); + } + + private ButtonColorTable GetColorTable() + { + ButtonColorTable table = new ButtonColorTable(); + table.BackColorNormal = Color.White; + table.BackColorHover = Color.FromArgb(230, 230, 230); + table.BackColorPressed = Color.FromArgb(220, 220, 220); + return table; + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Theme/TrackBar/ThemeTrackBarXMP.cs b/Source/ryControls/Gdu.WinFormUI/Theme/TrackBar/ThemeTrackBarXMP.cs new file mode 100644 index 0000000..cfd48e4 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Theme/TrackBar/ThemeTrackBarXMP.cs @@ -0,0 +1,25 @@ +using System; +using System.Drawing; + +namespace MGdu.WinFormUI +{ + //忽略没有注释警告 +#pragma warning disable 1591 + public class ThemeTrackBarXMP : ThemeTrackBarTTPlayer + { + public ThemeTrackBarXMP() + { + MainLineRadius = 0; + MainLineRange1BackColor = Color.FromArgb(0, 90, 175); + MainLineRange2BackColor = Color.FromArgb(48, 49, 52); + + MainLineLength = 3; + ButtonOutterSpace2 = 12; + BackColor = Color.FromArgb(7, 7, 7); + ButtonLength1 = ButtonLength2 = 10; + ThumbButtonColorTable.BackColorNormal = Color.FromArgb(152, 152, 152); + ThumbButtonColorTable.BackColorHover = Color.FromArgb(192, 192, 192); + ThumbButtonColorTable.BackColorPressed = Color.FromArgb(172, 172, 172); + } + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/WLControls/WLButton.cs b/Source/ryControls/Gdu.WinFormUI/WLControls/WLButton.cs new file mode 100644 index 0000000..297bd90 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/WLControls/WLButton.cs @@ -0,0 +1,514 @@ +/* + * 本代码受中华人民共和国著作权法保护,作者仅授权下载代码之人在学习和交流范围内 + * 自由使用与修改代码;欲将代码用于商业用途的,请与作者联系。 + * 使用本代码请保留此处信息。作者联系方式:ping3108@163.com, 欢迎进行技术交流 + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +using MGdu.WinFormUI.MyGraphics; + +namespace MGdu.WinFormUI +{ + //忽略没有注释警告 + #pragma warning disable 1591 + /// + /// + /// + public class WLButton + { + #region private var + + private Control _owner; + private GMButtonState _state; + private EventHandler _click; + private PaintEventHandler _paint; + private bool _capture; + private Rectangle _bounds; + + #endregion + + #region properties + + /// + /// 是否在这个按钮上按下了鼠标未释放 + /// + public bool Capture + { get { return _capture; } } + + public Size BtnSize + { + get { return Bounds.Size; } + } + + public Point Location + { + get { return Bounds.Location; } + } + + public ButtonForePathGetter ForePathGetter { get; set; } + + public event EventHandler Click + { + add { _click = value; } + remove { _click = null; } + } + + public event PaintEventHandler Paint + { + add { _paint = value; } + remove { _paint = null; } + } + + public GMButtonState State + { + get { return _state; } + set + { + if (value != _state) + { + _state = value; + _owner.Invalidate(Bounds); + } + } + } + /// + /// 是否可见 + /// + public bool Visible { get; set; } + /// + /// + /// + public Rectangle Bounds + { + get { return _bounds; } + set + { + if (_bounds != value) + { + _bounds = value; + } + } + } + public Font ForeFont { get; set; } + public string Text { get; set; } + public Size ForePathSize { get; set; } + + public ButtonColorTable ColorTable { get; set; } + public ButtonBorderType BorderType { get; set; } + public bool DrawLightGlass { get; set; } + /// + /// 画两次可以加深颜色 + /// + public bool DrawForePathTwice { get; set; } + + /// + /// 用于在click事件中传回数据 + /// + public object ClickSendBackOject { get; set; } + + public Image BackImageNormal { get; set; } + public Image BackImageHover { get; set; } + public Image BackImagePressed { get; set; } + public Image BackImageDisabled { get; set; } + + public bool Enabled { get; set; } + public ForePathRatoteDirection RotateDirection { get; set; } + public ForePathRenderMode HowForePathRender { get; set; } + + /// + /// 获取或设置是否将绘制完全限制在指定的区域内 + /// + public bool RestrictedBounds { get; set; } + + public int Radius { get; set; } + public RoundStyle RoundedType { get; set; } + + #endregion + + #region private render method + + private void RenderNormal(Graphics g) + { + RenderInternal(g, BackImageNormal, ColorTable.BorderColorNormal, + ColorTable.BackColorNormal, ColorTable.ForeColorNormal); + } + + private void RenderHover(Graphics g) + { + RenderInternal(g, BackImageHover, ColorTable.BorderColorHover, + ColorTable.BackColorHover, ColorTable.ForeColorHover); + } + + private void RenderPressed(Graphics g) + { + RenderInternal(g, BackImagePressed, ColorTable.BorderColorPressed, + ColorTable.BackColorPressed, ColorTable.ForeColorPressed); + } + + private void RenderDisabled(Graphics g) + { + RenderInternal(g, BackImageDisabled, ColorTable.BorderColorDisabled, + ColorTable.BackColorDisabled, ColorTable.ForeColorDisabled); + } + + private void RenderInternal(Graphics g, Image backImage, Color borderColor, + Color backColor, Color foreColor) + { + Region oldClip = g.Clip; + Region newClip = null; + + if (RestrictedBounds) + { + newClip = new Region(Bounds); + g.Clip = newClip; + } + + if (backImage != null) + { + g.DrawImage(backImage, Bounds); + } + else + { + FillInBackground(g, backColor); + RenderForePathAndText(g, foreColor); + DrawBorder(g, borderColor); + } + + if (RestrictedBounds) + { + g.Clip = oldClip; + newClip.Dispose(); + } + } + + private void FillInBackground(Graphics g, Color backColor) + { + BasicBlockPainter.RenderFlatBackground( + g, + Bounds, + backColor, + BorderType, + Radius, + RoundedType); + + if (BorderType == ButtonBorderType.Ellipse && DrawLightGlass) + { + using (GraphicsPath gp = new GraphicsPath()) + { + Rectangle rect = Bounds; + rect.Height--; + rect.Width--; + gp.AddEllipse(rect); + using (PathGradientBrush pb = new PathGradientBrush(gp)) + { + pb.CenterPoint = new PointF(rect.X + rect.Width / 2.0f, rect.Y + rect.Height / 4.0f); + pb.CenterColor = Color.FromArgb(180, Color.White); + pb.SurroundColors = new Color[] { Color.FromArgb(40, Color.White) }; + g.FillPath(pb, gp); + } + } + } + } + + private void DrawBorder(Graphics g, Color borderColor) + { + BasicBlockPainter.RenderBorder( + g, + Bounds, + borderColor, + BorderType, + Radius, + RoundedType); + } + + private void RenderForePathAndText(Graphics g, Color foreColor) + { + if (ForePathGetter != null) + { + if(string.IsNullOrEmpty(Text)) + PathOnly(g,foreColor); + else + PathAndText(g,foreColor); + } + else if(!string.IsNullOrEmpty(Text)) + TextOnly(g,foreColor); + } + + private void PathOnly(Graphics g, Color foreColor) + { + using (GraphicsPath path = ForePathGetter(Bounds)) + { + PathWithRotate(g, path, foreColor, Bounds); + if (DrawForePathTwice) + PathWithRotate(g, path, foreColor, Bounds); + } + } + + private void TextOnly(Graphics g, Color foreColor) + { + Size size = TextRenderer.MeasureText(Text, ForeFont); + int x = Bounds.Left + (Bounds.Width - size.Width) / 2; + int y = Bounds.Top + (Bounds.Height - size.Height) / 2; + Rectangle textRect = new Rectangle(new Point(x, y), size); + TextRenderer.DrawText( + g, + Text, + ForeFont, + textRect, + foreColor, + TextFormatFlags.HorizontalCenter | + TextFormatFlags.VerticalCenter); + } + + private void PathAndText(Graphics g, Color foreColor) + { + Size size = TextRenderer.MeasureText(Text, ForeFont); + Rectangle rect = Bounds; + rect.Offset(-size.Width / 2 + 2, 0); + using (GraphicsPath path = ForePathGetter(rect)) + { + PathWithRotate(g, path, foreColor, rect); + int x = rect.Left + rect.Width / 2 + ForePathSize.Width / 2 + 1; + int y = rect.Top + (rect.Height - size.Height) / 2; + Rectangle textRect = new Rectangle(new Point(x, y), size); + TextRenderer.DrawText( + g, + Text, + ForeFont, + textRect, + foreColor, + TextFormatFlags.HorizontalCenter | + TextFormatFlags.VerticalCenter); + } + } + + private void PathWithRotate(Graphics g, GraphicsPath path, Color foreColor, Rectangle pathRect) + { + Pen p = new Pen(foreColor); + SolidBrush sb = new SolidBrush(foreColor); + + if (RotateDirection == ForePathRatoteDirection.Down) + { + if (HowForePathRender == ForePathRenderMode.Draw) + g.DrawPath(p, path); + else + g.FillPath(sb, path); + } + else + { + int dx = 0, dy = 0, angle = 0; + switch (RotateDirection) + { + case ForePathRatoteDirection.Left: + dx = ForePathSize.Width - 1; + dy = 0; + angle = 90; + break; + case ForePathRatoteDirection.Up: + dx = ForePathSize.Width - 1; + dy = ForePathSize.Height - 1; + angle = 180; + break; + case ForePathRatoteDirection.Right: + dx = 0; + dy = ForePathSize.Height - 1; + angle = 270; + break; + } + int pathX = pathRect.Left + (pathRect.Width - ForePathSize.Width) / 2; + int pathY = pathRect.Top + (pathRect.Height - ForePathSize.Height) / 2; + g.TranslateTransform(pathX, pathY); + g.TranslateTransform(dx, dy); + g.RotateTransform(angle); + using (GraphicsPath newPath = ForePathGetter(new Rectangle(Point.Empty, ForePathSize))) + { + if (HowForePathRender == ForePathRenderMode.Draw) + g.DrawPath(p, newPath); + else + g.FillPath(sb, newPath); + } + g.ResetTransform(); + } + p.Dispose(); + sb.Dispose(); + } + + #region mouse operation + + private void MouseDown(Point location) + { + if (Bounds.Contains(location)) + { + State = GMButtonState.Pressed; + _capture = true; + } + else + { + _capture = false; + } + } + + private void MouseMove(Point location) + { + if (Bounds.Contains(location)) + { + if (State == GMButtonState.Normal) + { + // 没有在窗体其他地方按下按钮 + if (!_owner.Capture) + { + State = GMButtonState.Hover; + } + } + else if (State == GMButtonState.PressLeave) + { + State = GMButtonState.Pressed; + } + + } + else + { + if (_capture) + { + State = GMButtonState.PressLeave; + } + else + { + State = GMButtonState.Normal; + } + } + } + + private void MouseLeave(Point location) + { + State = GMButtonState.Normal; + _capture = false; + } + + private void MouseUp(Point location) + { + + if (Bounds.Contains(location)) + { + State = GMButtonState.Hover; + if (_capture) + OnClick(EventArgs.Empty); + } + else + { + State = GMButtonState.Normal; + } + _capture = false; + } + + #endregion + + #endregion + + #region event + /// + /// + /// + /// + protected virtual void OnClick(EventArgs e) + { + if (_click != null) + { + object obj = (ClickSendBackOject != null) ? ClickSendBackOject : this; + _click(obj, e); + } + } + + protected virtual void OnPaint(PaintEventArgs e) + { + if (_paint != null) + { + _paint(this, e); + } + } + + #endregion + + #region public method + /// + /// + /// + /// + public WLButton(Control owner) + { + _owner = owner; + _state = GMButtonState.Normal; + Visible = true; + Enabled = true; + BorderType = ButtonBorderType.Rectangle; + DrawLightGlass = false; + RotateDirection = ForePathRatoteDirection.Down; + HowForePathRender = ForePathRenderMode.Draw; + RestrictedBounds = true; + Radius = 0; + RoundedType = RoundStyle.None; + } + + public void DrawButton(Graphics g) + { + if (!Visible) + return; + + if (Enabled) + { + switch (State) + { + case GMButtonState.Hover: + RenderHover(g); + break; + case GMButtonState.Pressed: + RenderPressed(g); + break; + default: + RenderNormal(g); + break; + } + } + else + { + RenderDisabled(g); + } + + OnPaint(new PaintEventArgs(g, Bounds)); + } + + public void MouseOperation(Point location, MouseOperationType type) + { + if (!Visible) + return; + + switch (type) + { + case MouseOperationType.Move: + MouseMove(location); + break; + + case MouseOperationType.Down: + MouseDown(location); + break; + + case MouseOperationType.Up: + MouseUp(location); + break; + + case MouseOperationType.Leave: + MouseLeave(location); + break; + + default: + break; + } + } + + #endregion + } +} diff --git a/Source/ryControls/Gdu.WinFormUI/Win32/WinAPI.cs b/Source/ryControls/Gdu.WinFormUI/Win32/WinAPI.cs new file mode 100644 index 0000000..7b4aca3 --- /dev/null +++ b/Source/ryControls/Gdu.WinFormUI/Win32/WinAPI.cs @@ -0,0 +1,429 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; + +namespace MGdu.WinFormUI.Win32 +{ + internal static class WinAPI + { + #region const + + public static readonly IntPtr TRUE = new IntPtr(1); + public static readonly IntPtr FALSE = IntPtr.Zero; + + #endregion + + #region WindowMessages + + public enum WindowMessages + { + WM_MOVE = 0x0003, + WM_SIZE = 0x0005, + WM_ACTIVATE = 0x0006, + + WM_ACTIVATEAPP = 0x001C, + + WM_SETCURSOR = 0x0020, + WM_MOUSEACTIVATE = 0x0021, + WM_GETMINMAXINFO = 0x24, + WM_WINDOWPOSCHANGING = 0x0046, + WM_WINDOWPOSCHANGED = 0x0047, + + // non client area + WM_NCCREATE = 0x0081, + WM_NCDESTROY = 0x0082, + WM_NCCALCSIZE = 0x0083, + WM_NCHITTEST = 0x84, + WM_NCPAINT = 0x0085, + WM_NCACTIVATE = 0x0086, + + // non client mouse + WM_NCMOUSEMOVE = 0x00A0, + WM_NCLBUTTONDOWN = 0x00A1, + WM_NCLBUTTONUP = 0x00A2, + WM_NCLBUTTONDBLCLK = 0x00A3, + WM_NCRBUTTONDOWN = 0x00A4, + WM_NCRBUTTONUP = 0x00A5, + WM_NCRBUTTONDBLCLK = 0x00A6, + WM_NCMBUTTONDOWN = 0x00A7, + WM_NCMBUTTONUP = 0x00A8, + WM_NCMBUTTONDBLCLK = 0x00A9, + + WM_SYSCOMMAND = 0x0112, + WM_PARENTNOTIFY = 0x0210, + + WM_MDINEXT = 0x224, + } + + #endregion + + #region WindowStyle + + [Flags] + public enum WindowStyle : uint + { + WS_OVERLAPPED = 0x00000000, + WS_POPUP = 0x80000000, + WS_CHILD = 0x40000000, + WS_MINIMIZE = 0x20000000, + WS_VISIBLE = 0x10000000, + WS_DISABLED = 0x08000000, + WS_CLIPSIBLINGS = 0x04000000, + WS_CLIPCHILDREN = 0x02000000, + WS_MAXIMIZE = 0x01000000, + WS_CAPTION = 0x00C00000, + WS_BORDER = 0x00800000, + WS_DLGFRAME = 0x00400000, + WS_VSCROLL = 0x00200000, + WS_HSCROLL = 0x00100000, + WS_SYSMENU = 0x00080000, + WS_THICKFRAME = 0x00040000, + WS_GROUP = 0x00020000, + WS_TABSTOP = 0x00010000, + WS_MINIMIZEBOX = 0x00020000, + WS_MAXIMIZEBOX = 0x00010000, + WS_TILED = WS_OVERLAPPED, + WS_ICONIC = WS_MINIMIZE, + WS_SIZEBOX = WS_THICKFRAME, + WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW, + WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | + WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX), + WS_POPUPWINDOW = (WS_POPUP | WS_BORDER | WS_SYSMENU), + WS_CHILDWINDOW = (WS_CHILD) + } + + #endregion + + #region WindowStyleEx + + [Flags] + public enum WindowStyleEx + { + WS_EX_DLGMODALFRAME = 0x00000001, + WS_EX_NOPARENTNOTIFY = 0x00000004, + WS_EX_TOPMOST = 0x00000008, + WS_EX_ACCEPTFILES = 0x00000010, + WS_EX_TRANSPARENT = 0x00000020, + WS_EX_MDICHILD = 0x00000040, + WS_EX_TOOLWINDOW = 0x00000080, + WS_EX_WINDOWEDGE = 0x00000100, + WS_EX_CLIENTEDGE = 0x00000200, + WS_EX_CONTEXTHELP = 0x00000400, + WS_EX_RIGHT = 0x00001000, + WS_EX_LEFT = 0x00000000, + WS_EX_RTLREADING = 0x00002000, + WS_EX_LTRREADING = 0x00000000, + WS_EX_LEFTSCROLLBAR = 0x00004000, + WS_EX_RIGHTSCROLLBAR = 0x00000000, + WS_EX_CONTROLPARENT = 0x00010000, + WS_EX_STATICEDGE = 0x00020000, + WS_EX_APPWINDOW = 0x00040000, + WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE), + WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST), + WS_EX_LAYERED = 0x00080000, + WS_EX_NOINHERITLAYOUT = 0x00100000, // Disable inheritence of mirroring by children + WS_EX_LAYOUTRTL = 0x00400000, // Right to left mirroring + WS_EX_COMPOSITED = 0x02000000, + WS_EX_NOACTIVATE = 0x08000000, + } + + #endregion + + #region Scrollbar + + public enum ScrollBar + { + SB_HORZ = 0, + SB_VERT = 1, + SB_CTL = 2, + SB_BOTH = 3, + } + + #endregion + + #region NCHITTEST + /// + /// Location of cursor hot spot returnet in WM_NCHITTEST. + /// + public enum NCHITTEST + { + /// + /// On the screen background or on a dividing line between windows + /// (same as HTNOWHERE, except that the DefWindowProc function produces a system beep to indicate an error). + /// + HTERROR = (-2), + /// + /// In a window currently covered by another window in the same thread + /// (the message will be sent to underlying windows in the same thread until one of them returns a code that is not HTTRANSPARENT). + /// + HTTRANSPARENT = (-1), + /// + /// On the screen background or on a dividing line between windows. + /// + HTNOWHERE = 0, + /// In a client area. + HTCLIENT = 1, + /// In a title bar. + HTCAPTION = 2, + /// In a window menu or in a Close button in a child window. + HTSYSMENU = 3, + /// In a size box (same as HTSIZE). + HTGROWBOX = 4, + /// In a menu. + HTMENU = 5, + /// In a horizontal scroll bar. + HTHSCROLL = 6, + /// In the vertical scroll bar. + HTVSCROLL = 7, + /// In a Minimize button. + HTMINBUTTON = 8, + /// In a Maximize button. + HTMAXBUTTON = 9, + /// In the left border of a resizable window + /// (the user can click the mouse to resize the window horizontally). + HTLEFT = 10, + /// + /// In the right border of a resizable window + /// (the user can click the mouse to resize the window horizontally). + /// + HTRIGHT = 11, + /// In the upper-horizontal border of a window. + HTTOP = 12, + /// In the upper-left corner of a window border. + HTTOPLEFT = 13, + /// In the upper-right corner of a window border. + HTTOPRIGHT = 14, + /// In the lower-horizontal border of a resizable window + /// (the user can click the mouse to resize the window vertically). + HTBOTTOM = 15, + /// In the lower-left corner of a border of a resizable window + /// (the user can click the mouse to resize the window diagonally). + HTBOTTOMLEFT = 16, + /// In the lower-right corner of a border of a resizable window + /// (the user can click the mouse to resize the window diagonally). + HTBOTTOMRIGHT = 17, + /// In the border of a window that does not have a sizing border. + HTBORDER = 18, + + HTOBJECT = 19, + /// In a Close button. + HTCLOSE = 20, + /// In a Help button. + HTHELP = 21, + } + + #endregion + + #region struct + + [StructLayout(LayoutKind.Sequential)] + public struct RECT + { + public int Left; + public int Top; + public int Right; + public int Bottom; + + public RECT(int left, int top, int right, int bottom) + { + this.Left = left; + this.Top = top; + this.Right = right; + this.Bottom = bottom; + } + + public override string ToString() + { + return "{ Left:" + this.Left + ", Top:" + this.Top + + ", Width:" + (this.Right - this.Left).ToString() + + ", Height:" + (this.Bottom - this.Top).ToString() + "}"; + } + } + + [StructLayout(LayoutKind.Sequential)] + public struct WINDOWPOS + { + public IntPtr hwnd; + public IntPtr hWndInsertAfter; + public int x; + public int y; + public int cx; + public int cy; + public uint flags; + } + + [StructLayout(LayoutKind.Sequential)] + public struct NCCALCSIZE_PARAMS + { + /// + /// Contains the new coordinates of a window that has been moved or resized, that is, it is the proposed new window coordinates. + /// + public RECT rectNewForm; + /// + /// Contains the coordinates of the window before it was moved or resized. + /// + public RECT rectOldForm; + /// + /// Contains the coordinates of the window's client area before the window was moved or resized. + /// + public RECT rectOldClient; + /// + /// Pointer to a WINDOWPOS structure that contains the size and position values specified in the operation that moved or resized the window. + /// + public WINDOWPOS lpPos; + } + + [StructLayout(LayoutKind.Sequential)] + public struct SIZE + { + public Int32 cx; + public Int32 cy; + + public SIZE(Int32 x, Int32 y) + { + cx = x; + cy = y; + } + } + + [StructLayout(LayoutKind.Sequential)] + public struct BLENDFUNCTION + { + byte BlendOp; + byte BlendFlags; + byte SourceConstantAlpha; + byte AlphaFormat; + + public BLENDFUNCTION(byte op, byte flags, byte alpha, byte format) + { + BlendOp = op; + BlendFlags = flags; + SourceConstantAlpha = alpha; + AlphaFormat = format; + } + } + + public enum BlendOp : byte + { + AC_SRC_OVER = 0x00, + AC_SRC_ALPHA = 0x01, + } + + [StructLayout(LayoutKind.Sequential)] + public struct POINT + { + public Int32 x; + public Int32 y; + + public POINT(Int32 x, Int32 y) + { + this.x = x; + this.y = y; + } + } + + #endregion + + // update-layered-window + public enum ULWPara + { + ULW_COLORKEY = 0x00000001, + ULW_ALPHA = 0x00000002, + ULW_OPAQUE = 0x00000004, + ULW_EX_NORESIZE = 0x00000008, + } + + // get-wondow-long + public enum GWLPara + { + GWL_WNDPROC = -4, + GWL_HINSTANCE = -6, + GWL_HWNDPARENT = -8, + GWL_STYLE = -16, + GWL_EXSTYLE = -20, + GWL_USERDATA = -21, + GWL_ID = -12, + } + + // set-window-position + public enum SWPPara : uint + { + SWP_NOSIZE = 0x0001, + SWP_NOMOVE = 0x0002, + SWP_NOZORDER = 0x0004, + SWP_NOREDRAW = 0x0008, + SWP_NOACTIVATE = 0x0010, + SWP_FRAMECHANGED = 0x0020, + SWP_SHOWWINDOW = 0x0040, + SWP_HIDEWINDOW = 0x0080, + SWP_NOCOPYBITS = 0x0100, + SWP_NOOWNERZORDER = 0x0200, + SWP_NOSENDCHANGING = 0x0400, + } + + #region non-dll method + + public static int LOWORD(int value) + { + return value & 0xFFFF; + } + + public static int HIWORD(int value) + { + return value >> 16; + } + + #endregion + + #region dll-import method + + [DllImport("user32.dll")] + public static extern int ShowScrollBar(IntPtr hWnd, int wBar, int bShow); + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public static extern int GetWindowLong(IntPtr hWnd, int Index); + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public static extern int SetWindowLong(IntPtr hWnd, int Index, int Value); + + [DllImport("user32.dll", ExactSpelling = true)] + public static extern int SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); + + [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)] + public static extern IntPtr GetDC(IntPtr hWnd); + + [DllImport("gdi32.dll", ExactSpelling = true, PreserveSig = true, SetLastError = true)] + public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj); + + [DllImport("gdi32.dll")] + public static extern bool DeleteDC(IntPtr hdc); + + [DllImport("user32.dll", ExactSpelling = true)] + public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC); + + [DllImport("gdi32.dll")] + public static extern bool DeleteObject(IntPtr hObject); + + [DllImport("gdi32.dll", SetLastError = true)] + public static extern IntPtr CreateCompatibleDC(IntPtr hdc); + + [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)] + public static extern bool UpdateLayeredWindow(IntPtr hwnd + , IntPtr hdcDst + , ref POINT pptDst + , ref SIZE psize + , IntPtr hdcSrc + , ref POINT pptSrc + , uint crKey + , [In] ref BLENDFUNCTION pblend + , uint dwFlags + ); + + [System.Security.SuppressUnmanagedCodeSecurity] + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public static extern IntPtr SendMessage(IntPtr hWnd, int msg, + IntPtr wParam, IntPtr lParam); + + #endregion + } +} diff --git a/Source/ryControls/Properties/AssemblyInfo.cs b/Source/ryControls/Properties/AssemblyInfo.cs index b5cf810..4bee8c5 100644 --- a/Source/ryControls/Properties/AssemblyInfo.cs +++ b/Source/ryControls/Properties/AssemblyInfo.cs @@ -6,11 +6,11 @@ using System.Runtime.InteropServices; // 控制。更改这些特性值可修改 // 与程序集关联的信息。 [assembly: AssemblyTitle("ryControls")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyDescription("LUI")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("睿元网络工作室")] +[assembly: AssemblyCompany("睿元网络")] [assembly: AssemblyProduct("ryControls")] -[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyCopyright("Copyright ©Itrycn 2021")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, // 方法是按如下所示使用“*”: : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.2101.2301")] -[assembly: AssemblyFileVersion("2.1.2101.2301")] \ No newline at end of file +[assembly: AssemblyVersion("2.1.2102.2201")] +[assembly: AssemblyFileVersion("2.1.2102.2201")] \ No newline at end of file diff --git a/Source/ryControls/bin/x86/Debug/MyDb.dll b/Source/ryControls/bin/x86/Debug/MyDb.dll index 11202e9..dfdc566 100644 Binary files a/Source/ryControls/bin/x86/Debug/MyDb.dll and b/Source/ryControls/bin/x86/Debug/MyDb.dll differ diff --git a/Source/ryControls/bin/x86/Debug/ryControls.dll b/Source/ryControls/bin/x86/Debug/ryControls.dll index 46a6cd4..bfdb5cd 100644 Binary files a/Source/ryControls/bin/x86/Debug/ryControls.dll and b/Source/ryControls/bin/x86/Debug/ryControls.dll differ diff --git a/Source/ryControls/bin/x86/Release/MyDb.dll b/Source/ryControls/bin/x86/Release/MyDb.dll index 06bbe29..0d2b348 100644 Binary files a/Source/ryControls/bin/x86/Release/MyDb.dll and b/Source/ryControls/bin/x86/Release/MyDb.dll differ diff --git a/Source/ryControls/bin/x86/Release/ryControls.dll b/Source/ryControls/bin/x86/Release/ryControls.dll index a6b1468..bffdfda 100644 Binary files a/Source/ryControls/bin/x86/Release/ryControls.dll and b/Source/ryControls/bin/x86/Release/ryControls.dll differ diff --git a/Source/ryControls/ryControlsV4.csproj b/Source/ryControls/ryControlsV4.csproj index 82fcfdf..3a72122 100644 --- a/Source/ryControls/ryControlsV4.csproj +++ b/Source/ryControls/ryControlsV4.csproj @@ -190,9 +190,6 @@ PanelEx.cs - - Component - UserControl @@ -247,6 +244,83 @@ + + + + + Form + + + GMForm.cs + + + Form + + + GMShadow.cs + + + + + Component + + + + + + Component + + + + Component + + + + + Component + + + Component + + + + Component + + + + Component + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -485,6 +559,9 @@ TextBoxEx2.cs + + GMShadow.cs + ColumnSelectionForm.cs