diff --git a/Bin/Debug/CommonControls/.NET4 示例/Itrycn_Project.exe b/Bin/Debug/CommonControls/.NET4 示例/Itrycn_Project.exe index 285f52a..0382665 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 cb6566b..04c7464 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 b618d14..20e696e 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 a1e4242..ca851d0 100644 --- a/Bin/Debug/CommonControls/.NET4 示例/MyDb.xml +++ b/Bin/Debug/CommonControls/.NET4 示例/MyDb.xml @@ -982,6 +982,16 @@ + + + 支持忽略大小写的替换功能 + + + + + 是否忽略大小写 + + 获取匹配的内容 @@ -1065,6 +1075,16 @@ 是否是通配符表达式,不是,则普通替换,忽略大小写,是,则启用通配符替换 + + + 支持忽略大小写的替换文本功能 + + + + + 是否忽略大小写 + + 获取符合要求的第一个结果 diff --git a/Bin/Debug/CommonControls/.NET4 示例/MyDb_SQLite.dll b/Bin/Debug/CommonControls/.NET4 示例/MyDb_SQLite.dll index ed84c77..8a6215c 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 0414f74..e14ba9a 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 d59f490..01a363b 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 示例/RyWeb.xml b/Bin/Debug/CommonControls/.NET4 示例/RyWeb.xml index 36dfc4a..0f17d55 100644 --- a/Bin/Debug/CommonControls/.NET4 示例/RyWeb.xml +++ b/Bin/Debug/CommonControls/.NET4 示例/RyWeb.xml @@ -472,6 +472,11 @@ + + + + + diff --git a/Bin/Debug/CommonControls/.NET4 示例/UserDb/Win.dat b/Bin/Debug/CommonControls/.NET4 示例/UserDb/Win.dat index e23a2ce..ee4a826 100644 --- a/Bin/Debug/CommonControls/.NET4 示例/UserDb/Win.dat +++ b/Bin/Debug/CommonControls/.NET4 示例/UserDb/Win.dat @@ -1,2 +1,2 @@ [Money_Op] -hwnd=263848 +hwnd=1707890 diff --git a/Bin/Debug/CommonControls/.NET4 示例/cUpdate.dat b/Bin/Debug/CommonControls/.NET4 示例/cUpdate.dat index 1a53d64..d0e32f2 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 e95ae72..9e7c2c2 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 01e3c20..cea5fe2 100644 --- a/Bin/Debug/CommonControls/.NET4 示例/ryControls.xml +++ b/Bin/Debug/CommonControls/.NET4 示例/ryControls.xml @@ -26898,6 +26898,2798 @@ The index of the matched row, or -1 + + + 初始化的时候给个alpha值,这样在灰图片的时候可以半透明 + + + + + + 使图片单色化 + + + + + + + 自定义 + + + + + 预置 + + + + + 系统 + + + + + 颜色表示法 + + + + + 根据颜色表示字符串获取对应的颜色 + + + + + + + 从文件中获取Image对象 + 这个函数的主要功能是处理一些ico文件 + 一些ico文件的格式可能比较新,直接Image.FormFile,会报内存不足的异常 + + + 是否将文件读入内存操作,如果为false,将直接返回Image.FromFile,在此情况下, + 必须手动释放Image对象,否则文件将一直处于占用状态,如果为true,则在内存中拷贝副本 + + + + + 将图像转为Icon对象,使用png格式 + + + + + + + 将图像转为Icon对象 + + + + + + + + 返回适应指定容器大小的图像 + 如果图像的尺寸(长或宽)超出了容器范围,将按比例获取图像的缩略图返回,否则直接返回图像 + 此方法最终调用 Image.GetThumbnailImage + 但是注意,在指定的容器尺寸过小时,返回的Image尺寸不可知,是在为了显示16x16的小缩略图是发现了此问题 + 使用 GetScaleImage + + + + + + + + + 返回适应指定容器大小的图像 + 在需要的情况下,此方法创建一个新对象,进行绘制 + + + + + + + + + 返回适应指定容器大小的图像 + 在需要的情况下,此方法创建一个新对象,进行绘制 + + + + + + + + + Gets the bounding rectangle of an image required to fit + in to the given rectangle keeping the image aspect ratio. + + The source image. + The rectangle to fit in to. + Horizontal image aligment in percent. + Vertical image aligment in percent. + New image size. + + + + Gets the bounding rectangle of an image required to fit + in to the given rectangle keeping the image aspect ratio. + The image will be centered in the fit box. + + The source image. + The rectangle to fit in to. + New image size. + + + + Gets the scaled size of an image required to fit + in to the given size keeping the image aspect ratio. + + The source image. + The size to fit in to. + New image size. + + + + 获取一个圆角矩形 + + + + 角度 + + + + + 获取一个圆角矩形 + + + + 角度 + + + + + 返回一个表示箭头的Path + 如果开始坐标和结束坐标之间的距离大于箭头的大小,箭头向结束坐标对齐,顶着结束坐标 + + 开始坐标 + 结束坐标(顶点,方向) + 箭头的长短,大小 + 箭头的粗细 + + + + + 在指定的Image上绘制特定标记 + + + + + 文件不存在 + + + + + + 文件不存在 + + + + + + 无法读取文件 + + + + + + 验证失败中显示错误信息时用的标题 + + + + + 验证失败时是否需要高亮显示(改变背景色) + + + + + 验证控件的输入 + + + + + + + 自定义验证方法 + 在基础验证都通过后,才会调用自定义验证方法(如果有) + + + + + 是否支持 Windows Vista 以上的玻璃效果 + + + + + 是否打开了玻璃效果 + + + + + 获取应用程序主窗体 + + + + + 所对应的绑定数据类型 + + + + + 是否对 DataBoundType 的子类型有效 + 默认无效 + 如果设置为 true,又同时添加了基类与子类的 codon,则运行时会取到哪个codon不确定 + 通常取先添加的那个 + + + + + 如果输入的字符串包含 "${...}" 这样的格式,则认为是指代资源文件中的一个字符串资源 + + + + + + + 获取授予该组件的许可证密钥 + + + + + 0:未验证 + 1:验证失败 + 2:验证通过 + + + + + 获取组件的实例或类型的许可证(如果已给定上下文并确定拒绝许可证是否引发异常)。 + + + + + + + + + + 强类型资源类,用于查找本地化字符串等。 + + + + + 返回此类使用的缓存 ResourceManager 实例。 + + + + + 为使用此强类型资源类的所有资源查找 + 重写当前线程的 CurrentUICulture 属性。 + + + + + 查找类似 消息 的本地化字符串。 + + + + + 查找类似 底部 的本地化字符串。 + + + + + 查找类似 顶部 的本地化字符串。 + + + + + 查找类似 更大 (48x48) 的本地化字符串。 + + + + + 查找类似 大 (32x32) 的本地化字符串。 + + + + + 查找类似 中 (24x24) 的本地化字符串。 + + + + + 查找类似 小 (16x16) 的本地化字符串。 + + + + + Returns true if the current language is the default language. + + + + + Returns a System.String that represents the current System.Object. + + + + + 返回此类使用的缓存 ResourceManager 实例。 + + + + + 为使用此强类型资源类的所有资源查找 + 重写当前线程的 CurrentUICulture 属性。 + + + + + 查找类似 消息 的本地化字符串。 + + + + + 查找类似 底部 的本地化字符串。 + + + + + 查找类似 顶部 的本地化字符串。 + + + + + 查找类似 更大 (48x48) 的本地化字符串。 + + + + + 查找类似 大 (32x32) 的本地化字符串。 + + + + + 查找类似 中 (24x24) 的本地化字符串。 + + + + + 查找类似 小 (16x16) 的本地化字符串。 + + + + + Returns true if the current language is the default language. + + + + + Call GetLanguages() to retrieve a list of possible languages that can be used to set this property. + The default value is the default language. + + + + + Gets a list of available languages defined in this assembly. + + + + + 如果输入的字符串包含 "${...}" 这样的格式,则认为是指代资源文件中的一个字符串资源 + + + + + + + Represents a pop-up window. + + + + + Gets the content of the pop-up. + + + + + Determines which animation to use while showing the pop-up window. + + + + + Determines which animation to use while hiding the pop-up window. + + + + + Determines the duration of the animation. + + + + + Gets or sets a value indicating whether the content should receive the focus after the pop-up has been opened. + + true if the content should be focused after the pop-up has been opened; otherwise, false. + If the FocusOnOpen property is set to false, then pop-up cannot use the fade effect. + + + + Gets or sets a value indicating whether presing the alt key should close the pop-up. + + true if presing the alt key does not close the pop-up; otherwise, false. + + + + Gets or sets a value indicating whether the is resizable. + + true if resizable; otherwise, false. + + + + Gets or sets a minimum size of the pop-up. + + An ordered pair of type representing the width and height of a rectangle. + + + + Gets or sets a maximum size of the pop-up. + + An ordered pair of type representing the width and height of a rectangle. + + + + Gets parameters of a new window. + + An object of type used when creating a new window. + + + + Initializes a new instance of the class. + + The content of the pop-up. + + Pop-up will be disposed immediately after disposion of the content control. + + is null. + + + + Raises the event. + + An that contains the event data. + + + + Processes a dialog box key. + + One of the values that represents the key to process. + + true if the key was processed by the control; otherwise, false. + + + + + Updates the pop-up region. + + + + + Shows the pop-up window below the specified control. + + The control below which the pop-up will be shown. + + When there is no space below the specified control, the pop-up control is shown above it. + + is null. + + + + Shows the pop-up window below the specified area of the specified control. + + The control used to compute screen location of specified area. + The area of control below which the pop-up will be shown. + + When there is no space below specified area, the pop-up control is shown above it. + + is null. + + + + Raises the event. + + An that contains the event data. + + + + Raises the event. + + A that contains the event data. + + + + Raises the event. + + An that contains the event data. + + + + Raises the event. + + A that contains the event data. + + + + Processes Windows messages. + + The Windows to process. + + + + Processes the resizing messages. + + The message. + true, if the WndProc method from the base class shouldn't be invoked. + + + + Paints the sizing grip. + + The instance containing the event data. + + + + 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. + + + + + Types of animation of the pop-up window. + + + + + Uses no animation. + + + + + Animates the window from left to right. This flag can be used with roll or slide animation. + + + + + Animates the window from right to left. This flag can be used with roll or slide animation. + + + + + Animates the window from top to bottom. This flag can be used with roll or slide animation. + + + + + Animates the window from bottom to top. This flag can be used with roll or slide animation. + + + + + Makes the window appear to collapse inward if it is hiding or expand outward if the window is showing. + + + + + Uses a slide animation. + + + + + Uses a fade effect. + + + + + Uses a roll animation. + + + + + Uses a default animation. + + + + + Represents a Windows combo box control with a custom popup control attached. + + + + + Initializes a new instance of the class. + + + + + Gets or sets the drop down control. + + The drop down control. + + + + Gets or sets a value indicating whether the combo box is displaying its drop-down portion. + + + true if the drop-down portion is displayed; otherwise, false. The default is false. + + + + + Occurs when the drop-down portion of a is shown. + + + + + Shows the drop down. + + + + + Occurs when the drop-down portion of the is no longer visible. + + + + + Hides the drop down. + + + + + Processes Windows messages. + + The Windows to process. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + + 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. + + + + + Represents a Windows combo box control which can be used in a popup's content control. + + + + + Initializes a new instance of the class. + + + + + Raises the event. + + An that contains the event data. + + + + Raises the event. + + An that contains the event data. + + + + 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. + + + + + 白色到灰色的垂直渐变 + + + + + A ToolstripManager rendering class with advanced control features + + + + + Creates a new EasyRender class for modifications + + + + + Gets the manager to edit and change the appearance of the Toolstrip + + + + + Gets the manager to edit and change the appearance of Toolstrip buttons + + + + + Gets the manager to edit and change the appearance of other Toolstrip controls + + + + + Gets the manager to edit and change the appearance of the Panels + + + + + Gets the manager to edit and change the appearance of the Toolstrip split buttons + + + + + Gets the manager to edit and change the appearance of the Status-bar + + + + + Gets or sets whether to smooth the font text on all controls + + + + + Gets or sets the color of the text if the AlterColor is set to true + + + + + Gets or sets whether to override the font-color on all controls + + + + + Creates a GraphicsPath that appreciates an area where things can be drawn + + The rectangular area which will serve as the base + The curve amount of the corners + + + + + Creates a triangle based on the size and bounds sectors + + The area which the triangle is confined to + The size of the triangle + The direction which the triangle is pointing + + + + + Gets a color array based on the state of a normal button + + The button to check the state of + + + + + Gets a color array based on the state of a split-button + + The button to check the state of + + + + + Gets a color array based on the state of a menu-item + + The button to check the state of + + + + + Gets a color array based on the state of a drop-down button + + The button to check the state of + + + + + Gets a blending property for a specified type of Toolstrip item + + The Toolstrip item + The type of item this is + + + + + Fills a specified boundary with color + + The Graphics object to draw onto + The boundaries to draw the color + The brush to fill the color + + + + Fills a specified boundary with a gradient with specified colors + + The Graphics object to draw onto + The boundaries to draw the color + The color of the gradient at the top + The color of the gradient at the bottom + + + + Fills a specified boundary with a gradient with specified colors at a given angle + + The Graphics object to draw onto + The boundaries to draw the color + The color of the gradient at the top + The color of the gradient at the bottom + The angle which the gradient is drawn (null defaults to 90f) + + + + Fills a specified boundary with a gradient with specified colors at a given angle and with blending properties + + The Graphics object to draw onto + The boundaries to draw the color + The color of the gradient at the top + The color of the gradient at the bottom + The angle which the gradient is drawn (null defaults to 90f) + The blending options to draw the gradient + + + + Draws a set path with a defined brush + + The Graphics object to draw onto + The path to draw along + The brush to fill the color + + + + Draws a set path with specified colors + + The Graphics object to draw onto + The path to draw along + The area of span the border gradient covers + The color of the gradient at the top + The color of the gradient at the bottom + + + + Draws a set path with specified colors at a given angle + + The Graphics object to draw onto + The path to draw along + The area of span the border gradient covers + The color of the gradient at the top + The color of the gradient at the bottom + The angle which the gradient is drawn (null defaults to 90f) + + + + Draws a set path with specified colors at a given angle with blending properties + + The Graphics object to draw onto + The path to draw along + The color of the gradient at the top + The color of the gradient at the bottom + The angle which the gradient is drawn (null defaults to 90f) + The blending options to draw the gradient + + + + Draws a Toolstrip button + + The Toolstrip button + The Graphics object to handle + The parent Toolstrip + + + + Draws a Toolstrip button + + The Toolstrip button + The Graphics object to handle + The parent Toolstrip + + + + Draws the Toolstrip background + + The Toolstrip being drawn + The Graphics object to handle + The affected bounds + + + + Draws a Toolstrip split-button + + The Toolstrip split-button + The Graphics object to handle + The parent Toolstrip + + + + Draws the Statusbar background + + The Statusbar being drawn + The Graphics object to handle + The affected bounds + + + + Draws a Menustrip item + + The Menustrip item + The Graphics object to handle + The parent Toolstrip + + + + Covers the button background rendering + + + + + + Applies any and all changes made to the Renderer + + + + + A class designed to be used in the EasyRender master control to customize the look and feel of the base Toolstrip + + + + + Creates a new IToolstrip class for customization + + + + + Creates a new IToolstrip class for customization + + The IToolstrip to import the settings from + + + + Disposes of the IToolstrip class and clears all resources related to it + + + + + Gets or sets the color of the Toolstrip background gradient from the top + + + + + Gets or sets the color of the Toolstrip background gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Toolstrip background + If set to null, the Toolstrip will simply draw the gradient + + + + + Gets or sets the angle which the Toolstrip background will be drawn + + + + + Gets or sets the color of the Toolstrip border gradient from the top + + + + + Gets or sets the color of the Toolstrip border gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Toolstrip border + If set to null, the Toolstrip will simply draw the border + + + + + Gets or sets the angle which the Toolstrip border will be drawn + + + + + Gets or sets the curve of the border of the Toolstrip + + + + + Imports the settings from a previous or pre-defined IToolstrip and applies it to the current + + The IToolstrip to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + Creates a new IToolstripControls class for customization + + + + + Disposes of the IToolstripControls class and clears all resources related to it + + + + + Gets or sets the color of the Toolstrip seperator on the dark side + + + + + Gets or sets the color of the Toolstrip seperator on the light side + + + + + Gets or sets the height of the Toolstrip seperator control + + + + + Gets or sets the color of the grip dots/line at the top + + + + + Gets or sets the color of the grip shadow + + + + + Gets or sets in what mode the grip will be drawn + + + + + Gets or sets the distance, in pixels, between each grip dot + + + + + Gets or sets the size of the dots or lines for the grip + + + + + Imports the settings from a previous or pre-defined IToolstripControls and applies it to the current + + The IToolstripControls to import the settings from + + + + Creates a new IButton class for customization + + + + + Creates a new IButton class for customization + + The IButton to import the settings from + + + + Disposes of the IButton class and clears all resources related to it + + + + + Gets or sets the color of the Button background at the top, when hovered over + + + + + Gets or sets the color of the Button background at the bottom, when hovered over + + + + + Gets or sets the color of the Button background at the top, when clicked + + + + + Gets or sets the color of the Button background at the bottom, when clicked + + + + + Gets or sets the blending that will occur when rendering the Button background + If set to null, the Button will simply draw the gradient + + + + + Gets or sets the angle which the Button background will be drawn + + + + + Gets or sets the color of the Button border gradient from the top + + + + + Gets or sets the color of the Button border gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Button border + If set to null, the Button will simply draw the border + + + + + Gets or sets the angle which the Button border will be drawn + + + + + Gets or sets the color of the inside border + + + + + Gets or sets when to apply the rendering ("Normal" does not apply here) + + + + + Gets or sets the curve of the border of the Button + + + + + Imports the settings from a previous or pre-defined IButton and applies it to the current + + The IButton to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + Creates a new IButton class for customization + + + + + Creates a new IButton class for customization + + The IButton to import the settings from + + + + Disposes of the IButton class and clears all resources related to it + + + + + Gets or sets the color of the Button background at the top, when hovered over + + + + + Gets or sets the color of the Button background at the bottom, when hovered over + + + + + Gets or sets the blending that will occur when rendering the Button background + If set to null, the Button will simply draw the gradient + + + + + Gets or sets the angle which the Button background will be drawn + + + + + Gets or sets the color of the Button border gradient from the top + + + + + Gets or sets the color of the Button border gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Button border + If set to null, the Button will simply draw the border + + + + + Gets or sets the angle which the Button border will be drawn + + + + + Gets or sets the color of the inside border + + + + + Gets or sets when to apply the rendering ("Normal" and "Click" do not apply here) + + + + + Gets or sets the curve of the border of the Button + + + + + Imports the settings from a previous or pre-defined IDropDownButton and applies it to the current + + The IDropDownButton to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + Creates a new ISplitButton class for customization + + + + + Disposes of the ISplitButton class and clears all resources related to it + + + + + Gets or sets the color of the Button background at the top, when hovered over + + + + + Gets or sets the color of the Button background at the bottom, when hovered over + + + + + Gets or sets the color of the Button background at the top, when clicked + + + + + Gets or sets the color of the Button background at the bottom, when clicked + + + + + Gets or sets the blending that will occur when rendering the Button background + If set to null, the Button will simply draw the gradient + + + + + Gets or sets the angle which the Button background will be drawn + + + + + Gets or sets the color of the Button border gradient from the top + + + + + Gets or sets the color of the Button border gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Button border + If set to null, the Button will simply draw the border + + + + + Gets or sets the angle which the Button border will be drawn + + + + + Gets or sets the color of the inside border + + + + + Gets or sets when to apply the rendering ("Normal" does not apply here) + + + + + Gets or sets the curve of the border of the Button + + + + + Gets or sets when to display the drop-down arrow + + + + + Gets or sets the color of the drop-down arrow + + + + + Imports the settings from a previous or pre-defined ISplitButton and applies it to the current + + The ISplitButton to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + Creates a new IPanel class for customization + + + + + Disposes of the IButton class and clears all resources related to it + + + + + Gets or sets the color of the gradient at the top of the content panel + + + + + Gets or sets the color of the gradient at the bottom of the content panel + + + + + Gets or sets whether each panel inherits the shading from the content panel + + + + + Gets or sets the angle which the background gradient is drawn + + + + + Gets or sets the blend of the background + + + + + Gets or sets a mode to render the background in + + + + + Creates a new IStatusBar class for customization + + + + + Disposes of the IButton class and clears all resources related to it + + + + + Gets or sets the color of the gradient of the background at the top + + + + + Gets or sets the color of the gradient of the background at the bottom + + + + + Gets or sets the blending that will apply to the background + + + + + Gets or sets the angle which the background gradient will be drawn + + + + + Gets or sets the color of the dark border + + + + + Gets or sets the color of the light border + + + + + Gets or sets the color of the grip at the top-most + + + + + Gets or sets the color of the grip at the bottom-most + + + + + Gets or sets the spacing of the grip blocks + + + + + Imports the settings from a previous or pre-defined IStatusBar and applies it to the current + + The IStatusBar to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + A class designed to be used in the EasyRender master control to customize the look and feel of the base Menustrip + + + + + Creates a new IToolstrip class for customization + + + + + Creates a new IMenustrip class for customization + + The IMenustrip to import the settings from + + + + Disposes of the IMenustrip class and clears all resources related to it + + + + + Gets or sets the color of the menu-strip border (dark) + + + + + Gets or sets the color of the menu-strip border (light) + + + + + Gets or sets how the background of the menu-strip is inherited + + + + + If inheritence is set to none, the color of the background gradient at the top + + + + + If inheritence is set to none, the color of the background gradient at the bottom + + + + + If inheritence is set to none, the blending option for the background + + + + + Gets or sets the color of the margin gradient at the left + + + + + Gets or sets the color of the margin gradient at the right + + + + + Gets or sets the color of the margin border (displayed to the right) + + + + + Gets or sets the color of the root menu-strip button background when it is selected + + + + + Gets or sets the color of the root menu-strip button border when it is selected + + + + + Gets or sets the color of the seperator dark color + + + + + Gets or sets the color of the seperator light color + + + + + Gets or sets the inset position of the seperator from the left + + + + + Gets the class that handles the look and feel of the menu-strip items + + + + + Imports the settings from a previous or pre-defined IMenustrip and applies it to the current + + The IMenustrip to import the settings from + + + + Sets the blending for the background to it's default + + + + + Defines when to show an arrow + + + + + Defines when to use a blend property + + + + + Use the blend when the object is drawn + + + + + Use the blend when the object is hovered over + + + + + Use the blend when the object is clicked + + + + + Use the blend when the object is checked + + + + + Always use the blend regardless of the state of the object + + + + + Defines a method of drawing a grip on a control + + + + + Draws the grip as a set of dots + + + + + Draws the grip as two lines + + + + + Does not draw the grip at all, but the object remains moveable + + + + + Defines a specific type of button to search by + + + + + Defines a method for background or object inheritence + + + + + Defines a method of rendering + + + + + 主菜单 + + + + + 背景透明的工具条 + + + + + 银白色至白色渐变 + + + + + 白色至银白色渐变 + + + + + 当前工作区窗体所关联并激活的工具栏 + + + + + 模拟运行时的外观 + + + + + Represents the visual state of an image list view item. + + + + + 没有任何选择状态,处于一般正常状态 + + + + + 项处于选中状态 + + + + + 鼠标滑过 + + + + + 边框宽度 + + + + + 文本和description文本之间的间距 + + + + + 最大显示的项数 + + + + + 是否显示说明字段,此属性不影响弹出面板是否显示 + 弹出面板是否显示由DescriptionMember是否设置决定 + + + + + 下拉列表的布局模式 + + + + + 是否允许空 + + + + + 测量当前控件应该的高度 + + + + + + 整个可用的绘图表面 + + + + + 右边按钮的绘图表面 + + + + + 绘制边框 + + + + + + 绘制背景 + + + + + + 绘制文本 + + + + + + 当前热点项生改变 + + + + + 通过外能事件获取用于绘制项的文本 + + + + + 标题 + + + + + 验证失败时是否需要高亮显示(改变背景色) + + + + + 排序箭头开始颜色 + + + + + 排序箭头开始颜色 + + + + + 控件的背景画布颜色 + 因为控件的边框和过度色都有依靠改变透明度实现渐变,所以一个白色的底版就非常重要 + 使过度色不受控件本身背景色的影响,光不绘制背景不行,要刷上白色背景 + + + + + 控件背景色 + + + + + 边框颜色 + + + + + Represents the visual state of an image list view item. + + + + + 没有任何选择状态,处于一般正常状态 + + + + + 项处于选中状态 + + + + + 该项具有输入焦点 + + + + + 鼠标滑过 + + + + + The item is not visible. + + + + + The item is partially visible. + + + + + The item is fully visible. + + + + + 布局方式 + + + + + 标准布局 + + + + + 使项带有描述的布局 + + + + + 双击项事件参数 + + + + + 项被删除事件参数 + + + + + 为项绘制带有描述信息的渲染器 + + + + + 字的高度是否已初始化 + 在第一次绘制时,测量文本的高度 + + + + + 框选的最短开始长度 + + + + + 框选时滚动条的自动滚动速度 + + + + + 用于鼠标框选时,框出了控件中项的显示范围时,自动滚动滚动条 + + + + + 自动滚动时,滚动值 + + + + + 是否处于框选状态中 + + + + + 内框offset,内框offset是绝对相对于滚动条的 + + + + + 整个可显示项的边界的offset,包括上下padding部分 + + + + + 鼠标按下时项区域边界的offset,即 _itemsAreaOffset + 用于框选时,跨越可视部队画框 + + + + + 当前所能显示的最大行数 + + + + + Gets whether the shift key is down. + + + + + Gets whether the control key is down. + + + + + 没有任何项 + + + + + 没有任何项处于可显示状态 + + + + + 整个控件区域 + + + + + 整个可用于绘制项的可视区域 + 去除左右Padding部分,去除滚动条 + + + + + 用于绘制项的区域 + 考虑边距间隔大小和滚动条区域 + + + + + 项的尺寸 + 不放在ListView本身中定义而是放在LayoutManager中定义,是因为不同的布局方式 + 可能会是带长宽的Size做为itemSize,比如平铺的方式 + + + + + 项周围的边距 + + + + + 更新整个布局引擎的状态 + + + + + 判断指定的项是否处于可见状态 + + + + + + + 获取项的呈现区域 + + + + + + + 获取当前所有可见项 + + + + + + Calculates the maximum number of rows and columns + that can be fully displayed. + + + + + 计算当前可见项的index范围 + + + + + 更新滚动条状态 + + + + + 创建框选框 + + + + + + 根据矩形区域选择项 + + + + + + 应用导航键,如上下左右,返回应用导航键之后的项的坐标 + + + + + 使指定下标的项处于可见状态 + + + + + + 默认渲染器,不绘制项的实际内容,但是绘制DEBUG信息 + + + + + 用于子类重写时删除相应的缓存 + + + + + + 绘制项的背景 + + The System.Drawing.Graphics to draw on. + The client coordinates of the item area. + + + + 绘制最终的前景 + + + + + + + 绘制选择边框 + + The System.Drawing.Graphics to draw on. + The client coordinates of the selection rectangle. + + + + 绘制项的边框 + + + + + + + 绘制项 + + + + + + + + + 绘制项的背景 + + + + + + + 绘制项的内容 + + + + + + + + 绘制背景 + + + + + + 绘制当前所有可见项 + + + + + + Renders the selection rectangle. + + The graphics to draw on. + + + + 默认渲染器,以类似微软ListView的方式按行绘制项,只绘制简单的文本 + + + + + 字的高度是否已初始化 + 在第一次绘制时,测量文本的高度 + + + + + 项的背景色 + + + + + 控件背景色 + + + + + 项的边框色 + + + + + 选择框颜色 + + + + + 选择框的边框色 + + + + + 当控件具有焦点时选定项的背景色 + + + + + 控件失去焦点时选定项的背景色 + + + + + 热点项的背景色 + + + + + 图像内边框颜色 + + + + + 图像外边框颜色 + + + + + Creates a control with a border. + + + + + Specifies that the control has a border with a sunken edge. + + + + + 是否需要在调用 ResumeLayout 时重绘 + + + + + 为项扩展的用于呈现的属性 + + + + + Gets whether the shift key is down. + + + + + Gets whether the control key is down. + + + + + 鼠标左键是否处于按下状态 + + + + + 鼠标右键是否处于按下状态 + + + + + 鼠标最后点击的位置 + + + + + 当前鼠标经过的项 + + + + + 配色方案 + + + + + 当前布局中项的高度 + + + + + 是否没有任何项 + + + + + 获取当前具有输入焦点的项 + + + + + 默认的用于呈现为项中文本的Property + + + + + 更改了选择的项 + + + + + 双击项 + + + + + + 请求在下次调用 ResumeLayout 时重绘 + + + + + 获取当前选中的所有项 + + + + + + 设置扩展属性供特定LayoutEngine使用 + 如果指定的 ExtendMember 已存在,覆盖之 + 用String.Empty 或 null 做为 propertyName传入,表示删除指定的 member + + + + + + + 恢复正常的布局逻辑。 + + + + + 临时挂起控件的布局逻辑。 + + + + + 获取当前选中项所绑定的对象 + 如果没有选中项,返回null,如果选中多项,返回选中项集合中的第一个 + + + + + + 根据指定的绑定项对象 + 设置当前列表中选定的项 + + + + + + 获取当前选中的所有项的绑定对象集合 + 如果当前没有选中任何项,返回空集合 + + + + + + 取消所有项的选择 + + + + + 获取创建控件句柄时所需要的创建参数 + + + + + 更改了选择的项 + + + + + 双击项 + + + + + 项被删除 + + + + + 通过外能事件获取用于绘制项的文本 + + + + + Represents the color palette of the image list view. + + + + + Gets or sets the background color of the ImageListView control. + + + + + Gets or sets the background color of the ImageListViewItem. + + + + + Gets or sets the background color of alternating cells in Details View. + + + + + Gets or sets the border color of the ImageListViewItem. + + + + + Gets or sets the foreground color of the ImageListViewItem. + + + + + Gets or sets the background gradient color1 of the ImageListViewItem if the control is not focused. + + + + + Gets or sets the background gradient color2 of the ImageListViewItem if the control is not focused. + + + + + Gets or sets the border color of the ImageListViewItem if the control is not focused. + + + + + Gets or sets the fore color of the ImageListViewItem if the control is not focused. + + + + + Gets or sets the background gradient color1 if the ImageListViewItem is hovered. + + + + + Gets or sets the background gradient color2 if the ImageListViewItem is hovered. + + + + + Gets or sets the border color of the ImageListViewItem if the item is hovered. + + + + + Gets or sets the color of the insertion caret. + + + + + Gets or sets the background gradient color1 if the ImageListViewItem is selected. + + + + + Gets or sets the background gradient color2 if the ImageListViewItem is selected. + + + + + Gets or sets the border color of the ImageListViewItem if the item is selected. + + + + + Gets or sets the fore color of the ImageListViewItem if the item is selected. + + + + + Gets or sets the background gradient color1 of the column header. + + + + + Gets or sets the background gradient color2 of the column header. + + + + + Gets or sets the background hover gradient color1 of the column header. + + + + + Gets or sets the background hover gradient color2 of the column header. + + + + + Gets or sets the cells foreground color of the column header text. + + + + + Gets or sets the cells background color if column is selected in Details View. + + + + + Gets or sets the color of the separator in Details View. + + + + + Gets or sets the foreground color of the cell text in Details View. + + + + + Gets or sets the foreground color of alternating cells text in Details View. + + + + + Gets or sets the background color of the image pane. + + + + + Gets or sets the separator line color between image pane and thumbnail view. + + + + + Gets or sets the color of labels in pane view. + + + + + Gets or sets the image inner border color for thumbnails and pane. + + + + + Gets or sets the image outer border color for thumbnails and pane. + + + + + Gets or sets the background color1 of the selection rectangle. + + + + + Gets or sets the background color2 of the selection rectangle. + + + + + Gets or sets the color of the selection rectangle border. + + + + + Initializes a new instance of the ImageListViewColor class. + + + + + Initializes a new instance of the ImageListViewColor class + from its string representation. + + String representation of the object. + + + + Copies color values from the given object. + + The source object. + + + + Represents the default color theme. + + + + + Represents the noir color theme. + + + + + Represents the mandarin color theme. + + + + + Sets the color palette to default colors. + + + + + Sets the color palette to mandarin colors. + + + + + Sets the color palette to noir colors. + + + + + Determines whether all color values of the specified + ImageListViewColor are equal to this instance. + + The object to compare with this instance. + true if the two instances have the same color values; + otherwise false. + + + + Returns a hash code for this instance. + + + A hash code for this instance, suitable for use in + hashing algorithms and data structures like a hash table. + + + + + Returns a string that represents this instance. + + + A string that represents this instance. + + + + + 测试坐标 + + + + + 项的坐标 + + + + + 是否点击了项 + + + + + 该项当前的选中状态 + + + + + 所绑定的对象 + + + + + 将指定的事件移动到(紧邻)另一个事件之前 + + + + + + + 将指定的事件移动到(紧邻)另一个事件之后 + + + + + + + 通过窗口的标题来查找窗口的句柄 + + + + + + + + 发送 Windows 消息 + + + + + + + + + + 发送消息,只能传递一个自定义的消息ID和消息字符串,想传一个结构,但没成功 + + 目标进程名称,如果有多个,则给每个都发送 + 自定义数据,可以通过这个来决定如何解析下面的strMsg + 传递的消息,是一个字符串 + + + + 接收消息,得到消息字符串 + + System.Windows.Forms.Message m + 接收到的消息字符串 + + + + 最大圆角半径 + + + + + 最小矩形边长,用于自动处理圆角大小 + + + + + 绘制一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 矩形左上角X坐标 + 矩形左上角Y坐标 + 矩形右下角X坐标 + 矩形右下角Y坐标 + 圆角的半径长度 + + + + 绘制一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 要绘制的矩形对象 + 圆角的半径长度 + + + + 绘制一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 要绘制的矩形对象 + + + + 填充一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 矩形左上角X坐标 + 矩形左上角Y坐标 + 矩形右下角X坐标 + 矩形右下角Y坐标 + 圆角的半径长度 + + + + 填充一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 要填充的矩形 + 填充区域针对矩形的缩进距离 + 圆角的半径长度 + + + + 填充一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 要填充的矩形 + + + + 使图片单色化 + + + + 获取颜色 diff --git a/Bin/Debug/CommonControls/.NET4 示例/ryUpdate.dll b/Bin/Debug/CommonControls/.NET4 示例/ryUpdate.dll index ac81536..26700de 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 b618d14..20e696e 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 a1e4242..ca851d0 100644 --- a/Bin/Debug/CommonControls/.NET4/MyDb.xml +++ b/Bin/Debug/CommonControls/.NET4/MyDb.xml @@ -982,6 +982,16 @@ + + + 支持忽略大小写的替换功能 + + + + + 是否忽略大小写 + + 获取匹配的内容 @@ -1065,6 +1075,16 @@ 是否是通配符表达式,不是,则普通替换,忽略大小写,是,则启用通配符替换 + + + 支持忽略大小写的替换文本功能 + + + + + 是否忽略大小写 + + 获取符合要求的第一个结果 diff --git a/Bin/Debug/CommonControls/.NET4/MyDb_MSSQL.dll b/Bin/Debug/CommonControls/.NET4/MyDb_MSSQL.dll index d22f2fe..fc0beb9 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 6cf9476..8503b3a 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 ed84c77..8a6215c 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 0414f74..e14ba9a 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 d59f490..17ef08f 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/RyWeb.xml b/Bin/Debug/CommonControls/.NET4/RyWeb.xml index 36dfc4a..0f17d55 100644 --- a/Bin/Debug/CommonControls/.NET4/RyWeb.xml +++ b/Bin/Debug/CommonControls/.NET4/RyWeb.xml @@ -472,6 +472,11 @@ + + + + + diff --git a/Bin/Debug/CommonControls/.NET4/ryControls.dll b/Bin/Debug/CommonControls/.NET4/ryControls.dll index e95ae72..9e7c2c2 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 01e3c20..cea5fe2 100644 --- a/Bin/Debug/CommonControls/.NET4/ryControls.xml +++ b/Bin/Debug/CommonControls/.NET4/ryControls.xml @@ -26898,6 +26898,2798 @@ The index of the matched row, or -1 + + + 初始化的时候给个alpha值,这样在灰图片的时候可以半透明 + + + + + + 使图片单色化 + + + + + + + 自定义 + + + + + 预置 + + + + + 系统 + + + + + 颜色表示法 + + + + + 根据颜色表示字符串获取对应的颜色 + + + + + + + 从文件中获取Image对象 + 这个函数的主要功能是处理一些ico文件 + 一些ico文件的格式可能比较新,直接Image.FormFile,会报内存不足的异常 + + + 是否将文件读入内存操作,如果为false,将直接返回Image.FromFile,在此情况下, + 必须手动释放Image对象,否则文件将一直处于占用状态,如果为true,则在内存中拷贝副本 + + + + + 将图像转为Icon对象,使用png格式 + + + + + + + 将图像转为Icon对象 + + + + + + + + 返回适应指定容器大小的图像 + 如果图像的尺寸(长或宽)超出了容器范围,将按比例获取图像的缩略图返回,否则直接返回图像 + 此方法最终调用 Image.GetThumbnailImage + 但是注意,在指定的容器尺寸过小时,返回的Image尺寸不可知,是在为了显示16x16的小缩略图是发现了此问题 + 使用 GetScaleImage + + + + + + + + + 返回适应指定容器大小的图像 + 在需要的情况下,此方法创建一个新对象,进行绘制 + + + + + + + + + 返回适应指定容器大小的图像 + 在需要的情况下,此方法创建一个新对象,进行绘制 + + + + + + + + + Gets the bounding rectangle of an image required to fit + in to the given rectangle keeping the image aspect ratio. + + The source image. + The rectangle to fit in to. + Horizontal image aligment in percent. + Vertical image aligment in percent. + New image size. + + + + Gets the bounding rectangle of an image required to fit + in to the given rectangle keeping the image aspect ratio. + The image will be centered in the fit box. + + The source image. + The rectangle to fit in to. + New image size. + + + + Gets the scaled size of an image required to fit + in to the given size keeping the image aspect ratio. + + The source image. + The size to fit in to. + New image size. + + + + 获取一个圆角矩形 + + + + 角度 + + + + + 获取一个圆角矩形 + + + + 角度 + + + + + 返回一个表示箭头的Path + 如果开始坐标和结束坐标之间的距离大于箭头的大小,箭头向结束坐标对齐,顶着结束坐标 + + 开始坐标 + 结束坐标(顶点,方向) + 箭头的长短,大小 + 箭头的粗细 + + + + + 在指定的Image上绘制特定标记 + + + + + 文件不存在 + + + + + + 文件不存在 + + + + + + 无法读取文件 + + + + + + 验证失败中显示错误信息时用的标题 + + + + + 验证失败时是否需要高亮显示(改变背景色) + + + + + 验证控件的输入 + + + + + + + 自定义验证方法 + 在基础验证都通过后,才会调用自定义验证方法(如果有) + + + + + 是否支持 Windows Vista 以上的玻璃效果 + + + + + 是否打开了玻璃效果 + + + + + 获取应用程序主窗体 + + + + + 所对应的绑定数据类型 + + + + + 是否对 DataBoundType 的子类型有效 + 默认无效 + 如果设置为 true,又同时添加了基类与子类的 codon,则运行时会取到哪个codon不确定 + 通常取先添加的那个 + + + + + 如果输入的字符串包含 "${...}" 这样的格式,则认为是指代资源文件中的一个字符串资源 + + + + + + + 获取授予该组件的许可证密钥 + + + + + 0:未验证 + 1:验证失败 + 2:验证通过 + + + + + 获取组件的实例或类型的许可证(如果已给定上下文并确定拒绝许可证是否引发异常)。 + + + + + + + + + + 强类型资源类,用于查找本地化字符串等。 + + + + + 返回此类使用的缓存 ResourceManager 实例。 + + + + + 为使用此强类型资源类的所有资源查找 + 重写当前线程的 CurrentUICulture 属性。 + + + + + 查找类似 消息 的本地化字符串。 + + + + + 查找类似 底部 的本地化字符串。 + + + + + 查找类似 顶部 的本地化字符串。 + + + + + 查找类似 更大 (48x48) 的本地化字符串。 + + + + + 查找类似 大 (32x32) 的本地化字符串。 + + + + + 查找类似 中 (24x24) 的本地化字符串。 + + + + + 查找类似 小 (16x16) 的本地化字符串。 + + + + + Returns true if the current language is the default language. + + + + + Returns a System.String that represents the current System.Object. + + + + + 返回此类使用的缓存 ResourceManager 实例。 + + + + + 为使用此强类型资源类的所有资源查找 + 重写当前线程的 CurrentUICulture 属性。 + + + + + 查找类似 消息 的本地化字符串。 + + + + + 查找类似 底部 的本地化字符串。 + + + + + 查找类似 顶部 的本地化字符串。 + + + + + 查找类似 更大 (48x48) 的本地化字符串。 + + + + + 查找类似 大 (32x32) 的本地化字符串。 + + + + + 查找类似 中 (24x24) 的本地化字符串。 + + + + + 查找类似 小 (16x16) 的本地化字符串。 + + + + + Returns true if the current language is the default language. + + + + + Call GetLanguages() to retrieve a list of possible languages that can be used to set this property. + The default value is the default language. + + + + + Gets a list of available languages defined in this assembly. + + + + + 如果输入的字符串包含 "${...}" 这样的格式,则认为是指代资源文件中的一个字符串资源 + + + + + + + Represents a pop-up window. + + + + + Gets the content of the pop-up. + + + + + Determines which animation to use while showing the pop-up window. + + + + + Determines which animation to use while hiding the pop-up window. + + + + + Determines the duration of the animation. + + + + + Gets or sets a value indicating whether the content should receive the focus after the pop-up has been opened. + + true if the content should be focused after the pop-up has been opened; otherwise, false. + If the FocusOnOpen property is set to false, then pop-up cannot use the fade effect. + + + + Gets or sets a value indicating whether presing the alt key should close the pop-up. + + true if presing the alt key does not close the pop-up; otherwise, false. + + + + Gets or sets a value indicating whether the is resizable. + + true if resizable; otherwise, false. + + + + Gets or sets a minimum size of the pop-up. + + An ordered pair of type representing the width and height of a rectangle. + + + + Gets or sets a maximum size of the pop-up. + + An ordered pair of type representing the width and height of a rectangle. + + + + Gets parameters of a new window. + + An object of type used when creating a new window. + + + + Initializes a new instance of the class. + + The content of the pop-up. + + Pop-up will be disposed immediately after disposion of the content control. + + is null. + + + + Raises the event. + + An that contains the event data. + + + + Processes a dialog box key. + + One of the values that represents the key to process. + + true if the key was processed by the control; otherwise, false. + + + + + Updates the pop-up region. + + + + + Shows the pop-up window below the specified control. + + The control below which the pop-up will be shown. + + When there is no space below the specified control, the pop-up control is shown above it. + + is null. + + + + Shows the pop-up window below the specified area of the specified control. + + The control used to compute screen location of specified area. + The area of control below which the pop-up will be shown. + + When there is no space below specified area, the pop-up control is shown above it. + + is null. + + + + Raises the event. + + An that contains the event data. + + + + Raises the event. + + A that contains the event data. + + + + Raises the event. + + An that contains the event data. + + + + Raises the event. + + A that contains the event data. + + + + Processes Windows messages. + + The Windows to process. + + + + Processes the resizing messages. + + The message. + true, if the WndProc method from the base class shouldn't be invoked. + + + + Paints the sizing grip. + + The instance containing the event data. + + + + 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. + + + + + Types of animation of the pop-up window. + + + + + Uses no animation. + + + + + Animates the window from left to right. This flag can be used with roll or slide animation. + + + + + Animates the window from right to left. This flag can be used with roll or slide animation. + + + + + Animates the window from top to bottom. This flag can be used with roll or slide animation. + + + + + Animates the window from bottom to top. This flag can be used with roll or slide animation. + + + + + Makes the window appear to collapse inward if it is hiding or expand outward if the window is showing. + + + + + Uses a slide animation. + + + + + Uses a fade effect. + + + + + Uses a roll animation. + + + + + Uses a default animation. + + + + + Represents a Windows combo box control with a custom popup control attached. + + + + + Initializes a new instance of the class. + + + + + Gets or sets the drop down control. + + The drop down control. + + + + Gets or sets a value indicating whether the combo box is displaying its drop-down portion. + + + true if the drop-down portion is displayed; otherwise, false. The default is false. + + + + + Occurs when the drop-down portion of a is shown. + + + + + Shows the drop down. + + + + + Occurs when the drop-down portion of the is no longer visible. + + + + + Hides the drop down. + + + + + Processes Windows messages. + + The Windows to process. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + + 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. + + + + + Represents a Windows combo box control which can be used in a popup's content control. + + + + + Initializes a new instance of the class. + + + + + Raises the event. + + An that contains the event data. + + + + Raises the event. + + An that contains the event data. + + + + 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. + + + + + 白色到灰色的垂直渐变 + + + + + A ToolstripManager rendering class with advanced control features + + + + + Creates a new EasyRender class for modifications + + + + + Gets the manager to edit and change the appearance of the Toolstrip + + + + + Gets the manager to edit and change the appearance of Toolstrip buttons + + + + + Gets the manager to edit and change the appearance of other Toolstrip controls + + + + + Gets the manager to edit and change the appearance of the Panels + + + + + Gets the manager to edit and change the appearance of the Toolstrip split buttons + + + + + Gets the manager to edit and change the appearance of the Status-bar + + + + + Gets or sets whether to smooth the font text on all controls + + + + + Gets or sets the color of the text if the AlterColor is set to true + + + + + Gets or sets whether to override the font-color on all controls + + + + + Creates a GraphicsPath that appreciates an area where things can be drawn + + The rectangular area which will serve as the base + The curve amount of the corners + + + + + Creates a triangle based on the size and bounds sectors + + The area which the triangle is confined to + The size of the triangle + The direction which the triangle is pointing + + + + + Gets a color array based on the state of a normal button + + The button to check the state of + + + + + Gets a color array based on the state of a split-button + + The button to check the state of + + + + + Gets a color array based on the state of a menu-item + + The button to check the state of + + + + + Gets a color array based on the state of a drop-down button + + The button to check the state of + + + + + Gets a blending property for a specified type of Toolstrip item + + The Toolstrip item + The type of item this is + + + + + Fills a specified boundary with color + + The Graphics object to draw onto + The boundaries to draw the color + The brush to fill the color + + + + Fills a specified boundary with a gradient with specified colors + + The Graphics object to draw onto + The boundaries to draw the color + The color of the gradient at the top + The color of the gradient at the bottom + + + + Fills a specified boundary with a gradient with specified colors at a given angle + + The Graphics object to draw onto + The boundaries to draw the color + The color of the gradient at the top + The color of the gradient at the bottom + The angle which the gradient is drawn (null defaults to 90f) + + + + Fills a specified boundary with a gradient with specified colors at a given angle and with blending properties + + The Graphics object to draw onto + The boundaries to draw the color + The color of the gradient at the top + The color of the gradient at the bottom + The angle which the gradient is drawn (null defaults to 90f) + The blending options to draw the gradient + + + + Draws a set path with a defined brush + + The Graphics object to draw onto + The path to draw along + The brush to fill the color + + + + Draws a set path with specified colors + + The Graphics object to draw onto + The path to draw along + The area of span the border gradient covers + The color of the gradient at the top + The color of the gradient at the bottom + + + + Draws a set path with specified colors at a given angle + + The Graphics object to draw onto + The path to draw along + The area of span the border gradient covers + The color of the gradient at the top + The color of the gradient at the bottom + The angle which the gradient is drawn (null defaults to 90f) + + + + Draws a set path with specified colors at a given angle with blending properties + + The Graphics object to draw onto + The path to draw along + The color of the gradient at the top + The color of the gradient at the bottom + The angle which the gradient is drawn (null defaults to 90f) + The blending options to draw the gradient + + + + Draws a Toolstrip button + + The Toolstrip button + The Graphics object to handle + The parent Toolstrip + + + + Draws a Toolstrip button + + The Toolstrip button + The Graphics object to handle + The parent Toolstrip + + + + Draws the Toolstrip background + + The Toolstrip being drawn + The Graphics object to handle + The affected bounds + + + + Draws a Toolstrip split-button + + The Toolstrip split-button + The Graphics object to handle + The parent Toolstrip + + + + Draws the Statusbar background + + The Statusbar being drawn + The Graphics object to handle + The affected bounds + + + + Draws a Menustrip item + + The Menustrip item + The Graphics object to handle + The parent Toolstrip + + + + Covers the button background rendering + + + + + + Applies any and all changes made to the Renderer + + + + + A class designed to be used in the EasyRender master control to customize the look and feel of the base Toolstrip + + + + + Creates a new IToolstrip class for customization + + + + + Creates a new IToolstrip class for customization + + The IToolstrip to import the settings from + + + + Disposes of the IToolstrip class and clears all resources related to it + + + + + Gets or sets the color of the Toolstrip background gradient from the top + + + + + Gets or sets the color of the Toolstrip background gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Toolstrip background + If set to null, the Toolstrip will simply draw the gradient + + + + + Gets or sets the angle which the Toolstrip background will be drawn + + + + + Gets or sets the color of the Toolstrip border gradient from the top + + + + + Gets or sets the color of the Toolstrip border gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Toolstrip border + If set to null, the Toolstrip will simply draw the border + + + + + Gets or sets the angle which the Toolstrip border will be drawn + + + + + Gets or sets the curve of the border of the Toolstrip + + + + + Imports the settings from a previous or pre-defined IToolstrip and applies it to the current + + The IToolstrip to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + Creates a new IToolstripControls class for customization + + + + + Disposes of the IToolstripControls class and clears all resources related to it + + + + + Gets or sets the color of the Toolstrip seperator on the dark side + + + + + Gets or sets the color of the Toolstrip seperator on the light side + + + + + Gets or sets the height of the Toolstrip seperator control + + + + + Gets or sets the color of the grip dots/line at the top + + + + + Gets or sets the color of the grip shadow + + + + + Gets or sets in what mode the grip will be drawn + + + + + Gets or sets the distance, in pixels, between each grip dot + + + + + Gets or sets the size of the dots or lines for the grip + + + + + Imports the settings from a previous or pre-defined IToolstripControls and applies it to the current + + The IToolstripControls to import the settings from + + + + Creates a new IButton class for customization + + + + + Creates a new IButton class for customization + + The IButton to import the settings from + + + + Disposes of the IButton class and clears all resources related to it + + + + + Gets or sets the color of the Button background at the top, when hovered over + + + + + Gets or sets the color of the Button background at the bottom, when hovered over + + + + + Gets or sets the color of the Button background at the top, when clicked + + + + + Gets or sets the color of the Button background at the bottom, when clicked + + + + + Gets or sets the blending that will occur when rendering the Button background + If set to null, the Button will simply draw the gradient + + + + + Gets or sets the angle which the Button background will be drawn + + + + + Gets or sets the color of the Button border gradient from the top + + + + + Gets or sets the color of the Button border gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Button border + If set to null, the Button will simply draw the border + + + + + Gets or sets the angle which the Button border will be drawn + + + + + Gets or sets the color of the inside border + + + + + Gets or sets when to apply the rendering ("Normal" does not apply here) + + + + + Gets or sets the curve of the border of the Button + + + + + Imports the settings from a previous or pre-defined IButton and applies it to the current + + The IButton to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + Creates a new IButton class for customization + + + + + Creates a new IButton class for customization + + The IButton to import the settings from + + + + Disposes of the IButton class and clears all resources related to it + + + + + Gets or sets the color of the Button background at the top, when hovered over + + + + + Gets or sets the color of the Button background at the bottom, when hovered over + + + + + Gets or sets the blending that will occur when rendering the Button background + If set to null, the Button will simply draw the gradient + + + + + Gets or sets the angle which the Button background will be drawn + + + + + Gets or sets the color of the Button border gradient from the top + + + + + Gets or sets the color of the Button border gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Button border + If set to null, the Button will simply draw the border + + + + + Gets or sets the angle which the Button border will be drawn + + + + + Gets or sets the color of the inside border + + + + + Gets or sets when to apply the rendering ("Normal" and "Click" do not apply here) + + + + + Gets or sets the curve of the border of the Button + + + + + Imports the settings from a previous or pre-defined IDropDownButton and applies it to the current + + The IDropDownButton to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + Creates a new ISplitButton class for customization + + + + + Disposes of the ISplitButton class and clears all resources related to it + + + + + Gets or sets the color of the Button background at the top, when hovered over + + + + + Gets or sets the color of the Button background at the bottom, when hovered over + + + + + Gets or sets the color of the Button background at the top, when clicked + + + + + Gets or sets the color of the Button background at the bottom, when clicked + + + + + Gets or sets the blending that will occur when rendering the Button background + If set to null, the Button will simply draw the gradient + + + + + Gets or sets the angle which the Button background will be drawn + + + + + Gets or sets the color of the Button border gradient from the top + + + + + Gets or sets the color of the Button border gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Button border + If set to null, the Button will simply draw the border + + + + + Gets or sets the angle which the Button border will be drawn + + + + + Gets or sets the color of the inside border + + + + + Gets or sets when to apply the rendering ("Normal" does not apply here) + + + + + Gets or sets the curve of the border of the Button + + + + + Gets or sets when to display the drop-down arrow + + + + + Gets or sets the color of the drop-down arrow + + + + + Imports the settings from a previous or pre-defined ISplitButton and applies it to the current + + The ISplitButton to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + Creates a new IPanel class for customization + + + + + Disposes of the IButton class and clears all resources related to it + + + + + Gets or sets the color of the gradient at the top of the content panel + + + + + Gets or sets the color of the gradient at the bottom of the content panel + + + + + Gets or sets whether each panel inherits the shading from the content panel + + + + + Gets or sets the angle which the background gradient is drawn + + + + + Gets or sets the blend of the background + + + + + Gets or sets a mode to render the background in + + + + + Creates a new IStatusBar class for customization + + + + + Disposes of the IButton class and clears all resources related to it + + + + + Gets or sets the color of the gradient of the background at the top + + + + + Gets or sets the color of the gradient of the background at the bottom + + + + + Gets or sets the blending that will apply to the background + + + + + Gets or sets the angle which the background gradient will be drawn + + + + + Gets or sets the color of the dark border + + + + + Gets or sets the color of the light border + + + + + Gets or sets the color of the grip at the top-most + + + + + Gets or sets the color of the grip at the bottom-most + + + + + Gets or sets the spacing of the grip blocks + + + + + Imports the settings from a previous or pre-defined IStatusBar and applies it to the current + + The IStatusBar to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + A class designed to be used in the EasyRender master control to customize the look and feel of the base Menustrip + + + + + Creates a new IToolstrip class for customization + + + + + Creates a new IMenustrip class for customization + + The IMenustrip to import the settings from + + + + Disposes of the IMenustrip class and clears all resources related to it + + + + + Gets or sets the color of the menu-strip border (dark) + + + + + Gets or sets the color of the menu-strip border (light) + + + + + Gets or sets how the background of the menu-strip is inherited + + + + + If inheritence is set to none, the color of the background gradient at the top + + + + + If inheritence is set to none, the color of the background gradient at the bottom + + + + + If inheritence is set to none, the blending option for the background + + + + + Gets or sets the color of the margin gradient at the left + + + + + Gets or sets the color of the margin gradient at the right + + + + + Gets or sets the color of the margin border (displayed to the right) + + + + + Gets or sets the color of the root menu-strip button background when it is selected + + + + + Gets or sets the color of the root menu-strip button border when it is selected + + + + + Gets or sets the color of the seperator dark color + + + + + Gets or sets the color of the seperator light color + + + + + Gets or sets the inset position of the seperator from the left + + + + + Gets the class that handles the look and feel of the menu-strip items + + + + + Imports the settings from a previous or pre-defined IMenustrip and applies it to the current + + The IMenustrip to import the settings from + + + + Sets the blending for the background to it's default + + + + + Defines when to show an arrow + + + + + Defines when to use a blend property + + + + + Use the blend when the object is drawn + + + + + Use the blend when the object is hovered over + + + + + Use the blend when the object is clicked + + + + + Use the blend when the object is checked + + + + + Always use the blend regardless of the state of the object + + + + + Defines a method of drawing a grip on a control + + + + + Draws the grip as a set of dots + + + + + Draws the grip as two lines + + + + + Does not draw the grip at all, but the object remains moveable + + + + + Defines a specific type of button to search by + + + + + Defines a method for background or object inheritence + + + + + Defines a method of rendering + + + + + 主菜单 + + + + + 背景透明的工具条 + + + + + 银白色至白色渐变 + + + + + 白色至银白色渐变 + + + + + 当前工作区窗体所关联并激活的工具栏 + + + + + 模拟运行时的外观 + + + + + Represents the visual state of an image list view item. + + + + + 没有任何选择状态,处于一般正常状态 + + + + + 项处于选中状态 + + + + + 鼠标滑过 + + + + + 边框宽度 + + + + + 文本和description文本之间的间距 + + + + + 最大显示的项数 + + + + + 是否显示说明字段,此属性不影响弹出面板是否显示 + 弹出面板是否显示由DescriptionMember是否设置决定 + + + + + 下拉列表的布局模式 + + + + + 是否允许空 + + + + + 测量当前控件应该的高度 + + + + + + 整个可用的绘图表面 + + + + + 右边按钮的绘图表面 + + + + + 绘制边框 + + + + + + 绘制背景 + + + + + + 绘制文本 + + + + + + 当前热点项生改变 + + + + + 通过外能事件获取用于绘制项的文本 + + + + + 标题 + + + + + 验证失败时是否需要高亮显示(改变背景色) + + + + + 排序箭头开始颜色 + + + + + 排序箭头开始颜色 + + + + + 控件的背景画布颜色 + 因为控件的边框和过度色都有依靠改变透明度实现渐变,所以一个白色的底版就非常重要 + 使过度色不受控件本身背景色的影响,光不绘制背景不行,要刷上白色背景 + + + + + 控件背景色 + + + + + 边框颜色 + + + + + Represents the visual state of an image list view item. + + + + + 没有任何选择状态,处于一般正常状态 + + + + + 项处于选中状态 + + + + + 该项具有输入焦点 + + + + + 鼠标滑过 + + + + + The item is not visible. + + + + + The item is partially visible. + + + + + The item is fully visible. + + + + + 布局方式 + + + + + 标准布局 + + + + + 使项带有描述的布局 + + + + + 双击项事件参数 + + + + + 项被删除事件参数 + + + + + 为项绘制带有描述信息的渲染器 + + + + + 字的高度是否已初始化 + 在第一次绘制时,测量文本的高度 + + + + + 框选的最短开始长度 + + + + + 框选时滚动条的自动滚动速度 + + + + + 用于鼠标框选时,框出了控件中项的显示范围时,自动滚动滚动条 + + + + + 自动滚动时,滚动值 + + + + + 是否处于框选状态中 + + + + + 内框offset,内框offset是绝对相对于滚动条的 + + + + + 整个可显示项的边界的offset,包括上下padding部分 + + + + + 鼠标按下时项区域边界的offset,即 _itemsAreaOffset + 用于框选时,跨越可视部队画框 + + + + + 当前所能显示的最大行数 + + + + + Gets whether the shift key is down. + + + + + Gets whether the control key is down. + + + + + 没有任何项 + + + + + 没有任何项处于可显示状态 + + + + + 整个控件区域 + + + + + 整个可用于绘制项的可视区域 + 去除左右Padding部分,去除滚动条 + + + + + 用于绘制项的区域 + 考虑边距间隔大小和滚动条区域 + + + + + 项的尺寸 + 不放在ListView本身中定义而是放在LayoutManager中定义,是因为不同的布局方式 + 可能会是带长宽的Size做为itemSize,比如平铺的方式 + + + + + 项周围的边距 + + + + + 更新整个布局引擎的状态 + + + + + 判断指定的项是否处于可见状态 + + + + + + + 获取项的呈现区域 + + + + + + + 获取当前所有可见项 + + + + + + Calculates the maximum number of rows and columns + that can be fully displayed. + + + + + 计算当前可见项的index范围 + + + + + 更新滚动条状态 + + + + + 创建框选框 + + + + + + 根据矩形区域选择项 + + + + + + 应用导航键,如上下左右,返回应用导航键之后的项的坐标 + + + + + 使指定下标的项处于可见状态 + + + + + + 默认渲染器,不绘制项的实际内容,但是绘制DEBUG信息 + + + + + 用于子类重写时删除相应的缓存 + + + + + + 绘制项的背景 + + The System.Drawing.Graphics to draw on. + The client coordinates of the item area. + + + + 绘制最终的前景 + + + + + + + 绘制选择边框 + + The System.Drawing.Graphics to draw on. + The client coordinates of the selection rectangle. + + + + 绘制项的边框 + + + + + + + 绘制项 + + + + + + + + + 绘制项的背景 + + + + + + + 绘制项的内容 + + + + + + + + 绘制背景 + + + + + + 绘制当前所有可见项 + + + + + + Renders the selection rectangle. + + The graphics to draw on. + + + + 默认渲染器,以类似微软ListView的方式按行绘制项,只绘制简单的文本 + + + + + 字的高度是否已初始化 + 在第一次绘制时,测量文本的高度 + + + + + 项的背景色 + + + + + 控件背景色 + + + + + 项的边框色 + + + + + 选择框颜色 + + + + + 选择框的边框色 + + + + + 当控件具有焦点时选定项的背景色 + + + + + 控件失去焦点时选定项的背景色 + + + + + 热点项的背景色 + + + + + 图像内边框颜色 + + + + + 图像外边框颜色 + + + + + Creates a control with a border. + + + + + Specifies that the control has a border with a sunken edge. + + + + + 是否需要在调用 ResumeLayout 时重绘 + + + + + 为项扩展的用于呈现的属性 + + + + + Gets whether the shift key is down. + + + + + Gets whether the control key is down. + + + + + 鼠标左键是否处于按下状态 + + + + + 鼠标右键是否处于按下状态 + + + + + 鼠标最后点击的位置 + + + + + 当前鼠标经过的项 + + + + + 配色方案 + + + + + 当前布局中项的高度 + + + + + 是否没有任何项 + + + + + 获取当前具有输入焦点的项 + + + + + 默认的用于呈现为项中文本的Property + + + + + 更改了选择的项 + + + + + 双击项 + + + + + + 请求在下次调用 ResumeLayout 时重绘 + + + + + 获取当前选中的所有项 + + + + + + 设置扩展属性供特定LayoutEngine使用 + 如果指定的 ExtendMember 已存在,覆盖之 + 用String.Empty 或 null 做为 propertyName传入,表示删除指定的 member + + + + + + + 恢复正常的布局逻辑。 + + + + + 临时挂起控件的布局逻辑。 + + + + + 获取当前选中项所绑定的对象 + 如果没有选中项,返回null,如果选中多项,返回选中项集合中的第一个 + + + + + + 根据指定的绑定项对象 + 设置当前列表中选定的项 + + + + + + 获取当前选中的所有项的绑定对象集合 + 如果当前没有选中任何项,返回空集合 + + + + + + 取消所有项的选择 + + + + + 获取创建控件句柄时所需要的创建参数 + + + + + 更改了选择的项 + + + + + 双击项 + + + + + 项被删除 + + + + + 通过外能事件获取用于绘制项的文本 + + + + + Represents the color palette of the image list view. + + + + + Gets or sets the background color of the ImageListView control. + + + + + Gets or sets the background color of the ImageListViewItem. + + + + + Gets or sets the background color of alternating cells in Details View. + + + + + Gets or sets the border color of the ImageListViewItem. + + + + + Gets or sets the foreground color of the ImageListViewItem. + + + + + Gets or sets the background gradient color1 of the ImageListViewItem if the control is not focused. + + + + + Gets or sets the background gradient color2 of the ImageListViewItem if the control is not focused. + + + + + Gets or sets the border color of the ImageListViewItem if the control is not focused. + + + + + Gets or sets the fore color of the ImageListViewItem if the control is not focused. + + + + + Gets or sets the background gradient color1 if the ImageListViewItem is hovered. + + + + + Gets or sets the background gradient color2 if the ImageListViewItem is hovered. + + + + + Gets or sets the border color of the ImageListViewItem if the item is hovered. + + + + + Gets or sets the color of the insertion caret. + + + + + Gets or sets the background gradient color1 if the ImageListViewItem is selected. + + + + + Gets or sets the background gradient color2 if the ImageListViewItem is selected. + + + + + Gets or sets the border color of the ImageListViewItem if the item is selected. + + + + + Gets or sets the fore color of the ImageListViewItem if the item is selected. + + + + + Gets or sets the background gradient color1 of the column header. + + + + + Gets or sets the background gradient color2 of the column header. + + + + + Gets or sets the background hover gradient color1 of the column header. + + + + + Gets or sets the background hover gradient color2 of the column header. + + + + + Gets or sets the cells foreground color of the column header text. + + + + + Gets or sets the cells background color if column is selected in Details View. + + + + + Gets or sets the color of the separator in Details View. + + + + + Gets or sets the foreground color of the cell text in Details View. + + + + + Gets or sets the foreground color of alternating cells text in Details View. + + + + + Gets or sets the background color of the image pane. + + + + + Gets or sets the separator line color between image pane and thumbnail view. + + + + + Gets or sets the color of labels in pane view. + + + + + Gets or sets the image inner border color for thumbnails and pane. + + + + + Gets or sets the image outer border color for thumbnails and pane. + + + + + Gets or sets the background color1 of the selection rectangle. + + + + + Gets or sets the background color2 of the selection rectangle. + + + + + Gets or sets the color of the selection rectangle border. + + + + + Initializes a new instance of the ImageListViewColor class. + + + + + Initializes a new instance of the ImageListViewColor class + from its string representation. + + String representation of the object. + + + + Copies color values from the given object. + + The source object. + + + + Represents the default color theme. + + + + + Represents the noir color theme. + + + + + Represents the mandarin color theme. + + + + + Sets the color palette to default colors. + + + + + Sets the color palette to mandarin colors. + + + + + Sets the color palette to noir colors. + + + + + Determines whether all color values of the specified + ImageListViewColor are equal to this instance. + + The object to compare with this instance. + true if the two instances have the same color values; + otherwise false. + + + + Returns a hash code for this instance. + + + A hash code for this instance, suitable for use in + hashing algorithms and data structures like a hash table. + + + + + Returns a string that represents this instance. + + + A string that represents this instance. + + + + + 测试坐标 + + + + + 项的坐标 + + + + + 是否点击了项 + + + + + 该项当前的选中状态 + + + + + 所绑定的对象 + + + + + 将指定的事件移动到(紧邻)另一个事件之前 + + + + + + + 将指定的事件移动到(紧邻)另一个事件之后 + + + + + + + 通过窗口的标题来查找窗口的句柄 + + + + + + + + 发送 Windows 消息 + + + + + + + + + + 发送消息,只能传递一个自定义的消息ID和消息字符串,想传一个结构,但没成功 + + 目标进程名称,如果有多个,则给每个都发送 + 自定义数据,可以通过这个来决定如何解析下面的strMsg + 传递的消息,是一个字符串 + + + + 接收消息,得到消息字符串 + + System.Windows.Forms.Message m + 接收到的消息字符串 + + + + 最大圆角半径 + + + + + 最小矩形边长,用于自动处理圆角大小 + + + + + 绘制一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 矩形左上角X坐标 + 矩形左上角Y坐标 + 矩形右下角X坐标 + 矩形右下角Y坐标 + 圆角的半径长度 + + + + 绘制一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 要绘制的矩形对象 + 圆角的半径长度 + + + + 绘制一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 要绘制的矩形对象 + + + + 填充一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 矩形左上角X坐标 + 矩形左上角Y坐标 + 矩形右下角X坐标 + 矩形右下角Y坐标 + 圆角的半径长度 + + + + 填充一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 要填充的矩形 + 填充区域针对矩形的缩进距离 + 圆角的半径长度 + + + + 填充一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 要填充的矩形 + + + + 使图片单色化 + + + + 获取颜色 diff --git a/Bin/Debug/CommonControls/.NET4/ryUpdate.dll b/Bin/Debug/CommonControls/.NET4/ryUpdate.dll index ac81536..26700de 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 ea2b1fa..2c68059 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 3923da8..76c08a5 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 a1e4242..ca851d0 100644 --- a/Bin/Release/CommonControls/.NET4 示例/MyDb.xml +++ b/Bin/Release/CommonControls/.NET4 示例/MyDb.xml @@ -982,6 +982,16 @@ + + + 支持忽略大小写的替换功能 + + + + + 是否忽略大小写 + + 获取匹配的内容 @@ -1065,6 +1075,16 @@ 是否是通配符表达式,不是,则普通替换,忽略大小写,是,则启用通配符替换 + + + 支持忽略大小写的替换文本功能 + + + + + 是否忽略大小写 + + 获取符合要求的第一个结果 diff --git a/Bin/Release/CommonControls/.NET4 示例/MyDb_SQLite.dll b/Bin/Release/CommonControls/.NET4 示例/MyDb_SQLite.dll index ebcd6e2..0469281 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 5d19da3..c954a9a 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 083dba2..01a363b 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 示例/RyWeb.xml b/Bin/Release/CommonControls/.NET4 示例/RyWeb.xml index 36dfc4a..0f17d55 100644 --- a/Bin/Release/CommonControls/.NET4 示例/RyWeb.xml +++ b/Bin/Release/CommonControls/.NET4 示例/RyWeb.xml @@ -472,6 +472,11 @@ + + + + + diff --git a/Bin/Release/CommonControls/.NET4 示例/ryControls.dll b/Bin/Release/CommonControls/.NET4 示例/ryControls.dll index 3f08c52..c476fc0 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 01e3c20..cea5fe2 100644 --- a/Bin/Release/CommonControls/.NET4 示例/ryControls.xml +++ b/Bin/Release/CommonControls/.NET4 示例/ryControls.xml @@ -26898,6 +26898,2798 @@ The index of the matched row, or -1 + + + 初始化的时候给个alpha值,这样在灰图片的时候可以半透明 + + + + + + 使图片单色化 + + + + + + + 自定义 + + + + + 预置 + + + + + 系统 + + + + + 颜色表示法 + + + + + 根据颜色表示字符串获取对应的颜色 + + + + + + + 从文件中获取Image对象 + 这个函数的主要功能是处理一些ico文件 + 一些ico文件的格式可能比较新,直接Image.FormFile,会报内存不足的异常 + + + 是否将文件读入内存操作,如果为false,将直接返回Image.FromFile,在此情况下, + 必须手动释放Image对象,否则文件将一直处于占用状态,如果为true,则在内存中拷贝副本 + + + + + 将图像转为Icon对象,使用png格式 + + + + + + + 将图像转为Icon对象 + + + + + + + + 返回适应指定容器大小的图像 + 如果图像的尺寸(长或宽)超出了容器范围,将按比例获取图像的缩略图返回,否则直接返回图像 + 此方法最终调用 Image.GetThumbnailImage + 但是注意,在指定的容器尺寸过小时,返回的Image尺寸不可知,是在为了显示16x16的小缩略图是发现了此问题 + 使用 GetScaleImage + + + + + + + + + 返回适应指定容器大小的图像 + 在需要的情况下,此方法创建一个新对象,进行绘制 + + + + + + + + + 返回适应指定容器大小的图像 + 在需要的情况下,此方法创建一个新对象,进行绘制 + + + + + + + + + Gets the bounding rectangle of an image required to fit + in to the given rectangle keeping the image aspect ratio. + + The source image. + The rectangle to fit in to. + Horizontal image aligment in percent. + Vertical image aligment in percent. + New image size. + + + + Gets the bounding rectangle of an image required to fit + in to the given rectangle keeping the image aspect ratio. + The image will be centered in the fit box. + + The source image. + The rectangle to fit in to. + New image size. + + + + Gets the scaled size of an image required to fit + in to the given size keeping the image aspect ratio. + + The source image. + The size to fit in to. + New image size. + + + + 获取一个圆角矩形 + + + + 角度 + + + + + 获取一个圆角矩形 + + + + 角度 + + + + + 返回一个表示箭头的Path + 如果开始坐标和结束坐标之间的距离大于箭头的大小,箭头向结束坐标对齐,顶着结束坐标 + + 开始坐标 + 结束坐标(顶点,方向) + 箭头的长短,大小 + 箭头的粗细 + + + + + 在指定的Image上绘制特定标记 + + + + + 文件不存在 + + + + + + 文件不存在 + + + + + + 无法读取文件 + + + + + + 验证失败中显示错误信息时用的标题 + + + + + 验证失败时是否需要高亮显示(改变背景色) + + + + + 验证控件的输入 + + + + + + + 自定义验证方法 + 在基础验证都通过后,才会调用自定义验证方法(如果有) + + + + + 是否支持 Windows Vista 以上的玻璃效果 + + + + + 是否打开了玻璃效果 + + + + + 获取应用程序主窗体 + + + + + 所对应的绑定数据类型 + + + + + 是否对 DataBoundType 的子类型有效 + 默认无效 + 如果设置为 true,又同时添加了基类与子类的 codon,则运行时会取到哪个codon不确定 + 通常取先添加的那个 + + + + + 如果输入的字符串包含 "${...}" 这样的格式,则认为是指代资源文件中的一个字符串资源 + + + + + + + 获取授予该组件的许可证密钥 + + + + + 0:未验证 + 1:验证失败 + 2:验证通过 + + + + + 获取组件的实例或类型的许可证(如果已给定上下文并确定拒绝许可证是否引发异常)。 + + + + + + + + + + 强类型资源类,用于查找本地化字符串等。 + + + + + 返回此类使用的缓存 ResourceManager 实例。 + + + + + 为使用此强类型资源类的所有资源查找 + 重写当前线程的 CurrentUICulture 属性。 + + + + + 查找类似 消息 的本地化字符串。 + + + + + 查找类似 底部 的本地化字符串。 + + + + + 查找类似 顶部 的本地化字符串。 + + + + + 查找类似 更大 (48x48) 的本地化字符串。 + + + + + 查找类似 大 (32x32) 的本地化字符串。 + + + + + 查找类似 中 (24x24) 的本地化字符串。 + + + + + 查找类似 小 (16x16) 的本地化字符串。 + + + + + Returns true if the current language is the default language. + + + + + Returns a System.String that represents the current System.Object. + + + + + 返回此类使用的缓存 ResourceManager 实例。 + + + + + 为使用此强类型资源类的所有资源查找 + 重写当前线程的 CurrentUICulture 属性。 + + + + + 查找类似 消息 的本地化字符串。 + + + + + 查找类似 底部 的本地化字符串。 + + + + + 查找类似 顶部 的本地化字符串。 + + + + + 查找类似 更大 (48x48) 的本地化字符串。 + + + + + 查找类似 大 (32x32) 的本地化字符串。 + + + + + 查找类似 中 (24x24) 的本地化字符串。 + + + + + 查找类似 小 (16x16) 的本地化字符串。 + + + + + Returns true if the current language is the default language. + + + + + Call GetLanguages() to retrieve a list of possible languages that can be used to set this property. + The default value is the default language. + + + + + Gets a list of available languages defined in this assembly. + + + + + 如果输入的字符串包含 "${...}" 这样的格式,则认为是指代资源文件中的一个字符串资源 + + + + + + + Represents a pop-up window. + + + + + Gets the content of the pop-up. + + + + + Determines which animation to use while showing the pop-up window. + + + + + Determines which animation to use while hiding the pop-up window. + + + + + Determines the duration of the animation. + + + + + Gets or sets a value indicating whether the content should receive the focus after the pop-up has been opened. + + true if the content should be focused after the pop-up has been opened; otherwise, false. + If the FocusOnOpen property is set to false, then pop-up cannot use the fade effect. + + + + Gets or sets a value indicating whether presing the alt key should close the pop-up. + + true if presing the alt key does not close the pop-up; otherwise, false. + + + + Gets or sets a value indicating whether the is resizable. + + true if resizable; otherwise, false. + + + + Gets or sets a minimum size of the pop-up. + + An ordered pair of type representing the width and height of a rectangle. + + + + Gets or sets a maximum size of the pop-up. + + An ordered pair of type representing the width and height of a rectangle. + + + + Gets parameters of a new window. + + An object of type used when creating a new window. + + + + Initializes a new instance of the class. + + The content of the pop-up. + + Pop-up will be disposed immediately after disposion of the content control. + + is null. + + + + Raises the event. + + An that contains the event data. + + + + Processes a dialog box key. + + One of the values that represents the key to process. + + true if the key was processed by the control; otherwise, false. + + + + + Updates the pop-up region. + + + + + Shows the pop-up window below the specified control. + + The control below which the pop-up will be shown. + + When there is no space below the specified control, the pop-up control is shown above it. + + is null. + + + + Shows the pop-up window below the specified area of the specified control. + + The control used to compute screen location of specified area. + The area of control below which the pop-up will be shown. + + When there is no space below specified area, the pop-up control is shown above it. + + is null. + + + + Raises the event. + + An that contains the event data. + + + + Raises the event. + + A that contains the event data. + + + + Raises the event. + + An that contains the event data. + + + + Raises the event. + + A that contains the event data. + + + + Processes Windows messages. + + The Windows to process. + + + + Processes the resizing messages. + + The message. + true, if the WndProc method from the base class shouldn't be invoked. + + + + Paints the sizing grip. + + The instance containing the event data. + + + + 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. + + + + + Types of animation of the pop-up window. + + + + + Uses no animation. + + + + + Animates the window from left to right. This flag can be used with roll or slide animation. + + + + + Animates the window from right to left. This flag can be used with roll or slide animation. + + + + + Animates the window from top to bottom. This flag can be used with roll or slide animation. + + + + + Animates the window from bottom to top. This flag can be used with roll or slide animation. + + + + + Makes the window appear to collapse inward if it is hiding or expand outward if the window is showing. + + + + + Uses a slide animation. + + + + + Uses a fade effect. + + + + + Uses a roll animation. + + + + + Uses a default animation. + + + + + Represents a Windows combo box control with a custom popup control attached. + + + + + Initializes a new instance of the class. + + + + + Gets or sets the drop down control. + + The drop down control. + + + + Gets or sets a value indicating whether the combo box is displaying its drop-down portion. + + + true if the drop-down portion is displayed; otherwise, false. The default is false. + + + + + Occurs when the drop-down portion of a is shown. + + + + + Shows the drop down. + + + + + Occurs when the drop-down portion of the is no longer visible. + + + + + Hides the drop down. + + + + + Processes Windows messages. + + The Windows to process. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + + 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. + + + + + Represents a Windows combo box control which can be used in a popup's content control. + + + + + Initializes a new instance of the class. + + + + + Raises the event. + + An that contains the event data. + + + + Raises the event. + + An that contains the event data. + + + + 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. + + + + + 白色到灰色的垂直渐变 + + + + + A ToolstripManager rendering class with advanced control features + + + + + Creates a new EasyRender class for modifications + + + + + Gets the manager to edit and change the appearance of the Toolstrip + + + + + Gets the manager to edit and change the appearance of Toolstrip buttons + + + + + Gets the manager to edit and change the appearance of other Toolstrip controls + + + + + Gets the manager to edit and change the appearance of the Panels + + + + + Gets the manager to edit and change the appearance of the Toolstrip split buttons + + + + + Gets the manager to edit and change the appearance of the Status-bar + + + + + Gets or sets whether to smooth the font text on all controls + + + + + Gets or sets the color of the text if the AlterColor is set to true + + + + + Gets or sets whether to override the font-color on all controls + + + + + Creates a GraphicsPath that appreciates an area where things can be drawn + + The rectangular area which will serve as the base + The curve amount of the corners + + + + + Creates a triangle based on the size and bounds sectors + + The area which the triangle is confined to + The size of the triangle + The direction which the triangle is pointing + + + + + Gets a color array based on the state of a normal button + + The button to check the state of + + + + + Gets a color array based on the state of a split-button + + The button to check the state of + + + + + Gets a color array based on the state of a menu-item + + The button to check the state of + + + + + Gets a color array based on the state of a drop-down button + + The button to check the state of + + + + + Gets a blending property for a specified type of Toolstrip item + + The Toolstrip item + The type of item this is + + + + + Fills a specified boundary with color + + The Graphics object to draw onto + The boundaries to draw the color + The brush to fill the color + + + + Fills a specified boundary with a gradient with specified colors + + The Graphics object to draw onto + The boundaries to draw the color + The color of the gradient at the top + The color of the gradient at the bottom + + + + Fills a specified boundary with a gradient with specified colors at a given angle + + The Graphics object to draw onto + The boundaries to draw the color + The color of the gradient at the top + The color of the gradient at the bottom + The angle which the gradient is drawn (null defaults to 90f) + + + + Fills a specified boundary with a gradient with specified colors at a given angle and with blending properties + + The Graphics object to draw onto + The boundaries to draw the color + The color of the gradient at the top + The color of the gradient at the bottom + The angle which the gradient is drawn (null defaults to 90f) + The blending options to draw the gradient + + + + Draws a set path with a defined brush + + The Graphics object to draw onto + The path to draw along + The brush to fill the color + + + + Draws a set path with specified colors + + The Graphics object to draw onto + The path to draw along + The area of span the border gradient covers + The color of the gradient at the top + The color of the gradient at the bottom + + + + Draws a set path with specified colors at a given angle + + The Graphics object to draw onto + The path to draw along + The area of span the border gradient covers + The color of the gradient at the top + The color of the gradient at the bottom + The angle which the gradient is drawn (null defaults to 90f) + + + + Draws a set path with specified colors at a given angle with blending properties + + The Graphics object to draw onto + The path to draw along + The color of the gradient at the top + The color of the gradient at the bottom + The angle which the gradient is drawn (null defaults to 90f) + The blending options to draw the gradient + + + + Draws a Toolstrip button + + The Toolstrip button + The Graphics object to handle + The parent Toolstrip + + + + Draws a Toolstrip button + + The Toolstrip button + The Graphics object to handle + The parent Toolstrip + + + + Draws the Toolstrip background + + The Toolstrip being drawn + The Graphics object to handle + The affected bounds + + + + Draws a Toolstrip split-button + + The Toolstrip split-button + The Graphics object to handle + The parent Toolstrip + + + + Draws the Statusbar background + + The Statusbar being drawn + The Graphics object to handle + The affected bounds + + + + Draws a Menustrip item + + The Menustrip item + The Graphics object to handle + The parent Toolstrip + + + + Covers the button background rendering + + + + + + Applies any and all changes made to the Renderer + + + + + A class designed to be used in the EasyRender master control to customize the look and feel of the base Toolstrip + + + + + Creates a new IToolstrip class for customization + + + + + Creates a new IToolstrip class for customization + + The IToolstrip to import the settings from + + + + Disposes of the IToolstrip class and clears all resources related to it + + + + + Gets or sets the color of the Toolstrip background gradient from the top + + + + + Gets or sets the color of the Toolstrip background gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Toolstrip background + If set to null, the Toolstrip will simply draw the gradient + + + + + Gets or sets the angle which the Toolstrip background will be drawn + + + + + Gets or sets the color of the Toolstrip border gradient from the top + + + + + Gets or sets the color of the Toolstrip border gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Toolstrip border + If set to null, the Toolstrip will simply draw the border + + + + + Gets or sets the angle which the Toolstrip border will be drawn + + + + + Gets or sets the curve of the border of the Toolstrip + + + + + Imports the settings from a previous or pre-defined IToolstrip and applies it to the current + + The IToolstrip to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + Creates a new IToolstripControls class for customization + + + + + Disposes of the IToolstripControls class and clears all resources related to it + + + + + Gets or sets the color of the Toolstrip seperator on the dark side + + + + + Gets or sets the color of the Toolstrip seperator on the light side + + + + + Gets or sets the height of the Toolstrip seperator control + + + + + Gets or sets the color of the grip dots/line at the top + + + + + Gets or sets the color of the grip shadow + + + + + Gets or sets in what mode the grip will be drawn + + + + + Gets or sets the distance, in pixels, between each grip dot + + + + + Gets or sets the size of the dots or lines for the grip + + + + + Imports the settings from a previous or pre-defined IToolstripControls and applies it to the current + + The IToolstripControls to import the settings from + + + + Creates a new IButton class for customization + + + + + Creates a new IButton class for customization + + The IButton to import the settings from + + + + Disposes of the IButton class and clears all resources related to it + + + + + Gets or sets the color of the Button background at the top, when hovered over + + + + + Gets or sets the color of the Button background at the bottom, when hovered over + + + + + Gets or sets the color of the Button background at the top, when clicked + + + + + Gets or sets the color of the Button background at the bottom, when clicked + + + + + Gets or sets the blending that will occur when rendering the Button background + If set to null, the Button will simply draw the gradient + + + + + Gets or sets the angle which the Button background will be drawn + + + + + Gets or sets the color of the Button border gradient from the top + + + + + Gets or sets the color of the Button border gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Button border + If set to null, the Button will simply draw the border + + + + + Gets or sets the angle which the Button border will be drawn + + + + + Gets or sets the color of the inside border + + + + + Gets or sets when to apply the rendering ("Normal" does not apply here) + + + + + Gets or sets the curve of the border of the Button + + + + + Imports the settings from a previous or pre-defined IButton and applies it to the current + + The IButton to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + Creates a new IButton class for customization + + + + + Creates a new IButton class for customization + + The IButton to import the settings from + + + + Disposes of the IButton class and clears all resources related to it + + + + + Gets or sets the color of the Button background at the top, when hovered over + + + + + Gets or sets the color of the Button background at the bottom, when hovered over + + + + + Gets or sets the blending that will occur when rendering the Button background + If set to null, the Button will simply draw the gradient + + + + + Gets or sets the angle which the Button background will be drawn + + + + + Gets or sets the color of the Button border gradient from the top + + + + + Gets or sets the color of the Button border gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Button border + If set to null, the Button will simply draw the border + + + + + Gets or sets the angle which the Button border will be drawn + + + + + Gets or sets the color of the inside border + + + + + Gets or sets when to apply the rendering ("Normal" and "Click" do not apply here) + + + + + Gets or sets the curve of the border of the Button + + + + + Imports the settings from a previous or pre-defined IDropDownButton and applies it to the current + + The IDropDownButton to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + Creates a new ISplitButton class for customization + + + + + Disposes of the ISplitButton class and clears all resources related to it + + + + + Gets or sets the color of the Button background at the top, when hovered over + + + + + Gets or sets the color of the Button background at the bottom, when hovered over + + + + + Gets or sets the color of the Button background at the top, when clicked + + + + + Gets or sets the color of the Button background at the bottom, when clicked + + + + + Gets or sets the blending that will occur when rendering the Button background + If set to null, the Button will simply draw the gradient + + + + + Gets or sets the angle which the Button background will be drawn + + + + + Gets or sets the color of the Button border gradient from the top + + + + + Gets or sets the color of the Button border gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Button border + If set to null, the Button will simply draw the border + + + + + Gets or sets the angle which the Button border will be drawn + + + + + Gets or sets the color of the inside border + + + + + Gets or sets when to apply the rendering ("Normal" does not apply here) + + + + + Gets or sets the curve of the border of the Button + + + + + Gets or sets when to display the drop-down arrow + + + + + Gets or sets the color of the drop-down arrow + + + + + Imports the settings from a previous or pre-defined ISplitButton and applies it to the current + + The ISplitButton to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + Creates a new IPanel class for customization + + + + + Disposes of the IButton class and clears all resources related to it + + + + + Gets or sets the color of the gradient at the top of the content panel + + + + + Gets or sets the color of the gradient at the bottom of the content panel + + + + + Gets or sets whether each panel inherits the shading from the content panel + + + + + Gets or sets the angle which the background gradient is drawn + + + + + Gets or sets the blend of the background + + + + + Gets or sets a mode to render the background in + + + + + Creates a new IStatusBar class for customization + + + + + Disposes of the IButton class and clears all resources related to it + + + + + Gets or sets the color of the gradient of the background at the top + + + + + Gets or sets the color of the gradient of the background at the bottom + + + + + Gets or sets the blending that will apply to the background + + + + + Gets or sets the angle which the background gradient will be drawn + + + + + Gets or sets the color of the dark border + + + + + Gets or sets the color of the light border + + + + + Gets or sets the color of the grip at the top-most + + + + + Gets or sets the color of the grip at the bottom-most + + + + + Gets or sets the spacing of the grip blocks + + + + + Imports the settings from a previous or pre-defined IStatusBar and applies it to the current + + The IStatusBar to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + A class designed to be used in the EasyRender master control to customize the look and feel of the base Menustrip + + + + + Creates a new IToolstrip class for customization + + + + + Creates a new IMenustrip class for customization + + The IMenustrip to import the settings from + + + + Disposes of the IMenustrip class and clears all resources related to it + + + + + Gets or sets the color of the menu-strip border (dark) + + + + + Gets or sets the color of the menu-strip border (light) + + + + + Gets or sets how the background of the menu-strip is inherited + + + + + If inheritence is set to none, the color of the background gradient at the top + + + + + If inheritence is set to none, the color of the background gradient at the bottom + + + + + If inheritence is set to none, the blending option for the background + + + + + Gets or sets the color of the margin gradient at the left + + + + + Gets or sets the color of the margin gradient at the right + + + + + Gets or sets the color of the margin border (displayed to the right) + + + + + Gets or sets the color of the root menu-strip button background when it is selected + + + + + Gets or sets the color of the root menu-strip button border when it is selected + + + + + Gets or sets the color of the seperator dark color + + + + + Gets or sets the color of the seperator light color + + + + + Gets or sets the inset position of the seperator from the left + + + + + Gets the class that handles the look and feel of the menu-strip items + + + + + Imports the settings from a previous or pre-defined IMenustrip and applies it to the current + + The IMenustrip to import the settings from + + + + Sets the blending for the background to it's default + + + + + Defines when to show an arrow + + + + + Defines when to use a blend property + + + + + Use the blend when the object is drawn + + + + + Use the blend when the object is hovered over + + + + + Use the blend when the object is clicked + + + + + Use the blend when the object is checked + + + + + Always use the blend regardless of the state of the object + + + + + Defines a method of drawing a grip on a control + + + + + Draws the grip as a set of dots + + + + + Draws the grip as two lines + + + + + Does not draw the grip at all, but the object remains moveable + + + + + Defines a specific type of button to search by + + + + + Defines a method for background or object inheritence + + + + + Defines a method of rendering + + + + + 主菜单 + + + + + 背景透明的工具条 + + + + + 银白色至白色渐变 + + + + + 白色至银白色渐变 + + + + + 当前工作区窗体所关联并激活的工具栏 + + + + + 模拟运行时的外观 + + + + + Represents the visual state of an image list view item. + + + + + 没有任何选择状态,处于一般正常状态 + + + + + 项处于选中状态 + + + + + 鼠标滑过 + + + + + 边框宽度 + + + + + 文本和description文本之间的间距 + + + + + 最大显示的项数 + + + + + 是否显示说明字段,此属性不影响弹出面板是否显示 + 弹出面板是否显示由DescriptionMember是否设置决定 + + + + + 下拉列表的布局模式 + + + + + 是否允许空 + + + + + 测量当前控件应该的高度 + + + + + + 整个可用的绘图表面 + + + + + 右边按钮的绘图表面 + + + + + 绘制边框 + + + + + + 绘制背景 + + + + + + 绘制文本 + + + + + + 当前热点项生改变 + + + + + 通过外能事件获取用于绘制项的文本 + + + + + 标题 + + + + + 验证失败时是否需要高亮显示(改变背景色) + + + + + 排序箭头开始颜色 + + + + + 排序箭头开始颜色 + + + + + 控件的背景画布颜色 + 因为控件的边框和过度色都有依靠改变透明度实现渐变,所以一个白色的底版就非常重要 + 使过度色不受控件本身背景色的影响,光不绘制背景不行,要刷上白色背景 + + + + + 控件背景色 + + + + + 边框颜色 + + + + + Represents the visual state of an image list view item. + + + + + 没有任何选择状态,处于一般正常状态 + + + + + 项处于选中状态 + + + + + 该项具有输入焦点 + + + + + 鼠标滑过 + + + + + The item is not visible. + + + + + The item is partially visible. + + + + + The item is fully visible. + + + + + 布局方式 + + + + + 标准布局 + + + + + 使项带有描述的布局 + + + + + 双击项事件参数 + + + + + 项被删除事件参数 + + + + + 为项绘制带有描述信息的渲染器 + + + + + 字的高度是否已初始化 + 在第一次绘制时,测量文本的高度 + + + + + 框选的最短开始长度 + + + + + 框选时滚动条的自动滚动速度 + + + + + 用于鼠标框选时,框出了控件中项的显示范围时,自动滚动滚动条 + + + + + 自动滚动时,滚动值 + + + + + 是否处于框选状态中 + + + + + 内框offset,内框offset是绝对相对于滚动条的 + + + + + 整个可显示项的边界的offset,包括上下padding部分 + + + + + 鼠标按下时项区域边界的offset,即 _itemsAreaOffset + 用于框选时,跨越可视部队画框 + + + + + 当前所能显示的最大行数 + + + + + Gets whether the shift key is down. + + + + + Gets whether the control key is down. + + + + + 没有任何项 + + + + + 没有任何项处于可显示状态 + + + + + 整个控件区域 + + + + + 整个可用于绘制项的可视区域 + 去除左右Padding部分,去除滚动条 + + + + + 用于绘制项的区域 + 考虑边距间隔大小和滚动条区域 + + + + + 项的尺寸 + 不放在ListView本身中定义而是放在LayoutManager中定义,是因为不同的布局方式 + 可能会是带长宽的Size做为itemSize,比如平铺的方式 + + + + + 项周围的边距 + + + + + 更新整个布局引擎的状态 + + + + + 判断指定的项是否处于可见状态 + + + + + + + 获取项的呈现区域 + + + + + + + 获取当前所有可见项 + + + + + + Calculates the maximum number of rows and columns + that can be fully displayed. + + + + + 计算当前可见项的index范围 + + + + + 更新滚动条状态 + + + + + 创建框选框 + + + + + + 根据矩形区域选择项 + + + + + + 应用导航键,如上下左右,返回应用导航键之后的项的坐标 + + + + + 使指定下标的项处于可见状态 + + + + + + 默认渲染器,不绘制项的实际内容,但是绘制DEBUG信息 + + + + + 用于子类重写时删除相应的缓存 + + + + + + 绘制项的背景 + + The System.Drawing.Graphics to draw on. + The client coordinates of the item area. + + + + 绘制最终的前景 + + + + + + + 绘制选择边框 + + The System.Drawing.Graphics to draw on. + The client coordinates of the selection rectangle. + + + + 绘制项的边框 + + + + + + + 绘制项 + + + + + + + + + 绘制项的背景 + + + + + + + 绘制项的内容 + + + + + + + + 绘制背景 + + + + + + 绘制当前所有可见项 + + + + + + Renders the selection rectangle. + + The graphics to draw on. + + + + 默认渲染器,以类似微软ListView的方式按行绘制项,只绘制简单的文本 + + + + + 字的高度是否已初始化 + 在第一次绘制时,测量文本的高度 + + + + + 项的背景色 + + + + + 控件背景色 + + + + + 项的边框色 + + + + + 选择框颜色 + + + + + 选择框的边框色 + + + + + 当控件具有焦点时选定项的背景色 + + + + + 控件失去焦点时选定项的背景色 + + + + + 热点项的背景色 + + + + + 图像内边框颜色 + + + + + 图像外边框颜色 + + + + + Creates a control with a border. + + + + + Specifies that the control has a border with a sunken edge. + + + + + 是否需要在调用 ResumeLayout 时重绘 + + + + + 为项扩展的用于呈现的属性 + + + + + Gets whether the shift key is down. + + + + + Gets whether the control key is down. + + + + + 鼠标左键是否处于按下状态 + + + + + 鼠标右键是否处于按下状态 + + + + + 鼠标最后点击的位置 + + + + + 当前鼠标经过的项 + + + + + 配色方案 + + + + + 当前布局中项的高度 + + + + + 是否没有任何项 + + + + + 获取当前具有输入焦点的项 + + + + + 默认的用于呈现为项中文本的Property + + + + + 更改了选择的项 + + + + + 双击项 + + + + + + 请求在下次调用 ResumeLayout 时重绘 + + + + + 获取当前选中的所有项 + + + + + + 设置扩展属性供特定LayoutEngine使用 + 如果指定的 ExtendMember 已存在,覆盖之 + 用String.Empty 或 null 做为 propertyName传入,表示删除指定的 member + + + + + + + 恢复正常的布局逻辑。 + + + + + 临时挂起控件的布局逻辑。 + + + + + 获取当前选中项所绑定的对象 + 如果没有选中项,返回null,如果选中多项,返回选中项集合中的第一个 + + + + + + 根据指定的绑定项对象 + 设置当前列表中选定的项 + + + + + + 获取当前选中的所有项的绑定对象集合 + 如果当前没有选中任何项,返回空集合 + + + + + + 取消所有项的选择 + + + + + 获取创建控件句柄时所需要的创建参数 + + + + + 更改了选择的项 + + + + + 双击项 + + + + + 项被删除 + + + + + 通过外能事件获取用于绘制项的文本 + + + + + Represents the color palette of the image list view. + + + + + Gets or sets the background color of the ImageListView control. + + + + + Gets or sets the background color of the ImageListViewItem. + + + + + Gets or sets the background color of alternating cells in Details View. + + + + + Gets or sets the border color of the ImageListViewItem. + + + + + Gets or sets the foreground color of the ImageListViewItem. + + + + + Gets or sets the background gradient color1 of the ImageListViewItem if the control is not focused. + + + + + Gets or sets the background gradient color2 of the ImageListViewItem if the control is not focused. + + + + + Gets or sets the border color of the ImageListViewItem if the control is not focused. + + + + + Gets or sets the fore color of the ImageListViewItem if the control is not focused. + + + + + Gets or sets the background gradient color1 if the ImageListViewItem is hovered. + + + + + Gets or sets the background gradient color2 if the ImageListViewItem is hovered. + + + + + Gets or sets the border color of the ImageListViewItem if the item is hovered. + + + + + Gets or sets the color of the insertion caret. + + + + + Gets or sets the background gradient color1 if the ImageListViewItem is selected. + + + + + Gets or sets the background gradient color2 if the ImageListViewItem is selected. + + + + + Gets or sets the border color of the ImageListViewItem if the item is selected. + + + + + Gets or sets the fore color of the ImageListViewItem if the item is selected. + + + + + Gets or sets the background gradient color1 of the column header. + + + + + Gets or sets the background gradient color2 of the column header. + + + + + Gets or sets the background hover gradient color1 of the column header. + + + + + Gets or sets the background hover gradient color2 of the column header. + + + + + Gets or sets the cells foreground color of the column header text. + + + + + Gets or sets the cells background color if column is selected in Details View. + + + + + Gets or sets the color of the separator in Details View. + + + + + Gets or sets the foreground color of the cell text in Details View. + + + + + Gets or sets the foreground color of alternating cells text in Details View. + + + + + Gets or sets the background color of the image pane. + + + + + Gets or sets the separator line color between image pane and thumbnail view. + + + + + Gets or sets the color of labels in pane view. + + + + + Gets or sets the image inner border color for thumbnails and pane. + + + + + Gets or sets the image outer border color for thumbnails and pane. + + + + + Gets or sets the background color1 of the selection rectangle. + + + + + Gets or sets the background color2 of the selection rectangle. + + + + + Gets or sets the color of the selection rectangle border. + + + + + Initializes a new instance of the ImageListViewColor class. + + + + + Initializes a new instance of the ImageListViewColor class + from its string representation. + + String representation of the object. + + + + Copies color values from the given object. + + The source object. + + + + Represents the default color theme. + + + + + Represents the noir color theme. + + + + + Represents the mandarin color theme. + + + + + Sets the color palette to default colors. + + + + + Sets the color palette to mandarin colors. + + + + + Sets the color palette to noir colors. + + + + + Determines whether all color values of the specified + ImageListViewColor are equal to this instance. + + The object to compare with this instance. + true if the two instances have the same color values; + otherwise false. + + + + Returns a hash code for this instance. + + + A hash code for this instance, suitable for use in + hashing algorithms and data structures like a hash table. + + + + + Returns a string that represents this instance. + + + A string that represents this instance. + + + + + 测试坐标 + + + + + 项的坐标 + + + + + 是否点击了项 + + + + + 该项当前的选中状态 + + + + + 所绑定的对象 + + + + + 将指定的事件移动到(紧邻)另一个事件之前 + + + + + + + 将指定的事件移动到(紧邻)另一个事件之后 + + + + + + + 通过窗口的标题来查找窗口的句柄 + + + + + + + + 发送 Windows 消息 + + + + + + + + + + 发送消息,只能传递一个自定义的消息ID和消息字符串,想传一个结构,但没成功 + + 目标进程名称,如果有多个,则给每个都发送 + 自定义数据,可以通过这个来决定如何解析下面的strMsg + 传递的消息,是一个字符串 + + + + 接收消息,得到消息字符串 + + System.Windows.Forms.Message m + 接收到的消息字符串 + + + + 最大圆角半径 + + + + + 最小矩形边长,用于自动处理圆角大小 + + + + + 绘制一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 矩形左上角X坐标 + 矩形左上角Y坐标 + 矩形右下角X坐标 + 矩形右下角Y坐标 + 圆角的半径长度 + + + + 绘制一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 要绘制的矩形对象 + 圆角的半径长度 + + + + 绘制一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 要绘制的矩形对象 + + + + 填充一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 矩形左上角X坐标 + 矩形左上角Y坐标 + 矩形右下角X坐标 + 矩形右下角Y坐标 + 圆角的半径长度 + + + + 填充一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 要填充的矩形 + 填充区域针对矩形的缩进距离 + 圆角的半径长度 + + + + 填充一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 要填充的矩形 + + + + 使图片单色化 + + + + 获取颜色 diff --git a/Bin/Release/CommonControls/.NET4 示例/ryUpdate.dll b/Bin/Release/CommonControls/.NET4 示例/ryUpdate.dll index 1fd80bf..48d8f7d 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 3923da8..76c08a5 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 a1e4242..ca851d0 100644 --- a/Bin/Release/CommonControls/.NET4/MyDb.xml +++ b/Bin/Release/CommonControls/.NET4/MyDb.xml @@ -982,6 +982,16 @@ + + + 支持忽略大小写的替换功能 + + + + + 是否忽略大小写 + + 获取匹配的内容 @@ -1065,6 +1075,16 @@ 是否是通配符表达式,不是,则普通替换,忽略大小写,是,则启用通配符替换 + + + 支持忽略大小写的替换文本功能 + + + + + 是否忽略大小写 + + 获取符合要求的第一个结果 diff --git a/Bin/Release/CommonControls/.NET4/MyDb_MSSQL.dll b/Bin/Release/CommonControls/.NET4/MyDb_MSSQL.dll index a83935c..bce5822 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 20841f7..df58c06 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 ebcd6e2..0469281 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 5d19da3..c954a9a 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 18fdbc2..f01c184 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/RyWeb.xml b/Bin/Release/CommonControls/.NET4/RyWeb.xml index 36dfc4a..0f17d55 100644 --- a/Bin/Release/CommonControls/.NET4/RyWeb.xml +++ b/Bin/Release/CommonControls/.NET4/RyWeb.xml @@ -472,6 +472,11 @@ + + + + + diff --git a/Bin/Release/CommonControls/.NET4/ryControls.dll b/Bin/Release/CommonControls/.NET4/ryControls.dll index 3f08c52..c476fc0 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 01e3c20..cea5fe2 100644 --- a/Bin/Release/CommonControls/.NET4/ryControls.xml +++ b/Bin/Release/CommonControls/.NET4/ryControls.xml @@ -26898,6 +26898,2798 @@ The index of the matched row, or -1 + + + 初始化的时候给个alpha值,这样在灰图片的时候可以半透明 + + + + + + 使图片单色化 + + + + + + + 自定义 + + + + + 预置 + + + + + 系统 + + + + + 颜色表示法 + + + + + 根据颜色表示字符串获取对应的颜色 + + + + + + + 从文件中获取Image对象 + 这个函数的主要功能是处理一些ico文件 + 一些ico文件的格式可能比较新,直接Image.FormFile,会报内存不足的异常 + + + 是否将文件读入内存操作,如果为false,将直接返回Image.FromFile,在此情况下, + 必须手动释放Image对象,否则文件将一直处于占用状态,如果为true,则在内存中拷贝副本 + + + + + 将图像转为Icon对象,使用png格式 + + + + + + + 将图像转为Icon对象 + + + + + + + + 返回适应指定容器大小的图像 + 如果图像的尺寸(长或宽)超出了容器范围,将按比例获取图像的缩略图返回,否则直接返回图像 + 此方法最终调用 Image.GetThumbnailImage + 但是注意,在指定的容器尺寸过小时,返回的Image尺寸不可知,是在为了显示16x16的小缩略图是发现了此问题 + 使用 GetScaleImage + + + + + + + + + 返回适应指定容器大小的图像 + 在需要的情况下,此方法创建一个新对象,进行绘制 + + + + + + + + + 返回适应指定容器大小的图像 + 在需要的情况下,此方法创建一个新对象,进行绘制 + + + + + + + + + Gets the bounding rectangle of an image required to fit + in to the given rectangle keeping the image aspect ratio. + + The source image. + The rectangle to fit in to. + Horizontal image aligment in percent. + Vertical image aligment in percent. + New image size. + + + + Gets the bounding rectangle of an image required to fit + in to the given rectangle keeping the image aspect ratio. + The image will be centered in the fit box. + + The source image. + The rectangle to fit in to. + New image size. + + + + Gets the scaled size of an image required to fit + in to the given size keeping the image aspect ratio. + + The source image. + The size to fit in to. + New image size. + + + + 获取一个圆角矩形 + + + + 角度 + + + + + 获取一个圆角矩形 + + + + 角度 + + + + + 返回一个表示箭头的Path + 如果开始坐标和结束坐标之间的距离大于箭头的大小,箭头向结束坐标对齐,顶着结束坐标 + + 开始坐标 + 结束坐标(顶点,方向) + 箭头的长短,大小 + 箭头的粗细 + + + + + 在指定的Image上绘制特定标记 + + + + + 文件不存在 + + + + + + 文件不存在 + + + + + + 无法读取文件 + + + + + + 验证失败中显示错误信息时用的标题 + + + + + 验证失败时是否需要高亮显示(改变背景色) + + + + + 验证控件的输入 + + + + + + + 自定义验证方法 + 在基础验证都通过后,才会调用自定义验证方法(如果有) + + + + + 是否支持 Windows Vista 以上的玻璃效果 + + + + + 是否打开了玻璃效果 + + + + + 获取应用程序主窗体 + + + + + 所对应的绑定数据类型 + + + + + 是否对 DataBoundType 的子类型有效 + 默认无效 + 如果设置为 true,又同时添加了基类与子类的 codon,则运行时会取到哪个codon不确定 + 通常取先添加的那个 + + + + + 如果输入的字符串包含 "${...}" 这样的格式,则认为是指代资源文件中的一个字符串资源 + + + + + + + 获取授予该组件的许可证密钥 + + + + + 0:未验证 + 1:验证失败 + 2:验证通过 + + + + + 获取组件的实例或类型的许可证(如果已给定上下文并确定拒绝许可证是否引发异常)。 + + + + + + + + + + 强类型资源类,用于查找本地化字符串等。 + + + + + 返回此类使用的缓存 ResourceManager 实例。 + + + + + 为使用此强类型资源类的所有资源查找 + 重写当前线程的 CurrentUICulture 属性。 + + + + + 查找类似 消息 的本地化字符串。 + + + + + 查找类似 底部 的本地化字符串。 + + + + + 查找类似 顶部 的本地化字符串。 + + + + + 查找类似 更大 (48x48) 的本地化字符串。 + + + + + 查找类似 大 (32x32) 的本地化字符串。 + + + + + 查找类似 中 (24x24) 的本地化字符串。 + + + + + 查找类似 小 (16x16) 的本地化字符串。 + + + + + Returns true if the current language is the default language. + + + + + Returns a System.String that represents the current System.Object. + + + + + 返回此类使用的缓存 ResourceManager 实例。 + + + + + 为使用此强类型资源类的所有资源查找 + 重写当前线程的 CurrentUICulture 属性。 + + + + + 查找类似 消息 的本地化字符串。 + + + + + 查找类似 底部 的本地化字符串。 + + + + + 查找类似 顶部 的本地化字符串。 + + + + + 查找类似 更大 (48x48) 的本地化字符串。 + + + + + 查找类似 大 (32x32) 的本地化字符串。 + + + + + 查找类似 中 (24x24) 的本地化字符串。 + + + + + 查找类似 小 (16x16) 的本地化字符串。 + + + + + Returns true if the current language is the default language. + + + + + Call GetLanguages() to retrieve a list of possible languages that can be used to set this property. + The default value is the default language. + + + + + Gets a list of available languages defined in this assembly. + + + + + 如果输入的字符串包含 "${...}" 这样的格式,则认为是指代资源文件中的一个字符串资源 + + + + + + + Represents a pop-up window. + + + + + Gets the content of the pop-up. + + + + + Determines which animation to use while showing the pop-up window. + + + + + Determines which animation to use while hiding the pop-up window. + + + + + Determines the duration of the animation. + + + + + Gets or sets a value indicating whether the content should receive the focus after the pop-up has been opened. + + true if the content should be focused after the pop-up has been opened; otherwise, false. + If the FocusOnOpen property is set to false, then pop-up cannot use the fade effect. + + + + Gets or sets a value indicating whether presing the alt key should close the pop-up. + + true if presing the alt key does not close the pop-up; otherwise, false. + + + + Gets or sets a value indicating whether the is resizable. + + true if resizable; otherwise, false. + + + + Gets or sets a minimum size of the pop-up. + + An ordered pair of type representing the width and height of a rectangle. + + + + Gets or sets a maximum size of the pop-up. + + An ordered pair of type representing the width and height of a rectangle. + + + + Gets parameters of a new window. + + An object of type used when creating a new window. + + + + Initializes a new instance of the class. + + The content of the pop-up. + + Pop-up will be disposed immediately after disposion of the content control. + + is null. + + + + Raises the event. + + An that contains the event data. + + + + Processes a dialog box key. + + One of the values that represents the key to process. + + true if the key was processed by the control; otherwise, false. + + + + + Updates the pop-up region. + + + + + Shows the pop-up window below the specified control. + + The control below which the pop-up will be shown. + + When there is no space below the specified control, the pop-up control is shown above it. + + is null. + + + + Shows the pop-up window below the specified area of the specified control. + + The control used to compute screen location of specified area. + The area of control below which the pop-up will be shown. + + When there is no space below specified area, the pop-up control is shown above it. + + is null. + + + + Raises the event. + + An that contains the event data. + + + + Raises the event. + + A that contains the event data. + + + + Raises the event. + + An that contains the event data. + + + + Raises the event. + + A that contains the event data. + + + + Processes Windows messages. + + The Windows to process. + + + + Processes the resizing messages. + + The message. + true, if the WndProc method from the base class shouldn't be invoked. + + + + Paints the sizing grip. + + The instance containing the event data. + + + + 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. + + + + + Types of animation of the pop-up window. + + + + + Uses no animation. + + + + + Animates the window from left to right. This flag can be used with roll or slide animation. + + + + + Animates the window from right to left. This flag can be used with roll or slide animation. + + + + + Animates the window from top to bottom. This flag can be used with roll or slide animation. + + + + + Animates the window from bottom to top. This flag can be used with roll or slide animation. + + + + + Makes the window appear to collapse inward if it is hiding or expand outward if the window is showing. + + + + + Uses a slide animation. + + + + + Uses a fade effect. + + + + + Uses a roll animation. + + + + + Uses a default animation. + + + + + Represents a Windows combo box control with a custom popup control attached. + + + + + Initializes a new instance of the class. + + + + + Gets or sets the drop down control. + + The drop down control. + + + + Gets or sets a value indicating whether the combo box is displaying its drop-down portion. + + + true if the drop-down portion is displayed; otherwise, false. The default is false. + + + + + Occurs when the drop-down portion of a is shown. + + + + + Shows the drop down. + + + + + Occurs when the drop-down portion of the is no longer visible. + + + + + Hides the drop down. + + + + + Processes Windows messages. + + The Windows to process. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + This property is not relevant for this class. + This property is not relevant for this class. + + + + 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. + + + + + Represents a Windows combo box control which can be used in a popup's content control. + + + + + Initializes a new instance of the class. + + + + + Raises the event. + + An that contains the event data. + + + + Raises the event. + + An that contains the event data. + + + + 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. + + + + + 白色到灰色的垂直渐变 + + + + + A ToolstripManager rendering class with advanced control features + + + + + Creates a new EasyRender class for modifications + + + + + Gets the manager to edit and change the appearance of the Toolstrip + + + + + Gets the manager to edit and change the appearance of Toolstrip buttons + + + + + Gets the manager to edit and change the appearance of other Toolstrip controls + + + + + Gets the manager to edit and change the appearance of the Panels + + + + + Gets the manager to edit and change the appearance of the Toolstrip split buttons + + + + + Gets the manager to edit and change the appearance of the Status-bar + + + + + Gets or sets whether to smooth the font text on all controls + + + + + Gets or sets the color of the text if the AlterColor is set to true + + + + + Gets or sets whether to override the font-color on all controls + + + + + Creates a GraphicsPath that appreciates an area where things can be drawn + + The rectangular area which will serve as the base + The curve amount of the corners + + + + + Creates a triangle based on the size and bounds sectors + + The area which the triangle is confined to + The size of the triangle + The direction which the triangle is pointing + + + + + Gets a color array based on the state of a normal button + + The button to check the state of + + + + + Gets a color array based on the state of a split-button + + The button to check the state of + + + + + Gets a color array based on the state of a menu-item + + The button to check the state of + + + + + Gets a color array based on the state of a drop-down button + + The button to check the state of + + + + + Gets a blending property for a specified type of Toolstrip item + + The Toolstrip item + The type of item this is + + + + + Fills a specified boundary with color + + The Graphics object to draw onto + The boundaries to draw the color + The brush to fill the color + + + + Fills a specified boundary with a gradient with specified colors + + The Graphics object to draw onto + The boundaries to draw the color + The color of the gradient at the top + The color of the gradient at the bottom + + + + Fills a specified boundary with a gradient with specified colors at a given angle + + The Graphics object to draw onto + The boundaries to draw the color + The color of the gradient at the top + The color of the gradient at the bottom + The angle which the gradient is drawn (null defaults to 90f) + + + + Fills a specified boundary with a gradient with specified colors at a given angle and with blending properties + + The Graphics object to draw onto + The boundaries to draw the color + The color of the gradient at the top + The color of the gradient at the bottom + The angle which the gradient is drawn (null defaults to 90f) + The blending options to draw the gradient + + + + Draws a set path with a defined brush + + The Graphics object to draw onto + The path to draw along + The brush to fill the color + + + + Draws a set path with specified colors + + The Graphics object to draw onto + The path to draw along + The area of span the border gradient covers + The color of the gradient at the top + The color of the gradient at the bottom + + + + Draws a set path with specified colors at a given angle + + The Graphics object to draw onto + The path to draw along + The area of span the border gradient covers + The color of the gradient at the top + The color of the gradient at the bottom + The angle which the gradient is drawn (null defaults to 90f) + + + + Draws a set path with specified colors at a given angle with blending properties + + The Graphics object to draw onto + The path to draw along + The color of the gradient at the top + The color of the gradient at the bottom + The angle which the gradient is drawn (null defaults to 90f) + The blending options to draw the gradient + + + + Draws a Toolstrip button + + The Toolstrip button + The Graphics object to handle + The parent Toolstrip + + + + Draws a Toolstrip button + + The Toolstrip button + The Graphics object to handle + The parent Toolstrip + + + + Draws the Toolstrip background + + The Toolstrip being drawn + The Graphics object to handle + The affected bounds + + + + Draws a Toolstrip split-button + + The Toolstrip split-button + The Graphics object to handle + The parent Toolstrip + + + + Draws the Statusbar background + + The Statusbar being drawn + The Graphics object to handle + The affected bounds + + + + Draws a Menustrip item + + The Menustrip item + The Graphics object to handle + The parent Toolstrip + + + + Covers the button background rendering + + + + + + Applies any and all changes made to the Renderer + + + + + A class designed to be used in the EasyRender master control to customize the look and feel of the base Toolstrip + + + + + Creates a new IToolstrip class for customization + + + + + Creates a new IToolstrip class for customization + + The IToolstrip to import the settings from + + + + Disposes of the IToolstrip class and clears all resources related to it + + + + + Gets or sets the color of the Toolstrip background gradient from the top + + + + + Gets or sets the color of the Toolstrip background gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Toolstrip background + If set to null, the Toolstrip will simply draw the gradient + + + + + Gets or sets the angle which the Toolstrip background will be drawn + + + + + Gets or sets the color of the Toolstrip border gradient from the top + + + + + Gets or sets the color of the Toolstrip border gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Toolstrip border + If set to null, the Toolstrip will simply draw the border + + + + + Gets or sets the angle which the Toolstrip border will be drawn + + + + + Gets or sets the curve of the border of the Toolstrip + + + + + Imports the settings from a previous or pre-defined IToolstrip and applies it to the current + + The IToolstrip to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + Creates a new IToolstripControls class for customization + + + + + Disposes of the IToolstripControls class and clears all resources related to it + + + + + Gets or sets the color of the Toolstrip seperator on the dark side + + + + + Gets or sets the color of the Toolstrip seperator on the light side + + + + + Gets or sets the height of the Toolstrip seperator control + + + + + Gets or sets the color of the grip dots/line at the top + + + + + Gets or sets the color of the grip shadow + + + + + Gets or sets in what mode the grip will be drawn + + + + + Gets or sets the distance, in pixels, between each grip dot + + + + + Gets or sets the size of the dots or lines for the grip + + + + + Imports the settings from a previous or pre-defined IToolstripControls and applies it to the current + + The IToolstripControls to import the settings from + + + + Creates a new IButton class for customization + + + + + Creates a new IButton class for customization + + The IButton to import the settings from + + + + Disposes of the IButton class and clears all resources related to it + + + + + Gets or sets the color of the Button background at the top, when hovered over + + + + + Gets or sets the color of the Button background at the bottom, when hovered over + + + + + Gets or sets the color of the Button background at the top, when clicked + + + + + Gets or sets the color of the Button background at the bottom, when clicked + + + + + Gets or sets the blending that will occur when rendering the Button background + If set to null, the Button will simply draw the gradient + + + + + Gets or sets the angle which the Button background will be drawn + + + + + Gets or sets the color of the Button border gradient from the top + + + + + Gets or sets the color of the Button border gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Button border + If set to null, the Button will simply draw the border + + + + + Gets or sets the angle which the Button border will be drawn + + + + + Gets or sets the color of the inside border + + + + + Gets or sets when to apply the rendering ("Normal" does not apply here) + + + + + Gets or sets the curve of the border of the Button + + + + + Imports the settings from a previous or pre-defined IButton and applies it to the current + + The IButton to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + Creates a new IButton class for customization + + + + + Creates a new IButton class for customization + + The IButton to import the settings from + + + + Disposes of the IButton class and clears all resources related to it + + + + + Gets or sets the color of the Button background at the top, when hovered over + + + + + Gets or sets the color of the Button background at the bottom, when hovered over + + + + + Gets or sets the blending that will occur when rendering the Button background + If set to null, the Button will simply draw the gradient + + + + + Gets or sets the angle which the Button background will be drawn + + + + + Gets or sets the color of the Button border gradient from the top + + + + + Gets or sets the color of the Button border gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Button border + If set to null, the Button will simply draw the border + + + + + Gets or sets the angle which the Button border will be drawn + + + + + Gets or sets the color of the inside border + + + + + Gets or sets when to apply the rendering ("Normal" and "Click" do not apply here) + + + + + Gets or sets the curve of the border of the Button + + + + + Imports the settings from a previous or pre-defined IDropDownButton and applies it to the current + + The IDropDownButton to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + Creates a new ISplitButton class for customization + + + + + Disposes of the ISplitButton class and clears all resources related to it + + + + + Gets or sets the color of the Button background at the top, when hovered over + + + + + Gets or sets the color of the Button background at the bottom, when hovered over + + + + + Gets or sets the color of the Button background at the top, when clicked + + + + + Gets or sets the color of the Button background at the bottom, when clicked + + + + + Gets or sets the blending that will occur when rendering the Button background + If set to null, the Button will simply draw the gradient + + + + + Gets or sets the angle which the Button background will be drawn + + + + + Gets or sets the color of the Button border gradient from the top + + + + + Gets or sets the color of the Button border gradient from the bottom + + + + + Gets or sets the blending that will occur when rendering the Button border + If set to null, the Button will simply draw the border + + + + + Gets or sets the angle which the Button border will be drawn + + + + + Gets or sets the color of the inside border + + + + + Gets or sets when to apply the rendering ("Normal" does not apply here) + + + + + Gets or sets the curve of the border of the Button + + + + + Gets or sets when to display the drop-down arrow + + + + + Gets or sets the color of the drop-down arrow + + + + + Imports the settings from a previous or pre-defined ISplitButton and applies it to the current + + The ISplitButton to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + Creates a new IPanel class for customization + + + + + Disposes of the IButton class and clears all resources related to it + + + + + Gets or sets the color of the gradient at the top of the content panel + + + + + Gets or sets the color of the gradient at the bottom of the content panel + + + + + Gets or sets whether each panel inherits the shading from the content panel + + + + + Gets or sets the angle which the background gradient is drawn + + + + + Gets or sets the blend of the background + + + + + Gets or sets a mode to render the background in + + + + + Creates a new IStatusBar class for customization + + + + + Disposes of the IButton class and clears all resources related to it + + + + + Gets or sets the color of the gradient of the background at the top + + + + + Gets or sets the color of the gradient of the background at the bottom + + + + + Gets or sets the blending that will apply to the background + + + + + Gets or sets the angle which the background gradient will be drawn + + + + + Gets or sets the color of the dark border + + + + + Gets or sets the color of the light border + + + + + Gets or sets the color of the grip at the top-most + + + + + Gets or sets the color of the grip at the bottom-most + + + + + Gets or sets the spacing of the grip blocks + + + + + Imports the settings from a previous or pre-defined IStatusBar and applies it to the current + + The IStatusBar to import the settings from + + + + Sets the blending for both border and background to their defaults + + + + + A class designed to be used in the EasyRender master control to customize the look and feel of the base Menustrip + + + + + Creates a new IToolstrip class for customization + + + + + Creates a new IMenustrip class for customization + + The IMenustrip to import the settings from + + + + Disposes of the IMenustrip class and clears all resources related to it + + + + + Gets or sets the color of the menu-strip border (dark) + + + + + Gets or sets the color of the menu-strip border (light) + + + + + Gets or sets how the background of the menu-strip is inherited + + + + + If inheritence is set to none, the color of the background gradient at the top + + + + + If inheritence is set to none, the color of the background gradient at the bottom + + + + + If inheritence is set to none, the blending option for the background + + + + + Gets or sets the color of the margin gradient at the left + + + + + Gets or sets the color of the margin gradient at the right + + + + + Gets or sets the color of the margin border (displayed to the right) + + + + + Gets or sets the color of the root menu-strip button background when it is selected + + + + + Gets or sets the color of the root menu-strip button border when it is selected + + + + + Gets or sets the color of the seperator dark color + + + + + Gets or sets the color of the seperator light color + + + + + Gets or sets the inset position of the seperator from the left + + + + + Gets the class that handles the look and feel of the menu-strip items + + + + + Imports the settings from a previous or pre-defined IMenustrip and applies it to the current + + The IMenustrip to import the settings from + + + + Sets the blending for the background to it's default + + + + + Defines when to show an arrow + + + + + Defines when to use a blend property + + + + + Use the blend when the object is drawn + + + + + Use the blend when the object is hovered over + + + + + Use the blend when the object is clicked + + + + + Use the blend when the object is checked + + + + + Always use the blend regardless of the state of the object + + + + + Defines a method of drawing a grip on a control + + + + + Draws the grip as a set of dots + + + + + Draws the grip as two lines + + + + + Does not draw the grip at all, but the object remains moveable + + + + + Defines a specific type of button to search by + + + + + Defines a method for background or object inheritence + + + + + Defines a method of rendering + + + + + 主菜单 + + + + + 背景透明的工具条 + + + + + 银白色至白色渐变 + + + + + 白色至银白色渐变 + + + + + 当前工作区窗体所关联并激活的工具栏 + + + + + 模拟运行时的外观 + + + + + Represents the visual state of an image list view item. + + + + + 没有任何选择状态,处于一般正常状态 + + + + + 项处于选中状态 + + + + + 鼠标滑过 + + + + + 边框宽度 + + + + + 文本和description文本之间的间距 + + + + + 最大显示的项数 + + + + + 是否显示说明字段,此属性不影响弹出面板是否显示 + 弹出面板是否显示由DescriptionMember是否设置决定 + + + + + 下拉列表的布局模式 + + + + + 是否允许空 + + + + + 测量当前控件应该的高度 + + + + + + 整个可用的绘图表面 + + + + + 右边按钮的绘图表面 + + + + + 绘制边框 + + + + + + 绘制背景 + + + + + + 绘制文本 + + + + + + 当前热点项生改变 + + + + + 通过外能事件获取用于绘制项的文本 + + + + + 标题 + + + + + 验证失败时是否需要高亮显示(改变背景色) + + + + + 排序箭头开始颜色 + + + + + 排序箭头开始颜色 + + + + + 控件的背景画布颜色 + 因为控件的边框和过度色都有依靠改变透明度实现渐变,所以一个白色的底版就非常重要 + 使过度色不受控件本身背景色的影响,光不绘制背景不行,要刷上白色背景 + + + + + 控件背景色 + + + + + 边框颜色 + + + + + Represents the visual state of an image list view item. + + + + + 没有任何选择状态,处于一般正常状态 + + + + + 项处于选中状态 + + + + + 该项具有输入焦点 + + + + + 鼠标滑过 + + + + + The item is not visible. + + + + + The item is partially visible. + + + + + The item is fully visible. + + + + + 布局方式 + + + + + 标准布局 + + + + + 使项带有描述的布局 + + + + + 双击项事件参数 + + + + + 项被删除事件参数 + + + + + 为项绘制带有描述信息的渲染器 + + + + + 字的高度是否已初始化 + 在第一次绘制时,测量文本的高度 + + + + + 框选的最短开始长度 + + + + + 框选时滚动条的自动滚动速度 + + + + + 用于鼠标框选时,框出了控件中项的显示范围时,自动滚动滚动条 + + + + + 自动滚动时,滚动值 + + + + + 是否处于框选状态中 + + + + + 内框offset,内框offset是绝对相对于滚动条的 + + + + + 整个可显示项的边界的offset,包括上下padding部分 + + + + + 鼠标按下时项区域边界的offset,即 _itemsAreaOffset + 用于框选时,跨越可视部队画框 + + + + + 当前所能显示的最大行数 + + + + + Gets whether the shift key is down. + + + + + Gets whether the control key is down. + + + + + 没有任何项 + + + + + 没有任何项处于可显示状态 + + + + + 整个控件区域 + + + + + 整个可用于绘制项的可视区域 + 去除左右Padding部分,去除滚动条 + + + + + 用于绘制项的区域 + 考虑边距间隔大小和滚动条区域 + + + + + 项的尺寸 + 不放在ListView本身中定义而是放在LayoutManager中定义,是因为不同的布局方式 + 可能会是带长宽的Size做为itemSize,比如平铺的方式 + + + + + 项周围的边距 + + + + + 更新整个布局引擎的状态 + + + + + 判断指定的项是否处于可见状态 + + + + + + + 获取项的呈现区域 + + + + + + + 获取当前所有可见项 + + + + + + Calculates the maximum number of rows and columns + that can be fully displayed. + + + + + 计算当前可见项的index范围 + + + + + 更新滚动条状态 + + + + + 创建框选框 + + + + + + 根据矩形区域选择项 + + + + + + 应用导航键,如上下左右,返回应用导航键之后的项的坐标 + + + + + 使指定下标的项处于可见状态 + + + + + + 默认渲染器,不绘制项的实际内容,但是绘制DEBUG信息 + + + + + 用于子类重写时删除相应的缓存 + + + + + + 绘制项的背景 + + The System.Drawing.Graphics to draw on. + The client coordinates of the item area. + + + + 绘制最终的前景 + + + + + + + 绘制选择边框 + + The System.Drawing.Graphics to draw on. + The client coordinates of the selection rectangle. + + + + 绘制项的边框 + + + + + + + 绘制项 + + + + + + + + + 绘制项的背景 + + + + + + + 绘制项的内容 + + + + + + + + 绘制背景 + + + + + + 绘制当前所有可见项 + + + + + + Renders the selection rectangle. + + The graphics to draw on. + + + + 默认渲染器,以类似微软ListView的方式按行绘制项,只绘制简单的文本 + + + + + 字的高度是否已初始化 + 在第一次绘制时,测量文本的高度 + + + + + 项的背景色 + + + + + 控件背景色 + + + + + 项的边框色 + + + + + 选择框颜色 + + + + + 选择框的边框色 + + + + + 当控件具有焦点时选定项的背景色 + + + + + 控件失去焦点时选定项的背景色 + + + + + 热点项的背景色 + + + + + 图像内边框颜色 + + + + + 图像外边框颜色 + + + + + Creates a control with a border. + + + + + Specifies that the control has a border with a sunken edge. + + + + + 是否需要在调用 ResumeLayout 时重绘 + + + + + 为项扩展的用于呈现的属性 + + + + + Gets whether the shift key is down. + + + + + Gets whether the control key is down. + + + + + 鼠标左键是否处于按下状态 + + + + + 鼠标右键是否处于按下状态 + + + + + 鼠标最后点击的位置 + + + + + 当前鼠标经过的项 + + + + + 配色方案 + + + + + 当前布局中项的高度 + + + + + 是否没有任何项 + + + + + 获取当前具有输入焦点的项 + + + + + 默认的用于呈现为项中文本的Property + + + + + 更改了选择的项 + + + + + 双击项 + + + + + + 请求在下次调用 ResumeLayout 时重绘 + + + + + 获取当前选中的所有项 + + + + + + 设置扩展属性供特定LayoutEngine使用 + 如果指定的 ExtendMember 已存在,覆盖之 + 用String.Empty 或 null 做为 propertyName传入,表示删除指定的 member + + + + + + + 恢复正常的布局逻辑。 + + + + + 临时挂起控件的布局逻辑。 + + + + + 获取当前选中项所绑定的对象 + 如果没有选中项,返回null,如果选中多项,返回选中项集合中的第一个 + + + + + + 根据指定的绑定项对象 + 设置当前列表中选定的项 + + + + + + 获取当前选中的所有项的绑定对象集合 + 如果当前没有选中任何项,返回空集合 + + + + + + 取消所有项的选择 + + + + + 获取创建控件句柄时所需要的创建参数 + + + + + 更改了选择的项 + + + + + 双击项 + + + + + 项被删除 + + + + + 通过外能事件获取用于绘制项的文本 + + + + + Represents the color palette of the image list view. + + + + + Gets or sets the background color of the ImageListView control. + + + + + Gets or sets the background color of the ImageListViewItem. + + + + + Gets or sets the background color of alternating cells in Details View. + + + + + Gets or sets the border color of the ImageListViewItem. + + + + + Gets or sets the foreground color of the ImageListViewItem. + + + + + Gets or sets the background gradient color1 of the ImageListViewItem if the control is not focused. + + + + + Gets or sets the background gradient color2 of the ImageListViewItem if the control is not focused. + + + + + Gets or sets the border color of the ImageListViewItem if the control is not focused. + + + + + Gets or sets the fore color of the ImageListViewItem if the control is not focused. + + + + + Gets or sets the background gradient color1 if the ImageListViewItem is hovered. + + + + + Gets or sets the background gradient color2 if the ImageListViewItem is hovered. + + + + + Gets or sets the border color of the ImageListViewItem if the item is hovered. + + + + + Gets or sets the color of the insertion caret. + + + + + Gets or sets the background gradient color1 if the ImageListViewItem is selected. + + + + + Gets or sets the background gradient color2 if the ImageListViewItem is selected. + + + + + Gets or sets the border color of the ImageListViewItem if the item is selected. + + + + + Gets or sets the fore color of the ImageListViewItem if the item is selected. + + + + + Gets or sets the background gradient color1 of the column header. + + + + + Gets or sets the background gradient color2 of the column header. + + + + + Gets or sets the background hover gradient color1 of the column header. + + + + + Gets or sets the background hover gradient color2 of the column header. + + + + + Gets or sets the cells foreground color of the column header text. + + + + + Gets or sets the cells background color if column is selected in Details View. + + + + + Gets or sets the color of the separator in Details View. + + + + + Gets or sets the foreground color of the cell text in Details View. + + + + + Gets or sets the foreground color of alternating cells text in Details View. + + + + + Gets or sets the background color of the image pane. + + + + + Gets or sets the separator line color between image pane and thumbnail view. + + + + + Gets or sets the color of labels in pane view. + + + + + Gets or sets the image inner border color for thumbnails and pane. + + + + + Gets or sets the image outer border color for thumbnails and pane. + + + + + Gets or sets the background color1 of the selection rectangle. + + + + + Gets or sets the background color2 of the selection rectangle. + + + + + Gets or sets the color of the selection rectangle border. + + + + + Initializes a new instance of the ImageListViewColor class. + + + + + Initializes a new instance of the ImageListViewColor class + from its string representation. + + String representation of the object. + + + + Copies color values from the given object. + + The source object. + + + + Represents the default color theme. + + + + + Represents the noir color theme. + + + + + Represents the mandarin color theme. + + + + + Sets the color palette to default colors. + + + + + Sets the color palette to mandarin colors. + + + + + Sets the color palette to noir colors. + + + + + Determines whether all color values of the specified + ImageListViewColor are equal to this instance. + + The object to compare with this instance. + true if the two instances have the same color values; + otherwise false. + + + + Returns a hash code for this instance. + + + A hash code for this instance, suitable for use in + hashing algorithms and data structures like a hash table. + + + + + Returns a string that represents this instance. + + + A string that represents this instance. + + + + + 测试坐标 + + + + + 项的坐标 + + + + + 是否点击了项 + + + + + 该项当前的选中状态 + + + + + 所绑定的对象 + + + + + 将指定的事件移动到(紧邻)另一个事件之前 + + + + + + + 将指定的事件移动到(紧邻)另一个事件之后 + + + + + + + 通过窗口的标题来查找窗口的句柄 + + + + + + + + 发送 Windows 消息 + + + + + + + + + + 发送消息,只能传递一个自定义的消息ID和消息字符串,想传一个结构,但没成功 + + 目标进程名称,如果有多个,则给每个都发送 + 自定义数据,可以通过这个来决定如何解析下面的strMsg + 传递的消息,是一个字符串 + + + + 接收消息,得到消息字符串 + + System.Windows.Forms.Message m + 接收到的消息字符串 + + + + 最大圆角半径 + + + + + 最小矩形边长,用于自动处理圆角大小 + + + + + 绘制一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 矩形左上角X坐标 + 矩形左上角Y坐标 + 矩形右下角X坐标 + 矩形右下角Y坐标 + 圆角的半径长度 + + + + 绘制一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 要绘制的矩形对象 + 圆角的半径长度 + + + + 绘制一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 要绘制的矩形对象 + + + + 填充一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 矩形左上角X坐标 + 矩形左上角Y坐标 + 矩形右下角X坐标 + 矩形右下角Y坐标 + 圆角的半径长度 + + + + 填充一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 要填充的矩形 + 填充区域针对矩形的缩进距离 + 圆角的半径长度 + + + + 填充一个圆角矩形. + + 当前屏幕的图形对象 + 矩形线条的颜色 + 要填充的矩形 + + + + 使图片单色化 + + + + 获取颜色 diff --git a/Bin/Release/CommonControls/.NET4/ryUpdate.dll b/Bin/Release/CommonControls/.NET4/ryUpdate.dll index 1fd80bf..48d8f7d 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 2eea413..bb3b874 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,17 @@ -### 2021-06-13更新 +### 2021-07-01更新 +------ +#### ryControlsV4 V3.0.2107.0101 +- *.[新增]新增Sheng.Winform.Controls部分控件。 + +#### RyWeb V3.0.2107.0101 + +- *.[新增]QuickWeb新增引用页设置。 + +#### MyDbV4 V3.0.2107.0101 + +- *.[新增]支持忽略大小写的替换功能。 + +### 2021-06-13更新 ------ #### ryControls V2.1.2106.1301 @@ -17,6 +30,10 @@ #### ryControls V2.1.2104.0201 - *.[修复]修复在win7上Gdu.WinformUI会报错的BUG。 + ryControls V2.1.2104.0201 + + - *.[修复]修复在win7上Gdu.WinformUI会报错的BUG。 + ### 2021-03-13更新 ------ #### ryControls V2.1.2103.1301 diff --git a/Source/.vs/公用控件组V4/v16/.suo b/Source/.vs/公用控件组V4/v16/.suo index 53c9aac..e578c09 100644 Binary files a/Source/.vs/公用控件组V4/v16/.suo and b/Source/.vs/公用控件组V4/v16/.suo differ diff --git a/Source/Itrycn_Project/DbOp/FrmAdd.Designer.cs b/Source/Itrycn_Project/DbOp/FrmAdd.Designer.cs index a156e7b..bbfd661 100644 --- a/Source/Itrycn_Project/DbOp/FrmAdd.Designer.cs +++ b/Source/Itrycn_Project/DbOp/FrmAdd.Designer.cs @@ -1,4 +1,4 @@ -namespace Itrycn_Project.DbOp +namespace Itrycn_Project2.DbOp { partial class FrmAdd { diff --git a/Source/Itrycn_Project/DbOp/FrmAdd.cs b/Source/Itrycn_Project/DbOp/FrmAdd.cs index a4e826a..440cb10 100644 --- a/Source/Itrycn_Project/DbOp/FrmAdd.cs +++ b/Source/Itrycn_Project/DbOp/FrmAdd.cs @@ -9,7 +9,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; -namespace Itrycn_Project.DbOp +namespace Itrycn_Project2.DbOp { public partial class FrmAdd : Form { diff --git a/Source/Itrycn_Project/DbOp/FrmView.cs b/Source/Itrycn_Project/DbOp/FrmView.cs index 12574b0..cab3958 100644 --- a/Source/Itrycn_Project/DbOp/FrmView.cs +++ b/Source/Itrycn_Project/DbOp/FrmView.cs @@ -9,7 +9,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; -namespace Itrycn_Project.DbOp +namespace Itrycn_Project2.DbOp { public partial class FrmView : Form { diff --git a/Source/Itrycn_Project/DbOp/frmView.Designer.cs b/Source/Itrycn_Project/DbOp/frmView.Designer.cs index 8b7a667..9bfa3b9 100644 --- a/Source/Itrycn_Project/DbOp/frmView.Designer.cs +++ b/Source/Itrycn_Project/DbOp/frmView.Designer.cs @@ -1,4 +1,4 @@ -namespace Itrycn_Project.DbOp +namespace Itrycn_Project2.DbOp { partial class FrmView { diff --git a/Source/Itrycn_Project/FrmAbout.Designer.cs b/Source/Itrycn_Project/FrmAbout.Designer.cs index dd7b683..3fdaf39 100644 --- a/Source/Itrycn_Project/FrmAbout.Designer.cs +++ b/Source/Itrycn_Project/FrmAbout.Designer.cs @@ -1,4 +1,4 @@ -namespace Itrycn_Project +namespace Itrycn_Project2 { partial class FrmAbout { diff --git a/Source/Itrycn_Project/FrmAbout.cs b/Source/Itrycn_Project/FrmAbout.cs index 99f3d42..9b9ac1a 100644 --- a/Source/Itrycn_Project/FrmAbout.cs +++ b/Source/Itrycn_Project/FrmAbout.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; -namespace Itrycn_Project +namespace Itrycn_Project2 { public partial class FrmAbout : Form { diff --git a/Source/Itrycn_Project/Itrycn_Info.cs b/Source/Itrycn_Project/Itrycn_Info.cs index 067ebb1..12a8014 100644 --- a/Source/Itrycn_Project/Itrycn_Info.cs +++ b/Source/Itrycn_Project/Itrycn_Info.cs @@ -7,7 +7,7 @@ using System.Text; using System.Windows.Forms; using static ryCommonDb.DataProvider; -namespace Itrycn_Project +namespace Itrycn_Project2 { /// /// 配置类(本系统基于乘黄V1架构) diff --git a/Source/Itrycn_Project/Program.cs b/Source/Itrycn_Project/Program.cs index 519882f..b1cb198 100644 --- a/Source/Itrycn_Project/Program.cs +++ b/Source/Itrycn_Project/Program.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Forms; -namespace Itrycn_Project +namespace Itrycn_Project2 { static class Program { diff --git a/Source/Itrycn_Project/Properties/Resources.Designer.cs b/Source/Itrycn_Project/Properties/Resources.Designer.cs index 0487e9e..287b148 100644 --- a/Source/Itrycn_Project/Properties/Resources.Designer.cs +++ b/Source/Itrycn_Project/Properties/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Itrycn_Project.Properties { +namespace Itrycn_Project2.Properties { using System; diff --git a/Source/Itrycn_Project/Properties/Settings.Designer.cs b/Source/Itrycn_Project/Properties/Settings.Designer.cs index 87b3b8d..3e3d9ad 100644 --- a/Source/Itrycn_Project/Properties/Settings.Designer.cs +++ b/Source/Itrycn_Project/Properties/Settings.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Itrycn_Project.Properties +namespace Itrycn_Project2.Properties { diff --git a/Source/Itrycn_Project/RegSoft/frmLogin.cs b/Source/Itrycn_Project/RegSoft/frmLogin.cs index 990ca69..31301d0 100644 --- a/Source/Itrycn_Project/RegSoft/frmLogin.cs +++ b/Source/Itrycn_Project/RegSoft/frmLogin.cs @@ -1,4 +1,4 @@ -using Itrycn_Project; +using Itrycn_Project2; using ryCommon; using RyHardWare; using System; diff --git a/Source/Itrycn_Project/frmSetting.Designer.cs b/Source/Itrycn_Project/frmSetting.Designer.cs index f50684c..c04b33b 100644 --- a/Source/Itrycn_Project/frmSetting.Designer.cs +++ b/Source/Itrycn_Project/frmSetting.Designer.cs @@ -1,4 +1,4 @@ -namespace Itrycn_Project +namespace Itrycn_Project2 { partial class FrmSetting { diff --git a/Source/Itrycn_Project/frmSetting.cs b/Source/Itrycn_Project/frmSetting.cs index db4cdf0..83b1426 100644 --- a/Source/Itrycn_Project/frmSetting.cs +++ b/Source/Itrycn_Project/frmSetting.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; -namespace Itrycn_Project +namespace Itrycn_Project2 { public partial class FrmSetting : Form { diff --git a/Source/Itrycn_Project/frmmain.Designer.cs b/Source/Itrycn_Project/frmmain.Designer.cs index 6e04166..17215d5 100644 --- a/Source/Itrycn_Project/frmmain.Designer.cs +++ b/Source/Itrycn_Project/frmmain.Designer.cs @@ -113,7 +113,7 @@ // picExpand // this.picExpand.Cursor = System.Windows.Forms.Cursors.Hand; - this.picExpand.Image = global::Itrycn_Project.Properties.Resources.closetree; + this.picExpand.Image = global::Itrycn_Project2.Properties.Resources.closetree; this.picExpand.Location = new System.Drawing.Point(187, 247); this.picExpand.Name = "picExpand"; this.picExpand.Size = new System.Drawing.Size(10, 49); diff --git a/Source/Itrycn_Project/frmmain.cs b/Source/Itrycn_Project/frmmain.cs index 8ed838a..7b6f04a 100644 --- a/Source/Itrycn_Project/frmmain.cs +++ b/Source/Itrycn_Project/frmmain.cs @@ -1,4 +1,4 @@ -using Itrycn_Project; +using Itrycn_Project2; using ryCommon; using System; using System.Collections.Generic; @@ -179,7 +179,7 @@ namespace Itrycn { if (isExpand) { - picExpand.Image = Itrycn_Project.Properties.Resources.opentree; + picExpand.Image = Itrycn_Project2.Properties.Resources.opentree; toolTip1.SetToolTip(picExpand,"展开列表"); treeView1.Visible = false; picExpand.Left = 0; @@ -187,7 +187,7 @@ namespace Itrycn } else { - picExpand.Image = Itrycn_Project.Properties.Resources.closetree; + picExpand.Image = Itrycn_Project2.Properties.Resources.closetree; toolTip1.SetToolTip(picExpand, "关闭列表"); treeView1.Visible = true; picExpand.Left = treeView1.Left + treeView1.Width + 1; diff --git a/Source/Itrycn_Project2/Config/Itrycn_Db.cs b/Source/Itrycn_Project2/Config/Itrycn_Db.cs index 7dd4376..9ded494 100644 --- a/Source/Itrycn_Project2/Config/Itrycn_Db.cs +++ b/Source/Itrycn_Project2/Config/Itrycn_Db.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Text; using static ryCommonDb.DataProvider; -namespace Itrycn_Project +namespace Itrycn_Project2 { public static class Itrycn_Db { diff --git a/Source/Itrycn_Project2/Config/Public_Config.cs b/Source/Itrycn_Project2/Config/Public_Config.cs index 8eee60d..18c128f 100644 --- a/Source/Itrycn_Project2/Config/Public_Config.cs +++ b/Source/Itrycn_Project2/Config/Public_Config.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace Itrycn_Project +namespace Itrycn_Project2 { /// /// 配置类,保存在文件中的配置信息(本系统基于乘黄V2架构) diff --git a/Source/Itrycn_Project2/Config/Soft_Info.cs b/Source/Itrycn_Project2/Config/Soft_Info.cs index 8c72ce8..51e0897 100644 --- a/Source/Itrycn_Project2/Config/Soft_Info.cs +++ b/Source/Itrycn_Project2/Config/Soft_Info.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; -namespace Itrycn_Project +namespace Itrycn_Project2 { /// /// 运行期间存储的变量,不会存储在文件中,只存储内存中.每次启动软件会初始化变量。 diff --git a/Source/Itrycn_Project2/DbOp/FrmAdd.Designer.cs b/Source/Itrycn_Project2/DbOp/FrmAdd.Designer.cs index 5e10e7e..6a2a78d 100644 --- a/Source/Itrycn_Project2/DbOp/FrmAdd.Designer.cs +++ b/Source/Itrycn_Project2/DbOp/FrmAdd.Designer.cs @@ -1,4 +1,4 @@ -namespace Itrycn_Project.DbOp +namespace Itrycn_Project2.DbOp { partial class FrmAdd { diff --git a/Source/Itrycn_Project2/DbOp/FrmAdd.cs b/Source/Itrycn_Project2/DbOp/FrmAdd.cs index ffe5965..5d6d72f 100644 --- a/Source/Itrycn_Project2/DbOp/FrmAdd.cs +++ b/Source/Itrycn_Project2/DbOp/FrmAdd.cs @@ -9,7 +9,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; -namespace Itrycn_Project.DbOp +namespace Itrycn_Project2.DbOp { public partial class FrmAdd : RySkins.SKinForm { diff --git a/Source/Itrycn_Project2/DbOp/FrmView.cs b/Source/Itrycn_Project2/DbOp/FrmView.cs index fe30ecb..e32224f 100644 --- a/Source/Itrycn_Project2/DbOp/FrmView.cs +++ b/Source/Itrycn_Project2/DbOp/FrmView.cs @@ -1,182 +1,204 @@ -using ryCommon; -using ryCommonDb; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; - -namespace Itrycn_Project.DbOp -{ - public partial class FrmView : RySkins.SKinForm - { - string orderSQL = "order by addTime desc"; - string tableName = "MainTable1"; - string titleName = "数据"; - public FrmView() - { - InitializeComponent(); - OlvName.AspectGetter = delegate (object x) { return ((ViewInfo)x).Name; }; - OlvAddTime.AspectGetter = delegate (object x) { return ((ViewInfo)x).AddTimeStr; }; - } - #region 需要修改的内容 - private void RySearch1_OnSearch(object sender, EventArgs e) - { - //需要修改此处 - //LoadDb("(" + TableProject.name + " like @SearchText or " + TableProject.des + " like @SearchText)"); - } - - private void CtlMyPage1_OnPageChange(object sender, EventArgs e) - { - #region 重新载入数据 - LvCbResult.ClearObjects(); - DataProvider mydb = new DataProvider(); - IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); - List list = new List(); - if (db.ConnDb(Itrycn_Db.SQLConnStr) == 1) - { - DataSet ds = db.ReadData(ctlMyPage1.GetSQLText, ctlMyPage1.T_Parameters); - for (int i = 0; i < ds.Tables[0].Rows.Count; i++) - { - DataRow row = ds.Tables[0].Rows[i]; +using ryCommon; +using ryCommonDb; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace Itrycn_Project2.DbOp +{ + public partial class FrmView : RySkins.SKinForm + { + string orderSQL = "order by addTime desc"; + string tableName = "MainTable1"; + string titleName = "数据"; + public FrmView() + { + InitializeComponent(); + OlvName.AspectGetter = delegate (object x) { return ((ViewInfo)x).Name; }; + OlvAddTime.AspectGetter = delegate (object x) { return ((ViewInfo)x).AddTimeStr; }; + } + #region 需要修改的内容 + private void RySearch1_OnSearch(object sender, EventArgs e) + { + //需要修改此处 + //LoadDb("(" + TableProject.name + " like @SearchText or " + TableProject.des + " like @SearchText)"); + } + + private void CtlMyPage1_OnPageChange(object sender, EventArgs e) + { + #region 重新载入数据 + LvCbResult.ClearObjects(); + DataProvider mydb = new DataProvider(); + IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); + List list = new List(); + if (db.ConnDb(Itrycn_Db.SQLConnStr) == 1) + { + DataSet ds = db.ReadData(ctlMyPage1.GetSQLText, ctlMyPage1.T_Parameters); + for (int i = 0; i < ds.Tables[0].Rows.Count; i++) + { + DataRow row = ds.Tables[0].Rows[i]; list.Add(new ViewInfo() { Id=row["id"].ToInt(), - Name = row["Name"].ToString(), - AddTime = row["AddTime"].ToDateTime() - }) ; - } - } - db.Free(); - LvCbResult.AddObjects(list); - #endregion - } - private void GetRow(int id, int index) - { - #region 重新载入数据 - DataProvider mydb = new DataProvider(); - IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); - if (db.ConnDb(Itrycn_Db.SQLConnStr) == 1) - { - DataSet ds = db.ReadData("select * from " + tableName + " where id=" + id); - if (mydb.HaveData(ds)) - { - DataRow row = ds.Tables[0].Rows[0]; - var item=(ViewInfo) LvCbResult.GetModelObject(index); - item.Name = row["Name"].ToString(); - //添加剩余的项目 - //添加完毕 - LvCbResult.UpdateObject(item); - } - } - db.Free(); - #endregion - } - #endregion - public void LoadDb(string whereSQL) - { - string _whereSQL = whereSQL; - DataProvider mydb = new DataProvider(); - IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); - if (db.ConnDb(Itrycn_Db.SQLConnStr) == 1) - { - #region 重新载入数据 - db.AddParameter("SearchText", "%" + rySearch1.Text + "%"); - ctlMyPage1.RecordCount = db.GetCount(tableName, _whereSQL); - ctlMyPage1.T_Parameters = db.GetParameter(); - ctlMyPage1.SQLText= db.GetPageSQL(tableName, _whereSQL, orderSQL); - ctlMyPage1.SQLText2 = db.GetPageSQL2(tableName, _whereSQL, orderSQL); - ctlMyPage1.GotoPageIndex(1); - #endregion - } - db.Free(); - } - - private void BtnAdd_Click(object sender, EventArgs e) - { - FrmAdd frm = new FrmAdd() - { - Text = "添加"+ titleName, - Icon = Icon, - isAdd = 1 - }; - frm.mr = new ModalForm(this, frm); - frm.mr.OnDialogResult += new ModalForm.DialogResultHandler((object t, DialogResult dg) => { - if (dg == DialogResult.OK) - { - rySearch1.PerformClick(); - } - }); - frm.mr.ShowModal(); - } - - private void BtnEdit_Click(object sender, EventArgs e) - { - if (LvCbResult.SelectedObject == null) { return; } - var item = (ViewInfo)LvCbResult.SelectedObject; - var selectId = item.Id; - FrmAdd frm = new FrmAdd() - { - Text = "修改"+ titleName, - Icon = Icon, - isAdd = 0 - }; - frm.GetInfo(selectId.ToString()); - frm.mr = new ModalForm(this, frm); - frm.mr.OnDialogResult += new ModalForm.DialogResultHandler((object t, DialogResult dg) => { - if (dg == DialogResult.OK) - { - GetRow(selectId, LvCbResult.SelectedIndex); - } - }); - frm.mr.ShowModal(); - } - - private void BtnDel_Click(object sender, EventArgs e) + Name = row["Name"].ToString(), + AddTime = row["AddTime"].ToDateTime() + }) ; + } + } + db.Free(); + LvCbResult.AddObjects(list); + #endregion + } + private void GetRow(int id, int index) { - if (LvCbResult.SelectedObject == null) { MessageBox.Show("请先选择要删除的项。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } - var item = (ViewInfo)LvCbResult.SelectedObject; - var selectId = item.Id; - if (RySkins.Msg.ShowMsg("确定要删除该项吗?一旦删除将不可恢复。", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No) - { - return; - } - //DataProvider mydb = new DataProvider(); - IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); - if (db.ConnDb(Itrycn_Db.SQLConnStr) == 1) - { - db.DelById(tableName, selectId.ToString()); - LvCbResult.RemoveObject(item); - } - } - - private void FrmView_Load(object sender, EventArgs e) - { - Text = "浏览"+ titleName; - 添加数据ToolStripMenuItem.Text = "添加"+ titleName; - 修改数据ToolStripMenuItem.Text = "修改" + titleName; - 删除数据ToolStripMenuItem.Text = "删除" + titleName; - rySearch1.PerformClick(); - } - - private void 添加数据ToolStripMenuItem_Click(object sender, EventArgs e) - { - btnAdd.PerformClick(); - } - - private void 修改数据ToolStripMenuItem_Click(object sender, EventArgs e) - { - btnEdit.PerformClick(); - } - - private void 删除数据ToolStripMenuItem_Click(object sender, EventArgs e) - { - btnDel.PerformClick(); - } - } + #region 重新载入数据 + DataProvider mydb = new DataProvider(); + IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); + if (db.ConnDb(Itrycn_Db.SQLConnStr) == 1) + { + DataSet ds = db.ReadData("select * from " + tableName + " where id=" + id); + if (mydb.HaveData(ds)) + { + DataRow row = ds.Tables[0].Rows[0]; + var item=(ViewInfo) LvCbResult.GetModelObject(index); + item.Name = row["Name"].ToString(); + //添加剩余的项目 + //添加完毕 + LvCbResult.UpdateObject(item); + } + } + db.Free(); + #endregion + } + #endregion + public void LoadDb(string whereSQL) + { + string _whereSQL = whereSQL; + DataProvider mydb = new DataProvider(); + IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); + if (db.ConnDb(Itrycn_Db.SQLConnStr) == 1) + { + #region 重新载入数据 + db.AddParameter("SearchText", "%" + rySearch1.Text + "%"); + ctlMyPage1.RecordCount = db.GetCount(tableName, _whereSQL); + ctlMyPage1.T_Parameters = db.GetParameter(); + ctlMyPage1.SQLText= db.GetPageSQL(tableName, _whereSQL, orderSQL); + ctlMyPage1.SQLText2 = db.GetPageSQL2(tableName, _whereSQL, orderSQL); + ctlMyPage1.GotoPageIndex(1); + #endregion + } + db.Free(); + } + + private void BtnAdd_Click(object sender, EventArgs e) + { + FrmAdd frm = new FrmAdd() + { + Text = "添加"+ titleName, + Icon = Icon, + isAdd = 1 + }; + frm.mr = new ModalForm(this, frm); + frm.mr.OnDialogResult += new ModalForm.DialogResultHandler((object t, DialogResult dg) => { + if (dg == DialogResult.OK) + { + rySearch1.PerformClick(); + } + }); + frm.mr.ShowModal(); + } + + private void BtnEdit_Click(object sender, EventArgs e) + { + if (LvCbResult.SelectedObject == null) { return; } + var item = (ViewInfo)LvCbResult.SelectedObject; + var selectId = item.Id; + FrmAdd frm = new FrmAdd() + { + Text = "修改"+ titleName, + Icon = Icon, + isAdd = 0 + }; + frm.GetInfo(selectId.ToString()); + frm.mr = new ModalForm(this, frm); + frm.mr.OnDialogResult += new ModalForm.DialogResultHandler((object t, DialogResult dg) => { + if (dg == DialogResult.OK) + { + GetRow(selectId, LvCbResult.SelectedIndex); + } + }); + frm.mr.ShowModal(); + } + + private void BtnDel_Click(object sender, EventArgs e) + { + if (LvCbResult.SelectedObject == null) { MessageBox.Show("请先选择要删除的项。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } + var item = (ViewInfo)LvCbResult.SelectedObject; + var selectId = item.Id; + if (RySkins.Msg.ShowMsg("确定要删除该项吗?一旦删除将不可恢复。", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No) + { + return; + } + //DataProvider mydb = new DataProvider(); + IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); + if (db.ConnDb(Itrycn_Db.SQLConnStr) == 1) + { + db.DelById(tableName, selectId.ToString()); + LvCbResult.RemoveObject(item); + } + } + + private void FrmView_Load(object sender, EventArgs e) + { + Text = "浏览"+ titleName; + 添加数据ToolStripMenuItem.Text = "添加"+ titleName; + 修改数据ToolStripMenuItem.Text = "修改" + titleName; + 删除数据ToolStripMenuItem.Text = "删除" + titleName; + rySearch1.PerformClick(); + } + + private void 添加数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + btnAdd.PerformClick(); + } + + private void 修改数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + btnEdit.PerformClick(); + } + + private void 删除数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + btnDel.PerformClick(); + } + + private void 复制并添加数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + if (LvCbResult.SelectedObject == null) { return; } + var item = (ViewInfo)LvCbResult.SelectedObject; + var selectId = item.Id; + FrmAdd frm = new FrmAdd() + { + Text = "添加" + titleName, + Icon = Icon, + isAdd = 1 + }; + frm.GetInfo(selectId.ToString()); + frm.mr = new ModalForm(this, frm); + frm.mr.OnDialogResult += new ModalForm.DialogResultHandler((object t, DialogResult dg) => { + if (dg == DialogResult.OK) + { + rySearch1.PerformClick(); + } + }); + frm.mr.ShowModal(); + } + } class ViewInfo { /// @@ -198,5 +220,5 @@ namespace Itrycn_Project.DbOp { get { return AddTime.ToString("yyyy-MM-dd dddd HH:mm:ss"); } } - } -} + } +} diff --git a/Source/Itrycn_Project2/DbOp/frmView.Designer.cs b/Source/Itrycn_Project2/DbOp/frmView.Designer.cs index 8e93663..fed17d3 100644 --- a/Source/Itrycn_Project2/DbOp/frmView.Designer.cs +++ b/Source/Itrycn_Project2/DbOp/frmView.Designer.cs @@ -1,4 +1,4 @@ -namespace Itrycn_Project.DbOp +namespace Itrycn_Project2.DbOp { partial class FrmView { @@ -41,6 +41,7 @@ this.LvCbResult = new BrightIdeasSoftware.FastObjectListView(); this.OlvName = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); this.OlvAddTime = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); + this.复制并添加数据ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.contextMenuStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.LvCbResult)).BeginInit(); this.SuspendLayout(); @@ -59,11 +60,12 @@ // contextMenuStrip1 // this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.复制并添加数据ToolStripMenuItem, this.添加数据ToolStripMenuItem, this.修改数据ToolStripMenuItem, this.删除数据ToolStripMenuItem}); this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(125, 70); + this.contextMenuStrip1.Size = new System.Drawing.Size(181, 114); // // 添加数据ToolStripMenuItem // @@ -153,6 +155,7 @@ this.LvCbResult.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.OlvName, this.OlvAddTime}); + this.LvCbResult.ContextMenuStrip = this.contextMenuStrip1; this.LvCbResult.Cursor = System.Windows.Forms.Cursors.Default; this.LvCbResult.EmptyListMsg = "当前列表没有任何项"; this.LvCbResult.FullRowSelect = true; @@ -179,6 +182,13 @@ this.OlvAddTime.Text = "时间"; this.OlvAddTime.Width = 200; // + // 复制并添加数据ToolStripMenuItem + // + this.复制并添加数据ToolStripMenuItem.Name = "复制并添加数据ToolStripMenuItem"; + this.复制并添加数据ToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.复制并添加数据ToolStripMenuItem.Text = "复制并添加数据"; + this.复制并添加数据ToolStripMenuItem.Click += new System.EventHandler(this.复制并添加数据ToolStripMenuItem_Click); + // // FrmView // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -214,5 +224,6 @@ private BrightIdeasSoftware.FastObjectListView LvCbResult; private BrightIdeasSoftware.OLVColumn OlvName; private BrightIdeasSoftware.OLVColumn OlvAddTime; + private System.Windows.Forms.ToolStripMenuItem 复制并添加数据ToolStripMenuItem; } } \ No newline at end of file diff --git a/Source/Itrycn_Project2/DbOp/frmView.resx b/Source/Itrycn_Project2/DbOp/frmView.resx index 0f850fe..9c13369 100644 --- a/Source/Itrycn_Project2/DbOp/frmView.resx +++ b/Source/Itrycn_Project2/DbOp/frmView.resx @@ -118,6 +118,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 269, 21 + 35, 26 \ No newline at end of file diff --git a/Source/Itrycn_Project2/FrmAbout.Designer.cs b/Source/Itrycn_Project2/FrmAbout.Designer.cs index 9716c0c..2bf4782 100644 --- a/Source/Itrycn_Project2/FrmAbout.Designer.cs +++ b/Source/Itrycn_Project2/FrmAbout.Designer.cs @@ -1,4 +1,4 @@ -namespace Itrycn_Project +namespace Itrycn_Project2 { partial class FrmAbout { diff --git a/Source/Itrycn_Project2/FrmAbout.cs b/Source/Itrycn_Project2/FrmAbout.cs index a7dbab5..04c314f 100644 --- a/Source/Itrycn_Project2/FrmAbout.cs +++ b/Source/Itrycn_Project2/FrmAbout.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; -namespace Itrycn_Project +namespace Itrycn_Project2 { public partial class FrmAbout : RySkins.SKinForm { diff --git a/Source/Itrycn_Project2/FrmStart.cs b/Source/Itrycn_Project2/FrmStart.cs index 99323aa..f603354 100644 --- a/Source/Itrycn_Project2/FrmStart.cs +++ b/Source/Itrycn_Project2/FrmStart.cs @@ -1,4 +1,4 @@ -using Itrycn_Project; +using Itrycn_Project2; using ryCommon; using ryCommonDb; using System; diff --git a/Source/Itrycn_Project2/OTools/FrmScan.cs b/Source/Itrycn_Project2/OTools/FrmScan.cs index ad586fa..a2e7c69 100644 --- a/Source/Itrycn_Project2/OTools/FrmScan.cs +++ b/Source/Itrycn_Project2/OTools/FrmScan.cs @@ -1,4 +1,4 @@ -using Itrycn_Project; +using Itrycn_Project2; using ryCommon; using System; using System.Collections.Generic; @@ -164,12 +164,12 @@ namespace Itrycn_Project2 void Start() { //RyWeb.QuickWeb ry3h3 = new RyWeb.QuickWeb(); - IsExit = false; - IsRunning = false; - Soft_MemInfo.IsCanCloseForm = true; //将扫描的代码写在下面 //↑将扫描的代码写在上面 + IsExit = false; + IsRunning = false; + Soft_MemInfo.IsCanCloseForm = true; this.Invoke(new Action(() => { //LvCbResult.AddObjects(list); diff --git a/Source/Itrycn_Project2/OTools/RegSoft/frmLogin.cs b/Source/Itrycn_Project2/OTools/RegSoft/frmLogin.cs index 5892799..5cd3d6c 100644 --- a/Source/Itrycn_Project2/OTools/RegSoft/frmLogin.cs +++ b/Source/Itrycn_Project2/OTools/RegSoft/frmLogin.cs @@ -1,4 +1,4 @@ -using Itrycn_Project; +using Itrycn_Project2; using ryCommon; using RyHardWare; using System; diff --git a/Source/Itrycn_Project2/Program.cs b/Source/Itrycn_Project2/Program.cs index 60b2977..71a30e5 100644 --- a/Source/Itrycn_Project2/Program.cs +++ b/Source/Itrycn_Project2/Program.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; -namespace Itrycn_Project +namespace Itrycn_Project2 { static class Program { diff --git a/Source/Itrycn_Project2/Properties/Settings.Designer.cs b/Source/Itrycn_Project2/Properties/Settings.Designer.cs index 87b3b8d..3e3d9ad 100644 --- a/Source/Itrycn_Project2/Properties/Settings.Designer.cs +++ b/Source/Itrycn_Project2/Properties/Settings.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Itrycn_Project.Properties +namespace Itrycn_Project2.Properties { diff --git a/Source/Itrycn_Project2/SkinForms/FrmMessageBox.Designer.cs b/Source/Itrycn_Project2/SkinForms/FrmMessageBox.Designer.cs index 4a67020..c5b99ca 100644 --- a/Source/Itrycn_Project2/SkinForms/FrmMessageBox.Designer.cs +++ b/Source/Itrycn_Project2/SkinForms/FrmMessageBox.Designer.cs @@ -80,10 +80,12 @@ namespace RySkins this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnYes); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Location = new System.Drawing.Point(0, 0); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "FrmMessageBox"; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmMessageBox_FormClosing); this.ResumeLayout(false); } diff --git a/Source/Itrycn_Project2/SkinForms/FrmMessageBox.cs b/Source/Itrycn_Project2/SkinForms/FrmMessageBox.cs index 85e9670..0dd1ab7 100644 --- a/Source/Itrycn_Project2/SkinForms/FrmMessageBox.cs +++ b/Source/Itrycn_Project2/SkinForms/FrmMessageBox.cs @@ -15,9 +15,11 @@ namespace RySkins { InitializeComponent(); } + private bool ProcUse = false; public MessageBoxButtons ResultDg { get; set; } = MessageBoxButtons.OKCancel; private void BtnYes_Click(object sender, EventArgs e) { + ProcUse = true; if (this.Modal) { switch (ResultDg) @@ -38,6 +40,7 @@ namespace RySkins private void BtnCancel_Click(object sender, EventArgs e) { + ProcUse = true; switch (ResultDg) { case MessageBoxButtons.YesNo: @@ -54,5 +57,13 @@ namespace RySkins lblMsg.UpdateInfo(); lblMsg.Refresh(); } + + private void FrmMessageBox_FormClosing(object sender, FormClosingEventArgs e) + { + if (e.CloseReason == CloseReason.UserClosing && !ProcUse) + { + this.DialogResult = DialogResult.Cancel; + } + } } } diff --git a/Source/Itrycn_Project2/frmSetting.Designer.cs b/Source/Itrycn_Project2/frmSetting.Designer.cs index 13d7dda..50f770b 100644 --- a/Source/Itrycn_Project2/frmSetting.Designer.cs +++ b/Source/Itrycn_Project2/frmSetting.Designer.cs @@ -1,4 +1,4 @@ -namespace Itrycn_Project +namespace Itrycn_Project2 { partial class FrmSetting { diff --git a/Source/Itrycn_Project2/frmSetting.cs b/Source/Itrycn_Project2/frmSetting.cs index 6e99411..2c4b7bb 100644 --- a/Source/Itrycn_Project2/frmSetting.cs +++ b/Source/Itrycn_Project2/frmSetting.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; -namespace Itrycn_Project +namespace Itrycn_Project2 { public partial class FrmSetting : RySkins.SKinForm { diff --git a/Source/MyDb/DbManage/Strings.cs b/Source/MyDb/DbManage/Strings.cs index 620b1c1..dea73f4 100644 --- a/Source/MyDb/DbManage/Strings.cs +++ b/Source/MyDb/DbManage/Strings.cs @@ -342,6 +342,32 @@ namespace ryCommon //return replace.IsMatch(wildcardStr1); } /// + /// 支持忽略大小写的替换功能 + /// + /// + /// + /// + /// 是否忽略大小写 + /// + public static string Replace(string str, string oldValue, string newValue,bool IgnoreCase) + { + if(IgnoreCase) + { + var str2 = ""; + var str_tmp = str; + var pos = str_tmp.IndexOfEx(oldValue); + while(pos>=0) + { + str2 += str_tmp.Substring(0, pos); + str_tmp = str_tmp.Substring(pos + oldValue.Length); + pos = str_tmp.IndexOfEx(oldValue); + } + str2 += str_tmp; + return str2; + } + else { return str.Replace(oldValue,newValue); } + } + /// /// 获取匹配的内容 /// /// diff --git a/Source/MyDb/DbManage/VarExtension.cs b/Source/MyDb/DbManage/VarExtension.cs index a6adfdd..06d9237 100644 --- a/Source/MyDb/DbManage/VarExtension.cs +++ b/Source/MyDb/DbManage/VarExtension.cs @@ -55,6 +55,18 @@ namespace ryCommon } } /// + /// 支持忽略大小写的替换文本功能 + /// + /// + /// + /// + /// 是否忽略大小写 + /// + static public string Replace(this string original, string oldValue, string newValue, bool IgnoreCase) + { + return Strings.Replace(original, oldValue, newValue, IgnoreCase); + } + /// /// 获取符合要求的第一个结果 /// /// diff --git a/Source/MyDb/Properties/AssemblyInfo.cs b/Source/MyDb/Properties/AssemblyInfo.cs index e373760..31aab4d 100644 --- a/Source/MyDb/Properties/AssemblyInfo.cs +++ b/Source/MyDb/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, // 方法是按如下所示使用“*”: : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.0.2105.2201")] -[assembly: AssemblyFileVersion("3.0.2105.2201")] \ No newline at end of file +[assembly: AssemblyVersion("3.0.2107.0101")] +[assembly: AssemblyFileVersion("3.0.2107.0101")] \ No newline at end of file diff --git a/Source/RyWeb/Properties/AssemblyInfo.cs b/Source/RyWeb/Properties/AssemblyInfo.cs index 01cc02e..ba5a064 100644 --- a/Source/RyWeb/Properties/AssemblyInfo.cs +++ b/Source/RyWeb/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.0.2105.2201")] -[assembly: AssemblyFileVersion("3.0.2105.2201")] \ No newline at end of file +[assembly: AssemblyVersion("3.0.2107.0101")] +[assembly: AssemblyFileVersion("3.0.2107.0101")] \ No newline at end of file diff --git a/Source/RyWeb/QuickWeb.cs b/Source/RyWeb/QuickWeb.cs index 7c1f01b..605c2f1 100644 --- a/Source/RyWeb/QuickWeb.cs +++ b/Source/RyWeb/QuickWeb.cs @@ -1,282 +1,293 @@ -using DotNet4.Utilities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace RyWeb -{ +using DotNet4.Utilities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace RyWeb +{ /// /// - /// - public class QuickWeb - { - /// - /// 以post方式获取网页源码 - /// - /// - /// - /// - /// - public HttpResult Post(string url, string post, string cookie) - { - return Post(url, post, "application/x-www-form-urlencoded", cookie); - } - /// - /// 以post方式提交json内容 - /// - /// - /// - /// - /// - public HttpResult PostJson(string url, string post, string cookie) - { - return Post(url, post, "application/json", cookie); - } - /// - /// 以post方式提交json内容 - /// - /// - /// - /// - public HttpResult PostJson(string url, string post) - { - return Post(url, post, "application/json", ""); - } - /// - /// 以post方式获取网页源码 - /// - /// - /// - /// - /// - /// - public HttpResult Post(string url, string post,string ContentType, string cookie) - { - try - { - HttpHelper t = new HttpHelper(); - HttpItem m = new HttpItem() - { - URL = url, - Postdata = post, - ContentType = ContentType, - Method = "POST", - Timeout = Timeout, - ReadWriteTimeout = Timeout, - UserAgent = UserAgent - }; - if (cookie.Length > 0) - { - m.Cookie = cookie; - } - HttpResult r = t.GetHtml(m); - return r; - } - catch - { - HttpResult r = new HttpResult(); - return r; - } - } - /// - /// 以post方式获取网页源码 - /// - /// - /// - /// - public HttpResult Post(string url, string post) - { - return Post(url, post, cookie); - } - /// - /// 获取网址对应的文件大小 - /// - /// - /// - public long GetSize(string url) - { - try - { - HttpHelper t = new HttpHelper(); - HttpItem m = new HttpItem() - { - URL = url, - Method = "HEAD", - Allowautoredirect = true, - Cookie = cookie, - Timeout = Timeout, - ReadWriteTimeout = Timeout, - UserAgent=UserAgent - }; - HttpResult r = t.GetHtml(m); - if (r.StatusCode == System.Net.HttpStatusCode.OK) - { - return Convert.ToInt64(r.Header["Content-Length"]); - } - else if (r.StatusCode == System.Net.HttpStatusCode.MethodNotAllowed) - { - System.Net.ServicePointManager.DefaultConnectionLimit = 512; - System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url); - System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse(); - long totalBytes = response.ContentLength; - return totalBytes; - } - else - return 0; - } - catch - { - return 0; - } - } + /// + public class QuickWeb + { + /// + /// 以post方式获取网页源码 + /// + /// + /// + /// + /// + public HttpResult Post(string url, string post, string cookie) + { + return Post(url, post, "application/x-www-form-urlencoded", cookie); + } + /// + /// 以post方式提交json内容 + /// + /// + /// + /// + /// + public HttpResult PostJson(string url, string post, string cookie) + { + return Post(url, post, "application/json", cookie); + } + /// + /// 以post方式提交json内容 + /// + /// + /// + /// + public HttpResult PostJson(string url, string post) + { + return Post(url, post, "application/json", ""); + } + /// + /// 以post方式获取网页源码 + /// + /// + /// + /// + /// + /// + public HttpResult Post(string url, string post,string ContentType, string cookie) + { + try + { + HttpHelper t = new HttpHelper(); + HttpItem m = new HttpItem() + { + URL = url, + Postdata = post, + ContentType = ContentType, + Method = "POST", + Timeout = Timeout, + ReadWriteTimeout = Timeout, + UserAgent = UserAgent, + Referer=Referer + }; + if (cookie.Length > 0) + { + m.Cookie = cookie; + } + HttpResult r = t.GetHtml(m); + return r; + } + catch + { + HttpResult r = new HttpResult(); + return r; + } + } + /// + /// 以post方式获取网页源码 + /// + /// + /// + /// + public HttpResult Post(string url, string post) + { + return Post(url, post, cookie); + } + /// + /// 获取网址对应的文件大小 + /// + /// + /// + public long GetSize(string url) + { + try + { + HttpHelper t = new HttpHelper(); + HttpItem m = new HttpItem() + { + URL = url, + Method = "HEAD", + Allowautoredirect = true, + Cookie = cookie, + Timeout = Timeout, + ReadWriteTimeout = Timeout, + UserAgent = UserAgent, + Referer = Referer + }; + HttpResult r = t.GetHtml(m); + if (r.StatusCode == System.Net.HttpStatusCode.OK) + { + return Convert.ToInt64(r.Header["Content-Length"]); + } + else if (r.StatusCode == System.Net.HttpStatusCode.MethodNotAllowed) + { + System.Net.ServicePointManager.DefaultConnectionLimit = 512; + System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url); + System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse(); + long totalBytes = response.ContentLength; + return totalBytes; + } + else + return 0; + } + catch + { + return 0; + } + } /// /// - /// - public string UserAgent - { - get; set; - } = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"; - /// - /// 获取网页源码 - /// - /// - /// - /// - public HttpResult Get(string url, string cookie) - { - try - { - HttpHelper t = new HttpHelper(); - HttpItem m = new HttpItem() - { - URL = url, - ContentType= "application/x-www-form-urlencoded" - }; - if (cookie.Length>0) - { - m.Cookie = cookie; - } - m.UserAgent = UserAgent; - m.Allowautoredirect = true; - m.Timeout = Timeout; - m.ReadWriteTimeout = Timeout; - HttpResult r = t.GetHtml(m); - return r; - } - catch - { - HttpResult r = new HttpResult() - { - Html = "" - }; - return r; - } - } - /// - /// 获取网页源码 - /// - /// - /// - /// - /// - public HttpResult Get(string url,Encoding encoding, string cookie) - { - try - { - HttpHelper t = new HttpHelper(); - HttpItem m = new HttpItem() - { - URL = url - }; - if (cookie != "") - { - m.Cookie = cookie; - } - m.UserAgent = UserAgent; - m.Encoding = encoding; - m.Allowautoredirect = true; - m.Timeout = Timeout; - m.ReadWriteTimeout = Timeout; - HttpResult r = t.GetHtml(m); - return r; - } - catch - { - HttpResult r = new HttpResult() - { - Html = "" - }; - return r; - } - } - /// - /// 获取网页源码 - /// - /// - /// - public HttpResult Get(string url) - { - return Get(url, cookie); - } + /// + public string UserAgent + { + get; set; + } = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"; + /// + /// 获取网页源码 + /// + /// + /// + /// + public HttpResult Get(string url, string cookie) + { + try + { + HttpHelper t = new HttpHelper(); + HttpItem m = new HttpItem() + { + URL = url, + ContentType= "application/x-www-form-urlencoded" + }; + if (cookie.Length>0) + { + m.Cookie = cookie; + } + m.UserAgent = UserAgent; + m.Allowautoredirect = true; + m.Timeout = Timeout; + m.ReadWriteTimeout = Timeout; + m.Referer = Referer; + HttpResult r = t.GetHtml(m); + return r; + } + catch + { + HttpResult r = new HttpResult() + { + Html = "" + }; + return r; + } + } + /// + /// 获取网页源码 + /// + /// + /// + /// + /// + public HttpResult Get(string url,Encoding encoding, string cookie) + { + try + { + HttpHelper t = new HttpHelper(); + HttpItem m = new HttpItem() + { + URL = url + }; + if (cookie != "") + { + m.Cookie = cookie; + } + m.UserAgent = UserAgent; + m.Encoding = encoding; + m.Allowautoredirect = true; + m.Timeout = Timeout; + m.ReadWriteTimeout = Timeout; + m.Referer = Referer; + HttpResult r = t.GetHtml(m); + return r; + } + catch + { + HttpResult r = new HttpResult() + { + Html = "" + }; + return r; + } + } + /// + /// 获取网页源码 + /// + /// + /// + public HttpResult Get(string url) + { + return Get(url, cookie); + } /// /// - /// - public string Cookie - { - get { return cookie; } - } + /// + public string Cookie + { + get { return cookie; } + } /// /// - /// - public int Timeout { get; set; } = 10000; + /// + public string Referer + { + get;set; + } + /// + /// + /// + public int Timeout { get; set; } = 10000; /// /// /// /// /// - /// - public string UrlEncode(string str, Encoding encode) - { - StringBuilder sb = new StringBuilder(); - byte[] byStr = encode.GetBytes(str); //默认是System.Text.Encoding.Default.GetBytes(str) - for (int i = 0; i < byStr.Length; i++) - { - var item = Convert.ToString(byStr[i], 16); - if (item.Length == 1) { item = "0" + item; } - sb.Append(@"%" + item); - } - return (sb.ToString()); - } - private string cookie = ""; - /// - /// 将相对网址转换成绝对网址 - /// - /// 相对网址 - /// 当前页面地址 - /// 转换后的绝对网址 - public string ConvertUrl(string rel_url, string cur_pageUrl) - { - if (rel_url == "") - { - return cur_pageUrl; - } - try - { - string _rel_url = rel_url; - if (_rel_url.IndexOf("//")==0) - { - int iPos = cur_pageUrl.IndexOf(":"); - if (iPos > 0) - { - _rel_url = cur_pageUrl.Substring(0,iPos)+ ":" + _rel_url; - } - } - Uri baseUri = new Uri(cur_pageUrl); // - Uri absoluteUri = new Uri(baseUri, _rel_url);//相对绝对路径都在这里转 这里的urlx ="../test.html" - return absoluteUri.AbsoluteUri.Replace("&", "&");// - } - catch { return rel_url; } - } - } -} + /// + public string UrlEncode(string str, Encoding encode) + { + StringBuilder sb = new StringBuilder(); + byte[] byStr = encode.GetBytes(str); //默认是System.Text.Encoding.Default.GetBytes(str) + for (int i = 0; i < byStr.Length; i++) + { + var item = Convert.ToString(byStr[i], 16); + if (item.Length == 1) { item = "0" + item; } + sb.Append(@"%" + item); + } + return (sb.ToString()); + } + private string cookie = ""; + /// + /// 将相对网址转换成绝对网址 + /// + /// 相对网址 + /// 当前页面地址 + /// 转换后的绝对网址 + public string ConvertUrl(string rel_url, string cur_pageUrl) + { + if (rel_url == "") + { + return cur_pageUrl; + } + try + { + string _rel_url = rel_url; + if (_rel_url.IndexOf("//")==0) + { + int iPos = cur_pageUrl.IndexOf(":"); + if (iPos > 0) + { + _rel_url = cur_pageUrl.Substring(0,iPos)+ ":" + _rel_url; + } + } + Uri baseUri = new Uri(cur_pageUrl); // + Uri absoluteUri = new Uri(baseUri, _rel_url);//相对绝对路径都在这里转 这里的urlx ="../test.html" + return absoluteUri.AbsoluteUri.Replace("&", "&");// + } + catch { return rel_url; } + } + } +} diff --git a/Source/ryControls/Properties/AssemblyInfo.cs b/Source/ryControls/Properties/AssemblyInfo.cs index 3e12420..b988861 100644 --- a/Source/ryControls/Properties/AssemblyInfo.cs +++ b/Source/ryControls/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, // 方法是按如下所示使用“*”: : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.0.2106.1301")] -[assembly: AssemblyFileVersion("3.0.2106.1301")] \ No newline at end of file +[assembly: AssemblyVersion("3.0.2107.0101")] +[assembly: AssemblyFileVersion("3.0.2107.0101")] \ No newline at end of file diff --git a/Source/ryControls/Sheng.Winform.Controls/DragHelper.cs b/Source/ryControls/Sheng.Winform.Controls/DragHelper.cs new file mode 100644 index 0000000..c82794c --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/DragHelper.cs @@ -0,0 +1,41 @@ +//用在SETreeView 的拖放操作时 +//http://www.codeproject.com/KB/tree/TreeViewDragDrop.aspx + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Runtime.InteropServices; + +namespace Sheng.Winform.Controls +{ + public class DragHelper + { + [DllImport("comctl32.dll")] + public static extern bool InitCommonControls(); + + [DllImport("comctl32.dll", CharSet = CharSet.Auto)] + public static extern bool ImageList_BeginDrag(IntPtr himlTrack, int + iTrack, int dxHotspot, int dyHotspot); + + [DllImport("comctl32.dll", CharSet = CharSet.Auto)] + public static extern bool ImageList_DragMove(int x, int y); + + [DllImport("comctl32.dll", CharSet = CharSet.Auto)] + public static extern void ImageList_EndDrag(); + + [DllImport("comctl32.dll", CharSet = CharSet.Auto)] + public static extern bool ImageList_DragEnter(IntPtr hwndLock, int x, int y); + + [DllImport("comctl32.dll", CharSet = CharSet.Auto)] + public static extern bool ImageList_DragLeave(IntPtr hwndLock); + + [DllImport("comctl32.dll", CharSet = CharSet.Auto)] + public static extern bool ImageList_DragShowNolock(bool fShow); + + static DragHelper() + { + InitCommonControls(); + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Drawing/BmpAdjuster.cs b/Source/ryControls/Sheng.Winform.Controls/Drawing/BmpAdjuster.cs new file mode 100644 index 0000000..69336e2 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Drawing/BmpAdjuster.cs @@ -0,0 +1,279 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; +using System.Drawing.Imaging; +using System.Runtime.InteropServices; + +namespace Sheng.Winform.Controls.Drawing +{ + public class BmpAdjuster + { + #region 原有方法 + + public delegate ColorPalette PaletteAdjustEvent(ColorPalette plt); + + public unsafe delegate void ConvertScanLineEvent(IntPtr srcLine, IntPtr dstLine, int width, int srcPixBit, int dstPixBit, Bitmap srcBmp, Bitmap dstBmp); + + private int alpha = 255; + + public BmpAdjuster() + { + + } + + /// + /// 初始化的时候给个alpha值,这样在灰图片的时候可以半透明 + /// + /// + public BmpAdjuster(int alpha) + { + this.alpha = alpha; + } + + public void AdjustColor(ref Bitmap bmp, PixelFormat format, PaletteAdjustEvent PalleteAdjust, ConvertScanLineEvent ConvertScanLine) + { + Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); + Bitmap bmpOut = new Bitmap(bmp.Width, bmp.Height, format); + + bmpOut.Palette = PalleteAdjust(bmpOut.Palette); + + PixelFormat srcFmt = bmp.PixelFormat; + PixelFormat dstFmt = bmpOut.PixelFormat; + int srcPixBit = GetPixelSize(srcFmt); + int dstPixBit = GetPixelSize(dstFmt); + + BitmapData srcData = null; + BitmapData dstData = null; + try + { + srcData = bmp.LockBits(rect, ImageLockMode.ReadOnly, srcFmt); + dstData = bmpOut.LockBits(rect, ImageLockMode.WriteOnly, dstFmt); + + unsafe + { + byte* srcLine = (byte*)srcData.Scan0.ToPointer(); + byte* dstLine = (byte*)dstData.Scan0.ToPointer(); + for (int L = 0; L < srcData.Height; L++) + { + ConvertScanLine((IntPtr)srcLine, (IntPtr)dstLine, srcData.Width, srcPixBit, dstPixBit, bmp, bmpOut); + + srcLine += srcData.Stride; + dstLine += dstData.Stride; + } + } + } + finally + { + bmp.UnlockBits(srcData); + bmpOut.UnlockBits(dstData); + } + + bmp = bmpOut; + } + + internal int GetPixelSize(PixelFormat format) + { + switch (format) + { + case PixelFormat.Format16bppRgb555: return 16; + case PixelFormat.Format16bppRgb565: return 16; + case PixelFormat.Format24bppRgb: return 24; + case PixelFormat.Format32bppRgb: return 32; + case PixelFormat.Format1bppIndexed: return 1; + case PixelFormat.Format4bppIndexed: return 4; + case PixelFormat.Format8bppIndexed: return 8; + case PixelFormat.Format16bppArgb1555: return 16; + case PixelFormat.Format32bppPArgb: return 32; + case PixelFormat.Format16bppGrayScale: return 16; + case PixelFormat.Format48bppRgb: return 48; + case PixelFormat.Format64bppPArgb: return 64; + case PixelFormat.Canonical: return 32; + case PixelFormat.Format32bppArgb: return 32; + case PixelFormat.Format64bppArgb: return 64; + } + return 0; + } + + public unsafe void Monochrome(ref Bitmap bmp) + { + AdjustColor(ref bmp, PixelFormat.Format1bppIndexed, + new PaletteAdjustEvent(SetBlackWhitePallete), + new ConvertScanLineEvent(ConvertBlackWhiteScanLine)); + } + + ColorPalette SetBlackWhitePallete(ColorPalette plt) + { + plt.Entries[0] = Color.Black; + plt.Entries[1] = Color.White; + return plt; + } + + unsafe void ConvertBlackWhiteScanLine(IntPtr srcLine, IntPtr dstLine, int width, int srcPixBit, int dstPixBit, Bitmap srcBmp, Bitmap dstBmp) + { + byte* src = (byte*)srcLine.ToPointer(); + byte* dst = (byte*)dstLine.ToPointer(); + int srcPixByte = srcPixBit / 8; + int x, v, t = 0; + + for (x = 0; x < width; x++) + { + v = 28 * src[0] + 151 * src[1] + 77 * src[2]; + t = (t << 1) | (v > 200 * 256 ? 1 : 0); + src += srcPixByte; + + if (x % 8 == 7) + { + *dst = (byte)t; + dst++; + t = 0; + } + } + + if ((x %= 8) != 7) + { + t <<= 8 - x; + *dst = (byte)t; + } + } + + public void Gray(ref Bitmap bmp) + { + AdjustColor(ref bmp, PixelFormat.Format8bppIndexed, + new PaletteAdjustEvent(SetGrayPallete), + new ConvertScanLineEvent(ConvertGaryScanLine)); + } + + ColorPalette SetGrayPallete(ColorPalette plt) + { + //for (int i = plt.Entries.Length - 1; i >= 0; i--) + // plt.Entries[i] = Color.FromArgb( i, i, i); + for (int i = plt.Entries.Length - 1; i >= 0; i--) + plt.Entries[i] = Color.FromArgb(alpha, i, i, i); + return plt; + } + + unsafe void ConvertGaryScanLine(IntPtr srcLine, IntPtr dstLine, int width, int srcPixBit, int dstPixBit, Bitmap srcBmp, Bitmap dstBmp) + { + byte* src = (byte*)srcLine.ToPointer(); + byte* dst = (byte*)dstLine.ToPointer(); + int srcPixByte = srcPixBit / 8; + + for (int x = 0; x < width; x++) + { + *dst = (byte)((28 * src[0] + 151 * src[1] + 77 * src[2]) >> 8); + src += srcPixByte; + dst++; + } + } + + #endregion + + /// + /// 使图片单色化 + /// + /// + /// + public static Bitmap MonochromeLockBits(Bitmap pimage) + { + Bitmap source = null; + + // If original bitmap is not already in 32 BPP, ARGB format, then convert + if (pimage.PixelFormat != PixelFormat.Format32bppArgb) + { + source = new Bitmap(pimage.Width, pimage.Height, PixelFormat.Format32bppArgb); + source.SetResolution(pimage.HorizontalResolution, pimage.VerticalResolution); + using (Graphics g = Graphics.FromImage(source)) + { + g.DrawImageUnscaled(pimage, 0, 0); + } + } + else + { + source = pimage; + } + + // Lock source bitmap in memory + BitmapData sourceData = source.LockBits(new Rectangle(0, 0, source.Width, source.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); + + // Copy image data to binary array + int imageSize = sourceData.Stride * sourceData.Height; + byte[] sourceBuffer = new byte[imageSize]; + Marshal.Copy(sourceData.Scan0, sourceBuffer, 0, imageSize); + + // Unlock source bitmap + source.UnlockBits(sourceData); + + // Create destination bitmap + Bitmap destination = new Bitmap(source.Width, source.Height, PixelFormat.Format1bppIndexed); + + // Lock destination bitmap in memory + BitmapData destinationData = destination.LockBits(new Rectangle(0, 0, destination.Width, destination.Height), ImageLockMode.WriteOnly, PixelFormat.Format1bppIndexed); + + // Create destination buffer + imageSize = destinationData.Stride * destinationData.Height; + byte[] destinationBuffer = new byte[imageSize]; + + int sourceIndex = 0; + int destinationIndex = 0; + int pixelTotal = 0; + byte destinationValue = 0; + int pixelValue = 128; + int height = source.Height; + int width = source.Width; + int threshold = 500; + + // Iterate lines + for (int y = 0; y < height; y++) + { + sourceIndex = y * sourceData.Stride; + destinationIndex = y * destinationData.Stride; + destinationValue = 0; + pixelValue = 128; + + // Iterate pixels + for (int x = 0; x < width; x++) + { + // Compute pixel brightness (i.e. total of Red, Green, and Blue values) + pixelTotal = sourceBuffer[sourceIndex + 1] + sourceBuffer[sourceIndex + 2] + sourceBuffer[sourceIndex + 3]; + if (pixelTotal > threshold) + { + destinationValue += (byte)pixelValue; + } + if (pixelValue == 1) + { + destinationBuffer[destinationIndex] = destinationValue; + destinationIndex++; + destinationValue = 0; + pixelValue = 128; + } + else + { + pixelValue >>= 1; + } + sourceIndex += 4; + } + if (pixelValue != 128) + { + destinationBuffer[destinationIndex] = destinationValue; + } + } + + // Copy binary image data to destination bitmap + Marshal.Copy(destinationBuffer, 0, destinationData.Scan0, imageSize); + + // Unlock destination bitmap + destination.UnlockBits(destinationData); + + // Dispose of source if not originally supplied bitmap + if (source != pimage) + { + source.Dispose(); + } + + // Return + return destination; + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Drawing/ColorRepresentationHelper.cs b/Source/ryControls/Sheng.Winform.Controls/Drawing/ColorRepresentationHelper.cs new file mode 100644 index 0000000..69f8e16 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Drawing/ColorRepresentationHelper.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; +using System.Reflection; + +namespace Sheng.Winform.Controls.Drawing +{ + public enum ChooseColorType + { + /// + /// 自定义 + /// + Custom = 0, + /// + /// 预置 + /// + Define = 1, + /// + /// 系统 + /// + System = 2 + } + + /// + /// 颜色表示法 + /// + public class ColorRepresentationHelper + { + /// + /// 根据颜色表示字符串获取对应的颜色 + /// + /// + /// + public static Color GetColorByValue(string colorValueString) + { + if (colorValueString == null || colorValueString == String.Empty) + { + return Color.Empty; + } + + string[] strArray = colorValueString.Split('.'); + + ChooseColorType type = + (ChooseColorType)Convert.ToInt32(strArray[0]); + Color color = Color.Empty; + switch (type) + { + case ChooseColorType.Custom: + color = Color.FromArgb(Convert.ToInt32(strArray[2])); + break; + case ChooseColorType.Define: + color = Color.FromArgb(Convert.ToInt32(strArray[2])); + break; + case ChooseColorType.System: + Type typeSystemColors = typeof(System.Drawing.SystemColors); + PropertyInfo p = typeSystemColors.GetProperty(strArray[1]); + color = (Color)p.GetValue(typeSystemColors, null); + break; + } + + return color; + } + + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Drawing/DrawingTool.cs b/Source/ryControls/Sheng.Winform.Controls/Drawing/DrawingTool.cs new file mode 100644 index 0000000..135198a --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Drawing/DrawingTool.cs @@ -0,0 +1,494 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Drawing.Drawing2D; +using System.Runtime.InteropServices; +using System.Diagnostics; + +namespace Sheng.Winform.Controls.Drawing +{ + public static class DrawingTool + { + #region GetImage + + public static Image GetImage(string filePath) + { + return GetImage(filePath, true); + } + + public static Image GetImage(string filePath, bool memberCopy) + { + return GetImage(filePath, memberCopy, false); + } + + /// + /// 从文件中获取Image对象 + /// 这个函数的主要功能是处理一些ico文件 + /// 一些ico文件的格式可能比较新,直接Image.FormFile,会报内存不足的异常 + /// + /// + /// 是否将文件读入内存操作,如果为false,将直接返回Image.FromFile,在此情况下, + /// 必须手动释放Image对象,否则文件将一直处于占用状态,如果为true,则在内存中拷贝副本 + /// + public static Image GetImage(string filePath,bool memberCopy, bool markNotFind) + { + FileInfo file = new FileInfo(filePath); + Image image = null; + + if (!file.Exists) + { + if (markNotFind) + { + image = new Bitmap(16, 16); + Mark.FileNotFind(image); + return image; + } + else + { + return null; + } + } + + + switch (file.Extension.ToLower()) + { + case ".ico": try + { + Icon icon = new Icon(file.FullName); + image = icon.ToBitmap(); + } + catch + { + image = new Bitmap(16, 16); + Mark.FileCanNotRead(image); + } + break; + default: + if (memberCopy) + { + Image imgTemp = Image.FromFile(file.FullName); + image = new System.Drawing.Bitmap(imgTemp); + imgTemp.Dispose(); + } + else + { + // Image.FromFile(file.FullName);会使文件一直处于被占用状态,必须手动释放 + image = Image.FromFile(file.FullName); + } + break; + } + + return image; + } + + #endregion + + #region ImageToIcon + + /// + /// 将图像转为Icon对象,使用png格式 + /// + /// + /// + public static Icon ImageToIcon(Image image) + { + return ImageToIcon(image, ImageFormat.Png); + } + + /// + /// 将图像转为Icon对象 + /// + /// + /// + /// + public static Icon ImageToIcon(Image image, ImageFormat format) + { + System.IO.Stream ms = new MemoryStream(); + image.Save(ms, format); + Icon icon = Icon.FromHandle(new Bitmap(ms).GetHicon()); + ms.Close(); + return icon; + } + + #endregion + + #region GetScaleImage + + /// + /// 返回适应指定容器大小的图像 + /// 如果图像的尺寸(长或宽)超出了容器范围,将按比例获取图像的缩略图返回,否则直接返回图像 + /// 此方法最终调用 Image.GetThumbnailImage + /// 但是注意,在指定的容器尺寸过小时,返回的Image尺寸不可知,是在为了显示16x16的小缩略图是发现了此问题 + /// 使用 GetScaleImage + /// + /// + /// + /// + /// + public static Image GetAutoScaleThumbnailImage(Image image, int containerWidth, int containerHeight) + { + if (image.Size.Width > containerWidth || + image.Size.Height > containerHeight) + { + double height = containerHeight; + double width = containerWidth; + + double new_height; + double new_width; + double scale; + new_height = height; + new_width = width; + if ((image.Width > width) || (image.Height > height)) + { + if (image.Width > width) + { + scale = image.Width / width; + new_width = image.Width / scale; + new_height = image.Height / scale; + } + else + { + scale = image.Height / height; + new_width = image.Width / scale; + new_height = image.Height / scale; + } + } + + return image.GetThumbnailImage(Convert.ToInt32(new_width), Convert.ToInt32(new_height), + thumbnailCallback, IntPtr.Zero); + + } + else + { + return image; + } + + } + + static Image.GetThumbnailImageAbort thumbnailCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback); + private static bool ThumbnailCallback() + { + return false; + } + + /// + /// 返回适应指定容器大小的图像 + /// 在需要的情况下,此方法创建一个新对象,进行绘制 + /// + /// + /// + /// + /// + public static Image GetScaleImage(Image image, Size size) + { + if (image.Size.Width > size.Width || + image.Size.Height > size.Height) + { + double width = size.Width; + double height = size.Height; + + double new_width; + double new_height; + double scale; + new_height = height; + new_width = width; + if ((image.Width > width) || (image.Height > height)) + { + if (image.Width > width) + { + scale = image.Width / width; + new_width = image.Width / scale; + new_height = image.Height / scale; + } + else + { + scale = image.Height / height; + new_width = image.Width / scale; + new_height = image.Height / scale; + } + } + + Bitmap bitmap = new Bitmap(Convert.ToInt32(new_width), Convert.ToInt32(new_height)); + + Graphics g = Graphics.FromImage(bitmap); + + g.DrawImage(image, 0, 0, bitmap.Width, bitmap.Height); + + return bitmap; + } + else + { + return image; + } + } + + /// + /// 返回适应指定容器大小的图像 + /// 在需要的情况下,此方法创建一个新对象,进行绘制 + /// + /// + /// + /// + /// + public static Image GetScaleImage(Image image, int containerWidth, int containerHeight) + { + if (containerWidth == null || containerHeight == null) + { + Debug.Assert(false, "containerWidth 或 containerHeight为空"); + throw new ArgumentNullException(); + } + + return GetScaleImage(image, new Size(containerWidth, containerHeight)); + } + + #endregion + + /// + /// Gets the bounding rectangle of an image required to fit + /// in to the given rectangle keeping the image aspect ratio. + /// + /// The source image. + /// The rectangle to fit in to. + /// Horizontal image aligment in percent. + /// Vertical image aligment in percent. + /// New image size. + public static Rectangle GetSizedImageBounds(Image image, Rectangle fit, float hAlign, float vAlign) + { + if (hAlign < 0 || hAlign > 100.0f) + throw new ArgumentException("hAlign must be between 0.0 and 100.0 (inclusive).", "hAlign"); + if (vAlign < 0 || vAlign > 100.0f) + throw new ArgumentException("vAlign must be between 0.0 and 100.0 (inclusive).", "vAlign"); + Size scaled = GetSizedImageBounds(image, fit.Size); + int x = fit.Left + (int)(hAlign / 100.0f * (float)(fit.Width - scaled.Width)); + int y = fit.Top + (int)(vAlign / 100.0f * (float)(fit.Height - scaled.Height)); + + return new Rectangle(x, y, scaled.Width, scaled.Height); + } + /// + /// Gets the bounding rectangle of an image required to fit + /// in to the given rectangle keeping the image aspect ratio. + /// The image will be centered in the fit box. + /// + /// The source image. + /// The rectangle to fit in to. + /// New image size. + public static Rectangle GetSizedImageBounds(Image image, Rectangle fit) + { + return GetSizedImageBounds(image, fit, 50.0f, 50.0f); + } + + /// + /// Gets the scaled size of an image required to fit + /// in to the given size keeping the image aspect ratio. + /// + /// The source image. + /// The size to fit in to. + /// New image size. + public static Size GetSizedImageBounds(Image image, Size fit) + { + float f = System.Math.Max((float)image.Width / (float)fit.Width, (float)image.Height / (float)fit.Height); + if (f < 1.0f) f = 1.0f; // Do not upsize small images + int width = (int)System.Math.Round((float)image.Width / f); + int height = (int)System.Math.Round((float)image.Height / f); + return new Size(width, height); + } + + + #region RoundedRect + + /// + /// 获取一个圆角矩形 + /// + /// + /// + /// 角度 + /// + public static GraphicsPath RoundedRect(int width, int height, int radius) + { + RectangleF baseRect = new RectangleF(0, 0, width, height); + return RoundedRect(baseRect, radius); + } + + /// + /// 获取一个圆角矩形 + /// + /// + /// + /// 角度 + /// + public static GraphicsPath RoundedRect(RectangleF baseRect, int radius) + { + //RectangleF baseRect = new RectangleF(0, 0, width, height); + float diameter = radius * 2.0f; + SizeF sizeF = new SizeF(diameter, diameter); + RectangleF arc = new RectangleF(baseRect.Location, sizeF); + GraphicsPath path = new GraphicsPath(); + + // top left arc + path.AddArc(arc, 180, 90); + + // top right arc + arc.X = baseRect.Right - diameter; + path.AddArc(arc, 270, 90); + + // bottom right arc + arc.Y = baseRect.Bottom - diameter; + path.AddArc(arc, 0, 90); + + // bottom left arc + arc.X = baseRect.Left; + path.AddArc(arc, 90, 90); + + path.CloseFigure(); + return path; + } + + #endregion + + #region GetArrowPath + + public static GraphicsPath GetArrowPath(PointF startPoint, PointF endPoint) + { + return GetArrowPath(startPoint, endPoint, 7); + } + + public static GraphicsPath GetArrowPath(PointF startPoint, PointF endPoint, double arrowLength) + { + return GetArrowPath(startPoint, endPoint, arrowLength, 1); + } + + /// + /// 返回一个表示箭头的Path + /// 如果开始坐标和结束坐标之间的距离大于箭头的大小,箭头向结束坐标对齐,顶着结束坐标 + /// + /// 开始坐标 + /// 结束坐标(顶点,方向) + /// 箭头的长短,大小 + /// 箭头的粗细 + /// + public static GraphicsPath GetArrowPath(PointF startPoint, PointF endPoint, + double arrowLength, double relativeValue) + { + //http://www.cnblogs.com/jasenkin/archive/2011/01/04/graphic_drawing_arrow_head_II.html + + double distance = Math.Abs(Math.Sqrt( + (startPoint.X - endPoint.X) * (startPoint.X - endPoint.X) + + (startPoint.Y - endPoint.Y) * (startPoint.Y - endPoint.Y))); + + if (distance == 0) + { + return new GraphicsPath(); + } + + double xa = endPoint.X + arrowLength * ((startPoint.X - endPoint.X) + + (startPoint.Y - endPoint.Y) / relativeValue) / distance; + double ya = endPoint.Y + arrowLength * ((startPoint.Y - endPoint.Y) + - (startPoint.X - endPoint.X) / relativeValue) / distance; + double xb = endPoint.X + arrowLength * ((startPoint.X - endPoint.X) + - (startPoint.Y - endPoint.Y) / relativeValue) / distance; + double yb = endPoint.Y + arrowLength * ((startPoint.Y - endPoint.Y) + + (startPoint.X - endPoint.X) / relativeValue) / distance; + + PointF[] polygonPoints = + { + new PointF(endPoint.X , endPoint.Y), + new PointF( (float)xa , (float)ya), + new PointF( (float)xb , (float)yb) + }; + + GraphicsPath path = new GraphicsPath(); + path.AddLines(polygonPoints); + + return path; + } + + + #endregion + + #region Mark + + /// + /// 在指定的Image上绘制特定标记 + /// + public static class Mark + { + /// + /// 文件不存在 + /// + /// + [Obsolete("改用 FileNotFind(Size size)")] + public static void FileNotFind(Image image) + { + if (image == null) + { + Debug.Assert(false, "image = null"); + return; + } + + Graphics g = Graphics.FromImage(image); + g.DrawRectangle(Pens.Red, 0, 0, image.Width - 1, image.Height - 1); + g.DrawLine(Pens.Red, 0, 0, image.Width, image.Height); + g.DrawLine(Pens.Red, image.Width, 0, 0, image.Height); + g.Dispose(); + } + + /// + /// 文件不存在 + /// + /// + public static Image FileNotFind(Size size) + { + Image image = new Bitmap(size.Width, size.Height); + + Graphics g = Graphics.FromImage(image); + g.Clear(Color.White); + g.DrawRectangle(Pens.Red, 0, 0, image.Width - 1, image.Height - 1); + g.DrawLine(Pens.Red, 0, 0, image.Width, image.Height); + g.DrawLine(Pens.Red, image.Width, 0, 0, image.Height); + g.Dispose(); + + return image; + } + + /// + /// 无法读取文件 + /// + /// + [Obsolete("改用 FileCanNotRead(Size size)")] + public static void FileCanNotRead(Image image) + { + if (image == null) + { + Debug.Assert(false, "image = null"); + return; + } + + Graphics g = Graphics.FromImage(image); + g.DrawRectangle(Pens.Red, 0, 0, image.Width - 1, image.Height - 1); + g.DrawLine(Pens.Red, 0, 0, image.Width, image.Height); + g.DrawLine(Pens.Red, image.Width, 0, 0, image.Height); + g.Dispose(); + } + + public static Image FileCanNotRead(Size size) + { + Image image = new Bitmap(size.Width, size.Height); + + Graphics g = Graphics.FromImage(image); + g.Clear(Color.White); + g.DrawRectangle(Pens.Red, 0, 0, image.Width - 1, image.Height - 1); + g.DrawLine(Pens.Red, 0, 0, image.Width, image.Height); + g.DrawLine(Pens.Red, image.Width, 0, 0, image.Height); + g.Dispose(); + + return image; + } + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Drawing/GraphPlotting.cs b/Source/ryControls/Sheng.Winform.Controls/Drawing/GraphPlotting.cs new file mode 100644 index 0000000..f3ae27c --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Drawing/GraphPlotting.cs @@ -0,0 +1,268 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; +using System.Runtime.InteropServices; +using System.Drawing.Imaging; + +namespace SEDrawing +{ + public class GraphPlotting + { + /// + /// 最大圆角半径 + /// + protected const int roundMaxRoundRadius = 3; + /// + /// 最小矩形边长,用于自动处理圆角大小 + /// + protected const int roundMinBorderLength = 20; + + /// + /// 绘制一个圆角矩形. + /// + /// 当前屏幕的图形对象 + /// 矩形线条的颜色 + /// 矩形左上角X坐标 + /// 矩形左上角Y坐标 + /// 矩形右下角X坐标 + /// 矩形右下角Y坐标 + /// 圆角的半径长度 + public static void DrawRoundRect(System.Drawing.Graphics currentGraphicObject, Pen drawPen, int nLeft, int nTop, int nRight, int nBottom, int round) + { + if (round > roundMaxRoundRadius) + { + round = roundMaxRoundRadius; + } + else if (round < 0) + { + round = 0; + } + if (Math.Abs(nRight - nLeft) < roundMinBorderLength && Math.Abs(nBottom - nTop) < roundMinBorderLength) + { + round = 1; + } + + Point Polygon1 = new Point(nLeft + round, nTop); + Point Polygon2 = new Point(nRight - round + 1, nTop); + + Point Polygon3 = new Point(nLeft, nTop + round); + Point Polygon4 = new Point(nRight + 1, nTop + round); + + Point Polygon5 = new Point(nLeft, nBottom - round); + Point Polygon6 = new Point(nRight + 1, nBottom - round); + + Point Polygon7 = new Point(nLeft + round, nBottom + 1); + Point Polygon8 = new Point(nRight - round, nBottom + 1); + + //四条主线(上下左右) + currentGraphicObject.DrawLine(drawPen, Polygon1.X, Polygon1.Y, Polygon2.X, Polygon2.Y); + currentGraphicObject.DrawLine(drawPen, Polygon7.X, Polygon7.Y, Polygon8.X, Polygon8.Y); + currentGraphicObject.DrawLine(drawPen, Polygon3.X, Polygon3.Y, Polygon5.X, Polygon5.Y); + currentGraphicObject.DrawLine(drawPen, Polygon4.X, Polygon4.Y, Polygon6.X, Polygon6.Y); + + //四个边角 + currentGraphicObject.DrawLine(drawPen, Polygon1.X, Polygon1.Y, Polygon3.X, Polygon3.Y); + currentGraphicObject.DrawLine(drawPen, Polygon2.X, Polygon2.Y, Polygon4.X, Polygon4.Y); + currentGraphicObject.DrawLine(drawPen, Polygon5.X, Polygon5.Y, Polygon7.X, Polygon7.Y); + currentGraphicObject.DrawLine(drawPen, Polygon6.X, Polygon6.Y, Polygon8.X, Polygon8.Y); + } + /// + /// 绘制一个圆角矩形. + /// + /// 当前屏幕的图形对象 + /// 矩形线条的颜色 + /// 要绘制的矩形对象 + /// 圆角的半径长度 + public static void DrawRoundRect(System.Drawing.Graphics currentGraphicObject, Pen drawPen, Rectangle rect, int round) + { + DrawRoundRect(currentGraphicObject, drawPen, rect.Left, rect.Top, rect.Right, rect.Bottom, round); + } + /// + /// 绘制一个圆角矩形. + /// + /// 当前屏幕的图形对象 + /// 矩形线条的颜色 + /// 要绘制的矩形对象 + public static void DrawRoundRect(System.Drawing.Graphics currentGraphicObject, Pen drawPen, Rectangle rect) + { + DrawRoundRect(currentGraphicObject, drawPen, rect.Left, rect.Top, rect.Right, rect.Bottom, 2); + } + + /// + /// 填充一个圆角矩形. + /// + /// 当前屏幕的图形对象 + /// 矩形线条的颜色 + /// 矩形左上角X坐标 + /// 矩形左上角Y坐标 + /// 矩形右下角X坐标 + /// 矩形右下角Y坐标 + /// 圆角的半径长度 + public static void FillRoundRect(System.Drawing.Graphics currentGraphicObject, Brush brush, int nLeft, int nTop, int nRight, int nBottom, int round) + { + if (round > roundMaxRoundRadius) + { + round = roundMaxRoundRadius; + } + else if (round < 0) + { + round = 0; + } + if (Math.Abs(nRight - nLeft) < roundMinBorderLength && Math.Abs(nBottom - nTop) < roundMinBorderLength) + { + round = 1; + } + + Point Polygon1 = new Point(nLeft + round, nTop); + Point Polygon2 = new Point(nRight - round + 1, nTop); + + Point Polygon3 = new Point(nLeft, nTop + round); + Point Polygon4 = new Point(nRight + 1, nTop + round); + + Point Polygon5 = new Point(nLeft, nBottom - round); + Point Polygon6 = new Point(nRight + 1, nBottom - round); + + Point Polygon7 = new Point(nLeft + round, nBottom + 1); + Point Polygon8 = new Point(nRight - round, nBottom + 1); + + currentGraphicObject.FillPolygon(brush, new Point[]{ Polygon1, + Polygon3, + Polygon5, + Polygon7, + Polygon8, + Polygon6, + Polygon4, + Polygon2}); + } + /// + /// 填充一个圆角矩形. + /// + /// 当前屏幕的图形对象 + /// 矩形线条的颜色 + /// 要填充的矩形 + /// 填充区域针对矩形的缩进距离 + /// 圆角的半径长度 + public static void FillRoundRect(System.Drawing.Graphics currentGraphicObject, Brush brush, Rectangle rect, int indentSize, int round) + { + FillRoundRect(currentGraphicObject, brush, rect.Left + indentSize, rect.Top + indentSize, rect.Right - indentSize + 1, rect.Bottom - indentSize + 1, round); + } + /// + /// 填充一个圆角矩形. + /// + /// 当前屏幕的图形对象 + /// 矩形线条的颜色 + /// 要填充的矩形 + public static void FillRoundRect(System.Drawing.Graphics currentGraphicObject, Brush brush, Rectangle rect) + { + FillRoundRect(currentGraphicObject, brush, rect, 0, 2); + } + + /// + /// 使图片单色化 + /// + /// + /// + public static Bitmap MonochromeLockBits(Bitmap pimage) + { + Bitmap source = null; + + // If original bitmap is not already in 32 BPP, ARGB format, then convert + if (pimage.PixelFormat != PixelFormat.Format32bppArgb) + { + source = new Bitmap(pimage.Width, pimage.Height, PixelFormat.Format32bppArgb); + source.SetResolution(pimage.HorizontalResolution, pimage.VerticalResolution); + using (Graphics g = Graphics.FromImage(source)) + { + g.DrawImageUnscaled(pimage, 0, 0); + } + } + else + { + source = pimage; + } + + // Lock source bitmap in memory + BitmapData sourceData = source.LockBits(new Rectangle(0, 0, source.Width, source.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); + + // Copy image data to binary array + int imageSize = sourceData.Stride * sourceData.Height; + byte[] sourceBuffer = new byte[imageSize]; + Marshal.Copy(sourceData.Scan0, sourceBuffer, 0, imageSize); + + // Unlock source bitmap + source.UnlockBits(sourceData); + + // Create destination bitmap + Bitmap destination = new Bitmap(source.Width, source.Height, PixelFormat.Format1bppIndexed); + + // Lock destination bitmap in memory + BitmapData destinationData = destination.LockBits(new Rectangle(0, 0, destination.Width, destination.Height), ImageLockMode.WriteOnly, PixelFormat.Format1bppIndexed); + + // Create destination buffer + imageSize = destinationData.Stride * destinationData.Height; + byte[] destinationBuffer = new byte[imageSize]; + + int sourceIndex = 0; + int destinationIndex = 0; + int pixelTotal = 0; + byte destinationValue = 0; + int pixelValue = 128; + int height = source.Height; + int width = source.Width; + int threshold = 500; + + // Iterate lines + for (int y = 0; y < height; y++) + { + sourceIndex = y * sourceData.Stride; + destinationIndex = y * destinationData.Stride; + destinationValue = 0; + pixelValue = 128; + + // Iterate pixels + for (int x = 0; x < width; x++) + { + // Compute pixel brightness (i.e. total of Red, Green, and Blue values) + pixelTotal = sourceBuffer[sourceIndex + 1] + sourceBuffer[sourceIndex + 2] + sourceBuffer[sourceIndex + 3]; + if (pixelTotal > threshold) + { + destinationValue += (byte)pixelValue; + } + if (pixelValue == 1) + { + destinationBuffer[destinationIndex] = destinationValue; + destinationIndex++; + destinationValue = 0; + pixelValue = 128; + } + else + { + pixelValue >>= 1; + } + sourceIndex += 4; + } + if (pixelValue != 128) + { + destinationBuffer[destinationIndex] = destinationValue; + } + } + + // Copy binary image data to destination bitmap + Marshal.Copy(destinationBuffer, 0, destinationData.Scan0, imageSize); + + // Unlock destination bitmap + destination.UnlockBits(destinationData); + + // Dispose of source if not originally supplied bitmap + if (source != pimage) + { + source.Dispose(); + } + + // Return + return destination; + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Drawing/GraphicsExtension.cs b/Source/ryControls/Sheng.Winform.Controls/Drawing/GraphicsExtension.cs new file mode 100644 index 0000000..4d34671 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Drawing/GraphicsExtension.cs @@ -0,0 +1,454 @@ +/* GraphicsExtension - [Extended Graphics] + * Author name: Arun Reginald Zaheeruddin + * Current version: 1.0.0.4 (12b) + * Release documentation: http://www.codeproject.com + * License information: Microsoft Public License (Ms-PL) [http://www.opensource.org/licenses/ms-pl.html] + * + * Enhancements and history + * ------------------------ + * 1.0.0.1 (20 Jul 2009): Initial release with modified code from previous CodeProject article. + * 1.0.0.2 (25 Jul 2009): Added functionality that allows selected corners on a rectangle to be rounded. + * Modified code to adapt to an anti-aliased output while drawing and filling rounded rectangles. + * 1.0.0.3 (26 Jul 2009): Added DrawRoundedRectangle and FillRoundedRectangle methods that take a Rectangle and RectangleF object. + * 1.0.0.4 (27 Jul 2009): Added font metrics and measuring utility that measures a font's height, leading, ascent, etc. + * + * Issues addressed + * ---------------- + * 1. Rounded rectangles - rounding edges of a rectangle. + * 2. Font Metrics - Measuring a font's height, leading, ascent, etc. + */ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Runtime.InteropServices; + +namespace Sheng.Winform.Controls.Drawing +{ + static class GraphicsExtension + { + private static GraphicsPath GenerateRoundedRectangle( + this Graphics graphics, + RectangleF rectangle, + float radius, + RectangleEdgeFilter filter) + { + float diameter; + GraphicsPath path = new GraphicsPath(); + if (radius <= 0.0F || filter == RectangleEdgeFilter.None) + { + path.AddRectangle(rectangle); + path.CloseFigure(); + return path; + } + else + { + if (radius >= (Math.Min(rectangle.Width, rectangle.Height)) / 2.0) + return graphics.GenerateCapsule(rectangle); + diameter = radius * 2.0F; + SizeF sizeF = new SizeF(diameter, diameter); + RectangleF arc = new RectangleF(rectangle.Location, sizeF); + if ((RectangleEdgeFilter.TopLeft & filter) == RectangleEdgeFilter.TopLeft) + path.AddArc(arc, 180, 90); + else + { + path.AddLine(arc.X, arc.Y + arc.Height, arc.X, arc.Y); + path.AddLine(arc.X, arc.Y, arc.X + arc.Width, arc.Y); + } + arc.X = rectangle.Right - diameter; + if ((RectangleEdgeFilter.TopRight & filter) == RectangleEdgeFilter.TopRight) + path.AddArc(arc, 270, 90); + else + { + path.AddLine(arc.X, arc.Y, arc.X + arc.Width, arc.Y); + path.AddLine(arc.X + arc.Width, arc.Y + arc.Height, arc.X + arc.Width, arc.Y); + } + arc.Y = rectangle.Bottom - diameter; + if ((RectangleEdgeFilter.BottomRight & filter) == RectangleEdgeFilter.BottomRight) + path.AddArc(arc, 0, 90); + else + { + path.AddLine(arc.X + arc.Width, arc.Y, arc.X + arc.Width, arc.Y + arc.Height); + path.AddLine(arc.X, arc.Y + arc.Height, arc.X + arc.Width, arc.Y + arc.Height); + } + arc.X = rectangle.Left; + if ((RectangleEdgeFilter.BottomLeft & filter) == RectangleEdgeFilter.BottomLeft) + path.AddArc(arc, 90, 90); + else + { + path.AddLine(arc.X + arc.Width, arc.Y + arc.Height, arc.X, arc.Y + arc.Height); + path.AddLine(arc.X, arc.Y + arc.Height, arc.X, arc.Y); + } + path.CloseFigure(); + } + return path; + } + private static GraphicsPath GenerateCapsule( + this Graphics graphics, + RectangleF rectangle) + { + float diameter; + RectangleF arc; + GraphicsPath path = new GraphicsPath(); + try + { + if (rectangle.Width > rectangle.Height) + { + diameter = rectangle.Height; + SizeF sizeF = new SizeF(diameter, diameter); + arc = new RectangleF(rectangle.Location, sizeF); + path.AddArc(arc, 90, 180); + arc.X = rectangle.Right - diameter; + path.AddArc(arc, 270, 180); + } + else if (rectangle.Width < rectangle.Height) + { + diameter = rectangle.Width; + SizeF sizeF = new SizeF(diameter, diameter); + arc = new RectangleF(rectangle.Location, sizeF); + path.AddArc(arc, 180, 180); + arc.Y = rectangle.Bottom - diameter; + path.AddArc(arc, 0, 180); + } + else path.AddEllipse(rectangle); + } + catch { path.AddEllipse(rectangle); } + finally { path.CloseFigure(); } + return path; + } + public static void DrawRoundedRectangle( + this Graphics graphics, + Pen pen, + float x, + float y, + float width, + float height, + float radius, + RectangleEdgeFilter filter) + { + RectangleF rectangle = new RectangleF(x, y, width, height); + GraphicsPath path = graphics.GenerateRoundedRectangle(rectangle, radius, filter); + SmoothingMode old = graphics.SmoothingMode; + graphics.SmoothingMode = SmoothingMode.AntiAlias; + graphics.DrawPath(pen, path); + graphics.SmoothingMode = old; + } + public static void DrawRoundedRectangle( + this Graphics graphics, + Pen pen, + float x, + float y, + float width, + float height, + float radius) + { + graphics.DrawRoundedRectangle( + pen, + x, + y, + width, + height, + radius, + RectangleEdgeFilter.All); + } + public static void DrawRoundedRectangle( + this Graphics graphics, + Pen pen, + int x, + int y, + int width, + int height, + int radius) + { + graphics.DrawRoundedRectangle( + pen, + Convert.ToSingle(x), + Convert.ToSingle(y), + Convert.ToSingle(width), + Convert.ToSingle(height), + Convert.ToSingle(radius)); + } + public static void DrawRoundedRectangle( + this Graphics graphics, + Pen pen, + Rectangle rectangle, + int radius, + RectangleEdgeFilter filter) + { + graphics.DrawRoundedRectangle( + pen, + rectangle.X, + rectangle.Y, + rectangle.Width, + rectangle.Height, + radius, + filter); + } + public static void DrawRoundedRectangle( + this Graphics graphics, + Pen pen, + Rectangle rectangle, + int radius) + { + graphics.DrawRoundedRectangle( + pen, + rectangle.X, + rectangle.Y, + rectangle.Width, + rectangle.Height, + radius, + RectangleEdgeFilter.All); + } + public static void DrawRoundedRectangle( + this Graphics graphics, + Pen pen, + RectangleF rectangle, + int radius, + RectangleEdgeFilter filter) + { + graphics.DrawRoundedRectangle( + pen, + rectangle.X, + rectangle.Y, + rectangle.Width, + rectangle.Height, + radius, + filter); + } + public static void DrawRoundedRectangle( + this Graphics graphics, + Pen pen, + RectangleF rectangle, + int radius) + { + graphics.DrawRoundedRectangle( + pen, + rectangle.X, + rectangle.Y, + rectangle.Width, + rectangle.Height, + radius, + RectangleEdgeFilter.All); + } + public static void FillRoundedRectangle( + this Graphics graphics, + Brush brush, + float x, + float y, + float width, + float height, + float radius, + RectangleEdgeFilter filter) + { + RectangleF rectangle = new RectangleF(x, y, width, height); + GraphicsPath path = graphics.GenerateRoundedRectangle(rectangle, radius, filter); + SmoothingMode old = graphics.SmoothingMode; + graphics.SmoothingMode = SmoothingMode.AntiAlias; + graphics.FillPath(brush, path); + graphics.SmoothingMode = old; + } + public static void FillRoundedRectangle( + this Graphics graphics, + Brush brush, + float x, + float y, + float width, + float height, + float radius) + { + graphics.FillRoundedRectangle( + brush, + x, + y, + width, + height, + radius, + RectangleEdgeFilter.All); + } + public static void FillRoundedRectangle( + this Graphics graphics, + Brush brush, + int x, + int y, + int width, + int height, + int radius) + { + graphics.FillRoundedRectangle( + brush, + Convert.ToSingle(x), + Convert.ToSingle(y), + Convert.ToSingle(width), + Convert.ToSingle(height), + Convert.ToSingle(radius)); + } + public static void FillRoundedRectangle( + this Graphics graphics, + Brush brush, + Rectangle rectangle, + int radius, + RectangleEdgeFilter filter) + { + graphics.FillRoundedRectangle( + brush, + rectangle.X, + rectangle.Y, + rectangle.Width, + rectangle.Height, + radius, + filter); + } + public static void FillRoundedRectangle( + this Graphics graphics, + Brush brush, + Rectangle rectangle, + int radius) + { + graphics.FillRoundedRectangle( + brush, + rectangle.X, + rectangle.Y, + rectangle.Width, + rectangle.Height, + radius, + RectangleEdgeFilter.All); + } + public static void FillRoundedRectangle( + this Graphics graphics, + Brush brush, + RectangleF rectangle, + int radius, + RectangleEdgeFilter filter) + { + graphics.FillRoundedRectangle( + brush, + rectangle.X, + rectangle.Y, + rectangle.Width, + rectangle.Height, + radius, + filter); + } + public static void FillRoundedRectangle( + this Graphics graphics, + Brush brush, + RectangleF rectangle, + int radius) + { + graphics.FillRoundedRectangle( + brush, + rectangle.X, + rectangle.Y, + rectangle.Width, + rectangle.Height, + radius, + RectangleEdgeFilter.All); + } + public static FontMetrics GetFontMetrics( + this Graphics graphics, + Font font) + { + return FontMetricsImpl.GetFontMetrics(graphics, font); + } + private class FontMetricsImpl : FontMetrics + { + [StructLayout(LayoutKind.Sequential)] + public struct TEXTMETRIC + { + public int tmHeight; + public int tmAscent; + public int tmDescent; + public int tmInternalLeading; + public int tmExternalLeading; + public int tmAveCharWidth; + public int tmMaxCharWidth; + public int tmWeight; + public int tmOverhang; + public int tmDigitizedAspectX; + public int tmDigitizedAspectY; + public char tmFirstChar; + public char tmLastChar; + public char tmDefaultChar; + public char tmBreakChar; + public byte tmItalic; + public byte tmUnderlined; + public byte tmStruckOut; + public byte tmPitchAndFamily; + public byte tmCharSet; + } + [DllImport("gdi32.dll", CharSet = CharSet.Unicode)] + public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj); + [DllImport("gdi32.dll", CharSet = CharSet.Unicode)] + public static extern bool GetTextMetrics(IntPtr hdc, out TEXTMETRIC lptm); + [DllImport("gdi32.dll", CharSet = CharSet.Unicode)] + public static extern bool DeleteObject(IntPtr hdc); + private TEXTMETRIC GenerateTextMetrics( + Graphics graphics, + Font font) + { + IntPtr hDC = IntPtr.Zero; + TEXTMETRIC textMetric; + IntPtr hFont = IntPtr.Zero; + try + { + hDC = graphics.GetHdc(); + hFont = font.ToHfont(); + IntPtr hFontDefault = SelectObject(hDC, hFont); + bool result = GetTextMetrics(hDC, out textMetric); + SelectObject(hDC, hFontDefault); + } + finally + { + if (hFont != IntPtr.Zero) DeleteObject(hFont); + if (hDC != IntPtr.Zero) graphics.ReleaseHdc(hDC); + } + return textMetric; + } + private TEXTMETRIC metrics; + public override int Height { get { return this.metrics.tmHeight; } } + public override int Ascent { get { return this.metrics.tmAscent; } } + public override int Descent { get { return this.metrics.tmDescent; } } + public override int InternalLeading { get { return this.metrics.tmInternalLeading; } } + public override int ExternalLeading { get { return this.metrics.tmExternalLeading; } } + public override int AverageCharacterWidth { get { return this.metrics.tmAveCharWidth; } } + public override int MaximumCharacterWidth { get { return this.metrics.tmMaxCharWidth; } } + public override int Weight { get { return this.metrics.tmWeight; } } + public override int Overhang { get { return this.metrics.tmOverhang; } } + public override int DigitizedAspectX { get { return this.metrics.tmDigitizedAspectX; } } + public override int DigitizedAspectY { get { return this.metrics.tmDigitizedAspectY; } } + private FontMetricsImpl(Graphics graphics, Font font) + { + this.metrics = this.GenerateTextMetrics(graphics, font); + } + public static FontMetrics GetFontMetrics( + Graphics graphics, + Font font) + { + return new FontMetricsImpl(graphics, font); + } + } + + public enum RectangleEdgeFilter + { + None = 0, + TopLeft = 1, + TopRight = 2, + BottomLeft = 4, + BottomRight = 8, + All = TopLeft | TopRight | BottomLeft | BottomRight + } + public abstract class FontMetrics + { + public virtual int Height { get { return 0; } } + public virtual int Ascent { get { return 0; } } + public virtual int Descent { get { return 0; } } + public virtual int InternalLeading { get { return 0; } } + public virtual int ExternalLeading { get { return 0; } } + public virtual int AverageCharacterWidth { get { return 0; } } + public virtual int MaximumCharacterWidth { get { return 0; } } + public virtual int Weight { get { return 0; } } + public virtual int Overhang { get { return 0; } } + public virtual int DigitizedAspectX { get { return 0; } } + public virtual int DigitizedAspectY { get { return 0; } } + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/IShengValidate.cs b/Source/ryControls/Sheng.Winform.Controls/IShengValidate.cs new file mode 100644 index 0000000..f5fae1b --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/IShengValidate.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sheng.Winform.Controls +{ + public delegate bool CustomValidateMethod(object sender, out string msg); + + interface IShengValidate + { + /// + /// 验证失败中显示错误信息时用的标题 + /// + string Title { get; set; } + + /// + /// 验证失败时是否需要高亮显示(改变背景色) + /// + bool HighLight { get; set; } + + /// + /// 验证控件的输入 + /// + /// + /// + bool SEValidate(out string msg); + + /// + /// 自定义验证方法 + /// 在基础验证都通过后,才会调用自定义验证方法(如果有) + /// + CustomValidateMethod CustomValidate { get; set; } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Kernal/EnvironmentHelper.cs b/Source/ryControls/Sheng.Winform.Controls/Kernal/EnvironmentHelper.cs new file mode 100644 index 0000000..e28c287 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Kernal/EnvironmentHelper.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Sheng.Winform.Controls.Win32; + +namespace Sheng.Winform.Controls.Kernal +{ + public static class EnvironmentHelper + { + /// + /// 是否支持 Windows Vista 以上的玻璃效果 + /// + public static bool SupportAreo + { + get + { + if (Environment.OSVersion.Version.Major < 6) + { + return false; + } + + return true; + } + } + + /// + /// 是否打开了玻璃效果 + /// + public static bool DwmIsCompositionEnabled + { + get + { + return DwmApi.DwmIsCompositionEnabled(); + } + } + + /// + /// 获取应用程序主窗体 + /// + public static System.Windows.Forms.Form MainForm + { + get; + set; + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/ConstructorInvoker.cs b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/ConstructorInvoker.cs new file mode 100644 index 0000000..61e588f --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/ConstructorInvoker.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Reflection; +using System.Linq.Expressions; + +namespace Sheng.Winform.Controls.Kernal +{ + public interface IConstructorInvoker + { + object Invoke(params object[] parameters); + } + + public class ConstructorInvoker : IConstructorInvoker + { + private Func m_invoker; + + public ConstructorInfo ConstructorInfo { get; private set; } + + public ConstructorInvoker(ConstructorInfo constructorInfo) + { + this.ConstructorInfo = constructorInfo; + this.m_invoker = InitializeInvoker(constructorInfo); + } + + private Func InitializeInvoker(ConstructorInfo constructorInfo) + { + // Target: (object)new T((T0)parameters[0], (T1)parameters[1], ...) + + // parameters to execute + var parametersParameter = Expression.Parameter(typeof(object[]), "parameters"); + + // build parameter list + var parameterExpressions = new List(); + var paramInfos = constructorInfo.GetParameters(); + for (int i = 0; i < paramInfos.Length; i++) + { + // (Ti)parameters[i] + var valueObj = Expression.ArrayIndex(parametersParameter, Expression.Constant(i)); + var valueCast = Expression.Convert(valueObj, paramInfos[i].ParameterType); + + parameterExpressions.Add(valueCast); + } + + // new T((T0)parameters[0], (T1)parameters[1], ...) + var instanceCreate = Expression.New(constructorInfo, parameterExpressions); + + // (object)new T((T0)parameters[0], (T1)parameters[1], ...) + var instanceCreateCast = Expression.Convert(instanceCreate, typeof(object)); + + var lambda = Expression.Lambda>(instanceCreateCast, parametersParameter); + + return lambda.Compile(); + } + + public object Invoke(params object[] parameters) + { + return this.m_invoker(parameters); + } + + #region IConstructorInvoker Members + + object IConstructorInvoker.Invoke(params object[] parameters) + { + return this.Invoke(parameters); + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/ConstructorInvokerPool.cs b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/ConstructorInvokerPool.cs new file mode 100644 index 0000000..ece6702 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/ConstructorInvokerPool.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Reflection; +using System.Diagnostics; + +namespace Sheng.Winform.Controls.Kernal +{ + public class ConstructorInvokerPool : FastReflectionPool + { + public ConstructorInvokerPool() + { + CustomCompare = true; + } + + protected override bool Compare(Type[] key1, Type[] key2) + { + return key1.SequenceEqual(key2); + } + + protected override IConstructorInvoker Create(Type type, Type[] key) + { + if (type == null || key == null) + { + Debug.Assert(false, "type 或 key 为空"); + throw new ArgumentNullException(); + } + + ConstructorInfo constructorInfo = type.GetConstructor(key); + + if (constructorInfo == null) + { + Debug.Assert(false, "没有指定的ConstructorInfo"); + throw new InvalidOperationException(); + } + + return new ConstructorInvoker(constructorInfo); + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/FastReflectionPool.cs b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/FastReflectionPool.cs new file mode 100644 index 0000000..c6d7761 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/FastReflectionPool.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Reflection; + +namespace Sheng.Winform.Controls.Kernal +{ + /* + * 想用 Dictionary> + * 因为用于获取类构造函数的方法, type.GetConstructor + * 接收的是一个Types数组,而一般的GetProperty,GetMethod接收的都是一个String + * 构造函数接收的是Types数组,光光用Types数组做为缓存的Key + * 是没意义的,因为两个同样内容的数组Eques是不会相同的,必须使用扩展方法判断数组的内容是否相同 + * 所以用 GetAccessorKeyFunc 来专门为以Type数组做为缓存的构造函数Cache查找缓存中的key + * 但是用object的话,在构造函数缓存中定位key时,每次都要进行Type数组和object的转换 + * 比较麻烦,也可能会消耗性能,FastReflection的目的就是追求高性能, + * 所以加一个TKeyType来标识key的类型 + */ + //这个缓存是全局的 + public abstract class FastReflectionPool : IFastReflectionPool + { + private object _mutex = new object(); + + private Dictionary> _cache = + new Dictionary>(); + + private bool _customCompare = false; + public bool CustomCompare { get { return _customCompare; } set { _customCompare = value; } } + protected virtual bool Compare(TKeyType key1, TKeyType key2) + { + return false; + } + + public TAccessor Get(Type type, TKeyType key) + { + TAccessor accessor; + Dictionary accessorCache; + + if (this._cache.TryGetValue(type, out accessorCache)) + { + TKeyType accessorKey; + if (_customCompare) + { + accessorKey = accessorCache.Keys.Single((k) => { return Compare(k, key); }); + } + else + { + accessorKey = key; + } + + if (accessorCache.TryGetValue(key, out accessor)) + { + return accessor; + } + } + + lock (_mutex) + { + if (this._cache.ContainsKey(type) == false) + { + this._cache[type] = new Dictionary(); + } + + accessor = Create(type, key); + this._cache[type][key] = accessor; + + return accessor; + } + } + + protected abstract TAccessor Create(Type type, TKeyType key); + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/FieldAccessor.cs b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/FieldAccessor.cs new file mode 100644 index 0000000..e141d14 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/FieldAccessor.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Reflection; +using System.Linq.Expressions; + +namespace Sheng.Winform.Controls.Kernal +{ + public interface IFieldAccessor + { + object GetValue(object instance); + } + + public class FieldAccessor : IFieldAccessor + { + private Func m_getter; + + public FieldInfo FieldInfo { get; private set; } + + public FieldAccessor(FieldInfo fieldInfo) + { + this.FieldInfo = fieldInfo; + } + + private void InitializeGet(FieldInfo fieldInfo) + { + // target: (object)(((TInstance)instance).Field) + + // preparing parameter, object type + var instance = Expression.Parameter(typeof(object), "instance"); + + // non-instance for static method, or ((TInstance)instance) + var instanceCast = fieldInfo.IsStatic ? null : + Expression.Convert(instance, fieldInfo.ReflectedType); + + // ((TInstance)instance).Property + var fieldAccess = Expression.Field(instanceCast, fieldInfo); + + // (object)(((TInstance)instance).Property) + var castFieldValue = Expression.Convert(fieldAccess, typeof(object)); + + // Lambda expression + var lambda = Expression.Lambda>(castFieldValue, instance); + + this.m_getter = lambda.Compile(); + } + + public object GetValue(object instance) + { + return this.m_getter(instance); + } + + #region IFieldAccessor Members + + object IFieldAccessor.GetValue(object instance) + { + return this.GetValue(instance); + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/FieldAccessorPool.cs b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/FieldAccessorPool.cs new file mode 100644 index 0000000..8ab1403 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/FieldAccessorPool.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Reflection; +using System.Diagnostics; + +namespace Sheng.Winform.Controls.Kernal +{ + public class FieldAccessorPool : FastReflectionPool + { + protected override IFieldAccessor Create(Type type, string key) + { + if (type == null || String.IsNullOrEmpty(key)) + { + Debug.Assert(false, "type 或 key 为空"); + throw new ArgumentNullException(); + } + + FieldInfo fieldInfo = type.GetField(key); + + if (fieldInfo == null) + { + Debug.Assert(false, "没有指定的FieldInfo:" + key); + throw new MissingFieldException(key); + } + + return new FieldAccessor(fieldInfo); + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/IFastReflectionPool.cs b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/IFastReflectionPool.cs new file mode 100644 index 0000000..9564fb9 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/IFastReflectionPool.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sheng.Winform.Controls.Kernal +{ + public interface IFastReflectionPool + { + TAccessor Get(Type type, TKeyType key); + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/MethodInvoker.cs b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/MethodInvoker.cs new file mode 100644 index 0000000..f5b5dbb --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/MethodInvoker.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Reflection; +using System.Linq.Expressions; + +namespace Sheng.Winform.Controls.Kernal +{ + public interface IMethodInvoker + { + object Invoke(object instance, params object[] parameters); + } + + public class MethodInvoker : IMethodInvoker + { + private Func m_invoker; + + public MethodInfo MethodInfo { get; private set; } + + public MethodInvoker(MethodInfo methodInfo) + { + this.MethodInfo = methodInfo; + this.m_invoker = CreateInvokeDelegate(methodInfo); + } + + public object Invoke(object instance, params object[] parameters) + { + return this.m_invoker(instance, parameters); + } + + private static Func CreateInvokeDelegate(MethodInfo methodInfo) + { + // Target: ((TInstance)instance).Method((T0)parameters[0], (T1)parameters[1], ...) + + // parameters to execute + var instanceParameter = Expression.Parameter(typeof(object), "instance"); + var parametersParameter = Expression.Parameter(typeof(object[]), "parameters"); + + // build parameter list + var parameterExpressions = new List(); + var paramInfos = methodInfo.GetParameters(); + for (int i = 0; i < paramInfos.Length; i++) + { + // (Ti)parameters[i] + BinaryExpression valueObj = Expression.ArrayIndex( + parametersParameter, Expression.Constant(i)); + UnaryExpression valueCast = Expression.Convert( + valueObj, paramInfos[i].ParameterType); + + parameterExpressions.Add(valueCast); + } + + // non-instance for static method, or ((TInstance)instance) + var instanceCast = methodInfo.IsStatic ? null : + Expression.Convert(instanceParameter, methodInfo.ReflectedType); + + // static invoke or ((TInstance)instance).Method + var methodCall = Expression.Call(instanceCast, methodInfo, parameterExpressions); + + // ((TInstance)instance).Method((T0)parameters[0], (T1)parameters[1], ...) + if (methodCall.Type == typeof(void)) + { + var lambda = Expression.Lambda>( + methodCall, instanceParameter, parametersParameter); + + Action execute = lambda.Compile(); + return (instance, parameters) => + { + execute(instance, parameters); + return null; + }; + } + else + { + var castMethodCall = Expression.Convert(methodCall, typeof(object)); + var lambda =Expression.Lambda>( + castMethodCall, instanceParameter, parametersParameter); + + return lambda.Compile(); + } + } + + #region IMethodInvoker Members + + object IMethodInvoker.Invoke(object instance, params object[] parameters) + { + return this.Invoke(instance, parameters); + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/MethodInvokerPool.cs b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/MethodInvokerPool.cs new file mode 100644 index 0000000..c89e420 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/MethodInvokerPool.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Reflection; +using System.Diagnostics; + +namespace Sheng.Winform.Controls.Kernal +{ + public class MethodInvokerPool : FastReflectionPool + { + protected override IMethodInvoker Create(Type type, string key) + { + if (type == null || String.IsNullOrEmpty(key)) + { + Debug.Assert(false, "type 或 key 为空"); + throw new ArgumentNullException(); + } + + MethodInfo methodInfo = type.GetMethod(key); + + if (methodInfo == null) + { + Debug.Assert(false, "没有指定的MethodInfo:" + key); + throw new MissingMemberException(key); + } + + return new MethodInvoker(methodInfo); + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/PropertyAccessor.cs b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/PropertyAccessor.cs new file mode 100644 index 0000000..6fc3913 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/PropertyAccessor.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Linq.Expressions; +using System.Reflection; + +namespace Sheng.Winform.Controls.Kernal +{ + public interface IPropertyAccessor + { + object GetValue(object instance); + + void SetValue(object instance, object value); + } + + public class PropertyAccessor : IPropertyAccessor + { + private Func m_getter; + private MethodInvoker m_setMethodInvoker; + + public PropertyInfo PropertyInfo { get; private set; } + + public PropertyAccessor(PropertyInfo propertyInfo) + { + this.PropertyInfo = propertyInfo; + this.InitializeGet(propertyInfo); + this.InitializeSet(propertyInfo); + } + + private void InitializeGet(PropertyInfo propertyInfo) + { + if (!propertyInfo.CanRead) return; + + // Target: (object)(((TInstance)instance).Property) + + // preparing parameter, object type + var instance = Expression.Parameter(typeof(object), "instance"); + + // non-instance for static method, or ((TInstance)instance) + var instanceCast = propertyInfo.GetGetMethod(true).IsStatic ? null : + Expression.Convert(instance, propertyInfo.ReflectedType); + + // ((TInstance)instance).Property + var propertyAccess = Expression.Property(instanceCast, propertyInfo); + + // (object)(((TInstance)instance).Property) + var castPropertyValue = Expression.Convert(propertyAccess, typeof(object)); + + // Lambda expression + var lambda = Expression.Lambda>(castPropertyValue, instance); + + this.m_getter = lambda.Compile(); + } + + private void InitializeSet(PropertyInfo propertyInfo) + { + if (!propertyInfo.CanWrite) return; + this.m_setMethodInvoker = new MethodInvoker(propertyInfo.GetSetMethod(true)); + } + + public object GetValue(object o) + { + if (this.m_getter == null) + { + throw new NotSupportedException("Get method is not defined for this property."); + } + + return this.m_getter(o); + } + + public void SetValue(object o, object value) + { + if (this.m_setMethodInvoker == null) + { + throw new NotSupportedException("Set method is not defined for this property."); + } + + this.m_setMethodInvoker.Invoke(o, new object[] { value }); + } + + #region IPropertyAccessor Members + + object IPropertyAccessor.GetValue(object instance) + { + return this.GetValue(instance); + } + + void IPropertyAccessor.SetValue(object instance, object value) + { + this.SetValue(instance, value); + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/PropertyAccessorPool.cs b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/PropertyAccessorPool.cs new file mode 100644 index 0000000..47e83b4 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/PropertyAccessorPool.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Reflection; +using System.Diagnostics; + +namespace Sheng.Winform.Controls.Kernal +{ + public class PropertyAccessorPool : FastReflectionPool + { + protected override IPropertyAccessor Create(Type type, string key) + { + if (type == null || String.IsNullOrEmpty(key)) + { + Debug.Assert(false, "type 或 key 为空"); + throw new ArgumentNullException(); + } + + PropertyInfo propertyInfo = type.GetProperty(key); + + if (propertyInfo == null) + { + Debug.Assert(false, "没有指定的PropertyInfo:" + key); + throw new MissingMemberException(key); + } + + return new PropertyAccessor(propertyInfo); + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/ReflectionPool.cs b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/ReflectionPool.cs new file mode 100644 index 0000000..0d6a62a --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Kernal/FastReflection/ReflectionPool.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Diagnostics; + +namespace Sheng.Winform.Controls.Kernal +{ + public static class ReflectionPool + { + private static ConstructorInvokerPool _constructorInvokerPool = new ConstructorInvokerPool(); + + private static FieldAccessorPool _fieldAccessorPool = new FieldAccessorPool(); + + private static MethodInvokerPool _methodInvokerPool = new MethodInvokerPool(); + + private static PropertyAccessorPool _propertyAccessorPool = new PropertyAccessorPool(); + + static ReflectionPool() + { + } + + public static object GetPropertyValue(object instance, string propertyName) + { + if (instance == null || String.IsNullOrEmpty(propertyName)) + { + Debug.Assert(false, "instance 或 propertyName 为空"); + throw new ArgumentNullException(); + } + + return _propertyAccessorPool.Get(instance.GetType(), propertyName).GetValue(instance); + } + + public static void SetPropertyValue(object instance, string propertyName, object value) + { + if (instance == null || String.IsNullOrEmpty(propertyName)) + { + Debug.Assert(false, "instance 或 propertyName 为空"); + throw new ArgumentNullException(); + } + + _propertyAccessorPool.Get(instance.GetType(), propertyName).SetValue(instance, value); + } + + public static object GetFieldValue(object instance, string fieldName) + { + if (instance == null || String.IsNullOrEmpty(fieldName)) + { + Debug.Assert(false, "instance 或 fieldName 为空"); + throw new ArgumentNullException(); + } + + return _fieldAccessorPool.Get(instance.GetType(), fieldName).GetValue(instance); + } + + public static object GetMethodValue(object instance, string methodName) + { + if (instance == null || String.IsNullOrEmpty(methodName)) + { + Debug.Assert(false, "instance 或 methodName 为空"); + throw new ArgumentNullException(); + } + + return _methodInvokerPool.Get(instance.GetType(), methodName).Invoke(instance); + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Kernal/ImageAndTypeMappingCodon.cs b/Source/ryControls/Sheng.Winform.Controls/Kernal/ImageAndTypeMappingCodon.cs new file mode 100644 index 0000000..927d783 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Kernal/ImageAndTypeMappingCodon.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; + +namespace Sheng.Winform.Controls.Kernal +{ + public class ImageAndTypeMappingCodon + { + private Type _dataBoundType; + /// + /// 所对应的绑定数据类型 + /// + public Type DataBoundType + { + get { return _dataBoundType; } + set { _dataBoundType = value; } + } + + private bool _actOnSubClass = false; + /// + /// 是否对 DataBoundType 的子类型有效 + /// 默认无效 + /// 如果设置为 true,又同时添加了基类与子类的 codon,则运行时会取到哪个codon不确定 + /// 通常取先添加的那个 + /// + public bool ActOnSubClass + { + get { return _actOnSubClass; } + set { _actOnSubClass = value; } + } + + private Image _image; + public Image Image + { + get { return _image; } + set { _image = value; } + } + + public ImageAndTypeMappingCodon(Type dataBoundType, Image image) + : this(dataBoundType, image, false) + { + + } + + public ImageAndTypeMappingCodon(Type dataBoundType, Image image, bool actOnSubClass) + { + _dataBoundType = dataBoundType; + _image = image; + _actOnSubClass = actOnSubClass; + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Kernal/Localisation/LocalisationHelper.cs b/Source/ryControls/Sheng.Winform.Controls/Kernal/Localisation/LocalisationHelper.cs new file mode 100644 index 0000000..a323dd0 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Kernal/Localisation/LocalisationHelper.cs @@ -0,0 +1,184 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Resources; +using System.Text.RegularExpressions; +using System.Windows.Forms; + +namespace Sheng.Winform.Controls.Kernal +{ + public class LocalisationHelper + { + #region 私有成员 + + private ResourceManager _resourceManager; + + //TODO:匹配窗体元素的正则没有使用零宽断言这一技术,有时间改进一下 + //取${}花括号中间的字符串 + /* + * 这是一个使用了零宽断言的表达式 + * (?<=exp) 匹配exp后面的位置 + * (?=exp) 匹配exp前面的位置 + * * 重复零次或更多次 + * + 重复一次或更多次 + * ? 重复零次或一次 + * {n} 重复n次 + * {n,} 重复n次或更多次 + * {n,m} 重复n到m次 + */ + private readonly static Regex patternInner = new Regex(@"(?<=\${)([^\}]*)?(?=\})", + RegexOptions.Compiled | RegexOptions.CultureInvariant); + + //取${}形式的完整字符串 + private readonly static Regex pattern = new Regex(@"\$\{[^\}]+\}", + RegexOptions.Compiled | RegexOptions.CultureInvariant); + + #endregion + + #region 构造 + + public LocalisationHelper(ResourceManager resourceManager) + { + _resourceManager = resourceManager; + } + + #endregion + + #region 公开方法 + + public string GetString(string name) + { + return _resourceManager.GetString(name); + } + + /// + /// 如果输入的字符串包含 "${...}" 这样的格式,则认为是指代资源文件中的一个字符串资源 + /// + /// + /// + public string Parse(string input) + { + if (input == null) + return String.Empty; + + string result = input; + string resString; + MatchCollection matchs = pattern.Matches(input); + foreach (Match match in matchs) + { + resString = GetString(patternInner.Match(match.Value).Value); + //防止界面上的${}串写错没有取到对应的资源文本 + if (resString != null) + { + resString = resString.Replace("$NewLine$", System.Environment.NewLine); + result = result.Replace(match.Value, resString); + } + else + { + //用一条斜杠表示没有拿到资源,以访问在一个大字符串中有没拿到的资源一时看不到 + result = result.Replace(match.Value, "/"); + } + } + + return result; + } + + #region ApplyResource , 为界面应用语言文本资源 + + public void ApplyResource(UserControl userControl) + { + userControl.Text = Parse(userControl.Text); + + foreach (Control control in userControl.Controls) + { + ApplyResource(control); + } + } + + public void ApplyResource(Form form) + { + form.Text = Parse(form.Text); + + foreach (Control control in form.Controls) + { + ApplyResource(control); + } + } + + public void ApplyResource(Control control) + { + control.Text = Parse(control.Text); + + if (control.Controls != null) + { + foreach (Control ctrl in control.Controls) + { + ApplyResource(ctrl); + } + } + + if (control.ContextMenuStrip != null) + { + ContextMenuStrip contextMenuStrip = control.ContextMenuStrip as ContextMenuStrip; + ApplyResource(contextMenuStrip); + } + + //如果是datagridview,为列头文本应用资料 + if (control is DataGridView) + { + DataGridView dataGridView = control as DataGridView; + ApplyResource(dataGridView); + } + + if (control is ToolStrip) + { + ToolStrip toolStrip = control as ToolStrip; + ApplyResource(toolStrip); + } + } + + public void ApplyResource(DataGridView dataGridView) + { + foreach (DataGridViewColumn column in dataGridView.Columns) + { + column.HeaderText = Parse(column.HeaderText); + } + } + + public void ApplyResource(ToolStrip toolStrip) + { + foreach (System.Windows.Forms.ToolStripItem item in toolStrip.Items) + { + item.Text = Parse(item.Text); + if (item is ToolStripDropDownItem) + { + ToolStripDropDownItem toolStripDropDownItem = item as ToolStripDropDownItem; + ApplyResource(toolStripDropDownItem.DropDownItems); + } + } + } + + public void ApplyResource(ContextMenuStrip contextMenuStrip) + { + ApplyResource(contextMenuStrip.Items); + } + + public void ApplyResource(ToolStripItemCollection items) + { + foreach (System.Windows.Forms.ToolStripItem item in items) + { + item.Text = Parse(item.Text); + if (item is ToolStripMenuItem) + { + ToolStripMenuItem toolStripMenuItem = item as ToolStripMenuItem; + ApplyResource(toolStripMenuItem.DropDownItems); + } + } + } + + #endregion + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/License/SEControlLicense.cs b/Source/ryControls/Sheng.Winform.Controls/License/SEControlLicense.cs new file mode 100644 index 0000000..e120708 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/License/SEControlLicense.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel; + +namespace Sheng.Winform.Controls +{ + class SEControlLicense : License + { + private Type _Type; + + public SEControlLicense(Type type) + { + if (type == null) + { + throw (new NullReferenceException()); + } + + _Type = type; + } + + public override void Dispose() + { + // 根据需要插入垃圾回收的代码 + } + + /// + /// 获取授予该组件的许可证密钥 + /// + public override string LicenseKey + { + get { return (_Type.GUID.ToString()); } + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/License/SEControlLicenseProvider.cs b/Source/ryControls/Sheng.Winform.Controls/License/SEControlLicenseProvider.cs new file mode 100644 index 0000000..aae2edf --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/License/SEControlLicenseProvider.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel; +using Microsoft.Win32; + +namespace Sheng.Winform.Controls +{ + class SEControlLicenseProvider : LicenseProvider + { + /// + /// 0:未验证 + /// 1:验证失败 + /// 2:验证通过 + /// + //private static ushort _isValid = 0; + public bool IsValid + { + get + { + //TODO:SEControlLicenseProvider + return true; + // using (RegistryKey registryKey = + // Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Sheng.SIMBE\SEControl")) + // { + // object license = registryKey.GetValue("License"); + // if (license == null) + // { + // _isValid = 1; + // } + // else + // { + // if (license.ToString() == "sheng") + // _isValid = 2; + // else + // _isValid = 1; + // } + // } + + //return _isValid == 2 ? true : false; + } + } + + /// + /// 获取组件的实例或类型的许可证(如果已给定上下文并确定拒绝许可证是否引发异常)。 + /// + /// + /// + /// + /// + /// + public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions) + { + if (context.UsageMode == LicenseUsageMode.Runtime) + { + return new SEControlLicense(type); + } + + else if (context.UsageMode == LicenseUsageMode.Designtime) + { + // 限制编辑模式下的许可证(所谓的开发许可证),在这里添加相应的逻辑 + + if (!IsValid) + throw new LicenseException(type); + else + return new SEControlLicense(type); + } + + return (null); + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/License/TextFile1.txt b/Source/ryControls/Sheng.Winform.Controls/License/TextFile1.txt new file mode 100644 index 0000000..87f5eed --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/License/TextFile1.txt @@ -0,0 +1,3 @@ +在注册表的 +LocalMachine:SOFTWARE\Sheng.SIMBE\SEControl +下,以一个 License 属性保存 sheng ,则允许使用 \ No newline at end of file diff --git a/Source/ryControls/Sheng.Winform.Controls/Localisation/Chinese (Simplified).Designer.cs b/Source/ryControls/Sheng.Winform.Controls/Localisation/Chinese (Simplified).Designer.cs new file mode 100644 index 0000000..3e5ee72 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Localisation/Chinese (Simplified).Designer.cs @@ -0,0 +1,142 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:2.0.50727.4927 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace Sheng.Winform.Controls.Localisation { + using System; + + + /// + /// 强类型资源类,用于查找本地化字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Chinese__Simplified_ : ILanguage { + + private global::System.Resources.ResourceManager resourceMan; + + private global::System.Globalization.CultureInfo resourceCulture; + + public Chinese__Simplified_() { + } + + /// + /// 返回此类使用的缓存 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Sheng.Winform.Controls.Localisation.Chinese (Simplified)", typeof(Chinese__Simplified_).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 为使用此强类型资源类的所有资源查找 + /// 重写当前线程的 CurrentUICulture 属性。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public global::System.Globalization.CultureInfo Culture { + get { + if (object.ReferenceEquals(resourceCulture, null)) { + global::System.Globalization.CultureInfo temp = new global::System.Globalization.CultureInfo("zh-CHS"); + resourceCulture = temp; + } + return resourceCulture; + } + } + + /// + /// 查找类似 消息 的本地化字符串。 + /// + public string MessageBoxCaptiton_Message { + get { + return ResourceManager.GetString("MessageBoxCaptiton_Message", resourceCulture); + } + } + + /// + /// 查找类似 底部 的本地化字符串。 + /// + public string SEPaginationDataGridView_EnumNavigationLocation_Bottom { + get { + return ResourceManager.GetString("SEPaginationDataGridView_EnumNavigationLocation_Bottom", resourceCulture); + } + } + + /// + /// 查找类似 顶部 的本地化字符串。 + /// + public string SEPaginationDataGridView_EnumNavigationLocation_Top { + get { + return ResourceManager.GetString("SEPaginationDataGridView_EnumNavigationLocation_Top", resourceCulture); + } + } + + /// + /// 查找类似 更大 (48x48) 的本地化字符串。 + /// + public string SEToolStripImageSize_ExtraLarge { + get { + return ResourceManager.GetString("SEToolStripImageSize_ExtraLarge", resourceCulture); + } + } + + /// + /// 查找类似 大 (32x32) 的本地化字符串。 + /// + public string SEToolStripImageSize_Large { + get { + return ResourceManager.GetString("SEToolStripImageSize_Large", resourceCulture); + } + } + + /// + /// 查找类似 中 (24x24) 的本地化字符串。 + /// + public string SEToolStripImageSize_Medium { + get { + return ResourceManager.GetString("SEToolStripImageSize_Medium", resourceCulture); + } + } + + /// + /// 查找类似 小 (16x16) 的本地化字符串。 + /// + public string SEToolStripImageSize_Small { + get { + return ResourceManager.GetString("SEToolStripImageSize_Small", resourceCulture); + } + } + + /// + /// Returns true if the current language is the default language. + /// + public bool IsDefault { + get { + return false; + } + } + + /// + /// Returns a System.String that represents the current System.Object. + /// + public override string ToString() { + return Culture.EnglishName; + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Localisation/Chinese (Simplified).resx b/Source/ryControls/Sheng.Winform.Controls/Localisation/Chinese (Simplified).resx new file mode 100644 index 0000000..adde55c --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Localisation/Chinese (Simplified).resx @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 消息 + + + 小 (16x16) + + + 中 (24x24) + + + 大 (32x32) + + + 更大 (48x48) + + + 底部 + + + 顶部 + + \ No newline at end of file diff --git a/Source/ryControls/Sheng.Winform.Controls/Localisation/ILanguage.cs b/Source/ryControls/Sheng.Winform.Controls/Localisation/ILanguage.cs new file mode 100644 index 0000000..b24d8bf --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Localisation/ILanguage.cs @@ -0,0 +1,89 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:2.0.50727.4927 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace Sheng.Winform.Controls.Localisation { + + + public interface ILanguage { + + /// + /// 返回此类使用的缓存 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + global::System.Resources.ResourceManager ResourceManager { + get; + } + + /// + /// 为使用此强类型资源类的所有资源查找 + /// 重写当前线程的 CurrentUICulture 属性。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + global::System.Globalization.CultureInfo Culture { + get; + } + + /// + /// 查找类似 消息 的本地化字符串。 + /// + string MessageBoxCaptiton_Message { + get; + } + + /// + /// 查找类似 底部 的本地化字符串。 + /// + string SEPaginationDataGridView_EnumNavigationLocation_Bottom { + get; + } + + /// + /// 查找类似 顶部 的本地化字符串。 + /// + string SEPaginationDataGridView_EnumNavigationLocation_Top { + get; + } + + /// + /// 查找类似 更大 (48x48) 的本地化字符串。 + /// + string SEToolStripImageSize_ExtraLarge { + get; + } + + /// + /// 查找类似 大 (32x32) 的本地化字符串。 + /// + string SEToolStripImageSize_Large { + get; + } + + /// + /// 查找类似 中 (24x24) 的本地化字符串。 + /// + string SEToolStripImageSize_Medium { + get; + } + + /// + /// 查找类似 小 (16x16) 的本地化字符串。 + /// + string SEToolStripImageSize_Small { + get; + } + + /// + /// Returns true if the current language is the default language. + /// + bool IsDefault { + get; + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Localisation/Language.cs b/Source/ryControls/Sheng.Winform.Controls/Localisation/Language.cs new file mode 100644 index 0000000..dfe4ba3 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Localisation/Language.cs @@ -0,0 +1,109 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:2.0.50727.3082 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +using System.Text.RegularExpressions; +using System.Resources; +namespace Sheng.Winform.Controls.Localisation { + + + public class Language { + + private static ILanguage _Language; + + private Language() { + } + + /// + /// Call GetLanguages() to retrieve a list of possible languages that can be used to set this property. + /// The default value is the default language. + /// + public static ILanguage Current { + get { + if ((_Language == null)) { + //System.Collections.Generic.List list = Language.GetLanguages(); + //for (int i = 0; (i < list.Count); i = (i + 1)) { + // if (list[i].IsDefault) { + // _Language = list[i]; + // return _Language; + // } + //} + + _Language = new Chinese__Simplified_(); + } + return _Language; + } + set { + _Language = value; + } + } + + /// + /// Gets a list of available languages defined in this assembly. + /// + public static System.Collections.Generic.List GetLanguages() { + System.Collections.Generic.List items = new System.Collections.Generic.List(); + System.Type[] exportedTypes = System.Reflection.Assembly.GetExecutingAssembly().GetExportedTypes(); + for (int i = 0; (i < exportedTypes.Length); i = (i + 1)) { + if (exportedTypes[i].IsClass) { + if ((exportedTypes[i].GetInterface("ILanguage") != null)) { + try { + object obj = System.Activator.CreateInstance(exportedTypes[i]); + ILanguage interfaceReference = ((ILanguage)(obj)); + if ((interfaceReference != null)) { + items.Add(interfaceReference); + } + } + catch (System.Exception ) { + } + } + } + } + return items; + } + + + public static string GetString(string name) + { + return Current.ResourceManager.GetString(name); + } + + //取${}花括号中间的字符串 + readonly static Regex patternInner = new Regex(@"(?<=\${)([^\}]*)?(?=\})", + RegexOptions.Compiled | RegexOptions.CultureInvariant); + + //取${}形式的完整字符串 + readonly static Regex pattern = new Regex(@"\$\{[^\}]+\}", + RegexOptions.Compiled | RegexOptions.CultureInvariant); + /// + /// 如果输入的字符串包含 "${...}" 这样的格式,则认为是指代资源文件中的一个字符串资源 + /// + /// + /// + public static string Parse(string input) + { + if (input == null) + { + return null; + } + + string result = input; + string resString; + MatchCollection matchs = pattern.Matches(input); + foreach (Match match in matchs) + { + resString = GetString(patternInner.Match(match.Value).Value); + resString = resString.Replace("$NewLine$", System.Environment.NewLine); + result = result.Replace(match.Value, resString); + } + + return result; + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/PopupControl/GripBounds.cs b/Source/ryControls/Sheng.Winform.Controls/PopupControl/GripBounds.cs new file mode 100644 index 0000000..669ce4d --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/PopupControl/GripBounds.cs @@ -0,0 +1,113 @@ +using System; +using System.Drawing; + +namespace Sheng.Winform.Controls.PopupControl +{ + internal struct GripBounds + { + private const int GripSize = 6; + private const int CornerGripSize = GripSize << 1; + + public GripBounds(Rectangle clientRectangle) + { + this.clientRectangle = clientRectangle; + } + + private Rectangle clientRectangle; + public Rectangle ClientRectangle + { + get { return clientRectangle; } + //set { clientRectangle = value; } + } + + public Rectangle Bottom + { + get + { + Rectangle rect = ClientRectangle; + rect.Y = rect.Bottom - GripSize + 1; + rect.Height = GripSize; + return rect; + } + } + + public Rectangle BottomRight + { + get + { + Rectangle rect = ClientRectangle; + rect.Y = rect.Bottom - CornerGripSize + 1; + rect.Height = CornerGripSize; + rect.X = rect.Width - CornerGripSize + 1; + rect.Width = CornerGripSize; + return rect; + } + } + + public Rectangle Top + { + get + { + Rectangle rect = ClientRectangle; + rect.Height = GripSize; + return rect; + } + } + + public Rectangle TopRight + { + get + { + Rectangle rect = ClientRectangle; + rect.Height = CornerGripSize; + rect.X = rect.Width - CornerGripSize + 1; + rect.Width = CornerGripSize; + return rect; + } + } + + public Rectangle Left + { + get + { + Rectangle rect = ClientRectangle; + rect.Width = GripSize; + return rect; + } + } + + public Rectangle BottomLeft + { + get + { + Rectangle rect = ClientRectangle; + rect.Width = CornerGripSize; + rect.Y = rect.Height - CornerGripSize + 1; + rect.Height = CornerGripSize; + return rect; + } + } + + public Rectangle Right + { + get + { + Rectangle rect = ClientRectangle; + rect.X = rect.Right - GripSize + 1; + rect.Width = GripSize; + return rect; + } + } + + public Rectangle TopLeft + { + get + { + Rectangle rect = ClientRectangle; + rect.Width = CornerGripSize; + rect.Height = CornerGripSize; + return rect; + } + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/PopupControl/NativeMethods.cs b/Source/ryControls/Sheng.Winform.Controls/PopupControl/NativeMethods.cs new file mode 100644 index 0000000..7d22e0e --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/PopupControl/NativeMethods.cs @@ -0,0 +1,93 @@ +using System; +using System.Drawing; +using System.Runtime.InteropServices; +using System.Windows.Forms; +using System.Security; +using System.Security.Permissions; + +namespace Sheng.Winform.Controls.PopupControl +{ + internal static class NativeMethods + { + internal const int WM_NCHITTEST = 0x0084, + WM_NCACTIVATE = 0x0086, + WS_EX_NOACTIVATE = 0x08000000, + HTTRANSPARENT = -1, + HTLEFT = 10, + HTRIGHT = 11, + HTTOP = 12, + HTTOPLEFT = 13, + HTTOPRIGHT = 14, + HTBOTTOM = 15, + HTBOTTOMLEFT = 16, + HTBOTTOMRIGHT = 17, + WM_PRINT = 0x0317, + WM_USER = 0x0400, + WM_REFLECT = WM_USER + 0x1C00, + WM_COMMAND = 0x0111, + CBN_DROPDOWN = 7, + WM_GETMINMAXINFO = 0x0024; + + + [Flags] + internal enum AnimationFlags : int + { + Roll = 0x0000, // Uses a roll animation. + HorizontalPositive = 0x00001, // Animates the window from left to right. This flag can be used with roll or slide animation. + HorizontalNegative = 0x00002, // Animates the window from right to left. This flag can be used with roll or slide animation. + VerticalPositive = 0x00004, // Animates the window from top to bottom. This flag can be used with roll or slide animation. + VerticalNegative = 0x00008, // Animates the window from bottom to top. This flag can be used with roll or slide animation. + Center = 0x00010, // Makes the window appear to collapse inward if Hide is used or expand outward if the Hide is not used. + Hide = 0x10000, // Hides the window. By default, the window is shown. + Activate = 0x20000, // Activates the window. + Slide = 0x40000, // Uses a slide animation. By default, roll animation is used. + Blend = 0x80000, // Uses a fade effect. This flag can be used only with a top-level window. + Mask = 0xfffff, + } + + [SuppressUnmanagedCodeSecurity] + [DllImport("user32.dll", CharSet = CharSet.Auto)] + private static extern int AnimateWindow(HandleRef windowHandle, int time, AnimationFlags flags); + + internal static void AnimateWindow(Control control, int time, AnimationFlags flags) + { + try + { + SecurityPermission sp = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode); + sp.Demand(); + AnimateWindow(new HandleRef(control, control.Handle), time, flags); + } + catch (SecurityException) { } + } + + internal static int HIWORD(int n) + { + return (n >> 16) & 0xffff; + } + + internal static int HIWORD(IntPtr n) + { + return HIWORD(unchecked((int)(long)n)); + } + + internal static int LOWORD(int n) + { + return n & 0xffff; + } + + internal static int LOWORD(IntPtr n) + { + return LOWORD(unchecked((int)(long)n)); + } + + [StructLayout(LayoutKind.Sequential)] + internal struct MINMAXINFO + { + public Point reserved; + public Size maxSize; + public Point maxPosition; + public Size minTrackSize; + public Size maxTrackSize; + } + } +} \ No newline at end of file diff --git a/Source/ryControls/Sheng.Winform.Controls/PopupControl/Popup.Designer.cs b/Source/ryControls/Sheng.Winform.Controls/PopupControl/Popup.Designer.cs new file mode 100644 index 0000000..59ac959 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/PopupControl/Popup.Designer.cs @@ -0,0 +1,45 @@ +namespace Sheng.Winform.Controls.PopupControl +{ + partial class Popup + { + /// + /// 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) + { + if (components != null) + { + components.Dispose(); + } + if (content != null) + { + System.Windows.Forms.Control _content = content; + content = null; + _content.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/PopupControl/Popup.cs b/Source/ryControls/Sheng.Winform.Controls/PopupControl/Popup.cs new file mode 100644 index 0000000..2159e6d --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/PopupControl/Popup.cs @@ -0,0 +1,626 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Text; +using System.Windows.Forms; +using System.Security.Permissions; +using System.Runtime.InteropServices; +using VS = System.Windows.Forms.VisualStyles; + +/* +
  • Base class for custom tooltips.
  • +
  • Office-2007-like tooltip class.
  • +*/ +namespace Sheng.Winform.Controls.PopupControl +{ + /// + /// Represents a pop-up window. + /// + //[CLSCompliant(true), ToolboxItem(false)] + public partial class Popup : ToolStripDropDown + { + #region " Fields & Properties " + + private Control content; + /// + /// Gets the content of the pop-up. + /// + public Control Content + { + get { return content; } + } + + private PopupAnimations showingAnimation; + /// + /// Determines which animation to use while showing the pop-up window. + /// + public PopupAnimations ShowingAnimation + { + get { return showingAnimation; } + set { if (showingAnimation != value) showingAnimation = value; } + } + + private PopupAnimations hidingAnimation; + /// + /// Determines which animation to use while hiding the pop-up window. + /// + public PopupAnimations HidingAnimation + { + get { return hidingAnimation; } + set { if (hidingAnimation != value) hidingAnimation = value; } + } + + private int animationDuration; + /// + /// Determines the duration of the animation. + /// + public int AnimationDuration + { + get { return animationDuration; } + set { if (animationDuration != value) animationDuration = value; } + } + + private bool focusOnOpen = true; + /// + /// Gets or sets a value indicating whether the content should receive the focus after the pop-up has been opened. + /// + /// true if the content should be focused after the pop-up has been opened; otherwise, false. + /// If the FocusOnOpen property is set to false, then pop-up cannot use the fade effect. + public bool FocusOnOpen + { + get { return focusOnOpen; } + set { focusOnOpen = value; } + } + + private bool acceptAlt = true; + /// + /// Gets or sets a value indicating whether presing the alt key should close the pop-up. + /// + /// true if presing the alt key does not close the pop-up; otherwise, false. + public bool AcceptAlt + { + get { return acceptAlt; } + set { acceptAlt = value; } + } + + private Control opener; + private Popup ownerPopup; + private Popup childPopup; + private bool resizableTop; + private bool resizableLeft; + + private bool isChildPopupOpened; + private bool resizable; + /// + /// Gets or sets a value indicating whether the is resizable. + /// + /// true if resizable; otherwise, false. + public bool Resizable + { + get { return resizable && !isChildPopupOpened; } + set { resizable = value; } + } + + private ToolStripControlHost host; + + private Size minSize; + /// + /// Gets or sets a minimum size of the pop-up. + /// + /// An ordered pair of type representing the width and height of a rectangle. + public new Size MinimumSize + { + get { return minSize; } + set { minSize = value; } + } + + private Size maxSize; + /// + /// Gets or sets a maximum size of the pop-up. + /// + /// An ordered pair of type representing the width and height of a rectangle. + public new Size MaximumSize + { + get { return maxSize; } + set { maxSize = value; } + } + + /// + /// Gets parameters of a new window. + /// + /// An object of type used when creating a new window. + protected override CreateParams CreateParams + { + [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] + get + { + CreateParams cp = base.CreateParams; + cp.ExStyle |= NativeMethods.WS_EX_NOACTIVATE; + return cp; + } + } + + #endregion + + #region " Constructors " + + /// + /// Initializes a new instance of the class. + /// + /// The content of the pop-up. + /// + /// Pop-up will be disposed immediately after disposion of the content control. + /// + /// is null. + public Popup(Control content) + { + if (content == null) + { + throw new ArgumentNullException("content"); + } + this.content = content; + this.showingAnimation = PopupAnimations.SystemDefault; + this.hidingAnimation = PopupAnimations.None; + this.animationDuration = 100; + this.isChildPopupOpened = false; + InitializeComponent(); + AutoSize = false; + DoubleBuffered = true; + ResizeRedraw = true; + host = new ToolStripControlHost(content); + Padding = Margin = host.Padding = host.Margin = Padding.Empty; + MinimumSize = content.MinimumSize; + content.MinimumSize = content.Size; + MaximumSize = content.MaximumSize; + content.MaximumSize = content.Size; + Size = content.Size; + TabStop = content.TabStop = true; + content.Location = Point.Empty; + Items.Add(host); + content.Disposed += delegate(object sender, EventArgs e) + { + content = null; + Dispose(true); + }; + content.RegionChanged += delegate(object sender, EventArgs e) + { + UpdateRegion(); + }; + content.Paint += delegate(object sender, PaintEventArgs e) + { + PaintSizeGrip(e); + }; + UpdateRegion(); + } + + #endregion + + #region " Methods " + + /// + /// Raises the event. + /// + /// An that contains the event data. + protected override void OnVisibleChanged(EventArgs e) + { + base.OnVisibleChanged(e); + if ((Visible && ShowingAnimation == PopupAnimations.None) || (!Visible && HidingAnimation == PopupAnimations.None)) + { + return; + } + NativeMethods.AnimationFlags flags = Visible ? NativeMethods.AnimationFlags.Roll : NativeMethods.AnimationFlags.Hide; + PopupAnimations _flags = Visible ? ShowingAnimation : HidingAnimation; + if (_flags == PopupAnimations.SystemDefault) + { + if (SystemInformation.IsMenuAnimationEnabled) + { + if (SystemInformation.IsMenuFadeEnabled) + { + _flags = PopupAnimations.Blend; + } + else + { + _flags = PopupAnimations.Slide | (Visible ? PopupAnimations.TopToBottom : PopupAnimations.BottomToTop); + } + } + else + { + _flags = PopupAnimations.None; + } + } + if ((_flags & (PopupAnimations.Blend | PopupAnimations.Center | PopupAnimations.Roll | PopupAnimations.Slide)) == PopupAnimations.None) + { + return; + } + if (resizableTop) // popup is “inverted”, so the animation must be + { + if ((_flags & PopupAnimations.BottomToTop) != PopupAnimations.None) + { + _flags = (_flags & ~PopupAnimations.BottomToTop) | PopupAnimations.TopToBottom; + } + else if ((_flags & PopupAnimations.TopToBottom) != PopupAnimations.None) + { + _flags = (_flags & ~PopupAnimations.TopToBottom) | PopupAnimations.BottomToTop; + } + } + if (resizableLeft) // popup is “inverted”, so the animation must be + { + if ((_flags & PopupAnimations.RightToLeft) != PopupAnimations.None) + { + _flags = (_flags & ~PopupAnimations.RightToLeft) | PopupAnimations.LeftToRight; + } + else if ((_flags & PopupAnimations.LeftToRight) != PopupAnimations.None) + { + _flags = (_flags & ~PopupAnimations.LeftToRight) | PopupAnimations.RightToLeft; + } + } + flags = flags | (NativeMethods.AnimationFlags.Mask & (NativeMethods.AnimationFlags)(int)_flags); + NativeMethods.AnimateWindow(this, AnimationDuration, flags); + } + + /// + /// Processes a dialog box key. + /// + /// One of the values that represents the key to process. + /// + /// true if the key was processed by the control; otherwise, false. + /// + [UIPermission(SecurityAction.LinkDemand, Window = UIPermissionWindow.AllWindows)] + protected override bool ProcessDialogKey(Keys keyData) + { + if (acceptAlt && ((keyData & Keys.Alt) == Keys.Alt)) + { + if ((keyData & Keys.F4) != Keys.F4) + { + return false; + } + else + { + this.Close(); + } + } + bool processed = base.ProcessDialogKey(keyData); + if (!processed && (keyData == Keys.Tab || keyData == (Keys.Tab | Keys.Shift))) + { + bool backward = (keyData & Keys.Shift) == Keys.Shift; + this.Content.SelectNextControl(null, !backward, true, true, true); + } + return processed; + } + + /// + /// Updates the pop-up region. + /// + protected void UpdateRegion() + { + if (this.Region != null) + { + this.Region.Dispose(); + this.Region = null; + } + if (content.Region != null) + { + this.Region = content.Region.Clone(); + } + } + + /// + /// Shows the pop-up window below the specified control. + /// + /// The control below which the pop-up will be shown. + /// + /// When there is no space below the specified control, the pop-up control is shown above it. + /// + /// is null. + public void Show(Control control) + { + if (control == null) + { + throw new ArgumentNullException("control"); + } + Show(control, control.ClientRectangle); + } + + /// + /// Shows the pop-up window below the specified area of the specified control. + /// + /// The control used to compute screen location of specified area. + /// The area of control below which the pop-up will be shown. + /// + /// When there is no space below specified area, the pop-up control is shown above it. + /// + /// is null. + public void Show(Control control, Rectangle area) + { + if (control == null) + { + throw new ArgumentNullException("control"); + } + SetOwnerItem(control); + + resizableTop = resizableLeft = false; + Point location = control.PointToScreen(new Point(area.Left, area.Top + area.Height)); + Rectangle screen = Screen.FromControl(control).WorkingArea; + if (location.X + Size.Width > (screen.Left + screen.Width)) + { + resizableLeft = true; + location.X = (screen.Left + screen.Width) - Size.Width; + } + if (location.Y + Size.Height > (screen.Top + screen.Height)) + { + resizableTop = true; + location.Y -= Size.Height + area.Height; + } + location = control.PointToClient(location); + Show(control, location, ToolStripDropDownDirection.BelowRight); + } + + private void SetOwnerItem(Control control) + { + if (control == null) + { + return; + } + if (control is Popup) + { + Popup popupControl = control as Popup; + ownerPopup = popupControl; + ownerPopup.childPopup = this; + OwnerItem = popupControl.Items[0]; + return; + } + else if (opener == null) + { + opener = control; + } + if (control.Parent != null) + { + SetOwnerItem(control.Parent); + } + } + + /// + /// Raises the event. + /// + /// An that contains the event data. + protected override void OnSizeChanged(EventArgs e) + { + content.MinimumSize = Size; + content.MaximumSize = Size; + content.Size = Size; + content.Location = Point.Empty; + base.OnSizeChanged(e); + } + + /// + /// Raises the event. + /// + /// A that contains the event data. + protected override void OnOpening(CancelEventArgs e) + { + if (content.IsDisposed || content.Disposing) + { + e.Cancel = true; + return; + } + UpdateRegion(); + base.OnOpening(e); + } + + /// + /// Raises the event. + /// + /// An that contains the event data. + protected override void OnOpened(EventArgs e) + { + if (ownerPopup != null) + { + ownerPopup.isChildPopupOpened = true; + } + if (focusOnOpen) + { + content.Focus(); + } + base.OnOpened(e); + } + + /// + /// Raises the event. + /// + /// A that contains the event data. + protected override void OnClosed(ToolStripDropDownClosedEventArgs e) + { + opener = null; + if (ownerPopup != null) + { + ownerPopup.isChildPopupOpened = false; + } + base.OnClosed(e); + } + + #endregion + + #region " Resizing Support " + + /// + /// Processes Windows messages. + /// + /// The Windows to process. + [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] + protected override void WndProc(ref Message m) + { + //if (m.Msg == NativeMethods.WM_PRINT && !Visible) + //{ + // Visible = true; + //} + if (InternalProcessResizing(ref m, false)) + { + return; + } + base.WndProc(ref m); + } + + /// + /// Processes the resizing messages. + /// + /// The message. + /// true, if the WndProc method from the base class shouldn't be invoked. + [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] + public bool ProcessResizing(ref Message m) + { + return InternalProcessResizing(ref m, true); + } + + [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] + private bool InternalProcessResizing(ref Message m, bool contentControl) + { + if (m.Msg == NativeMethods.WM_NCACTIVATE && m.WParam != IntPtr.Zero && childPopup != null && childPopup.Visible) + { + childPopup.Hide(); + } + if (!Resizable) + { + return false; + } + if (m.Msg == NativeMethods.WM_NCHITTEST) + { + return OnNcHitTest(ref m, contentControl); + } + else if (m.Msg == NativeMethods.WM_GETMINMAXINFO) + { + return OnGetMinMaxInfo(ref m); + } + return false; + } + + [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] + private bool OnGetMinMaxInfo(ref Message m) + { + NativeMethods.MINMAXINFO minmax = (NativeMethods.MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.MINMAXINFO)); + if (!this.MaximumSize.IsEmpty) + { + minmax.maxTrackSize = this.MaximumSize; + } + minmax.minTrackSize = this.MinimumSize; + Marshal.StructureToPtr(minmax, m.LParam, false); + return true; + } + + private bool OnNcHitTest(ref Message m, bool contentControl) + { + int x = NativeMethods.LOWORD(m.LParam); + int y = NativeMethods.HIWORD(m.LParam); + Point clientLocation = PointToClient(new Point(x, y)); + + GripBounds gripBouns = new GripBounds(contentControl ? content.ClientRectangle : ClientRectangle); + IntPtr transparent = new IntPtr(NativeMethods.HTTRANSPARENT); + + if (resizableTop) + { + if (resizableLeft && gripBouns.TopLeft.Contains(clientLocation)) + { + m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTTOPLEFT; + return true; + } + if (!resizableLeft && gripBouns.TopRight.Contains(clientLocation)) + { + m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTTOPRIGHT; + return true; + } + if (gripBouns.Top.Contains(clientLocation)) + { + m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTTOP; + return true; + } + } + else + { + if (resizableLeft && gripBouns.BottomLeft.Contains(clientLocation)) + { + m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTBOTTOMLEFT; + return true; + } + if (!resizableLeft && gripBouns.BottomRight.Contains(clientLocation)) + { + m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTBOTTOMRIGHT; + return true; + } + if (gripBouns.Bottom.Contains(clientLocation)) + { + m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTBOTTOM; + return true; + } + } + if (resizableLeft && gripBouns.Left.Contains(clientLocation)) + { + m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTLEFT; + return true; + } + if (!resizableLeft && gripBouns.Right.Contains(clientLocation)) + { + m.Result = contentControl ? transparent : (IntPtr)NativeMethods.HTRIGHT; + return true; + } + return false; + } + + private VS.VisualStyleRenderer sizeGripRenderer; + /// + /// Paints the sizing grip. + /// + /// The instance containing the event data. + public void PaintSizeGrip(PaintEventArgs e) + { + if (e == null || e.Graphics == null || !resizable) + { + return; + } + Size clientSize = content.ClientSize; + using (Bitmap gripImage = new Bitmap(0x10, 0x10)) + { + using (Graphics g = Graphics.FromImage(gripImage)) + { + if (Application.RenderWithVisualStyles) + { + if (this.sizeGripRenderer == null) + { + this.sizeGripRenderer = new VS.VisualStyleRenderer(VS.VisualStyleElement.Status.Gripper.Normal); + } + this.sizeGripRenderer.DrawBackground(g, new Rectangle(0, 0, 0x10, 0x10)); + } + else + { + ControlPaint.DrawSizeGrip(g, content.BackColor, 0, 0, 0x10, 0x10); + } + } + GraphicsState gs = e.Graphics.Save(); + e.Graphics.ResetTransform(); + if (resizableTop) + { + if (resizableLeft) + { + e.Graphics.RotateTransform(180); + e.Graphics.TranslateTransform(-clientSize.Width, -clientSize.Height); + } + else + { + e.Graphics.ScaleTransform(1, -1); + e.Graphics.TranslateTransform(0, -clientSize.Height); + } + } + else if (resizableLeft) + { + e.Graphics.ScaleTransform(-1, 1); + e.Graphics.TranslateTransform(-clientSize.Width, 0); + } + e.Graphics.DrawImage(gripImage, clientSize.Width - 0x10, clientSize.Height - 0x10 + 1, 0x10, 0x10); + e.Graphics.Restore(gs); + } + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/PopupControl/PopupAnimation.cs b/Source/ryControls/Sheng.Winform.Controls/PopupControl/PopupAnimation.cs new file mode 100644 index 0000000..7b05565 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/PopupControl/PopupAnimation.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Sheng.Winform.Controls.PopupControl +{ + /// + /// Types of animation of the pop-up window. + /// + [Flags] + public enum PopupAnimations : int + { + /// + /// Uses no animation. + /// + None = 0, + /// + /// Animates the window from left to right. This flag can be used with roll or slide animation. + /// + LeftToRight = 0x00001, + /// + /// Animates the window from right to left. This flag can be used with roll or slide animation. + /// + RightToLeft = 0x00002, + /// + /// Animates the window from top to bottom. This flag can be used with roll or slide animation. + /// + TopToBottom = 0x00004, + /// + /// Animates the window from bottom to top. This flag can be used with roll or slide animation. + /// + BottomToTop = 0x00008, + /// + /// Makes the window appear to collapse inward if it is hiding or expand outward if the window is showing. + /// + Center = 0x00010, + /// + /// Uses a slide animation. + /// + Slide = 0x40000, + /// + /// Uses a fade effect. + /// + Blend = 0x80000, + /// + /// Uses a roll animation. + /// + Roll = 0x100000, + /// + /// Uses a default animation. + /// + SystemDefault = 0x200000, + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/PopupControl/PopupComboBox.Designer.cs b/Source/ryControls/Sheng.Winform.Controls/PopupControl/PopupComboBox.Designer.cs new file mode 100644 index 0000000..314349e --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/PopupControl/PopupComboBox.Designer.cs @@ -0,0 +1,48 @@ +namespace Sheng.Winform.Controls.PopupControl +{ + partial class PopupComboBox + { + /// + /// 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) + { + if (components != null) + { + components.Dispose(); + } + if (dropDown != null) + { + dropDown.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Component 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(); + // + // PopupComboBox + // + this.ResumeLayout(false); + + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/PopupControl/PopupComboBox.cs b/Source/ryControls/Sheng.Winform.Controls/PopupControl/PopupComboBox.cs new file mode 100644 index 0000000..2983ade --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/PopupControl/PopupComboBox.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using System.Security.Permissions; + +namespace Sheng.Winform.Controls.PopupControl +{ + /// + /// Represents a Windows combo box control with a custom popup control attached. + /// + [ToolboxBitmap(typeof(System.Windows.Forms.ComboBox)), ToolboxItem(true), ToolboxItemFilter("System.Windows.Forms"), Description("Displays an editable text box with a drop-down list of permitted values.")] + public partial class PopupComboBox : PopupControlComboBoxBase + { + /// + /// Initializes a new instance of the class. + /// + public PopupComboBox() + { + this.dropDownHideTime = DateTime.UtcNow; + InitializeComponent(); + base.DropDownHeight = base.DropDownWidth = 1; + base.IntegralHeight = false; + } + + private Popup dropDown; + + private Control dropDownControl; + /// + /// Gets or sets the drop down control. + /// + /// The drop down control. + public Control DropDownControl + { + get + { + return dropDownControl; + } + set + { + if (dropDownControl == value) + { + return; + } + dropDownControl = value; + if (dropDown != null) + { + dropDown.Closed -= dropDown_Closed; + dropDown.Dispose(); + } + dropDown = new Popup(value); + dropDown.Closed += dropDown_Closed; + } + } + + private DateTime dropDownHideTime; + private void dropDown_Closed(object sender, ToolStripDropDownClosedEventArgs e) + { + dropDownHideTime = DateTime.UtcNow; + } + + /// + /// Gets or sets a value indicating whether the combo box is displaying its drop-down portion. + /// + /// + /// true if the drop-down portion is displayed; otherwise, false. The default is false. + /// + public new bool DroppedDown + { + get + { + return dropDown.Visible; + } + set + { + if (DroppedDown) + { + HideDropDown(); + } + else + { + ShowDropDown(); + } + } + } + + /// + /// Occurs when the drop-down portion of a is shown. + /// + public new event EventHandler DropDown; + + /// + /// Shows the drop down. + /// + public void ShowDropDown() + { + if (dropDown != null) + { + if ((DateTime.UtcNow - dropDownHideTime).TotalSeconds > 0.5) + { + if (DropDown != null) + { + DropDown(this, EventArgs.Empty); + } + dropDown.Show(this); + } + else + { + dropDownHideTime = DateTime.UtcNow.Subtract(new TimeSpan(0, 0, 1)); + Focus(); + } + } + } + + /// + /// Occurs when the drop-down portion of the is no longer visible. + /// + public new event EventHandler DropDownClosed; + + /// + /// Hides the drop down. + /// + public void HideDropDown() + { + if (dropDown != null) + { + dropDown.Hide(); + if (DropDownClosed != null) + { + DropDownClosed(this, EventArgs.Empty); + } + } + } + + /// + /// Processes Windows messages. + /// + /// The Windows to process. + [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] + protected override void WndProc(ref Message m) + { + if (m.Msg == (NativeMethods.WM_COMMAND + NativeMethods.WM_REFLECT) && NativeMethods.HIWORD(m.WParam) == NativeMethods.CBN_DROPDOWN) + { + ShowDropDown(); + return; + } + base.WndProc(ref m); + } + + #region " Unused Properties " + + /// This property is not relevant for this class. + /// This property is not relevant for this class. + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)] + public new int DropDownWidth + { + get { return base.DropDownWidth; } + set { base.DropDownWidth = value; } + } + + /// This property is not relevant for this class. + /// This property is not relevant for this class. + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)] + public new int DropDownHeight + { + get { return base.DropDownHeight; } + set { base.DropDownHeight = value; } + } + + /// This property is not relevant for this class. + /// This property is not relevant for this class. + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)] + public new bool IntegralHeight + { + get { return base.IntegralHeight; } + set { base.IntegralHeight = value; } + } + + /// This property is not relevant for this class. + /// This property is not relevant for this class. + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)] + public new ObjectCollection Items + { + get { return base.Items; } + } + + /// This property is not relevant for this class. + /// This property is not relevant for this class. + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)] + public new int ItemHeight + { + get { return base.ItemHeight; } + set { base.ItemHeight = value; } + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/PopupControl/PopupControlComboBoxBase.Designer.cs b/Source/ryControls/Sheng.Winform.Controls/PopupControl/PopupControlComboBoxBase.Designer.cs new file mode 100644 index 0000000..0cd4a0e --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/PopupControl/PopupControlComboBoxBase.Designer.cs @@ -0,0 +1,44 @@ +namespace Sheng.Winform.Controls.PopupControl +{ + partial class PopupControlComboBoxBase + { + /// + /// 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) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Component 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(); + // + // ComboBox + // + this.ResumeLayout(false); + + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/PopupControl/PopupControlComboBoxBase.cs b/Source/ryControls/Sheng.Winform.Controls/PopupControl/PopupControlComboBoxBase.cs new file mode 100644 index 0000000..6a4301a --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/PopupControl/PopupControlComboBoxBase.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using System.Reflection; + +namespace Sheng.Winform.Controls.PopupControl +{ + /// + /// Represents a Windows combo box control which can be used in a popup's content control. + /// + [ToolboxBitmap(typeof(System.Windows.Forms.ComboBox)), ToolboxItem(true), ToolboxItemFilter("System.Windows.Forms"), Description("Displays an editable text box with a drop-down list of permitted values.")] + public partial class PopupControlComboBoxBase : System.Windows.Forms.ComboBox + { + /// + /// Initializes a new instance of the class. + /// + public PopupControlComboBoxBase() + { + InitializeComponent(); + } + + private static Type _modalMenuFilter; + private static Type modalMenuFilter + { + get + { + if (_modalMenuFilter == null) + { + _modalMenuFilter = Type.GetType("System.Windows.Forms.ToolStripManager+ModalMenuFilter"); + } + if (_modalMenuFilter == null) + { + _modalMenuFilter = new List(typeof(ToolStripManager).Assembly.GetTypes()).Find( + delegate(Type type) + { + return type.FullName == "System.Windows.Forms.ToolStripManager+ModalMenuFilter"; + }); + } + return _modalMenuFilter; + } + } + + private static MethodInfo _suspendMenuMode; + private static MethodInfo suspendMenuMode + { + get + { + if (_suspendMenuMode == null) + { + Type t = modalMenuFilter; + if (t != null) + { + _suspendMenuMode = t.GetMethod("SuspendMenuMode", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); + } + } + return _suspendMenuMode; + } + } + + private static void SuspendMenuMode() + { + MethodInfo suspendMenuMode = PopupControlComboBoxBase.suspendMenuMode; + if (suspendMenuMode != null) + { + suspendMenuMode.Invoke(null, null); + } + } + + private static MethodInfo _resumeMenuMode; + private static MethodInfo resumeMenuMode + { + get + { + if (_resumeMenuMode == null) + { + Type t = modalMenuFilter; + if (t != null) + { + _resumeMenuMode = t.GetMethod("ResumeMenuMode", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); + } + } + return _resumeMenuMode; + } + } + + private static void ResumeMenuMode() + { + MethodInfo resumeMenuMode = PopupControlComboBoxBase.resumeMenuMode; + if (resumeMenuMode != null) + { + resumeMenuMode.Invoke(null, null); + } + } + + /// + /// Raises the event. + /// + /// An that contains the event data. + protected override void OnDropDown(EventArgs e) + { + base.OnDropDown(e); + SuspendMenuMode(); + } + + /// + /// Raises the event. + /// + /// An that contains the event data. + protected override void OnDropDownClosed(EventArgs e) + { + ResumeMenuMode(); + base.OnDropDownClosed(e); + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Renderer/Office2010Renderer.cs b/Source/ryControls/Sheng.Winform.Controls/Renderer/Office2010Renderer.cs new file mode 100644 index 0000000..1ecd920 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Renderer/Office2010Renderer.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace Sheng.Winform.Controls +{ + public static class Office2010Renderer + { + public static Brush CreateDisabledBackgroundBrush(Rectangle bounds, Color baseColor) + { + Color color = Color.FromArgb(75, baseColor); + SolidBrush brush = new SolidBrush(color); + return brush; + } + + public static Brush CreateBackgroundBrush(Rectangle bounds, Color baseColor) + { + Color color = baseColor; + + Color[] colors = new Color[3]; + colors[0] = Color.Transparent; + colors[1] = Color.Transparent; + colors[2] = Color.FromArgb(60, color); + + //要向上移一个像素,否则上面会多出一个像素的空白,原因不明 + //bounds.X -= 1; + //bounds.Y -= 1; + + LinearGradientBrush brush = new LinearGradientBrush(bounds, Color.Empty, Color.Empty, + LinearGradientMode.Vertical); + + //渐变位置百分比 + float[] relativePositions = { 0f, 0.75f, 1f, }; + + ColorBlend colorBlend = new ColorBlend(); + colorBlend.Colors = colors; + colorBlend.Positions = relativePositions; + brush.InterpolationColors = colorBlend; + + return brush; + } + + public static Brush CreateBorderBrush(Rectangle bounds, Color baseColor) + { + Color color = baseColor; + Color colorStart = Color.FromArgb(125, color); + + LinearGradientBrush brush = new LinearGradientBrush(bounds, colorStart, color, + LinearGradientMode.Vertical); + + return brush; + } + + public static Brush CreateHoveredBackgroundBrush(Rectangle bounds, Color baseColor) + { + //过渡色的路径点和配色参见png设计图 + //需要五个过度色点,就是分成四段,分别占34%,33%,16%,17% + + Color color = baseColor; + + Color[] colors = new Color[5]; + colors[0] = Color.FromArgb(125, color); + colors[1] = color; + colors[2] = color; + colors[3] = Color.FromArgb(221, color); + colors[4] = Color.Transparent; + + //要向上移一个像素,否则上面会多出一个像素的空白,原因不明 + bounds.X -= 1; + bounds.Y -= 1; + + LinearGradientBrush brush = new LinearGradientBrush(bounds, Color.Empty, Color.Empty, + LinearGradientMode.Vertical); + + //渐变位置百分比 + float[] relativePositions = { 0f, 0.20f, 0.67f, 0.75f, 1f, }; + + ColorBlend colorBlend = new ColorBlend(); + colorBlend.Colors = colors; + colorBlend.Positions = relativePositions; + brush.InterpolationColors = colorBlend; + + return brush; + } + + public static Brush CreateHoveredBorderBrush(Rectangle bounds, Color baseColor) + { + Color color = baseColor; + + Color colorEnd = Color.FromArgb(125, color); + + LinearGradientBrush brush = new LinearGradientBrush(bounds, color, colorEnd, + LinearGradientMode.Vertical); + + return brush; + } + + public static Brush CreateSelectedBackgroundBrush(Rectangle bounds, Color baseColor) + { + //过渡色的路径点和配色参见png设计图 + //需要五个过度色点,就是分成四段,分别占34%,33%,16%,17% + + Color color = baseColor; + + Color[] colors = new Color[5]; + colors[0] = color; + colors[1] = color; + colors[2] = color; + colors[3] = Color.FromArgb(221, color); + colors[4] = Color.Transparent; + + //要向上移一个像素,否则上面会多出一个像素的空白,原因不明 + //bounds.X -= 1; + //bounds.Y -= 1; + + LinearGradientBrush brush = new LinearGradientBrush(bounds, Color.Empty, Color.Empty, + LinearGradientMode.Vertical); + + //渐变位置百分比 + float[] relativePositions = { 0f, 0.30f, 0.67f, 0.75f, 1f }; + + ColorBlend colorBlend = new ColorBlend(); + colorBlend.Colors = colors; + colorBlend.Positions = relativePositions; + brush.InterpolationColors = colorBlend; + + return brush; + } + + public static Brush CreateSelectedBorderBrush(Rectangle bounds, Color baseColor) + { + Color color = baseColor; + + Color colorEnd = Color.FromArgb(125, color); + + LinearGradientBrush brush = new LinearGradientBrush(bounds, color, colorEnd, + LinearGradientMode.Vertical); + + return brush; + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Renderer/SEToolStripProfessionalRenderer_Gary.cs b/Source/ryControls/Sheng.Winform.Controls/Renderer/SEToolStripProfessionalRenderer_Gary.cs new file mode 100644 index 0000000..653e284 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Renderer/SEToolStripProfessionalRenderer_Gary.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +namespace Sheng.Winform.Controls +{ + /// + /// 白色到灰色的垂直渐变 + /// + public class SEToolStripProfessionalRenderer_Gary : ToolStripProfessionalRenderer + { + static SEToolStripProfessionalRenderer_Gary() + { + + } + + public SEToolStripProfessionalRenderer_Gary() + { + } + + //// This method handles the RenderGrip event. + //protected override void OnRenderGrip(ToolStripGripRenderEventArgs e) + //{ + // DrawTitleBar( + // e.Graphics, + // new Rectangle(0, 0, e.ToolStrip.Width, 7)); + //} + + //// This method handles the RenderToolStripBorder event. + protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) + { + e.Graphics.DrawLine(new Pen(Color.FromArgb(163, 163, 124)), 0, e.ToolStrip.Height, e.ToolStrip.Width, e.ToolStrip.Height); + } + + protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) + { + //DrawTitleBar( + // e.Graphics, + // new Rectangle(0, 0, e.ToolStrip.Width, e.ToolStrip.Height)); + + if (e.ToolStrip.GetType().Name == "ToolStrip") + { + LinearGradientBrush brush = new LinearGradientBrush + (new Point(0, 0), new Point(0, e.ToolStrip.Height), Color.White, Color.FromArgb(230, 225, 202)); + + e.Graphics.FillRectangle(brush, new Rectangle(0, 0, e.ToolStrip.Width, e.ToolStrip.Height)); + + brush.Dispose(); + } + else + { + //如果不是工具栏本身,比如下拉菜单什么的,就调默认的绘制背景 + base.OnRenderToolStripBackground(e); + } + } + + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Renderer/SEToolStripRender.cs b/Source/ryControls/Sheng.Winform.Controls/Renderer/SEToolStripRender.cs new file mode 100644 index 0000000..c5a3a60 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Renderer/SEToolStripRender.cs @@ -0,0 +1,3336 @@ +using System; +using System.Collections.Generic; +using System.Collections; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Imaging; +using System.Data; +using System.Text; +using System.Windows.Forms; +using System.Threading; + +namespace Sheng.Winform.Controls +{ + #region "EasyRender based renderer class" + /// + /// A ToolstripManager rendering class with advanced control features + /// + public class SEToolStripRender : ToolStripProfessionalRenderer + { + #region "Initialization and Setup" + + /// + /// Creates a new EasyRender class for modifications + /// + public SEToolStripRender() + { + _tsManager = new IToolstrip(); + _btnManager = new IButton(); + _dBtnManager = new IDropDownButton(); + _tsCtrlManager = new IToolstripControls(); + _pManager = new IPanel(); + _sBtnManager = new ISplitButton(); + _sBarManager = new IStatusBar(); + _mnuManager = new IMenustrip(); + } + + #endregion + + #region "Private variables" + + private IToolstrip _tsManager = null; + private IButton _btnManager = null; + private IToolstripControls _tsCtrlManager = null; + private IPanel _pManager = null; + private ISplitButton _sBtnManager = null; + private IStatusBar _sBarManager = null; + private IMenustrip _mnuManager = null; + private IDropDownButton _dBtnManager = null; + + protected Boolean _smoothText = true; + protected Color _overrideColor = Color.FromArgb(47, 92, 150); + protected Boolean _overrideText = true; + + #endregion + + #region "Properties" + + /// + /// Gets the manager to edit and change the appearance of the Toolstrip + /// + [ReadOnly(true)] + public IToolstrip Toolstrip + { + get + { + return _tsManager; + } + } + + /// + /// Gets the manager to edit and change the appearance of Toolstrip buttons + /// + [ReadOnly(true)] + public IButton ToolstripButton + { + get + { + return _btnManager; + } + } + + /// + /// Gets the manager to edit and change the appearance of other Toolstrip controls + /// + [ReadOnly(true)] + public IToolstripControls ToolstripControls + { + get { return _tsCtrlManager; } + } + + /// + /// Gets the manager to edit and change the appearance of the Panels + /// + [ReadOnly(true)] + public IPanel Panels + { + get { return _pManager; } + } + + /// + /// Gets the manager to edit and change the appearance of the Toolstrip split buttons + /// + [ReadOnly(true)] + public ISplitButton SplitButton + { + get { return _sBtnManager; } + } + + /// + /// Gets the manager to edit and change the appearance of the Status-bar + /// + [ReadOnly(true)] + public IStatusBar StatusBar + { + get { return _sBarManager; } + } + + /// + /// Gets or sets whether to smooth the font text on all controls + /// + public Boolean SmoothText + { + get { return _smoothText; } + set { _smoothText = value; } + } + + /// + /// Gets or sets the color of the text if the AlterColor is set to true + /// + public Color OverrideColor + { + get { return _overrideColor; } + set { _overrideColor = value; } + } + + /// + /// Gets or sets whether to override the font-color on all controls + /// + public Boolean AlterColor + { + get { return _overrideText; } + set { _overrideText = value; } + } + + #endregion + + #region "Important -- Functions for getting drawing pointers" + + #region "CreatePanelBrush -- Gets a brush based on the docking position of a panel" + /* + /// + /// Gets a brush dependent on the dock style of a panel + /// + /// The panel which is docked + /// + private Brush CreatePanelBrush(ToolStripPanel Panel) + { + switch (Panel.Dock) + { + case DockStyle.Top: return new SolidBrush(ContentPanelTop); + case DockStyle.Bottom: return new SolidBrush(ContentPanelBottom); + case DockStyle.Left: + case DockStyle.Right: + return new LinearGradientBrush(Panel.ClientRectangle, ContentPanelTop, ContentPanelBottom, 90f); + } + + return null; + } + */ + #endregion + + #region "CreateDrawingPath -- Gets a path based on a rectangular area and a provided curve value" + /// + /// Creates a GraphicsPath that appreciates an area where things can be drawn + /// + /// The rectangular area which will serve as the base + /// The curve amount of the corners + /// + private GraphicsPath CreateDrawingPath(Rectangle Area, float Curve) + { + GraphicsPath Result = new GraphicsPath(); + + Result.AddLine(Area.Left + Curve, Area.Top, Area.Right - Curve, Area.Top); // Top + Result.AddLine(Area.Right - Curve, Area.Top, Area.Right, Area.Top + Curve); // Top-right + Result.AddLine(Area.Right, Area.Top + Curve, Area.Right, Area.Bottom - Curve); // Right + Result.AddLine(Area.Right, Area.Bottom - Curve, Area.Right - Curve, Area.Bottom); // Bottom-right + Result.AddLine(Area.Right - Curve, Area.Bottom, Area.Left + Curve, Area.Bottom); // Bottom + Result.AddLine(Area.Left + Curve, Area.Bottom, Area.Left, Area.Bottom - Curve); // Bottom-left + Result.AddLine(Area.Left, Area.Bottom - Curve, Area.Left, Area.Top + Curve); // Left + Result.AddLine(Area.Left, Area.Top + Curve, Area.Left + Curve, Area.Top); // Top-left + + return Result; + } + #endregion + + #region "CreateTrianglePath -- Gets a path based on a rectangle boundary as a triangle shape" + /// + /// Creates a triangle based on the size and bounds sectors + /// + /// The area which the triangle is confined to + /// The size of the triangle + /// The direction which the triangle is pointing + /// + private GraphicsPath CreateTrianglePath(Rectangle Bounds, Int32 Size, ArrowDirection Direction) + { + GraphicsPath Result = new GraphicsPath(); + int x, y, c, j; + + if (Direction == ArrowDirection.Left || Direction == ArrowDirection.Right) + { + x = Bounds.Right - (Bounds.Width - Size) / 2; + y = Bounds.Y + Bounds.Height / 2; + c = Size; + j = 0; + } + else + { + x = Bounds.X + Bounds.Width / 2; + y = Bounds.Bottom - ((Bounds.Height - (Size - 1)) / 2); + c = Size - 1; + j = Size - 2; + } + + switch (Direction) + { + case ArrowDirection.Right: + Result.AddLine(x, y, x - c, y - c); + Result.AddLine(x - c, y - c, x - c, y + c); + Result.AddLine(x - c, y + c, x, y); + break; + case ArrowDirection.Down: + Result.AddLine(x + j, y - j, x - j, y - j); + Result.AddLine(x - j, y - j, x, y); + Result.AddLine(x, y, x + j, y - j); + break; + case ArrowDirection.Left: + Result.AddLine(x - c, y, x, y - c); + Result.AddLine(x, y - c, x, y + c); + Result.AddLine(x, y + c, x - c, y); + break; + } + + return Result; + } + #endregion + + #region "GetButtonBackColor -- Returns different background gradient colors for a normal button state" + /// + /// Gets a color array based on the state of a normal button + /// + /// The button to check the state of + /// + private Color[] GetButtonBackColor(ToolStripButton Item, ButtonType Type) + { + Color[] Return = new Color[2]; + + if ( + (!Item.Selected) && + (!Item.Pressed && !Item.Checked) + ) + { + Return[0] = Color.Transparent; + Return[1] = Color.Transparent; + } + else if ( + (Item.Selected) && + (!Item.Pressed && !Item.Checked) + ) + { + Return[0] = _btnManager.HoverBackgroundTop; + Return[1] = _btnManager.HoverBackgroundBottom; + } + else + { + Return[0] = _btnManager.ClickBackgroundTop; + Return[1] = _btnManager.ClickBackgroundBottom; + } + + return Return; + } + #endregion + + #region "GetButtonBackColor -- Returns different background gradient colors for a split-button state" + /// + /// Gets a color array based on the state of a split-button + /// + /// The button to check the state of + /// + private Color[] GetButtonBackColor(ToolStripSplitButton Item, ButtonType Type) + { + Color[] Return = new Color[2]; + + if ( + (!Item.Selected) && + (!Item.ButtonPressed && !Item.DropDownButtonPressed) + ) + { + Return[0] = Color.Transparent; + Return[1] = Color.Transparent; + } + else if ( + (Item.Selected) && + (!Item.ButtonPressed && !Item.DropDownButtonPressed) + ) + { + Return[0] = _sBtnManager.HoverBackgroundTop; + Return[1] = _sBtnManager.HoverBackgroundBottom; + } + else + { + if (Item.ButtonPressed) + { + Return[0] = _sBtnManager.ClickBackgroundTop; + Return[1] = _sBtnManager.ClickBackgroundBottom; + } + else if (Item.DropDownButtonPressed) + { + Return[0] = _mnuManager.MenustripButtonBackground; + Return[1] = _mnuManager.MenustripButtonBackground; + } + } + + return Return; + } + #endregion + + #region "GetButtonBackColor -- Returns different background gradient colors for a menu-item state" + /// + /// Gets a color array based on the state of a menu-item + /// + /// The button to check the state of + /// + private Color[] GetButtonBackColor(ToolStripMenuItem Item, ButtonType Type) + { + Color[] Return = new Color[2]; + + if ( + (!Item.Selected) && + (!Item.Pressed && !Item.Checked) + ) + { + Return[0] = Color.Transparent; + Return[1] = Color.Transparent; + } + else if ( + (Item.Selected || Item.Pressed) && + (!Item.Checked) + ) + { + if (Item.Pressed && Item.OwnerItem == null) + { + Return[0] = _mnuManager.MenustripButtonBackground; + Return[1] = _mnuManager.MenustripButtonBackground; + } + else + { + Return[0] = _mnuManager.Items.HoverBackgroundTop; + Return[1] = _mnuManager.Items.HoverBackgroundBottom; + } + } + else + { + Return[0] = _mnuManager.Items.ClickBackgroundTop; + Return[1] = _mnuManager.Items.ClickBackgroundBottom; + } + + return Return; + } + #endregion + + #region "GetButtonBackColor -- Returns different background gradient colors for a dropdownbutton state" + /// + /// Gets a color array based on the state of a drop-down button + /// + /// The button to check the state of + /// + private Color[] GetButtonBackColor(ToolStripDropDownButton Item, ButtonType Type) + { + Color[] Return = new Color[2]; + + if ( + (!Item.Selected) && + (!Item.Pressed) + ) + { + Return[0] = Color.Transparent; + Return[1] = Color.Transparent; + } + else if ( + (Item.Selected) && + (!Item.Pressed) + ) + { + Return[0] = _dBtnManager.HoverBackgroundTop; + Return[1] = _dBtnManager.HoverBackgroundBottom; + } + else + { + Return[0] = _mnuManager.MenustripButtonBackground; + Return[1] = _mnuManager.MenustripButtonBackground; + } + + return Return; + } + #endregion + + #region "GetBlend -- Gets a blend property based on the blending options and current state" + /// + /// Gets a blending property for a specified type of Toolstrip item + /// + /// The Toolstrip item + /// The type of item this is + /// + private Blend GetBlend(ToolStripItem TSItem, ButtonType Type) + { + Blend BackBlend = null; + + if (Type == ButtonType.NormalButton) + { + ToolStripButton Item = (ToolStripButton)TSItem; + + if (Item.Selected && + (!Item.Checked && !Item.Pressed) && + (_btnManager.BlendOptions & BlendRender.Hover) == BlendRender.Hover) + { + BackBlend = _btnManager.BackgroundBlend; + } + else if (Item.Pressed && + (!Item.Checked) && + (_btnManager.BlendOptions & BlendRender.Click) == BlendRender.Click) + { + BackBlend = _btnManager.BackgroundBlend; + } + else if (Item.Checked && + (_btnManager.BlendOptions & BlendRender.Check) == BlendRender.Check) + { + BackBlend = _btnManager.BackgroundBlend; + } + } + if (Type == ButtonType.DropDownButton) + { + ToolStripDropDownButton Item = (ToolStripDropDownButton)TSItem; + + if (Item.Selected && + (!Item.Pressed) && + (_btnManager.BlendOptions & BlendRender.Hover) == BlendRender.Hover) + { + BackBlend = _btnManager.BackgroundBlend; + } + } + else if (Type == ButtonType.MenuItem) + { + ToolStripMenuItem Item = (ToolStripMenuItem)TSItem; + + if (Item.Selected && + (!Item.Checked && !Item.Pressed) && + (_btnManager.BlendOptions & BlendRender.Hover) == BlendRender.Hover) + { + BackBlend = _mnuManager.Items.BackgroundBlend; + } + else if (Item.Pressed && + (!Item.Checked) && + (_btnManager.BlendOptions & BlendRender.Click) == BlendRender.Click) + { + BackBlend = _mnuManager.Items.BackgroundBlend; + } + else if (Item.Checked && + (_btnManager.BlendOptions & BlendRender.Check) == BlendRender.Check) + { + BackBlend = _mnuManager.Items.BackgroundBlend; + } + } + else if (Type == ButtonType.SplitButton) + { + ToolStripSplitButton Item = (ToolStripSplitButton)TSItem; + + if (Item.Selected && + (!Item.ButtonPressed && !Item.DropDownButtonPressed) && + (_sBtnManager.BlendOptions & BlendRender.Hover) == BlendRender.Hover) + { + BackBlend = _sBtnManager.BackgroundBlend; + } + else if (Item.ButtonPressed && + (!Item.DropDownButtonPressed) && + (_sBtnManager.BlendOptions & BlendRender.Click) == BlendRender.Click) + { + BackBlend = _sBtnManager.BackgroundBlend; + } + } + + return BackBlend; + } + #endregion + + #endregion + + #region "Important -- Functions for drawing" + + #region "PaintBackground -- Simply fills a rectangle with a color" + /// + /// Fills a specified boundary with color + /// + /// The Graphics object to draw onto + /// The boundaries to draw the color + /// The brush to fill the color + public void PaintBackground(Graphics Link, Rectangle Boundary, Brush Brush) + { + Link.FillRectangle(Brush, Boundary); + } + #endregion + + #region "PaintBackground -- Fills a rectangle with Top and Bottom colors" + /// + /// Fills a specified boundary with a gradient with specified colors + /// + /// The Graphics object to draw onto + /// The boundaries to draw the color + /// The color of the gradient at the top + /// The color of the gradient at the bottom + public void PaintBackground(Graphics Link, Rectangle Boundary, Color Top, Color Bottom) + { + PaintBackground(Link, Boundary, Top, Bottom, 90f, null); + } + #endregion + + #region "PaintBackground -- Fills a rectangle with Top and Bottom colors at a given angle" + /// + /// Fills a specified boundary with a gradient with specified colors at a given angle + /// + /// The Graphics object to draw onto + /// The boundaries to draw the color + /// The color of the gradient at the top + /// The color of the gradient at the bottom + /// The angle which the gradient is drawn (null defaults to 90f) + public void PaintBackground(Graphics Link, Rectangle Boundary, Color Top, Color Bottom, float Angle) + { + PaintBackground(Link, Boundary, Top, Bottom, Angle, null); + } + #endregion + + #region "PaintBackground -- Fills a rectangle with Top and Bottom colors at a given angle with blending" + /// + /// Fills a specified boundary with a gradient with specified colors at a given angle and with blending properties + /// + /// The Graphics object to draw onto + /// The boundaries to draw the color + /// The color of the gradient at the top + /// The color of the gradient at the bottom + /// The angle which the gradient is drawn (null defaults to 90f) + /// The blending options to draw the gradient + public void PaintBackground(Graphics Link, Rectangle Boundary, Color Top, Color Bottom, float Angle, Blend Blend) + { + if ( float.IsNaN(Angle)) + { + Angle = 90f; + } + + using (LinearGradientBrush Fill = new LinearGradientBrush(Boundary, Top, Bottom, Angle)) + { + if (Blend != null) + { + Fill.Blend = Blend; + } + + Link.FillRectangle(Fill, Boundary); + Fill.Dispose(); + } + } + #endregion + + #region "PaintBorder -- Draws a border along a set path" + /// + /// Draws a set path with a defined brush + /// + /// The Graphics object to draw onto + /// The path to draw along + /// The brush to fill the color + public void PaintBorder(Graphics Link, GraphicsPath Path, Brush Brush) + { + Link.DrawPath(new Pen(Brush), Path); + } + #endregion + + #region "PaintBorder -- Draws a border along a set path with Top and Bottom colors" + /// + /// Draws a set path with specified colors + /// + /// The Graphics object to draw onto + /// The path to draw along + /// The area of span the border gradient covers + /// The color of the gradient at the top + /// The color of the gradient at the bottom + public void PaintBorder(Graphics Link, GraphicsPath Path, Rectangle Area, Color Top, Color Bottom) + { + PaintBorder(Link, Path, Area, Top, Bottom, 90f, null); + } + #endregion + + #region "PaintBorder -- Draws a border along a set path with Top and Bottom colors at a given angle" + /// + /// Draws a set path with specified colors at a given angle + /// + /// The Graphics object to draw onto + /// The path to draw along + /// The area of span the border gradient covers + /// The color of the gradient at the top + /// The color of the gradient at the bottom + /// The angle which the gradient is drawn (null defaults to 90f) + public void PaintBorder(Graphics Link, GraphicsPath Path, Rectangle Area, Color Top, Color Bottom, float Angle) + { + PaintBorder(Link, Path, Area, Top, Bottom, Angle, null); + } + #endregion + + #region "PaintBorder -- Draws a border along a set path with Top and Bottom colors at a given angle with blending" + /// + /// Draws a set path with specified colors at a given angle with blending properties + /// + /// The Graphics object to draw onto + /// The path to draw along + /// The color of the gradient at the top + /// The color of the gradient at the bottom + /// The angle which the gradient is drawn (null defaults to 90f) + /// The blending options to draw the gradient + public void PaintBorder(Graphics Link, GraphicsPath Path, Rectangle Area, Color Top, Color Bottom, float Angle, Blend Blend) + { + + if (float.IsNaN(Angle)) + { + Angle = 90f; + } + + using (LinearGradientBrush Fill = new LinearGradientBrush(Area, Top, Bottom, Angle)) + { + if (Blend != null) + { + Fill.Blend = Blend; + } + + Link.DrawPath(new Pen(Fill), Path); + Fill.Dispose(); + } + } + #endregion + + #endregion + + #region "Important -- Functions handling the OnRender delegations" + + #region "IDrawToolstripButton -- Draws a Toolstrip button applying the backround and border" + /// + /// Draws a Toolstrip button + /// + /// The Toolstrip button + /// The Graphics object to handle + /// The parent Toolstrip + public void IDrawToolstripButton(ToolStripButton Item, Graphics Link, ToolStrip Parent) + { + Rectangle Area = new Rectangle( + new Point(0, 0), + new Size(Item.Bounds.Size.Width - 1, Item.Bounds.Size.Height - 1) + ); + + Blend BackBlend = GetBlend(Item, ButtonType.NormalButton); + Color[] Render = GetButtonBackColor(Item, ButtonType.NormalButton); + + using (GraphicsPath Path = CreateDrawingPath(Area, _btnManager.Curve)) + { + Link.SetClip(Path); + + PaintBackground( + Link, + Area, + Render[0], + Render[1], + _btnManager.BackgroundAngle, + BackBlend + ); + + Link.ResetClip(); + + Link.SmoothingMode = SmoothingMode.AntiAlias; + + using (GraphicsPath OBPath = CreateDrawingPath(Area, _btnManager.Curve)) + { + PaintBorder( + Link, + OBPath, + Area, + _btnManager.BorderTop, + _btnManager.BorderBottom, + _btnManager.BorderAngle, + _btnManager.BorderBlend + ); + + OBPath.Dispose(); + } + + Area.Inflate(-1, -1); + + using (GraphicsPath IBPath = CreateDrawingPath(Area, _btnManager.Curve)) + { + using (SolidBrush InnerBorder = new SolidBrush(_btnManager.InnerBorder)) + { + PaintBorder( + Link, + IBPath, + InnerBorder + ); + + InnerBorder.Dispose(); + } + } + + Link.SmoothingMode = SmoothingMode.Default; + } + } + #endregion + + #region "IDrawDropDownButton -- Draws a Toolstrip dropdownbutton applying the backround and border" + /// + /// Draws a Toolstrip button + /// + /// The Toolstrip button + /// The Graphics object to handle + /// The parent Toolstrip + public void IDrawDropDownButton(ToolStripDropDownButton Item, Graphics Link, ToolStrip Parent) + { + Rectangle Area = new Rectangle( + new Point(0, 0), + new Size(Item.Bounds.Size.Width - 1, Item.Bounds.Size.Height - 1) + ); + + Blend BackBlend = GetBlend(Item, ButtonType.DropDownButton); + Color[] Render = GetButtonBackColor(Item, ButtonType.DropDownButton); + + using (GraphicsPath Path = CreateDrawingPath(Area, _btnManager.Curve)) + { + Link.SetClip(Path); + + PaintBackground( + Link, + Area, + Render[0], + Render[1], + _btnManager.BackgroundAngle, + BackBlend + ); + + Link.ResetClip(); + + Link.SmoothingMode = SmoothingMode.AntiAlias; + + using (GraphicsPath OBPath = CreateDrawingPath(Area, _btnManager.Curve)) + { + PaintBorder( + Link, + OBPath, + Area, + _btnManager.BorderTop, + _btnManager.BorderBottom, + _btnManager.BorderAngle, + _btnManager.BorderBlend + ); + + OBPath.Dispose(); + } + + if (!Item.Pressed) + { + Area.Inflate(-1, -1); + + using (GraphicsPath IBPath = CreateDrawingPath(Area, _dBtnManager.Curve)) + { + using (SolidBrush InnerBorder = new SolidBrush(_dBtnManager.InnerBorder)) + { + PaintBorder( + Link, + IBPath, + InnerBorder + ); + + InnerBorder.Dispose(); + } + } + } + + Link.SmoothingMode = SmoothingMode.Default; + } + } + #endregion + + #region "IDrawToolstripBackground -- Draws a Toolstrip background" + /// + /// Draws the Toolstrip background + /// + /// The Toolstrip being drawn + /// The Graphics object to handle + /// The affected bounds + public void IDrawToolstripBackground(ToolStrip Item, Graphics Link, Rectangle Bounds) + { + Rectangle Area = new Rectangle( + 0, + 0, + Bounds.Width - 1, + Bounds.Height - 1 + ); + + Link.SmoothingMode = SmoothingMode.None; + + using (GraphicsPath Path = CreateDrawingPath(Area, _tsManager.Curve)) + { + Link.SetClip(Path); + + PaintBackground( + Link, + Area, + _tsManager.BackgroundTop, + _tsManager.BackgroundBottom, + _tsManager.BackgroundAngle, + _tsManager.BackgroundBlend + ); + + Link.ResetClip(); + + Path.Dispose(); + } + } + #endregion + + #region "IDrawToolstripSplitButton -- Draws a Toolstrip split-button with the arrow" + /// + /// Draws a Toolstrip split-button + /// + /// The Toolstrip split-button + /// The Graphics object to handle + /// The parent Toolstrip + public void IDrawToolstripSplitButton(ToolStripSplitButton Item, Graphics Link, ToolStrip Parent) + { + if (Item.Selected || Item.DropDownButtonPressed || Item.ButtonPressed) + { + Rectangle Area = new Rectangle( + new Point(0, 0), + new Size(Item.Bounds.Size.Width - 1, Item.Bounds.Size.Height - 1) + ); + + Blend BackBlend = GetBlend(Item, ButtonType.SplitButton); + Color[] NormalRender = new Color[] { _sBtnManager.HoverBackgroundTop, _sBtnManager.HoverBackgroundBottom }; + Color[] Render = GetButtonBackColor(Item, ButtonType.SplitButton); + + using (GraphicsPath Path = CreateDrawingPath(Area, _sBtnManager.Curve)) + { + Link.SetClip(Path); + + if (!Item.DropDownButtonPressed) + { + PaintBackground( + Link, + Area, + NormalRender[0], + NormalRender[1], + _sBtnManager.BackgroundAngle, + BackBlend + ); + } + else + { + PaintBackground( + Link, + Area, + Render[0], + Render[1] + ); + } + + if (Item.ButtonPressed) + { + Rectangle ButtonArea = new Rectangle( + new Point(0, 0), + new Size(Item.ButtonBounds.Width, Item.ButtonBounds.Height - 1) + ); + + PaintBackground( + Link, + ButtonArea, + Render[0], + Render[1], + _sBtnManager.BackgroundAngle, + _sBtnManager.BackgroundBlend + ); + } + + Link.ResetClip(); + + Link.SmoothingMode = SmoothingMode.AntiAlias; + + using (GraphicsPath OBPath = CreateDrawingPath(Area, _sBtnManager.Curve)) + { + Color TopColor = (Item.DropDownButtonPressed ? _mnuManager.MenustripButtonBorder : _sBtnManager.BorderTop); + Color BottomColor = (Item.DropDownButtonPressed ? _mnuManager.MenustripButtonBorder : _sBtnManager.BorderBottom); + + PaintBorder( + Link, + OBPath, + Area, + TopColor, + BottomColor, + _sBtnManager.BorderAngle, + _sBtnManager.BorderBlend + ); + + OBPath.Dispose(); + } + + if (!Item.DropDownButtonPressed) + { + Area.Inflate(-1, -1); + + using (GraphicsPath IBPath = CreateDrawingPath(Area, _sBtnManager.Curve)) + { + using (SolidBrush InnerBorder = new SolidBrush(_sBtnManager.InnerBorder)) + { + PaintBorder( + Link, + IBPath, + InnerBorder + ); + + + Link.DrawRectangle( + new Pen(_sBtnManager.InnerBorder), + new Rectangle( + Item.ButtonBounds.Width, + 1, + 2, + Item.ButtonBounds.Height - 3 + ) + ); + + InnerBorder.Dispose(); + } + } + + using (LinearGradientBrush SplitLine = new LinearGradientBrush( + new Rectangle(0, 0, 1, Item.Height), + _sBtnManager.BorderTop, + _sBtnManager.BorderBottom, + _sBtnManager.BackgroundAngle + )) + { + if (_sBtnManager.BackgroundBlend != null) + { + SplitLine.Blend = _sBtnManager.BackgroundBlend; + } + + Link.DrawLine( + new Pen(SplitLine), + Item.ButtonBounds.Width + 1, + 0, + Item.ButtonBounds.Width + 1, + Item.Height - 1 + ); + + SplitLine.Dispose(); + } + } + + Link.SmoothingMode = SmoothingMode.Default; + } + } + + Int32 ArrowSize = 5; + + if ( + (_sBtnManager.ArrowDisplay == ArrowDisplay.Always) || + (_sBtnManager.ArrowDisplay == ArrowDisplay.Hover && Item.Selected) + ) + { + using (GraphicsPath TrianglePath = CreateTrianglePath( + new Rectangle( + Item.DropDownButtonBounds.Left + (ArrowSize / 2) - 1, + (Item.DropDownButtonBounds.Height / 2) - (ArrowSize / 2) - 3, + ArrowSize * 2, + ArrowSize * 2 + ), + ArrowSize, + ArrowDirection.Down + )) + { + Link.FillPath(new SolidBrush(_sBtnManager.ArrowColor), TrianglePath); + + TrianglePath.Dispose(); + } + + } + } + #endregion + + #region "IDrawStatusbarBackground -- Draws the statusbar background" + /// + /// Draws the Statusbar background + /// + /// The Statusbar being drawn + /// The Graphics object to handle + /// The affected bounds + public void IDrawStatusbarBackground(StatusStrip Item, Graphics Link, Rectangle Bounds) + { + PaintBackground( + Link, + Bounds, + _sBarManager.BackgroundTop, + _sBarManager.BackgroundBottom, + _sBarManager.BackgroundAngle, + _sBarManager.BackgroundBlend + ); + + Link.DrawLine( + new Pen(_sBarManager.DarkBorder), + 0, 0, Bounds.Width, 0 + ); + + Link.DrawLine( + new Pen(_sBarManager.LightBorder), + 0, 1, Bounds.Width, 1 + ); + } + #endregion + + #region "IDrawMenustripItem -- Draws a Menustrip item applying the background and border" + /// + /// Draws a Menustrip item + /// + /// The Menustrip item + /// The Graphics object to handle + /// The parent Toolstrip + public void IDrawMenustripItem(ToolStripMenuItem Item, Graphics Link, ToolStrip Parent) + { + Rectangle Area = new Rectangle( + new Point(0, 0), + new Size(Item.Bounds.Size.Width - 1, Item.Bounds.Size.Height - 1) + ); + + if (Item.OwnerItem != null) + { + Area.X += 2; + Area.Width -= 3; + } + + Blend BackBlend = GetBlend(Item, ButtonType.MenuItem); + Color[] Render = GetButtonBackColor(Item, ButtonType.MenuItem); + + using (GraphicsPath Path = CreateDrawingPath(Area, _btnManager.Curve)) + { + Link.SetClip(Path); + + PaintBackground( + Link, + Area, + Render[0], + Render[1], + _btnManager.BackgroundAngle, + BackBlend + ); + + Link.ResetClip(); + + Link.SmoothingMode = SmoothingMode.AntiAlias; + + using (GraphicsPath OBPath = CreateDrawingPath(Area, _btnManager.Curve)) + { + PaintBorder( + Link, + OBPath, + Area, + _mnuManager.MenustripButtonBorder, + _mnuManager.MenustripButtonBorder, + _btnManager.BorderAngle, + _btnManager.BorderBlend + ); + + OBPath.Dispose(); + } + + if (!Item.Pressed) + { + Area.Inflate(-1, -1); + + using (GraphicsPath IBPath = CreateDrawingPath(Area, _btnManager.Curve)) + { + using (SolidBrush InnerBorder = new SolidBrush(_btnManager.InnerBorder)) + { + PaintBorder( + Link, + IBPath, + InnerBorder + ); + + InnerBorder.Dispose(); + } + } + } + + Link.SmoothingMode = SmoothingMode.Default; + } + } + #endregion + + #endregion + + #region "Important* -- The OnRender protected overrides" + + #region "Render Button Background -- Handles drawing toolstrip/menu/status-strip buttons" + /// + /// Covers the button background rendering + /// + /// + protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e) + { + if ( + e.ToolStrip is ContextMenuStrip || + e.ToolStrip is ToolStripDropDownMenu || + e.ToolStrip is MenuStrip + ) + { + ToolStripMenuItem Item = (ToolStripMenuItem)e.Item; + + if (Item.Selected || Item.Checked || Item.Pressed) + IDrawMenustripItem(Item, e.Graphics, e.ToolStrip); + } + else if ( + e.ToolStrip is StatusStrip + ) + { + } + else + { + ToolStripButton Item = (ToolStripButton)e.Item; + + if (Item.Selected || Item.Checked || Item.Pressed) + IDrawToolstripButton(Item, e.Graphics, e.ToolStrip); + } + } + #endregion + + #region "Render Dropdown Button Background" + protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e) + { + if (e.Item.Selected || e.Item.Pressed) + IDrawDropDownButton((ToolStripDropDownButton)e.Item, e.Graphics, e.ToolStrip); + } + #endregion + + #region "Render Image Margin -- Handles drawing the image margin on drop-down menus" + protected override void OnRenderImageMargin(ToolStripRenderEventArgs e) + { + Rectangle Area = new Rectangle( + 2, + 2, + e.AffectedBounds.Width, + e.AffectedBounds.Height - 4 + ); + + PaintBackground(e.Graphics, Area, _mnuManager.MarginLeft, _mnuManager.MarginRight, 0f); + + e.Graphics.DrawLine( + new Pen(_mnuManager.MenuBorderDark), + e.AffectedBounds.Width + 1, + 2, + e.AffectedBounds.Width + 1, + e.AffectedBounds.Height - 3 + ); + } + #endregion + + #region "Render Item Text -- Allows smoothing of text and changing the color" + protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) + { + if (_smoothText) + e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; + + if (_overrideText) + e.TextColor = _overrideColor; + + base.OnRenderItemText(e); + } + #endregion + + #region "Render Menuitem Background -- Handles drawing menu-item backgrounds" + protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) + { + ToolStripMenuItem Item = (ToolStripMenuItem)e.Item; + + if ((!Item.Selected && !Item.Checked && !Item.Pressed) || Item.Enabled == false) + { + return; + } + + if ( + e.ToolStrip is MenuStrip || + e.ToolStrip is ToolStripDropDownMenu || + e.ToolStrip is ContextMenuStrip + ) + { + IDrawMenustripItem(Item, e.Graphics, e.ToolStrip); + } + } + #endregion + + #region "Render Seperator -- Handles drawing the seperator for the toolstrip and contextmenu controls" + protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e) + { + if ( + e.ToolStrip is ContextMenuStrip || + e.ToolStrip is ToolStripDropDownMenu + ) + { + // Draw it + + e.Graphics.DrawLine(new Pen(_mnuManager.SeperatorDark), _mnuManager.SeperatorInset, 3, e.Item.Width + 1, 3); + e.Graphics.DrawLine(new Pen(_mnuManager.SeperatorLight), _mnuManager.SeperatorInset, 4, e.Item.Width + 1, 4); + } + else + { + if (e.Vertical) + { + e.Graphics.DrawLine(new Pen(_tsCtrlManager.SeperatorDark), 3, 5, 3, e.Item.Height - 6); + e.Graphics.DrawLine(new Pen(_tsCtrlManager.SeperatorLight), 4, 6, 4, e.Item.Height - 6); + } + else + { + e.Graphics.DrawLine(new Pen(_tsCtrlManager.SeperatorDark), 8, 0, e.Item.Width - 6, 0); + e.Graphics.DrawLine(new Pen(_tsCtrlManager.SeperatorLight), 9, 1, e.Item.Width - 6, 1); + } + } + } + #endregion + + #region "Render SplitButton Background -- Handles drawing the split button" + protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e) + { + ToolStripSplitButton Item = (ToolStripSplitButton)e.Item; + + IDrawToolstripSplitButton(Item, e.Graphics, e.ToolStrip); + } + #endregion + + #region "Render Statusstrip Sizing Grip" + protected override void OnRenderStatusStripSizingGrip(ToolStripRenderEventArgs e) + { + using (SolidBrush Top = new SolidBrush(_sBarManager.GripTop), + Bottom = new SolidBrush(_sBarManager.GripBottom)) + { + Int32 d = _sBarManager.GripSpacing; + Int32 y = e.AffectedBounds.Bottom - (d * 4); + + for (int a = 1; a < 4; a++) + { + y = y + d; + + for (int b = 1; a >= b; b++) + { + Int32 x = e.AffectedBounds.Right - (d * b); + + e.Graphics.FillRectangle(Bottom, x + 1, y + 1, 2, 2); + e.Graphics.FillRectangle(Top, x, y, 2, 2); + } + } + } + } + #endregion + + #region "Render Toolstrip Background -- Handles drawing toolstrip/menu/status-strip backgrounds" + protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) + { + if ( + e.ToolStrip is ContextMenuStrip || + e.ToolStrip is ToolStripDropDownMenu + ) + { + PaintBackground(e.Graphics, e.AffectedBounds, _mnuManager.BackgroundTop, _mnuManager.BackgroundBottom, 90f, _mnuManager.BackgroundBlend); + + Rectangle Border = new Rectangle( + 0, + 0, + e.AffectedBounds.Width - 1, + e.AffectedBounds.Height - 1 + ); + + using (GraphicsPath Path = CreateDrawingPath(Border, 0)) + { + e.Graphics.ExcludeClip(new Rectangle( + 1, + 0, + e.ConnectedArea.Width, + e.ConnectedArea.Height - 1 + )); + + PaintBorder(e.Graphics, Path, new SolidBrush(_mnuManager.MenuBorderDark)); + + e.Graphics.ResetClip(); + + Path.Dispose(); + } + } + else if ( + e.ToolStrip is MenuStrip) + { + Rectangle Area = e.AffectedBounds; + + PaintBackground(e.Graphics, Area, new SolidBrush(_pManager.ContentPanelTop)); + } + else if ( + e.ToolStrip is StatusStrip + ) + { + IDrawStatusbarBackground((StatusStrip)e.ToolStrip, e.Graphics, e.AffectedBounds); + } + else + { + e.ToolStrip.BackColor = Color.Transparent; + + IDrawToolstripBackground(e.ToolStrip, e.Graphics, e.AffectedBounds); + } + } + #endregion + + #region "Render Toolstrip Border -- Handles drawing the border for toolstrip/menu/status-strip controls" + protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) + { + if ( + e.ToolStrip is ContextMenuStrip || + e.ToolStrip is ToolStripDropDownMenu + ) + { + } + else if ( + e.ToolStrip is StatusStrip + ) + { + } + else if ( + e.ToolStrip is MenuStrip + ) + { + } + else + { + Rectangle Area = new Rectangle( + 0, + -2, + e.AffectedBounds.Width - 2, + e.AffectedBounds.Height + 1 + ); + using (GraphicsPath Path = CreateDrawingPath(Area, _tsManager.Curve)) + { + PaintBorder( + e.Graphics, + Path, + e.AffectedBounds, + _tsManager.BorderTop, + _tsManager.BorderBottom, + _tsManager.BorderAngle, + _tsManager.BorderBlend + ); + + Path.Dispose(); + } + } + } + #endregion + + #region "Render Toolstrip Content Panel Background -- Handles drawing the content panel background" + protected override void OnRenderToolStripContentPanelBackground(ToolStripContentPanelRenderEventArgs e) + { + if (e.ToolStripContentPanel.ClientRectangle.Width < 3 || e.ToolStripContentPanel.ClientRectangle.Height < 3) + { + return; + } + + e.Handled = true; + + e.Graphics.SmoothingMode = _pManager.Mode; + + PaintBackground( + e.Graphics, + e.ToolStripContentPanel.ClientRectangle, + _pManager.ContentPanelTop, + _pManager.ContentPanelBottom, + _pManager.BackgroundAngle, + _pManager.BackgroundBlend + ); + } + #endregion + + #region "Render Toolstrip Panel Background -- Handles drawing the backgrounds for each panel" + protected override void OnRenderToolStripPanelBackground(ToolStripPanelRenderEventArgs e) + { + if (e.ToolStripPanel.ClientRectangle.Width < 3 || e.ToolStripPanel.ClientRectangle.Height < 3) + return; + + e.Handled = true; + + switch (e.ToolStripPanel.Dock) + { + case DockStyle.Top: + PaintBackground( + e.Graphics, + e.ToolStripPanel.ClientRectangle, + new SolidBrush(_pManager.ContentPanelTop) + ); + break; + + case DockStyle.Bottom: + PaintBackground( + e.Graphics, + e.ToolStripPanel.ClientRectangle, + new SolidBrush(_pManager.ContentPanelBottom) + ); + break; + + case DockStyle.Left: + case DockStyle.Right: + PaintBackground( + e.Graphics, + e.ToolStripPanel.ClientRectangle, + _pManager.ContentPanelTop, + _pManager.ContentPanelBottom, + _pManager.BackgroundAngle, + _pManager.BackgroundBlend + ); + break; + } + } + #endregion + + #endregion + + #region "Other functions" + + #region "Apply -- Applies any recent changes to the renderer" + /// + /// Applies any and all changes made to the Renderer + /// + public void Apply() + { + ToolStripManager.Renderer = this; + } + #endregion + + #endregion + } + #endregion + + #region "EasyRender -- Toolstrip controlling class" + /// + /// A class designed to be used in the EasyRender master control to customize the look and feel of the base Toolstrip + /// + public class IToolstrip : IDisposable + { + #region "Initialization and Setup" + + /// + /// Creates a new IToolstrip class for customization + /// + public IToolstrip() + { + DefaultBlending(); + } + + /// + /// Creates a new IToolstrip class for customization + /// + /// The IToolstrip to import the settings from + public IToolstrip(IToolstrip Import) + { + DefaultBlending(); + + Apply(Import); + } + + /// + /// Disposes of the IToolstrip class and clears all resources related to it + /// + public void Dispose() + { + GC.SuppressFinalize(this); + } + + #endregion + + #region "Private variables" + + private int _curve = 2; + + private Color _borderTop = Color.Transparent; + private Color _borderBottom = Color.FromArgb(71, 117, 177); + private Blend _borderBlend = null; + private float _borderAngle = 90; + + private Color _backTop = Color.FromArgb(227, 239, 255); + private Color _backBottom = Color.FromArgb(163, 193, 234); + private Blend _backBlend = null; + private float _backAngle = 90; + + #endregion + + #region "Properties" + + /// + /// Gets or sets the color of the Toolstrip background gradient from the top + /// + public Color BackgroundTop + { + get + { + return _backTop; + } + + set + { + _backTop = value; + } + } + + /// + /// Gets or sets the color of the Toolstrip background gradient from the bottom + /// + public Color BackgroundBottom + { + get + { + return _backBottom; + } + + set + { + _backBottom = value; + } + } + + /// + /// Gets or sets the blending that will occur when rendering the Toolstrip background + /// If set to null, the Toolstrip will simply draw the gradient + /// + public Blend BackgroundBlend + { + get + { + return _backBlend; + } + + set + { + _backBlend = value; + } + } + + /// + /// Gets or sets the angle which the Toolstrip background will be drawn + /// + public float BackgroundAngle + { + get + { + return _backAngle; + } + + set + { + _backAngle = value; + } + } + + /// + /// Gets or sets the color of the Toolstrip border gradient from the top + /// + public Color BorderTop + { + get + { + return _borderTop; + } + + set + { + _borderTop = value; + } + } + + /// + /// Gets or sets the color of the Toolstrip border gradient from the bottom + /// + public Color BorderBottom + { + get + { + return _borderBottom; + } + + set + { + _borderBottom = value; + } + } + + /// + /// Gets or sets the blending that will occur when rendering the Toolstrip border + /// If set to null, the Toolstrip will simply draw the border + /// + public Blend BorderBlend + { + get + { + return _borderBlend; + } + + set + { + _borderBlend = value; + } + } + + /// + /// Gets or sets the angle which the Toolstrip border will be drawn + /// + public float BorderAngle + { + get + { + return _borderAngle; + } + + set + { + _borderAngle = value; + } + } + + /// + /// Gets or sets the curve of the border of the Toolstrip + /// + public int Curve + { + get + { + return _curve; + } + + set + { + _curve = value; + } + } + + #endregion + + #region "Methods" + + /// + /// Imports the settings from a previous or pre-defined IToolstrip and applies it to the current + /// + /// The IToolstrip to import the settings from + public void Apply(IToolstrip Import) + { + _backTop = Import._borderTop; + _backBottom = Import._borderBottom; + _backAngle = Import._borderAngle; + _backBlend = Import._backBlend; + + _borderTop = Import._borderTop; + _borderBottom = Import._borderBottom; + _borderAngle = Import._borderAngle; + _borderBlend = Import._borderBlend; + + _curve = Import._curve; + } + + /// + /// Sets the blending for both border and background to their defaults + /// + public void DefaultBlending() + { + _borderBlend = new Blend(); + _borderBlend.Positions = new float[] { 0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1f }; + _borderBlend.Factors = new float[] { 0.1f, 0.2f, 0.3f, 0.3f, 0.3f, 0.4f, 0.4f, 0.4f, 0.5f, 0.7f, 0.7f }; + + _backBlend = new Blend(); + _backBlend.Positions = new float[] { 0f, 0.3f, 0.5f, 0.8f, 1f }; + _backBlend.Factors = new float[] { 0f, 0f, 0f, 0.5f, 1f }; + } + + #endregion + } + #endregion + + #region "EasyRender -- Toolstrip extended controls" + public class IToolstripControls : IDisposable + { + #region "Initialization and Setup" + + /// + /// Creates a new IToolstripControls class for customization + /// + public IToolstripControls() + { + } + + /// + /// Disposes of the IToolstripControls class and clears all resources related to it + /// + public void Dispose() + { + GC.SuppressFinalize(this); + } + + #endregion + + #region "Private variables" + + private Color _sepDark = Color.FromArgb(154, 198, 255); + private Color _sepLight = Color.White; + private int _sepHeight = 8; + + private Color _gripTop = Color.FromArgb(111, 157, 217); + private Color _gripBottom = Color.White; + private GripType _gripStyle = GripType.Dotted; + private int _gripDistance = 4; + private Size _gripSize = new Size(2, 2); + + #endregion + + #region "Properties" + + /// + /// Gets or sets the color of the Toolstrip seperator on the dark side + /// + public Color SeperatorDark + { + get + { + return _sepDark; + } + + set + { + _sepDark = value; + } + } + + /// + /// Gets or sets the color of the Toolstrip seperator on the light side + /// + public Color SeperatorLight + { + get + { + return _sepLight; + } + + set + { + _sepLight = value; + } + } + + /// + /// Gets or sets the height of the Toolstrip seperator control + /// + public int SeperatorHeight + { + get + { + return _sepHeight; + } + + set + { + _sepHeight = value; + } + } + + /// + /// Gets or sets the color of the grip dots/line at the top + /// + public Color GripTop + { + get + { + return _gripTop; + } + + set + { + _gripTop = value; + } + } + + /// + /// Gets or sets the color of the grip shadow + /// + public Color GripShadow + { + get + { + return _gripBottom; + } + + set + { + _gripBottom = value; + } + } + + /// + /// Gets or sets in what mode the grip will be drawn + /// + public GripType GripStyle + { + get { return _gripStyle; } + set { _gripStyle = value; } + } + + /// + /// Gets or sets the distance, in pixels, between each grip dot + /// + public int GripDistance + { + get { return _gripDistance; } + set { _gripDistance = value; } + } + + /// + /// Gets or sets the size of the dots or lines for the grip + /// + public Size GripSize + { + get { return _gripSize; } + set { _gripSize = value; } + } + + #endregion + + #region "Methods" + + /// + /// Imports the settings from a previous or pre-defined IToolstripControls and applies it to the current + /// + /// The IToolstripControls to import the settings from + public void Apply(IToolstripControls Import) + { + _sepDark = Import._sepDark; + _sepLight = Import._sepLight; + _sepHeight = Import._sepHeight; + + _gripTop = Import._gripTop; + _gripBottom = Import._gripBottom; + _gripDistance = Import._gripDistance; + _gripStyle = Import._gripStyle; + _gripSize = Import._gripSize; + } + + #endregion + } + #endregion + + #region "EasyRender -- Button controlling class" + public class IButton : IDisposable + { + #region "Initialization and Setup" + + /// + /// Creates a new IButton class for customization + /// + public IButton() + { + DefaultBlending(); + } + + /// + /// Creates a new IButton class for customization + /// + /// The IButton to import the settings from + public IButton(IButton Import) + { + DefaultBlending(); + + Apply(Import); + } + + /// + /// Disposes of the IButton class and clears all resources related to it + /// + public void Dispose() + { + GC.SuppressFinalize(this); + } + + #endregion + + #region "Private variables" + + private Color _borderTop = Color.FromArgb(157, 183, 217); + private Color _borderBottom = Color.FromArgb(157, 183, 217); + private Color _borderInner = Color.FromArgb(255, 247, 185); + private Blend _borderBlend = null; + private float _borderAngle = 90f; + + private Color _hoverBackTop = Color.FromArgb(255, 249, 218); + private Color _hoverBackBottom = Color.FromArgb(237, 189, 62); + + private Color _clickBackTop = Color.FromArgb(245, 207, 57); + private Color _clickBackBottom = Color.FromArgb(245, 225, 124); + + private float _backAngle = 90f; + private Blend _backBlend = null; + + private BlendRender _blendRender = BlendRender.Hover | BlendRender.Click | BlendRender.Check; + private int _curve = 1; + + #endregion + + #region "Properties" + + /// + /// Gets or sets the color of the Button background at the top, when hovered over + /// + public Color HoverBackgroundTop + { + get + { + return _hoverBackTop; + } + + set + { + _hoverBackTop = value; + } + } + + /// + /// Gets or sets the color of the Button background at the bottom, when hovered over + /// + public Color HoverBackgroundBottom + { + get + { + return _hoverBackBottom; + } + + set + { + _hoverBackBottom = value; + } + } + + /// + /// Gets or sets the color of the Button background at the top, when clicked + /// + public Color ClickBackgroundTop + { + get + { + return _clickBackTop; + } + + set + { + _clickBackTop = value; + } + } + + /// + /// Gets or sets the color of the Button background at the bottom, when clicked + /// + public Color ClickBackgroundBottom + { + get + { + return _clickBackBottom; + } + + set + { + _clickBackBottom = value; + } + } + + /// + /// Gets or sets the blending that will occur when rendering the Button background + /// If set to null, the Button will simply draw the gradient + /// + public Blend BackgroundBlend + { + get + { + return _backBlend; + } + + set + { + _backBlend = value; + } + } + + /// + /// Gets or sets the angle which the Button background will be drawn + /// + public float BackgroundAngle + { + get + { + return _backAngle; + } + + set + { + _backAngle = value; + } + } + + /// + /// Gets or sets the color of the Button border gradient from the top + /// + public Color BorderTop + { + get + { + return _borderTop; + } + + set + { + _borderTop = value; + } + } + + /// + /// Gets or sets the color of the Button border gradient from the bottom + /// + public Color BorderBottom + { + get + { + return _borderBottom; + } + + set + { + _borderBottom = value; + } + } + + /// + /// Gets or sets the blending that will occur when rendering the Button border + /// If set to null, the Button will simply draw the border + /// + public Blend BorderBlend + { + get + { + return _borderBlend; + } + + set + { + _borderBlend = value; + } + } + + /// + /// Gets or sets the angle which the Button border will be drawn + /// + public float BorderAngle + { + get + { + return _borderAngle; + } + + set + { + _borderAngle = value; + } + } + + /// + /// Gets or sets the color of the inside border + /// + public Color InnerBorder + { + get { return _borderInner; } + set { _borderInner = value; } + } + + /// + /// Gets or sets when to apply the rendering ("Normal" does not apply here) + /// + public BlendRender BlendOptions + { + get + { + return _blendRender; + } + + set + { + _blendRender = value; + } + } + + /// + /// Gets or sets the curve of the border of the Button + /// + public int Curve + { + get + { + return _curve; + } + + set + { + _curve = value; + } + } + + #endregion + + #region "Methods" + + /// + /// Imports the settings from a previous or pre-defined IButton and applies it to the current + /// + /// The IButton to import the settings from + public void Apply(IButton Import) + { + _borderTop = Import._borderTop; + _borderBottom = Import._borderBottom; + _borderAngle = Import._borderAngle; + _borderBlend = Import._borderBlend; + + _hoverBackTop = Import._hoverBackTop; + _hoverBackBottom = Import._hoverBackBottom; + _clickBackTop = Import._clickBackTop; + _clickBackBottom = Import._clickBackBottom; + + _backAngle = Import._backAngle; + _backBlend = Import._backBlend; + + _blendRender = Import._blendRender; + _curve = Import._curve; + } + + /// + /// Sets the blending for both border and background to their defaults + /// + public void DefaultBlending() + { + _borderBlend = null; + + _backBlend = new Blend(); + _backBlend.Positions = new float[] { 0f, 0.5f, 0.5f, 1f }; + _backBlend.Factors = new float[] { 0f, 0.2f, 1f, 0.3f }; + } + + #endregion + } + + #endregion + + #region "EasyRender -- Dropdown Button controlling class" + public class IDropDownButton : IDisposable + { + #region "Initialization and Setup" + + /// + /// Creates a new IButton class for customization + /// + public IDropDownButton() + { + DefaultBlending(); + } + + /// + /// Creates a new IButton class for customization + /// + /// The IButton to import the settings from + public IDropDownButton(IDropDownButton Import) + { + DefaultBlending(); + + Apply(Import); + } + + /// + /// Disposes of the IButton class and clears all resources related to it + /// + public void Dispose() + { + GC.SuppressFinalize(this); + } + + #endregion + + #region "Private variables" + + private Color _borderTop = Color.FromArgb(157, 183, 217); + private Color _borderBottom = Color.FromArgb(157, 183, 217); + private Color _borderInner = Color.FromArgb(255, 247, 185); + private Blend _borderBlend = null; + private float _borderAngle = 90f; + + private Color _hoverBackTop = Color.FromArgb(255, 249, 218); + private Color _hoverBackBottom = Color.FromArgb(237, 189, 62); + + private float _backAngle = 90f; + private Blend _backBlend = null; + + private BlendRender _blendRender = BlendRender.Hover | BlendRender.Check; + private int _curve = 1; + + #endregion + + #region "Properties" + + /// + /// Gets or sets the color of the Button background at the top, when hovered over + /// + public Color HoverBackgroundTop + { + get + { + return _hoverBackTop; + } + + set + { + _hoverBackTop = value; + } + } + + /// + /// Gets or sets the color of the Button background at the bottom, when hovered over + /// + public Color HoverBackgroundBottom + { + get + { + return _hoverBackBottom; + } + + set + { + _hoverBackBottom = value; + } + } + + /// + /// Gets or sets the blending that will occur when rendering the Button background + /// If set to null, the Button will simply draw the gradient + /// + public Blend BackgroundBlend + { + get + { + return _backBlend; + } + + set + { + _backBlend = value; + } + } + + /// + /// Gets or sets the angle which the Button background will be drawn + /// + public float BackgroundAngle + { + get + { + return _backAngle; + } + + set + { + _backAngle = value; + } + } + + /// + /// Gets or sets the color of the Button border gradient from the top + /// + public Color BorderTop + { + get + { + return _borderTop; + } + + set + { + _borderTop = value; + } + } + + /// + /// Gets or sets the color of the Button border gradient from the bottom + /// + public Color BorderBottom + { + get + { + return _borderBottom; + } + + set + { + _borderBottom = value; + } + } + + /// + /// Gets or sets the blending that will occur when rendering the Button border + /// If set to null, the Button will simply draw the border + /// + public Blend BorderBlend + { + get + { + return _borderBlend; + } + + set + { + _borderBlend = value; + } + } + + /// + /// Gets or sets the angle which the Button border will be drawn + /// + public float BorderAngle + { + get + { + return _borderAngle; + } + + set + { + _borderAngle = value; + } + } + + /// + /// Gets or sets the color of the inside border + /// + public Color InnerBorder + { + get { return _borderInner; } + set { _borderInner = value; } + } + + /// + /// Gets or sets when to apply the rendering ("Normal" and "Click" do not apply here) + /// + public BlendRender BlendOptions + { + get + { + return _blendRender; + } + + set + { + _blendRender = value; + } + } + + /// + /// Gets or sets the curve of the border of the Button + /// + public int Curve + { + get + { + return _curve; + } + + set + { + _curve = value; + } + } + + #endregion + + #region "Methods" + + /// + /// Imports the settings from a previous or pre-defined IDropDownButton and applies it to the current + /// + /// The IDropDownButton to import the settings from + public void Apply(IDropDownButton Import) + { + _borderTop = Import._borderTop; + _borderBottom = Import._borderBottom; + _borderAngle = Import._borderAngle; + _borderBlend = Import._borderBlend; + + _hoverBackTop = Import._hoverBackTop; + _hoverBackBottom = Import._hoverBackBottom; + + _backAngle = Import._backAngle; + _backBlend = Import._backBlend; + + _blendRender = Import._blendRender; + _curve = Import._curve; + } + + /// + /// Sets the blending for both border and background to their defaults + /// + public void DefaultBlending() + { + _borderBlend = null; + + _backBlend = new Blend(); + _backBlend.Positions = new float[] { 0f, 0.5f, 0.5f, 1f }; + _backBlend.Factors = new float[] { 0f, 0.2f, 1f, 0.3f }; + } + + #endregion + } + + #endregion + + #region "EasyRender -- Split Button controlling class" + public class ISplitButton : IDisposable + { + #region "Initialization and Setup" + + /// + /// Creates a new ISplitButton class for customization + /// + public ISplitButton() + { + DefaultBlending(); + } + + /// + /// Disposes of the ISplitButton class and clears all resources related to it + /// + public void Dispose() + { + GC.SuppressFinalize(this); + } + + #endregion + + #region "Private variables" + + private Color _borderTop = Color.FromArgb(157, 183, 217); + private Color _borderBottom = Color.FromArgb(157, 183, 217); + private Color _borderInner = Color.FromArgb(255, 247, 185); + private Blend _borderBlend = null; + private float _borderAngle = 90f; + + private Color _hoverBackTop = Color.FromArgb(255, 249, 218); + private Color _hoverBackBottom = Color.FromArgb(237, 189, 62); + + private Color _clickBackTop = Color.FromArgb(245, 207, 57); + private Color _clickBackBottom = Color.FromArgb(245, 225, 124); + + private float _backAngle = 90f; + private Blend _backBlend = null; + + private ArrowDisplay _arrowDisplay = ArrowDisplay.Always; + private Color _arrowColor = Color.Black; + + private BlendRender _blendRender = BlendRender.Hover | BlendRender.Click | BlendRender.Check; + private int _curve = 1; + + #endregion + + #region "Properties" + + /// + /// Gets or sets the color of the Button background at the top, when hovered over + /// + public Color HoverBackgroundTop + { + get + { + return _hoverBackTop; + } + + set + { + _hoverBackTop = value; + } + } + + /// + /// Gets or sets the color of the Button background at the bottom, when hovered over + /// + public Color HoverBackgroundBottom + { + get + { + return _hoverBackBottom; + } + + set + { + _hoverBackBottom = value; + } + } + + /// + /// Gets or sets the color of the Button background at the top, when clicked + /// + public Color ClickBackgroundTop + { + get + { + return _clickBackTop; + } + + set + { + _clickBackTop = value; + } + } + + /// + /// Gets or sets the color of the Button background at the bottom, when clicked + /// + public Color ClickBackgroundBottom + { + get + { + return _clickBackBottom; + } + + set + { + _clickBackBottom = value; + } + } + + /// + /// Gets or sets the blending that will occur when rendering the Button background + /// If set to null, the Button will simply draw the gradient + /// + public Blend BackgroundBlend + { + get + { + return _backBlend; + } + + set + { + _backBlend = value; + } + } + + /// + /// Gets or sets the angle which the Button background will be drawn + /// + public float BackgroundAngle + { + get + { + return _backAngle; + } + + set + { + _backAngle = value; + } + } + + /// + /// Gets or sets the color of the Button border gradient from the top + /// + public Color BorderTop + { + get + { + return _borderTop; + } + + set + { + _borderTop = value; + } + } + + /// + /// Gets or sets the color of the Button border gradient from the bottom + /// + public Color BorderBottom + { + get + { + return _borderBottom; + } + + set + { + _borderBottom = value; + } + } + + /// + /// Gets or sets the blending that will occur when rendering the Button border + /// If set to null, the Button will simply draw the border + /// + public Blend BorderBlend + { + get + { + return _borderBlend; + } + + set + { + _borderBlend = value; + } + } + + /// + /// Gets or sets the angle which the Button border will be drawn + /// + public float BorderAngle + { + get + { + return _borderAngle; + } + + set + { + _borderAngle = value; + } + } + + /// + /// Gets or sets the color of the inside border + /// + public Color InnerBorder + { + get { return _borderInner; } + set { _borderInner = value; } + } + + /// + /// Gets or sets when to apply the rendering ("Normal" does not apply here) + /// + public BlendRender BlendOptions + { + get + { + return _blendRender; + } + + set + { + _blendRender = value; + } + } + + /// + /// Gets or sets the curve of the border of the Button + /// + public int Curve + { + get + { + return _curve; + } + + set + { + _curve = value; + } + } + + /// + /// Gets or sets when to display the drop-down arrow + /// + public ArrowDisplay ArrowDisplay + { + get { return _arrowDisplay; } + set { _arrowDisplay = value; } + } + + /// + /// Gets or sets the color of the drop-down arrow + /// + public Color ArrowColor + { + get { return _arrowColor; } + set { _arrowColor = value; } + } + + #endregion + + #region "Methods" + + /// + /// Imports the settings from a previous or pre-defined ISplitButton and applies it to the current + /// + /// The ISplitButton to import the settings from + public void Apply(ISplitButton Import) + { + _borderTop = Import._borderTop; + _borderBottom = Import._borderBottom; + _borderAngle = Import._borderAngle; + _borderBlend = Import._borderBlend; + + _hoverBackTop = Import._hoverBackTop; + _hoverBackBottom = Import._hoverBackBottom; + _clickBackTop = Import._clickBackTop; + _clickBackBottom = Import._clickBackBottom; + + _backAngle = Import._backAngle; + _backBlend = Import._backBlend; + + _blendRender = Import._blendRender; + _curve = Import._curve; + + _arrowDisplay = Import._arrowDisplay; + _arrowColor = Import._arrowColor; + } + + /// + /// Sets the blending for both border and background to their defaults + /// + public void DefaultBlending() + { + _borderBlend = null; + + _backBlend = new Blend(); + _backBlend.Positions = new float[] { 0f, 0.5f, 0.5f, 1f }; + _backBlend.Factors = new float[] { 0f, 0.2f, 1f, 0.3f }; + } + + #endregion + } + #endregion + + #region "EasyRender -- Content and Panel controlling class" + public class IPanel : IDisposable + { + #region "Initialization and Setup" + + /// + /// Creates a new IPanel class for customization + /// + public IPanel() + { + } + + /// + /// Disposes of the IButton class and clears all resources related to it + /// + public void Dispose() + { + GC.SuppressFinalize(this); + } + + #endregion + + #region "Private variables" + + private Color _cPanelTop = Color.FromArgb(191, 219, 255); + private Color _cPanelBottom = Color.FromArgb(132, 171, 227); + private float _cPanelAngle = 90f; + private Blend _cPanelBlend = null; + + private SmoothingMode _mode = SmoothingMode.HighSpeed; + + private Boolean _panelsInherit = false; + + #endregion + + #region "Properties" + + /// + /// Gets or sets the color of the gradient at the top of the content panel + /// + public Color ContentPanelTop + { + get { return _cPanelTop; } + set { _cPanelTop = value; } + } + + /// + /// Gets or sets the color of the gradient at the bottom of the content panel + /// + public Color ContentPanelBottom + { + get { return _cPanelBottom; } + set { _cPanelBottom = value; } + } + + /// + /// Gets or sets whether each panel inherits the shading from the content panel + /// + public Boolean PanelInheritance + { + get { return _panelsInherit; } + set { _panelsInherit = value; } + } + + /// + /// Gets or sets the angle which the background gradient is drawn + /// + public float BackgroundAngle + { + get { return _cPanelAngle; } + set { _cPanelAngle = value; } + } + + /// + /// Gets or sets the blend of the background + /// + public Blend BackgroundBlend + { + get { return _cPanelBlend; } + set { _cPanelBlend = value; } + } + + /// + /// Gets or sets a mode to render the background in + /// + public SmoothingMode Mode + { + get { return _mode; } + set { _mode = value; } + } + + #endregion + } + #endregion + + #region "EasyRender -- Status bar controlling class + public class IStatusBar : IDisposable + { + #region "Initialization and Setup" + + /// + /// Creates a new IStatusBar class for customization + /// + public IStatusBar() + { + DefaultBlending(); + } + + /// + /// Disposes of the IButton class and clears all resources related to it + /// + public void Dispose() + { + GC.SuppressFinalize(this); + } + + #endregion + + #region "Private variables" + + private Color _backTop = Color.FromArgb(227, 239, 255); + private Color _backBottom = Color.FromArgb(173, 209, 255); + private Blend _backBlend = null; + private float _backAngle = 90; + + private Color _borderDark = Color.FromArgb(86, 125, 176); + private Color _borderLight = Color.White; + //private Blend _borderBlend = null; + //private float _borderAngle = 90; + + private Color _gripTop = Color.FromArgb(114, 152, 204); + private Color _gripBottom = Color.FromArgb(248, 248, 248); + private Int32 _gripSpacing = 4; + + #endregion + + #region "Properties" + + /// + /// Gets or sets the color of the gradient of the background at the top + /// + public Color BackgroundTop + { + get { return _backTop; } + set { _backTop = value; } + } + + /// + /// Gets or sets the color of the gradient of the background at the bottom + /// + public Color BackgroundBottom + { + get { return _backBottom; } + set { _backBottom = value; } + } + + /// + /// Gets or sets the blending that will apply to the background + /// + public Blend BackgroundBlend + { + get { return _backBlend; } + set { _backBlend = value; } + } + + /// + /// Gets or sets the angle which the background gradient will be drawn + /// + public float BackgroundAngle + { + get { return _backAngle; } + set { _backAngle = value; } + } + + /// + /// Gets or sets the color of the dark border + /// + public Color DarkBorder + { + get { return _borderDark; } + set { _borderDark = value; } + } + + /// + /// Gets or sets the color of the light border + /// + public Color LightBorder + { + get { return _borderLight; } + set { _borderLight = value; } + } + + /// + /// Gets or sets the color of the grip at the top-most + /// + public Color GripTop + { + get { return _gripTop; } + set { _gripTop = value; } + } + + /// + /// Gets or sets the color of the grip at the bottom-most + /// + public Color GripBottom + { + get { return _gripBottom; } + set { _gripBottom = value; } + } + + /// + /// Gets or sets the spacing of the grip blocks + /// + public Int32 GripSpacing + { + get { return _gripSpacing; } + set { _gripSpacing = value; } + } + + #endregion + + #region "Methods" + + /// + /// Imports the settings from a previous or pre-defined IStatusBar and applies it to the current + /// + /// The IStatusBar to import the settings from + public void Apply(IStatusBar Import) + { + _borderDark = Import._borderDark; + _borderLight = Import._borderLight; + + _backTop = Import._backTop; + _backBottom = Import._backBottom; + _backAngle = Import._backAngle; + _backBlend = Import._backBlend; + } + + /// + /// Sets the blending for both border and background to their defaults + /// + public void DefaultBlending() + { + //_borderBlend = null; + + _backBlend = new Blend(); + _backBlend.Positions = new float[] { 0f, 0.25f, 0.25f, 0.57f, 0.86f, 1f }; + _backBlend.Factors = new float[] { 0.1f, 0.6f, 1f, 0.4f, 0f, 0.95f }; + } + + #endregion + } + #endregion + + #region "EasyRender -- Menustrip controlling class" + /// + /// A class designed to be used in the EasyRender master control to customize the look and feel of the base Menustrip + /// + public class IMenustrip : IDisposable + { + #region "Initialization and Setup" + + /// + /// Creates a new IToolstrip class for customization + /// + public IMenustrip() + { + _buttons = new IButton(); + + DefaultBlending(); + } + + /// + /// Creates a new IMenustrip class for customization + /// + /// The IMenustrip to import the settings from + public IMenustrip(IMenustrip Import) + { + _buttons = new IButton(); + + DefaultBlending(); + + Apply(Import); + } + + /// + /// Disposes of the IMenustrip class and clears all resources related to it + /// + public void Dispose() + { + GC.SuppressFinalize(this); + } + + #endregion + + #region "Private variables" + + private Color _menuBorderDark = Color.FromArgb(157, 183, 217); + private Color _menuBorderLight = Color.Transparent; + + private InheritenceType _menuBackInh = InheritenceType.FromContentPanel; + private Color _menuBackTop = Color.White; + private Color _menuBackBottom = Color.White; + private Blend _menuBackBlend = null; + + private Color _menuStripBtnBackground = Color.White; + private Color _menuStripBtnBorder = Color.FromArgb(157, 183, 217); + + private IButton _buttons = null; + + private Color _marginLeft = Color.FromArgb(242, 255, 255); + private Color _marginRight = Color.FromArgb(233, 238, 238); + private Color _marginBorder = Color.FromArgb(197, 197, 197); + + private Color _sepDark = Color.FromArgb(197, 197, 197); + private Color _sepLight = Color.FromArgb(254, 254, 254); + private Int32 _sepInset = 30; + + #endregion + + #region "Properties" + + /// + /// Gets or sets the color of the menu-strip border (dark) + /// + public Color MenuBorderDark + { + get { return _menuBorderDark; } + set { _menuBorderDark = value; } + } + + /// + /// Gets or sets the color of the menu-strip border (light) + /// + public Color MenuBorderLight + { + get { return _menuBorderLight; } + set { _menuBorderLight = value; } + } + + /// + /// Gets or sets how the background of the menu-strip is inherited + /// + public InheritenceType BackgroundInheritence + { + get { return _menuBackInh; } + set { _menuBackInh = value; } + } + + /// + /// If inheritence is set to none, the color of the background gradient at the top + /// + public Color BackgroundTop + { + get { return _menuBackTop; } + set { _menuBackTop = value; } + } + + /// + /// If inheritence is set to none, the color of the background gradient at the bottom + /// + public Color BackgroundBottom + { + get { return _menuBackBottom; } + set { _menuBackBottom = value; } + } + + /// + /// If inheritence is set to none, the blending option for the background + /// + public Blend BackgroundBlend + { + get { return _menuBackBlend; } + set { _menuBackBlend = value; } + } + + /// + /// Gets or sets the color of the margin gradient at the left + /// + public Color MarginLeft + { + get { return _marginLeft; } + set { _marginLeft = value; } + } + + /// + /// Gets or sets the color of the margin gradient at the right + /// + public Color MarginRight + { + get { return _marginRight; } + set { _marginRight = value; } + } + + /// + /// Gets or sets the color of the margin border (displayed to the right) + /// + public Color MarginBorder + { + get { return _marginBorder; } + set { _marginBorder = value; } + } + + /// + /// Gets or sets the color of the root menu-strip button background when it is selected + /// + public Color MenustripButtonBackground + { + get { return _menuStripBtnBackground; } + set { _menuStripBtnBackground = value; } + } + + /// + /// Gets or sets the color of the root menu-strip button border when it is selected + /// + public Color MenustripButtonBorder + { + get { return _menuStripBtnBorder; } + set { _menuStripBtnBorder = value; } + } + + /// + /// Gets or sets the color of the seperator dark color + /// + public Color SeperatorDark + { + get { return _sepDark; } + set { _sepDark = value; } + } + + /// + /// Gets or sets the color of the seperator light color + /// + public Color SeperatorLight + { + get { return _sepLight; } + set { _sepLight = value; } + } + + /// + /// Gets or sets the inset position of the seperator from the left + /// + public Int32 SeperatorInset + { + get { return _sepInset; } + set { _sepInset = value; } + } + + /// + /// Gets the class that handles the look and feel of the menu-strip items + /// + [ReadOnly(true)] + public IButton Items + { + get { return _buttons; } + } + + #endregion + + #region "Methods" + + /// + /// Imports the settings from a previous or pre-defined IMenustrip and applies it to the current + /// + /// The IMenustrip to import the settings from + public void Apply(IMenustrip Import) + { + _menuBackInh = Import._menuBackInh; + _menuBackTop = Import._menuBackTop; + _menuBackBottom = Import._menuBackBottom; + _menuBorderDark = Import._menuBorderDark; + _menuBorderLight = Import._menuBorderLight; + _menuBackBlend = Import._menuBackBlend; + _buttons = Import._buttons; + } + + /// + /// Sets the blending for the background to it's default + /// + public void DefaultBlending() + { + _menuBackBlend = new Blend(); + _menuBackBlend.Positions = new float[] { 0f, 0.3f, 0.5f, 0.8f, 1f }; + _menuBackBlend.Factors = new float[] { 0f, 0f, 0f, 0.5f, 1f }; + } + + #endregion + } + #endregion + + #region "EasyRender -- Enumerators" + + /// + /// Defines when to show an arrow + /// + public enum ArrowDisplay + { + Always, + Hover, + Never + } + + /// + /// Defines when to use a blend property + /// + public enum BlendRender + { + /// + /// Use the blend when the object is drawn + /// + Normal, + /// + /// Use the blend when the object is hovered over + /// + Hover, + /// + /// Use the blend when the object is clicked + /// + Click, + /// + /// Use the blend when the object is checked + /// + Check, + /// + /// Always use the blend regardless of the state of the object + /// + All = Normal | Hover | Click | Check + } + + /// + /// Defines a method of drawing a grip on a control + /// + public enum GripType + { + /// + /// Draws the grip as a set of dots + /// + Dotted, + /// + /// Draws the grip as two lines + /// + Lines, + /// + /// Does not draw the grip at all, but the object remains moveable + /// + None + } + + /// + /// Defines a specific type of button to search by + /// + public enum ButtonType + { + NormalButton, + SplitButton, + MenuItem, + DropDownButton + } + + /// + /// Defines a method for background or object inheritence + /// + public enum InheritenceType + { + FromContentPanel, + None + } + + /// + /// Defines a method of rendering + /// + public enum RenderingMode + { + System, + Professional, + Custom + } + + #endregion +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Renderer/ToolStripRenders.cs b/Source/ryControls/Sheng.Winform.Controls/Renderer/ToolStripRenders.cs new file mode 100644 index 0000000..5f72c26 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Renderer/ToolStripRenders.cs @@ -0,0 +1,256 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; + +namespace Sheng.Winform.Controls +{ + public static class ToolStripRenders + { + static ToolStripRenders() + { + } + + private static SEToolStripRender _default; + public static SEToolStripRender Default + { + get + { + if (_default == null) + { + _default = new SEToolStripRender(); + _default.Panels.ContentPanelTop = Color.FromArgb(241, 239, 228); + + _default.Toolstrip.BackgroundTop = Color.FromArgb(250, 249, 245); + _default.Toolstrip.BackgroundBottom = Color.FromArgb(200, 199, 178); + _default.Toolstrip.BorderBottom = Color.FromArgb(200, 199, 178); + + _default.StatusBar.DarkBorder = Color.FromArgb(250, 249, 245); + _default.StatusBar.BackgroundTop = Color.FromArgb(250, 249, 245); + _default.StatusBar.BackgroundBottom = Color.FromArgb(200, 199, 178); + + _default.Toolstrip.Curve = 0; + _default.AlterColor = true; + _default.OverrideColor = Color.Black; + } + + return _default; + } + } + + private static SEToolStripRender _mainMenu; + /// + /// 主菜单 + /// + public static SEToolStripRender MainMenu + { + get + { + if (_mainMenu == null) + { + _mainMenu = new SEToolStripRender(); + + //_mainMenu.Panels.BackgroundAngle = 0; + _mainMenu.Panels.ContentPanelTop = SystemColors.Control; + //_mainMenu.Panels.ContentPanelBottom = Color.Yellow; + + _mainMenu.AlterColor = true; + _mainMenu.OverrideColor = Color.Black; + } + + return _mainMenu; + } + } + + private static SEToolStripRender _transparentToolStrip; + /// + /// 背景透明的工具条 + /// + public static SEToolStripRender TransparentToolStrip + { + get + { + if (_transparentToolStrip == null) + { + _transparentToolStrip = new SEToolStripRender(); + + _transparentToolStrip.Panels.ContentPanelTop = Color.Transparent; + + _transparentToolStrip.Toolstrip.BackgroundTop = Color.Transparent; + _transparentToolStrip.Toolstrip.BackgroundBottom = Color.Transparent; + _transparentToolStrip.Toolstrip.BorderTop = Color.Transparent; + _transparentToolStrip.Toolstrip.BorderBottom = Color.Transparent; + + _transparentToolStrip.Toolstrip.Curve = 0; + _transparentToolStrip.AlterColor = true; + _transparentToolStrip.OverrideColor = Color.Black; + } + + return _transparentToolStrip; + } + } + + private static SEToolStripRender _silverGrayToWhite; + /// + /// 银白色至白色渐变 + /// + public static SEToolStripRender SilverGrayToWhite + { + get + { + if (_silverGrayToWhite == null) + { + _silverGrayToWhite = new SEToolStripRender(); + + _silverGrayToWhite.Panels.ContentPanelTop = Color.FromArgb(243, 242, 236); + _silverGrayToWhite.Toolstrip.BackgroundTop = Color.FromArgb(243, 242, 236); + _silverGrayToWhite.Toolstrip.BackgroundBottom = Color.White; + + _silverGrayToWhite.Toolstrip.BorderBottom = Color.FromArgb(243, 242, 236); + _silverGrayToWhite.Toolstrip.BorderTop = Color.FromArgb(243, 242, 236); + + _silverGrayToWhite.Toolstrip.Curve = 0; + _silverGrayToWhite.AlterColor = true; + _silverGrayToWhite.OverrideColor = Color.Black; + } + + return _silverGrayToWhite; + } + } + + private static SEToolStripRender _whiteToSilverGray; + /// + /// 白色至银白色渐变 + /// + public static SEToolStripRender WhiteToSilverGray + { + get + { + if (_whiteToSilverGray == null) + { + _whiteToSilverGray = new SEToolStripRender(); + + _whiteToSilverGray.Panels.ContentPanelTop = Color.FromArgb(243, 242, 236); + _whiteToSilverGray.Toolstrip.BackgroundTop = Color.White; + _whiteToSilverGray.Toolstrip.BackgroundBottom = Color.FromArgb(243, 242, 236); + + _whiteToSilverGray.Toolstrip.BorderBottom = Color.FromArgb(243, 242, 236); + _whiteToSilverGray.Toolstrip.BorderTop = Color.FromArgb(243, 242, 236); + + _whiteToSilverGray.Toolstrip.Curve = 0; + _whiteToSilverGray.AlterColor = true; + _whiteToSilverGray.OverrideColor = Color.Black; + } + + return _whiteToSilverGray; + } + } + + private static SEToolStripRender _controlToControlLight; + public static SEToolStripRender ControlToControlLight + { + get + { + if (_controlToControlLight == null) + { + _controlToControlLight = new SEToolStripRender(); + + _controlToControlLight.Panels.ContentPanelTop = SystemColors.Control; + + _controlToControlLight.Toolstrip.BackgroundTop = SystemColors.Control; + _controlToControlLight.Toolstrip.BackgroundBottom = SystemColors.ControlLight; + _controlToControlLight.Toolstrip.BorderTop = SystemColors.ControlLight; + _controlToControlLight.Toolstrip.BorderBottom = SystemColors.ControlLight; + + _controlToControlLight.Toolstrip.Curve = 0; + _controlToControlLight.AlterColor = true; + _controlToControlLight.OverrideColor = Color.Black; + } + + return _controlToControlLight; + } + } + + private static SEToolStripRender _control; + public static SEToolStripRender Control + { + get + { + if (_control == null) + { + _control = new SEToolStripRender(); + + _control.Panels.ContentPanelTop = SystemColors.Control; + + _control.Toolstrip.BackgroundTop = SystemColors.Control; + _control.Toolstrip.BackgroundBottom = SystemColors.Control; + _control.Toolstrip.BorderTop = SystemColors.Control; + _control.Toolstrip.BorderBottom = SystemColors.Control; + _control.Toolstrip.Curve = 0; + _control.AlterColor = true; + _control.OverrideColor = Color.Black; + } + + return _control; + } + } + + private static SEToolStripRender _activateToolStrip; + /// + /// 当前工作区窗体所关联并激活的工具栏 + /// + public static SEToolStripRender ActivateToolStrip + { + get + { + if (_activateToolStrip == null) + { + _activateToolStrip = new SEToolStripRender(); + + _activateToolStrip.Panels.ContentPanelTop = SystemColors.Control; + + _activateToolStrip.Toolstrip.BackgroundTop = SystemColors.Control; + _activateToolStrip.Toolstrip.BackgroundBottom = Color.LightGreen; + _activateToolStrip.Toolstrip.BorderTop = SystemColors.Control; + _activateToolStrip.Toolstrip.BorderBottom = SystemColors.Control; + _activateToolStrip.Toolstrip.Curve = 0; + _activateToolStrip.AlterColor = true; + _activateToolStrip.OverrideColor = Color.Black; + } + + return _activateToolStrip; + } + } + + private static SEToolStripRender _shell; + /// + /// 模拟运行时的外观 + /// + public static SEToolStripRender Shell + { + get + { + if (_shell == null) + { + _shell = new SEToolStripRender(); + _shell.Panels.ContentPanelTop = Color.FromArgb(241, 239, 228); + + _shell.Toolstrip.BackgroundTop = Color.FromArgb(250, 249, 245); + _shell.Toolstrip.BackgroundBottom = Color.FromArgb(200, 199, 178); + _shell.Toolstrip.BorderBottom = Color.FromArgb(200, 199, 178); + + _shell.StatusBar.DarkBorder = Color.FromArgb(250, 249, 245); + _shell.StatusBar.BackgroundTop = Color.FromArgb(250, 249, 245); + _shell.StatusBar.BackgroundBottom = Color.FromArgb(200, 199, 178); + + _shell.Toolstrip.Curve = 0; + _shell.AlterColor = true; + _shell.OverrideColor = Color.Black; + } + + return _shell; + } + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengComboSelector2/Enums.cs b/Source/ryControls/Sheng.Winform.Controls/ShengComboSelector2/Enums.cs new file mode 100644 index 0000000..a435229 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengComboSelector2/Enums.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sheng.Winform.Controls +{ + /// + /// Represents the visual state of an image list view item. + /// + [Flags] + public enum ShengComboSelectorState + { + /// + /// 没有任何选择状态,处于一般正常状态 + /// + None = 0, + /// + /// 项处于选中状态 + /// + Selected = 1, + /// + /// 鼠标滑过 + /// + Hovered = 2, + //再加不要忘了是4 + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengComboSelector2/ShengComboSelector2.cs b/Source/ryControls/Sheng.Winform.Controls/ShengComboSelector2/ShengComboSelector2.cs new file mode 100644 index 0000000..9e421e1 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengComboSelector2/ShengComboSelector2.cs @@ -0,0 +1,807 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Drawing; +using System.Drawing.Drawing2D; +using Sheng.Winform.Controls.PopupControl; +using System.Collections; +using Sheng.Winform.Controls.Kernal; +using Sheng.Winform.Controls.Drawing; +using System.ComponentModel; + +namespace Sheng.Winform.Controls +{ + /* + * 控件的高度根据内容自动调整,忽略外部设置 + */ + public class ShengComboSelector2 : Control, IShengValidate + { + #region 私有成员 + + /// + /// 边框宽度 + /// + const int _borderSize = 1; + + /* + * 下拉框弹出之后,再次点击控件,下拉框又会闪出来 + * 是因为点控件,下拉框自动关闭,但因为点了控件,所以下拉框又会闪出来 + * 所以在下拉框关闭时,记下时间,点击时判断与上次下拉框关闭时的时间间隔 + * 如果过小,就不打开下拉框 + */ + private DateTime _dropDownHideTime; + + private Popup _popup; + private ShengListView _listView; + + #region 当前状态 + + private ShengComboSelectorState _state = ShengComboSelectorState.None; + + private bool Selected + { + get + { + return (_state & ShengComboSelectorState.Selected) == ShengComboSelectorState.Selected; + } + set + { + bool selected = Selected; + + if (value) + _state = _state | ShengComboSelectorState.Selected; + else + _state = _state ^ ShengComboSelectorState.Selected; + + if (selected != Selected) + Refresh(); + } + } + + private bool Hovered + { + get + { + return (_state & ShengComboSelectorState.Hovered) == ShengComboSelectorState.Hovered; + } + set + { + bool hovered = Hovered; + + if (value) + _state = _state | ShengComboSelectorState.Hovered; + else + _state = _state ^ ShengComboSelectorState.Hovered; + + if (hovered != Hovered) + Refresh(); + } + } + + #endregion + + #region 绘图表面 + + //箭头的大小是指的箭头的高度,宽度将是高度的2倍 + private int _buttonSize =6; + + /// + /// 文本和description文本之间的间距 + /// + private int _textSpaceBetween = 2; + + private TextFormatFlags _textFlags = TextFormatFlags.SingleLine | TextFormatFlags.WordEllipsis; + + #endregion + + #endregion + + #region 公开属性 + + private int _maxItem = 5; + /// + /// 最大显示的项数 + /// + public int MaxItem + { + get { return _maxItem; } + set { _maxItem = value; } + } + + private ShengComboSelectorTheme _theme = new ShengComboSelectorTheme(); + public ShengComboSelectorTheme Theme + { + get { return _theme; } + set { _theme = value; } + } + + private bool _showDescription = true; + /// + /// 是否显示说明字段,此属性不影响弹出面板是否显示 + /// 弹出面板是否显示由DescriptionMember是否设置决定 + /// + public bool ShowDescription + { + get { return _showDescription; } + set + { + _showDescription = value; + this.Height = MeasureHeight(); + } + } + + public string DisplayMember + { + get { return _listView.DisplayMember; } + set { _listView.DisplayMember = value; } + } + + private string _descriptionMember; + public string DescriptionMember + { + get { return _descriptionMember; } + set + { + _descriptionMember = value; + _listView.SetExtendMember(ShengListViewDescriptiveMembers.DescriptioinMember, value); + } + } + + /// + /// 下拉列表的布局模式 + /// + public ShengListViewLayoutMode LayoutMode + { + get { return _listView.LayoutMode; } + set { _listView.LayoutMode = value; } + } + + public override Font Font + { + get + { + return base.Font; + } + set + { + base.Font = value; + this.Height = MeasureHeight(); + } + } + + #region 数据校验有关 + + private bool allowEmpty = true; + /// + /// 是否允许空 + /// + [Description("是否允许空")] + [Category("Sheng.Winform.Controls")] + public bool AllowEmpty + { + get + { + return this.allowEmpty; + } + set + { + this.allowEmpty = value; + } + } + + #endregion + + #endregion + + #region 构造 + + public ShengComboSelector2() + { + if (DesignMode) + return; + + SetStyle(ControlStyles.ResizeRedraw, true); + SetStyle(ControlStyles.OptimizedDoubleBuffer, true); + SetStyle(ControlStyles.Selectable, true); + + this.Padding = new System.Windows.Forms.Padding(5); + + _listView = new ShengListView(); + _listView.Padding = new System.Windows.Forms.Padding(0); + _listView.BorderStyle = BorderStyle.None; + _listView.AllowMultiSelection = false; + _listView.LayoutMode = ShengListViewLayoutMode.Descriptive; + + //SelectedItemChanaged事件不行,如果就点当前已选中的项,就关不掉下拉框了 + _listView.Click += new EventHandler(_listView_Click); + _listView.SelectedItemChanaged += new EventHandler(_listView_SelectedItemChanaged); + _listView.ItemTextGetting += new EventHandler(_listView_ItemTextGetting); + + _popup = new Popup(_listView); + _popup.Closed += new ToolStripDropDownClosedEventHandler(_popup_Closed); + + this._dropDownHideTime = DateTime.UtcNow; + + ApplyTheme(); + } + + #endregion + + #region 事件处理 + + void _listView_Click(object sender, EventArgs e) + { + _popup.Close(); + } + + void _listView_SelectedItemChanaged(object sender, EventArgs e) + { + object value = GetSelectedValue(); + OnSelectedValueChanged(value); + } + + void _listView_ItemTextGetting(object sender, ShengListViewGetItemTextEventArgs e) + { + if (this.ItemTextGetting != null) + { + ItemTextGettingEventArgs args = new ItemTextGettingEventArgs(e.Item); + ItemTextGetting(this, args); + e.Text = args.Text; + } + } + + void _popup_Closed(object sender, ToolStripDropDownClosedEventArgs e) + { + _dropDownHideTime = DateTime.UtcNow; + + this.Selected = false; + } + + #endregion + + #region 方法 + + #region private + + private void ApplyTheme() + { + this.BackColor = _theme.BackgroundColor; + + _listView.Theme.HoverColorStart = _theme.HoveredBackColor; + _listView.Theme.HoverColorEnd = Color.FromArgb(125, _theme.HoveredBackColor); + _listView.Theme.ItemBorderColor = _theme.HoveredBorderColor; + _listView.Theme.SelectedColorStart = _theme.SelectedBackColor; + _listView.Theme.SelectedColorEnd = Color.FromArgb(125, _theme.HoveredBackColor); + } + + private void OnSelectedValueChanged(object value) + { + //允许value为null + //从原来有选定的变为没选定了,事件肯定还是要触发的 + if (this.SelectedValueChanged != null) + { + SelectedValueChanged(this, new OnSelectedValueChangedEventArgs(value)); + } + } + + /// + /// 测量当前控件应该的高度 + /// + /// + private int MeasureHeight() + { + int textHeight = this.FontHeight; + + int height = _borderSize * 2 + textHeight + Padding.Top + Padding.Bottom; + + if (ShowDescription) + height = height + textHeight + _textSpaceBetween; + + return height; + } + + /// + /// 整个可用的绘图表面 + /// + private Rectangle GetBorderRectangle() + { + Rectangle rect = new Rectangle(this.ClientRectangle.Location, this.ClientRectangle.Size); + rect.Width--; + rect.Height--; + return rect; + } + + private Rectangle GetContentRectangle() + { + Rectangle contentRectangle = GetBorderRectangle(); + //return Rectangle.Inflate(contentRectangle, -1, -1); + + contentRectangle.X += 1; + contentRectangle.Y += 1; + contentRectangle.Width -= 1; + contentRectangle.Height -= 1; + + return contentRectangle; + } + + /// + /// 右边按钮的绘图表面 + /// + private Rectangle GetButtonAreaRectangle() + { + Rectangle clientRectangle = ClientRectangle; + + Rectangle rectangle = new Rectangle(); + //箭头的大小是指的箭头的高度,宽度将是高度的2倍 + rectangle.Size = new Size(_buttonSize * 2, _buttonSize); + rectangle.Location = new Point( + clientRectangle.Width - rectangle.Width - Padding.Right, + (clientRectangle.Height - rectangle.Height) / 2); + return rectangle; + } + + private Rectangle GetTextRectangle() + { + Rectangle clientRectangle = GetContentRectangle(); + Rectangle buttonRectangle = GetButtonAreaRectangle(); + Rectangle textRectangle = new Rectangle(); + + textRectangle.Location = new Point(Padding.Left, clientRectangle.Y + Padding.Top); + textRectangle.Width = clientRectangle.Width - (clientRectangle.Width - buttonRectangle.Left) + - textRectangle.Left - 5; //多减5为字和按钮的间距 + textRectangle.Height = this.FontHeight; + + return textRectangle; + } + + private Rectangle GetDescriptionRectangle() + { + Rectangle clientRectangle = GetContentRectangle(); + Rectangle textRectangle = GetTextRectangle(); + Rectangle buttonRectangle = GetButtonAreaRectangle(); + Rectangle descriptionRectangle = new Rectangle(); + + int descriptionY = textRectangle.Y + textRectangle.Height + _textSpaceBetween; + descriptionRectangle.Location = new Point(Padding.Left, descriptionY); + descriptionRectangle.Width = clientRectangle.Width - (clientRectangle.Width - buttonRectangle.Left) + - descriptionRectangle.Left - 5; //多减5为字和按钮的间距 + descriptionRectangle.Height = this.FontHeight; + + return descriptionRectangle; + } + + private void Render(Graphics g) + { + DrawBorderground(g); + + DrawBackground(g); + + DrawText(g); + + DrawButton(g); + + //DrawFocusRectangle(g); + } + + /// + /// 绘制边框 + /// + /// + private void DrawBorderground(Graphics g) + { + Rectangle borderRectangle = ClientRectangle; + + //using (Pen borderPen = new Pen(Theme.BorderColor)) + //{ + // g.DrawRectangle(borderPen, borderRectangle); + //} + + Brush brush; + + if (this.Selected) + brush = _theme.CreateSelectedBorderBrush(borderRectangle); + else if(this.Hovered) + brush = _theme.CreateHoveredBorderBrush(borderRectangle); + else + brush = _theme.CreateBorderBrush(borderRectangle); + + g.FillRectangle(brush, borderRectangle); + + Rectangle rectangle = borderRectangle; + rectangle.X += 1; + rectangle.Y += 1; + rectangle.Width -= 2; + rectangle.Height -= 2; + + g.FillRectangle(Brushes.White, rectangle); + } + + /// + /// 绘制背景 + /// + /// + private void DrawBackground(Graphics g) + { + Rectangle rectangle = GetContentRectangle(); + + if (this.Hovered && this.Selected == false) + { + //留出一个白色的内框 + rectangle.X += 1; + rectangle.Y += 1; + rectangle.Width -= 2; + rectangle.Height -= 2; + } + + Brush brush = null; + + if (this.Enabled) + { + if (this.Selected) + brush = _theme.CreateSelectedBackgroundBrush(rectangle); + else if (this.Hovered) + brush = _theme.CreateHoveredBackgroundBrush(rectangle); + else + { + //在正常状态下,还是要把指定的控件背景色考虑进去 + //比如在验证控件数据的时候,不合法数据会有一个突出的颜色显示 + //如现在会把不合法数据的控件背景色改成粉色 + using (Brush normalBackgroundBrush = new SolidBrush(this.BackColor)) + { + g.FillRectangle(normalBackgroundBrush, rectangle); + } + //这个CreateBackgroundBrush上面大部分是透明色,下面是一个淡灰色 + brush = _theme.CreateBackgroundBrush(rectangle); + } + } + else + { + brush = _theme.CreateDisabledBackgroundBrush(rectangle); + } + + g.FillRectangle(brush, rectangle); + } + + /// + /// 绘制文本 + /// + /// + private void DrawText(Graphics g) + { + object selectedValue = GetSelectedValue(); + if (selectedValue == null) + return; + + #region 绘制标题文本 + + object textObj = ReflectionPool.GetPropertyValue(selectedValue, DisplayMember); + if (textObj != null) + { + string text = textObj.ToString(); + if (text != String.Empty) + { + Color textColor; + if (this.Selected) + textColor = _theme.SelectedTextColor; + else if (this.Hovered) + textColor = _theme.HoveredTextColor; + else + textColor = _theme.TextColor; + + Font textFont = new System.Drawing.Font(this.Font, FontStyle.Bold); + Rectangle textRectangle = GetTextRectangle(); + // g.FillRectangle(Brushes.Red, textRectangle); + TextRenderer.DrawText(g, text, textFont, textRectangle, textColor, _textFlags); + } + } + + #endregion + + if (this.ShowDescription) + { + #region 绘制Description + + object descriptionObj = ReflectionPool.GetPropertyValue(selectedValue, DescriptionMember); + if (descriptionObj != null) + { + string description = descriptionObj.ToString(); + if (description != String.Empty) + { + Color textColor; + if (this.Selected) + textColor = _theme.SelectedDescriptionTextColor; + else if (this.Hovered) + textColor = _theme.HoveredDescriptionColor; + else + textColor = _theme.DescriptionTextColor; + + Rectangle descriptionRectangle = GetDescriptionRectangle(); + // g.FillRectangle(Brushes.Red, descriptionRectangle); + TextRenderer.DrawText(g, description, this.Font, descriptionRectangle, textColor, _textFlags); + } + } + + #endregion + } + } + + private void DrawButton(Graphics g) + { + Rectangle rectangle = GetButtonAreaRectangle(); + // g.FillRectangle(Brushes.Red, rectangle); + + int arrowX = rectangle.Left + (rectangle.Width - rectangle.Width / 2); + int arrowY = rectangle.Y; + Point startPoint = new Point(arrowX, arrowY); + Point endPoint = new Point(arrowX, arrowY + rectangle.Height); + GraphicsPath arrowPath = DrawingTool.GetArrowPath(startPoint, endPoint, rectangle.Height); + + using (Brush arrowBrush = new LinearGradientBrush(rectangle, + _theme.ArrowColorStart, _theme.ArrowColorEnd, 45)) + { + g.FillPath(arrowBrush, arrowPath); + } + + arrowPath.Dispose(); + } + + private void DrawFocusRectangle(Graphics g) + { + if (this.Focused) + ControlPaint.DrawFocusRectangle(g, GetBorderRectangle()); + } + + #endregion + + #region protected + + protected override void OnSizeChanged(EventArgs e) + { + this.Height = MeasureHeight(); + base.OnSizeChanged(e); + } + + protected override void OnPaintBackground(PaintEventArgs pevent) + { + pevent.Graphics.Clear(_theme.BackgroundColor); + // base.OnPaintBackground(pevent); + } + + protected override void OnPaint(PaintEventArgs e) + { + Render(e.Graphics); + } + + protected override void OnMouseEnter(EventArgs e) + { + if (this.Enabled) + { + this.Hovered = true; + } + + base.OnMouseEnter(e); + } + + protected override void OnMouseLeave(EventArgs e) + { + if (this.Enabled) + { + //if (_popup.Visible == false) + //{ + this.Hovered = false; + //} + } + + base.OnMouseLeave(e); + } + + protected override void OnEnter(EventArgs e) + { + //this.Selected = true; + base.OnEnter(e); + } + + protected override void OnLeave(EventArgs e) + { + + //this.Selected = false; + base.OnLeave(e); + } + + protected override void OnGotFocus(EventArgs e) + { + this.Refresh(); + base.OnGotFocus(e); + } + + protected override void OnLostFocus(EventArgs e) + { + this.Refresh(); + base.OnLostFocus(e); + } + + protected override void OnMouseDown(MouseEventArgs e) + { + base.OnMouseDown(e); + + this.Focus(); + + if ((DateTime.UtcNow - _dropDownHideTime).TotalSeconds > 0.2) + { + Selected = true; + ShowDropDown(); + } + } + + private void ShowDropDown() + { + //每次打开都要判读,如果把PopupWidth做成属性,在set里设置 + //那么控件resize时,popup的宽度可能就不对了 + _popup.Width = this.Width; + + int showItem = 1; + int itemCount = _listView.Items.Count; + + if (itemCount > this.MaxItem) + showItem = this.MaxItem; + else if (itemCount == 0) + showItem = 1; + else + showItem = itemCount; + + _popup.Height = showItem * _listView.ItemHeight; + + _popup.Height = _listView.Height; + + _popup.Show(this); + + _popup.Select(); + } + + + #endregion + + #region public + + public void DataBind(IList dataSource) + { + _listView.DataBind(dataSource); + this.Refresh(); + } + + public object GetSelectedValue() + { + return _listView.GetSelectedValue(); + } + + public void SetSelectedValue(object obj) + { + _listView.SetSelectedValue(obj); + } + + public void Clear() + { + _listView.Clear(); + this.Refresh(); + } + + #endregion + + #endregion + + #region 公开事件 + + /// + /// 当前热点项生改变 + /// + public event EventHandler SelectedValueChanged; + + public class OnSelectedValueChangedEventArgs:EventArgs + { + private object _value; + public object Value + { + get { return _value; } + } + + public OnSelectedValueChangedEventArgs(object value) + { + _value = value; + } + } + + /// + /// 通过外能事件获取用于绘制项的文本 + /// + public event EventHandler ItemTextGetting; + + public class ItemTextGettingEventArgs : EventArgs + { + public object Item { get; private set; } + + public string Text { get; set; } + + public ItemTextGettingEventArgs(object item) + { + Item = item; + } + } + + #endregion + + #region ISEValidate 成员 + + private string title; + /// + /// 标题 + /// + [Description("标题")] + [Category("Sheng.Winform.Controls")] + public string Title + { + get + { + return this.title; + } + set + { + this.title = value; + } + } + + private bool highLight = true; + /// + /// 验证失败时是否需要高亮显示(改变背景色) + /// + [Description("验证失败时是否需要高亮显示(改变背景色)")] + [Category("Sheng.Winform.Controls")] + public bool HighLight + { + get + { + return this.highLight; + } + set + { + this.highLight = value; + } + } + + public bool SEValidate(out string msg) + { + msg = String.Empty; + + if (this.AllowEmpty == false && this.GetSelectedValue() == null) + { + msg += String.Format("[ {0} ] {1}", this.Title, "不允许为空"); + return false; + } + + #region CustomValidate + + if (CustomValidate != null) + { + string customValidateMsg; + if (CustomValidate(this, out customValidateMsg) == false) + { + msg += String.Format("[ {0} ] {1}", this.Title, customValidateMsg); + return false; + } + } + + #endregion + + return true; + } + + public CustomValidateMethod CustomValidate + { + get; + set; + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengComboSelector2/ShengComboSelectorTheme.cs b/Source/ryControls/Sheng.Winform.Controls/ShengComboSelector2/ShengComboSelectorTheme.cs new file mode 100644 index 0000000..5aa6622 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengComboSelector2/ShengComboSelectorTheme.cs @@ -0,0 +1,255 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace Sheng.Winform.Controls +{ + public class ShengComboSelectorTheme + { + private Color _arrowColorStart = Color.Gray;// Color.FromArgb(255, SystemColors.Highlight); + /// + /// 排序箭头开始颜色 + /// + public Color ArrowColorStart + { + get { return _arrowColorStart; } + set { _arrowColorStart = value; } + } + + private Color _arrowColorEnd = Color.LightGray;// Color.FromArgb(16, SystemColors.Highlight); + /// + /// 排序箭头开始颜色 + /// + public Color ArrowColorEnd + { + get { return _arrowColorEnd; } + set { _arrowColorEnd = value; } + } + + #region Selected + + private Color _selectedTextColor = SystemColors.WindowText; + public Color SelectedTextColor + { + get + { + return _selectedTextColor; + } + set + { + _selectedTextColor = value; + } + } + + private Color _selectedDescriptionTextColor = SystemColors.GrayText; + public Color SelectedDescriptionTextColor + { + get + { + return _selectedDescriptionTextColor; + } + set + { + _selectedDescriptionTextColor = value; + } + } + + private Color _selectedBackColor = Color.FromArgb(255, 216, 107); + public Color SelectedBackColor + { + get + { + return _selectedBackColor; + } + set + { + _selectedBackColor = value; + } + } + + private Color _selectedBorderColor = Color.FromArgb(194, 138, 48); + public Color SelectedBorderColor + { + get + { + return _selectedBorderColor; + } + set + { + _selectedBorderColor = value; + } + } + + #endregion + + #region Hovered + + private Color _hoveredTextColor = SystemColors.WindowText; + public Color HoveredTextColor + { + get + { + return _hoveredTextColor; + } + set + { + _hoveredTextColor = value; + } + } + + private Color _hoveredDescriptionTextColor = SystemColors.GrayText; + public Color HoveredDescriptionColor + { + get + { + return _hoveredDescriptionTextColor; + } + set + { + _hoveredDescriptionTextColor = value; + } + } + + /* + * 淡蓝色 + * seComboSelectorTheme1.HoveredBackColor = + * System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(232)))), ((int)(((byte)(246))))); + seComboSelectorTheme1.HoveredBorderColor = + * System.Drawing.Color.FromArgb(((int)(((byte)(152)))), ((int)(((byte)(180)))), ((int)(((byte)(226))))); + */ + + private Color _hoveredBackColor = Color.FromArgb(254, 228, 134); + public Color HoveredBackColor + { + get + { + return _hoveredBackColor; + } + set + { + _hoveredBackColor = value; + } + } + + private Color _hoveredBorderColor = Color.FromArgb(242, 202, 88); + public Color HoveredBorderColor + { + get + { + return _hoveredBorderColor; + } + set + { + _hoveredBorderColor = value; + } + } + + #endregion + + #region Normal + + private Color _backgroundColor = Color.White; + /// + /// 控件的背景画布颜色 + /// 因为控件的边框和过度色都有依靠改变透明度实现渐变,所以一个白色的底版就非常重要 + /// 使过度色不受控件本身背景色的影响,光不绘制背景不行,要刷上白色背景 + /// + public Color BackgroundColor + { + get { return _backgroundColor; } + set { _backgroundColor = value; } + } + + private Color _backColor = Color.Gray; + /// + /// 控件背景色 + /// + public Color BackColor + { + get { return _backColor; } + set { _backColor = value; } + } + + private Color _textColor = SystemColors.WindowText; + public Color TextColor + { + get + { + return _textColor; + } + set + { + _textColor = value; + } + } + + private Color _descriptionTextColor = SystemColors.GrayText; + public Color DescriptionTextColor + { + get + { + return _descriptionTextColor; + } + set + { + _descriptionTextColor = value; + } + } + + private Color _borderColor = Color.LightGray; + /// + /// 边框颜色 + /// + public Color BorderColor + { + get + { + return _borderColor; + } + set + { + _borderColor = value; + } + } + + #endregion + + public Brush CreateDisabledBackgroundBrush(Rectangle bounds) + { + return Office2010Renderer.CreateDisabledBackgroundBrush(bounds,_borderColor); + } + + public Brush CreateBackgroundBrush(Rectangle bounds) + { + return Office2010Renderer.CreateBackgroundBrush(bounds, _backColor); + } + + public Brush CreateBorderBrush(Rectangle bounds) + { + return Office2010Renderer.CreateBorderBrush(bounds, _borderColor); + } + + public Brush CreateHoveredBackgroundBrush(Rectangle bounds) + { + return Office2010Renderer.CreateHoveredBackgroundBrush(bounds, _hoveredBackColor); + } + + public Brush CreateHoveredBorderBrush(Rectangle bounds) + { + return Office2010Renderer.CreateHoveredBorderBrush(bounds, _hoveredBorderColor); + } + + public Brush CreateSelectedBackgroundBrush(Rectangle bounds) + { + return Office2010Renderer.CreateSelectedBackgroundBrush(bounds, _selectedBackColor); + } + + public Brush CreateSelectedBorderBrush(Rectangle bounds) + { + return Office2010Renderer.CreateSelectedBorderBrush(bounds, _selectedBorderColor); + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengComboSelector2/brush.png b/Source/ryControls/Sheng.Winform.Controls/ShengComboSelector2/brush.png new file mode 100644 index 0000000..7273e44 Binary files /dev/null and b/Source/ryControls/Sheng.Winform.Controls/ShengComboSelector2/brush.png differ diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengComboSelector2/brush2.png b/Source/ryControls/Sheng.Winform.Controls/ShengComboSelector2/brush2.png new file mode 100644 index 0000000..796453b Binary files /dev/null and b/Source/ryControls/Sheng.Winform.Controls/ShengComboSelector2/brush2.png differ diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengListView/Enums.cs b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Enums.cs new file mode 100644 index 0000000..0c0605b --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Enums.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sheng.Winform.Controls +{ + /// + /// Represents the visual state of an image list view item. + /// + [Flags] + public enum ShengListViewItemState + { + /// + /// 没有任何选择状态,处于一般正常状态 + /// + None = 0, + /// + /// 项处于选中状态 + /// + Selected = 1, + /// + /// 该项具有输入焦点 + /// + Focused = 2, + /// + /// 鼠标滑过 + /// + Hovered = 4, + } + + public enum ShengListViewItemVisibility + { + /// + /// The item is not visible. + /// + NotVisible, + /// + /// The item is partially visible. + /// + PartiallyVisible, + /// + /// The item is fully visible. + /// + Visible, + } + + /// + /// 布局方式 + /// + public enum ShengListViewLayoutMode + { + /// + /// 标准布局 + /// + Standard = 0, + /// + /// 使项带有描述的布局 + /// + Descriptive = 1 + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengListView/Events.cs b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Events.cs new file mode 100644 index 0000000..2115719 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Events.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sheng.Winform.Controls +{ + + /// + /// 双击项事件参数 + /// + public class ShengListViewItemDoubleClickEventArgs : EventArgs + { + public ShengListViewItem Item { get; private set; } + + public ShengListViewItemDoubleClickEventArgs(ShengListViewItem item) + { + Item = item; + } + } + + /// + /// 项被删除事件参数 + /// + public class ShengListViewItemsRemovedEventArgs : EventArgs + { + public List Items { get; private set; } + + public ShengListViewItemsRemovedEventArgs(List items) + { + Items = items; + } + } + + public class ShengListViewGetItemTextEventArgs : EventArgs + { + public object Item { get; private set; } + + public string Text { get; set; } + + public ShengListViewGetItemTextEventArgs(object item) + { + Item = item; + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/IShengListViewExtendMember.cs b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/IShengListViewExtendMember.cs new file mode 100644 index 0000000..a7bdfb2 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/IShengListViewExtendMember.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sheng.Winform.Controls +{ + public interface IShengListViewExtendMember + { + Dictionary GetExtendMembers(); + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewDescriptiveLayoutManager.cs b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewDescriptiveLayoutManager.cs new file mode 100644 index 0000000..bdfdb35 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewDescriptiveLayoutManager.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sheng.Winform.Controls +{ + class ShengListViewDescriptiveLayoutManager : ShengListViewLayoutManager + { + public ShengListViewDescriptiveLayoutManager(ShengListView imageListView) + : base(imageListView) + { + this.ItemHeight = 40; + this.Renderer = new ShengListViewDescriptiveRenderer(this); + this.Renderer.Theme = imageListView.Theme; + } + } + + +} \ No newline at end of file diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewDescriptiveMembers.cs b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewDescriptiveMembers.cs new file mode 100644 index 0000000..9ba4c90 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewDescriptiveMembers.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sheng.Winform.Controls +{ + public class ShengListViewDescriptiveMembers : IShengListViewExtendMember + { + public const string DescriptioinMember = "Description"; + public string Description { get; set; } + + #region ISEListViewExtendMember 成员 + + public Dictionary GetExtendMembers() + { + Dictionary members = new Dictionary(); + + if (String.IsNullOrEmpty(Description) == false) + members.Add(DescriptioinMember, Description); + + return members; + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewDescriptiveRenderer.cs b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewDescriptiveRenderer.cs new file mode 100644 index 0000000..66d5503 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewDescriptiveRenderer.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; + +namespace Sheng.Winform.Controls +{ + /// + /// 为项绘制带有描述信息的渲染器 + /// + public class ShengListViewDescriptiveRenderer : ShengListViewRenderer + { + #region 私有成员 + + /// + /// 字的高度是否已初始化 + /// 在第一次绘制时,测量文本的高度 + /// + bool _headerHeightInited = false; + + int _headerHeight; + Font _headerFont; + Size _itemPadding = new Size(8, 4); + StringFormat _itemHeaderStringFormat = new StringFormat(); + + #endregion + + #region 构造 + + public ShengListViewDescriptiveRenderer(ShengListViewLayoutManager layoutManager) + : base(layoutManager) + { + layoutManager.ItemHeight = 40; + + //_itemHeaderStringFormat.Alignment = StringAlignment.Center; + _itemHeaderStringFormat.FormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoWrap; + } + + #endregion + + #region 受保护的方法 + + internal override void DrawForeground(Graphics g) + { + + } + + internal override void DrawItemContent(Graphics g, Rectangle bounds, ShengListViewItem item) + { + string header = LayoutManager.GetItemText(item.Value); + + //如果header为空则不南要绘制内容了 + if (String.IsNullOrEmpty(header)) + return; + + string description = null; + if (LayoutManager.ContainerExtendMember(ShengListViewDescriptiveMembers.DescriptioinMember)) + { + description = LayoutManager.GetItemText(item.Value, + LayoutManager.GetExtendMember(ShengListViewDescriptiveMembers.DescriptioinMember)); + } + + if (_headerHeightInited == false) + { + _headerFont = new Font(Theme.ItemHeaderFont, FontStyle.Bold); + + SizeF headerSize = g.MeasureString(header, _headerFont); + _headerHeight = (int)Math.Ceiling(headerSize.Height); + + _headerHeightInited = true; + } + + #region 绘制文本 + + Rectangle _headerBounds = new Rectangle(); + _headerBounds.X = _itemPadding.Width; + _headerBounds.Y = _itemPadding.Height;//LayoutManager.ItemSize - _headerHeight - _itemPadding.Height; + _headerBounds.Width = bounds.Width; + _headerBounds.Height = _headerHeight; + + Rectangle _descriptionBounds = new Rectangle(); + _descriptionBounds.X = _itemPadding.Width; + _descriptionBounds.Y = _headerBounds.Y + _headerBounds.Height + _itemPadding.Height; + _descriptionBounds.Width = bounds.Width; + _descriptionBounds.Height = _headerHeight; + + //注意,offset必须在最后,如果先offset了_headerBounds,再带入_headerBounds来计算_descriptionBounds + //就不对了 + _headerBounds.Offset(bounds.Location); + _descriptionBounds.Offset(bounds.Location); + + if (String.IsNullOrEmpty(header) == false) + { + using (SolidBrush brush = new SolidBrush(Theme.ItemHeaderColor)) + { + g.DrawString(header, _headerFont, brush, _headerBounds, _itemHeaderStringFormat); + } + } + + if (String.IsNullOrEmpty(description) == false) + { + using (SolidBrush brush = new SolidBrush(Theme.ItemDescriptioniColor)) + { + g.DrawString(description, Theme.ItemHeaderFont, brush, _descriptionBounds, _itemHeaderStringFormat); + } + } + + #endregion + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewLayoutManager.cs b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewLayoutManager.cs new file mode 100644 index 0000000..eca10a4 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewLayoutManager.cs @@ -0,0 +1,1168 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; +using System.Windows.Forms; +using System.Diagnostics; + +namespace Sheng.Winform.Controls +{ + //默认布局引擎,以类似微软ListView的方式按行排列项 + public class ShengListViewLayoutManager + { + #region 常量 + + /// + /// 框选的最短开始长度 + /// + private const int SELECTION_TOLERANCE = 5; + + /// + /// 框选时滚动条的自动滚动速度 + /// + private const int AUTOSCROLL_VALUE = 10; + + #endregion + + #region 私有成员 + + private ShengListView _imageListView; + + //滚动条放到布局引擎中来定义,这样可以实现不同布局引擎完全不同的布局方式 + //比如为图像分组显示的引擎可以同时显示多个水平滚动条 + private VScrollBar _vScrollBar = new VScrollBar(); + + private int ScrollBarWidth + { + get { return _vScrollBar.Width; } + } + + /// + /// 用于鼠标框选时,框出了控件中项的显示范围时,自动滚动滚动条 + /// + private Timer _scrollTimer = new Timer(); + + /// + /// 自动滚动时,滚动值 + /// + private int _autoScrollValue = 0; + + /// + /// 是否处于框选状态中 + /// + internal bool MouseSelecting { get; private set; } + + /// + /// 内框offset,内框offset是绝对相对于滚动条的 + /// + private int _itemsAreaOffset = 0; + + /// + /// 整个可显示项的边界的offset,包括上下padding部分 + /// + private int _itemsBoundsOffset + { + get + { + int offSet = _itemsAreaOffset - (ItemsArea.Location.Y - ItemsBounds.Location.Y); + if (offSet < 0) + offSet = 0; + return offSet; + } + } + + /// + /// 鼠标按下时项区域边界的offset,即 _itemsAreaOffset + /// 用于框选时,跨越可视部队画框 + /// + private int _mouseItemsAreaOffset = 0; + + ///// + ///// 当前所能显示的最大列数 + ///// + //private int _columnCount; + + /// + /// 当前所能显示的最大行数 + /// + private int _rowCount; + + #endregion + + #region 公开属性 + + private ShengListViewRenderer _renderer; + protected ShengListViewRenderer Renderer + { + get { return _renderer; } + set { _renderer = value; } + } + + /// + /// Gets whether the shift key is down. + /// + internal bool ShiftKey { get { return _imageListView.ShiftKey; } } + /// + /// Gets whether the control key is down. + /// + internal bool ControlKey { get { return _imageListView.ControlKey; } } + + internal bool Focused { get { return _imageListView.Focused; } } + + internal Rectangle SelectionRectangle { get; private set; } + + internal bool Suspend + { + get { return _imageListView.Suspend; } + } + + internal string DisplayMember + { + get + { + return _imageListView.DisplayMember; + } + } + + //TODO:在出现滚动条后,计算错误 + //临时调用用,完成后改为internal + private int _firstPartiallyVisible; + public int FirstPartiallyVisible { get { return _firstPartiallyVisible; } } + + private int _lastPartiallyVisible; + public int LastPartiallyVisible { get { return _lastPartiallyVisible; } } + + private int _firstVisible; + public int FirstVisible { get { return _firstVisible; } } + + private int _lastVisible; + public int LastVisible { get { return _lastVisible; } } + + /// + /// 没有任何项 + /// + public bool IsEmpty + { + get + { + return _imageListView.IsEmpty; + } + } + + /// + /// 没有任何项处于可显示状态 + /// + public bool NoneItemVisible + { + get + { + return _firstPartiallyVisible == -1 || _lastPartiallyVisible == -1; + } + } + + /// + /// 整个控件区域 + /// + public Rectangle ClientArea + { + get { return _imageListView.ClientRectangle; } + } + + /// + /// 整个可用于绘制项的可视区域 + /// 去除左右Padding部分,去除滚动条 + /// + public Rectangle ItemsBounds + { + get + { + int scrollBarWidth = this.ScrollBarWidth; + Rectangle clientArea = this.ClientArea; + Padding padding = _imageListView.Padding; + int x = padding.Left; + int width = clientArea.Width - padding.Left - padding.Right - scrollBarWidth; + + Rectangle itemsBounds = new Rectangle(x, clientArea.Y, width, clientArea.Height); + return itemsBounds; + } + } + + /// + /// 用于绘制项的区域 + /// 考虑边距间隔大小和滚动条区域 + /// + public Rectangle ItemsArea + { + //要考虑边距间隔大小和滚动条区域 + get + { + int scrollBarWidth = this.ScrollBarWidth; + Rectangle clientArea = this.ClientArea; + Padding padding = _imageListView.Padding; + int x = padding.Left; + int y = padding.Top; + int width = clientArea.Width - padding.Left - padding.Right - scrollBarWidth; + int height = clientArea.Height - padding.Top - padding.Bottom; + + //在最小化窗口后,clientArea的尺寸为0 + if (width < 0) width = 1; + if (height < 0) height = 1; + + Rectangle itemsArea = new Rectangle(x, y, width, height); + return itemsArea; + } + } + + //TODO:项的大小是不能固定死的,因为要考虑到操作系统的默认字体大小 + private int _itemHeight = 24; + /// + /// 项的尺寸 + /// 不放在ListView本身中定义而是放在LayoutManager中定义,是因为不同的布局方式 + /// 可能会是带长宽的Size做为itemSize,比如平铺的方式 + /// + internal int ItemHeight + { + get { return _itemHeight; } + set + { + _itemHeight = value; + _itemHeightWithMargin = _itemHeight + _margin; + } + } + + private int _margin = 2; + /// + /// 项周围的边距 + /// + public int Margin + { + get { return _margin; } + set + { + _margin = value; + _itemHeightWithMargin = _itemHeight + value; + } + } + + private int _itemHeightWithMargin; + internal int ItemHeightWithMargin + { + get { return _itemHeightWithMargin; } + } + + #endregion + + #region debug 临时调试用 + + public int StartRow { get; set; } + public int EndRow { get; set; } + //public int StartCol { get; set; } + //public int EndCol { get; set; } + + #endregion + + #region 构造 + + public ShengListViewLayoutManager(ShengListView imageListView) + { + _imageListView = imageListView; + + //_itemSize = new Size(ImageSize, ImageSize); + _itemHeightWithMargin = _itemHeight + _margin; + + UpdateScrollBars(); + + _vScrollBar.Dock = DockStyle.Right; + _imageListView.Controls.Add(_vScrollBar); + _vScrollBar.Scroll += new ScrollEventHandler(_vScrollBar_Scroll); + _vScrollBar.ValueChanged += new EventHandler(_vScrollBar_ValueChanged); + + _scrollTimer.Interval = 20; + _scrollTimer.Enabled = false; + _scrollTimer.Tick += new EventHandler(_scrollTimer_Tick); + + //_renderer = new ListViewStandardRenderer(this); + //_renderer = new ListViewRenderer(this); + //_renderer = new ListViewDescriptiveRenderer(this); + + //_renderer.Theme = _imageListView.Theme; + } + + #endregion + + #region 事件处理 + + void _vScrollBar_Scroll(object sender, ScrollEventArgs e) + { + //这里判断的原因是在鼠标操作滚动条时,即使只点一下,这里也会进来两次,原因不明 + if (_itemsAreaOffset != e.NewValue) + { + _itemsAreaOffset = e.NewValue; + } + } + + void _vScrollBar_ValueChanged(object sender, EventArgs e) + { + //这里判断的原因是可能在 _vScrollBar_Scroll 事件里就赋值过了 + if (_itemsAreaOffset != _vScrollBar.Value) + { + _itemsAreaOffset = _vScrollBar.Value; + } + + _imageListView.SuspendLayout(); + + if (MouseSelecting) + { + //如果处于框选状态,在重新绘制控件之前需要计算新的 SelectionRectangle + //因为SelectionRectangle一开始是在MouseMove中计算的,而当鼠标拉出控件边界时 + //滚动条会继续滚动,如果此时保持鼠标不动,就要靠这里计算 SelectionRectangle 了 + SelectionRectangle = CreateSelectionRectangle(); + SelectItemsByRectangle(SelectionRectangle); + } + + _imageListView.ResumeLayout(true); + + CalculateVisibleItemsRange(); + } + + void _scrollTimer_Tick(object sender, EventArgs e) + { + //自动滚动之后,必须重新绘制控件 + //借助 _vScrollBar_ValueChanged 事件实现 + + //另外,在自动滚动之后,光重绘还不行,必须重新计算 SelectionRectangle + //SelectionRectangle 一开始是在 MouseMove 中计算的,如果在自动滚动的过程中不移动鼠标 + //那就靠 _vScrollBar_ValueChanged 计算了 + + int scrollValue = _vScrollBar.Value + _autoScrollValue; + if (scrollValue > _vScrollBar.Maximum) + _vScrollBar.Value = _vScrollBar.Maximum; + else if (scrollValue < 0) + _vScrollBar.Value = 0; + else + _vScrollBar.Value = scrollValue; + } + + #endregion + + #region 受保护的方法 + + internal bool ContainerExtendMember(string member) + { + return _imageListView.ContainerExtendMember(member); + } + + internal string GetExtendMember(string member) + { + return _imageListView.GetExtendMember(member); + } + + internal string GetItemText(object itemValue) + { + return _imageListView.GetItemText(itemValue); + } + + internal string GetItemText(object itemValue, string propertyName) + { + return _imageListView.GetItemText(itemValue, propertyName); + } + + internal void OnItemsRemoved(List items) + { + _renderer.OnItemsRemoved(items); + } + + internal void Dispose() + { + _imageListView.Controls.Remove(_vScrollBar); + _vScrollBar.Dispose(); + _scrollTimer.Stop(); + _scrollTimer.Enabled = false; + _scrollTimer.Dispose(); + _renderer.Dispose(); + _imageListView = null; + } + + #endregion + + #region 公开方法 + + ///// + ///// 测量当前项应该的高度 + ///// + ///// + //public int MeasureItemHeight() + //{ + // int textHeight = _imageListView.Font.Height; + + // int height = _borderSize * 2 + textHeight + Padding.Top + Padding.Bottom; + + // if (ShowDescription) + // height = height + textHeight + _textSpaceBetween; + + // return height; + //} + + public void Render(Graphics graphics) + { + //Debug.Write("Render(Graphics graphics)" + Environment.NewLine); + + Update(); + + _renderer.Render(graphics); + } + + public void RenderItem(Graphics graphics, ShengListViewItem item) + { + Debug.Assert(MouseSelecting == false, "MouseSelecting 为 " + MouseSelecting.ToString()); + + _renderer.RenderItem(graphics, item); + } + + /// + /// 更新整个布局引擎的状态 + /// + public void Update() + { + //Debug.Write("Update()" + Environment.NewLine); + + CalculateGrid(); + + CalculateVisibleItemsRange(); + + UpdateScrollBars(); + } + + /// + /// 判断指定的项是否处于可见状态 + /// + /// + /// + public ShengListViewItemVisibility IsItemVisible(ShengListViewItem item) + { + int itemIndex = _imageListView.Items.IndexOf(item); + + if (_imageListView.Items.Count == 0) + return ShengListViewItemVisibility.NotVisible; + + if (itemIndex < 0 || itemIndex > _imageListView.Items.Count - 1) + return ShengListViewItemVisibility.NotVisible; + + if (itemIndex < _firstPartiallyVisible || itemIndex > _lastPartiallyVisible) + return ShengListViewItemVisibility.NotVisible; + else if (itemIndex >= _firstVisible && itemIndex <= _lastVisible) + return ShengListViewItemVisibility.Visible; + else + return ShengListViewItemVisibility.PartiallyVisible; + } + + /// + /// 获取项的呈现区域 + /// + /// + /// + public Rectangle GetItemBounds(ShengListViewItem item) + { + int index = _imageListView.Items.IndexOf(item); + + return GetItemBounds(index); + } + + public Rectangle GetItemBounds(int index) + { + Point location = ItemsArea.Location; + + //测算滚动条向下滚动过的高度,做为初始 Y 坐标 + location.Y += _margin / 2 - _itemsAreaOffset; + + ////itemIndex % _columnCount 得到项在第几列 + ////itemIndex / _columnCount 得到项在第几行 + //location.X += _margin / 2 + (index % _columnCount) * _itemSizeWithMargin.Width; + + ////在初始 Y 坐标的基础上,算出此项所在行,计算出其应该在的Y坐标 + location.Y += index * _itemHeightWithMargin; + + location.X = ItemsArea.X; + + return new Rectangle(location, new Size(ItemsArea.Width, _itemHeight)); + } + + public List GetItems() + { + return _imageListView.Items.ToList(); + } + + /// + /// 获取当前所有可见项 + /// + /// + public List GetVisibleItems() + { + List items = new List(); + + for (int i = _firstPartiallyVisible; i <= _lastPartiallyVisible; i++) + { + items.Add(_imageListView.Items[i]); + } + + return items; + } + + public ShengListViewHitInfo HitTest(Point point) + { + int itemIndex = -1; + + //这里对X,Y坐标的减,实现目的是平移坐标 + //传进来的是相对控件左上角的坐标,应平移为Padding后的内框左上角相对坐标 + //但是要考虑滚动时,上面的Padding也允许显示项 + //X坐标直接向右平移即可 + //Y坐标在没有滚动时,直接向下平移,如果存在滚动,当滚动值小于顶部Padding时 + //将Y坐标平移至项的最层端Y坐标上,即:Padding-滚动值 + + //相对于Padding后的内框坐标系的坐标 + Point relativePoint = point; + + // Normalize to item area coordinates + relativePoint.X -= ItemsBounds.Left; + + //y即平移量 + //此处y坐标需要在绘制项的区域(Padding后的区域)的基础上,考虑滚动条的offset + int y = ItemsArea.Top - _itemsAreaOffset; + if (y < 0) y = 0; + relativePoint.Y -= y; + + if (relativePoint.X > 0 && relativePoint.Y > 0) + { + //当前点击的行和列的索引,从0开始 + //int col = relativePoint.X / _itemSizeWithMargin.Width; + int row = (relativePoint.Y + _itemsBoundsOffset) / _itemHeightWithMargin; + + ////判断点的是不是右边的空白,可能右边会有比较大的空白,又没大到够完整的显示一列图像 + //bool isNotHitRightEmptyArea = col <= _columnCount - 1; + //if (isNotHitRightEmptyArea) + //{ + // int index = row * _columnCount + col; + + // //判断是不是点在图像区域内,还是图像边上,四周的Margin上 + // Rectangle bounds = GetItemBounds(index); + // //判断点的坐标是不是在项的显示区域(Bounds)内,要用相对整个控件的原始坐标 + // //因为项的bounds是相对整个控件的 + // bool isHitInItem = bounds.Contains(point.X, point.Y); + + // if (isHitInItem) + // { + // itemIndex = index; + // } + //} + + int index = row; + Rectangle bounds = GetItemBounds(index); + bool isHitInItem = bounds.Contains(point.X, point.Y); + + if (isHitInItem) + { + itemIndex = index; + } + } + + //是否点击在了有效项上 + bool itemHit = itemIndex >= 0 && itemIndex < _imageListView.Items.Count; + + ShengListViewHitInfo hitInfo = new ShengListViewHitInfo(itemIndex, itemHit); + return hitInfo; + } + + #endregion + + #region 事件响应方法 + + public void MouseDown(MouseEventArgs e) + { + /* + * 如果按下的是鼠标右键 + * 如果按在已选定的项上,只切换焦点,不改变选择 + * 如果按在未选定项上,则切换为点的项为选中项 + * 不考虑键盘按键 + */ + + _mouseItemsAreaOffset = _itemsAreaOffset; + + List oldSelectedItems = _imageListView.GetSelectedItems(); + + ShengListViewHitInfo hitInfo = HitTest(e.Location); + + if (hitInfo.ItemHit) + { + ShengListViewItem item = _imageListView.Items[hitInfo.ItemIndex]; + List allItems = _imageListView.Items.ToList(); + ShengListViewItem currentFocusedItem = _imageListView.FocusedItem; + + if (_imageListView.LeftButton) + { + #region 如果不允许多选 + if (_imageListView.AllowMultiSelection == false) + { + //如果点击的项就是当前选择的项 + if (oldSelectedItems.Count > 0 && oldSelectedItems.Contains(item)) + { + //判断Control键是否按下,如果按下了Control键,取消当前项的选择状态 + if (_imageListView.ControlKey) + item.Selected = false; + } + else + { + //如果点击的项不是当前选择的项 + //清除原选定项的选定状态 + _imageListView.ClearSelect(); + //设置新项为选定项 + item.Selected = true; + } + } + #endregion + #region 如果允许多选 + //在同时按下 Control 和 Shift 的情况下,优先考虑 Shift + else + { + #region 如果按下 Shift + //判断是否按下了 Shift ,如果按下 Shift,不考虑 Control 的状态 + //也不用考虑是否点击的项是否是现有选定项之一 + if (_imageListView.ShiftKey) + { + //如果当前存在具有输入焦点的项 + if (currentFocusedItem != null && currentFocusedItem != item) + { + //连续选中从当前具有焦点的项至点击的项之间的所有项 + //并将不在此范围内的项取消选中状态 + int startIndex = Math.Min(currentFocusedItem.Index, hitInfo.ItemIndex); + int endIndex = Math.Max(currentFocusedItem.Index, hitInfo.ItemIndex); + foreach (var i in from c in oldSelectedItems where c.Index < startIndex || c.Index > endIndex select c) + { + i.Selected = false; + } + for (int i = startIndex; i <= endIndex; i++) + { + ShengListViewItem eachItem = allItems[i]; + if (eachItem.Selected == false) + eachItem.Selected = true; + } + } + //如果当前不存在具有输入焦点的项 + else + { + //清除原选定项的选定状态 + _imageListView.ClearSelect(); + item.Selected = true; + } + } + #endregion + #region 如果 Shift键没有处于按下状态 + else + { + #region 如果点击的项 是 当前选择的项之一 + if (oldSelectedItems.Count > 0 && oldSelectedItems.Contains(item)) + { + //判断是否按下了 Control,且没有按下 Shift + if (_imageListView.ControlKey && _imageListView.ShiftKey == false) + { + item.Selected = false; + } + + //判断是否什么键都没有按下 + if (_imageListView.ControlKey == false && _imageListView.ShiftKey == false) + { + //清除原选定项的选定状态 + _imageListView.ClearSelect(); + item.Selected = true; + } + } + #endregion + #region 如果点击的项 不是 当前选择的项之一 + else + { + //判断Control键是否按下,如果按下了Control键,则保持原有选择的情况把新项也设置为选中 + //否则清除当前选择 + if (_imageListView.ControlKey == false) + { + //清除原选定项的选定状态 + _imageListView.ClearSelect(); + } + item.Selected = true; + } + #endregion + } + #endregion + } + #endregion + } + else + { + //如果点在未选中的项上 + if (oldSelectedItems.Contains(item) == false) + { + _imageListView.ClearSelect(); + //设置新项为选定项 + item.Selected = true; + } + } + + #region 为项设置输入焦点 + + //设置新的输入焦点要放在后面处理,因为在使用Shift连续选择时,需要用到原具有焦点的项 + if (currentFocusedItem == null || (currentFocusedItem != null && currentFocusedItem != item)) + { + if (currentFocusedItem != null) + currentFocusedItem.Focused = false; + item.Focused = true; + } + #endregion + } + else + { + _imageListView.ClearSelect(); + } + + List newSelectedItems = _imageListView.GetSelectedItems(); + if (oldSelectedItems.SequenceEqual(newSelectedItems) == false) + { + _imageListView.NeedPaint(); + _imageListView.OnSelectedItemChanged(); + } + } + + public void MouseUp(MouseEventArgs e) + { + if (MouseSelecting) + { + MouseSelecting = false; + _scrollTimer.Enabled = false; + _autoScrollValue = 0; + _imageListView.NeedPaint(); + } + } + + public void MouseMove(MouseEventArgs e) + { + Point lastMouseDownLocation = _imageListView.LastMouseDownLocation; + + #region 如果处于框选状态 + if (MouseSelecting) + { + //处于框选状态时,框内的项被选中不能在 MouseMove 事件中处理 + //因为当鼠标移出控件,滚动条自动滚动时,不动鼠标,就不会触发 MouseMove 事件 + + #region 判断是否需要自动滚动滚动条 + + if (_scrollTimer.Enabled == false) + { + //需向下滚动 + if (e.Y > ItemsBounds.Bottom) + { + _autoScrollValue = AUTOSCROLL_VALUE; + _scrollTimer.Enabled = true; + } + //需向上滚动 + else if (e.Y < ItemsBounds.Top) + { + _autoScrollValue = -AUTOSCROLL_VALUE; + _scrollTimer.Enabled = true; + } + } + //鼠标从控件外面又回到了控件内,则停止自动滚动 + else if (_scrollTimer.Enabled && ItemsBounds.Contains(e.Location)) + { + _scrollTimer.Enabled = false; + _autoScrollValue = 0; + } + + #endregion + + //创建选择框 Rectangle + SelectionRectangle = CreateSelectionRectangle(); + SelectItemsByRectangle(SelectionRectangle); + + _imageListView.NeedPaint(); + } + #endregion + #region 如果不是处于框选状态 + else + { + //如果允许多选,鼠标处于按下状态,且距上次点击的点,大于了最小框选开始尺寸 + if (_imageListView.AllowMultiSelection && _imageListView.AnyMouseButton && ( + (Math.Abs(e.Location.X - lastMouseDownLocation.X) > SELECTION_TOLERANCE || + Math.Abs(e.Location.Y - lastMouseDownLocation.Y) > SELECTION_TOLERANCE))) + { + MouseSelecting = true; + } + } + #endregion + } + + public void OnMouseWheel(MouseEventArgs e) + { + int offSet = _itemsAreaOffset; + int newYOffset = offSet - (e.Delta / SystemInformation.MouseWheelScrollDelta) + * _vScrollBar.SmallChange; + if (newYOffset > _vScrollBar.Maximum - _vScrollBar.LargeChange + 1) + newYOffset = _vScrollBar.Maximum - _vScrollBar.LargeChange + 1; + if (newYOffset < 0) + newYOffset = 0; + if (newYOffset < _vScrollBar.Minimum) newYOffset = _vScrollBar.Minimum; + if (newYOffset > _vScrollBar.Maximum) newYOffset = _vScrollBar.Maximum; + _vScrollBar.Value = newYOffset; + } + + public void OnKeyDown(KeyEventArgs e) + { + + // If the shift key or the control key is pressed and there is no focused item + // set the first item as the focused item. + if ((ShiftKey || ControlKey) && _imageListView.Items.Count != 0 && + _imageListView.FocusedItem == null) + { + _imageListView.Items[0].Focused = true; + } + + ShengListViewItem currentFocusedItem = _imageListView.FocusedItem; + + if (_imageListView.Items.Count != 0) + { + int index = 0; + if (currentFocusedItem != null) + index = currentFocusedItem.Index; + + int newindex = ApplyNavKey(index, e.KeyCode); + if (index != newindex) + { + #region 根据新index做选择 + + if (ControlKey) + { + // Just move the focus + } + else if (_imageListView.AllowMultiSelection && ShiftKey) + { + int startIndex = 0; + int endIndex = 0; + List selectedItems = _imageListView.GetSelectedItems(); + if (selectedItems.Count != 0) + { + startIndex = selectedItems[0].Index; + endIndex = selectedItems[selectedItems.Count - 1].Index; + _imageListView.ClearSelect(); + } + if (index == startIndex) + startIndex = newindex; + else if (index == endIndex) + endIndex = newindex; + for (int i = Math.Min(startIndex, endIndex); i <= Math.Max(startIndex, endIndex); i++) + { + _imageListView.Items[i].Selected = true; + } + } + else + { + _imageListView.ClearSelect(); + _imageListView.Items[newindex].Selected = true; + } + + currentFocusedItem.Focused = false; + _imageListView.Items[newindex].Focused = true; + + EnsureVisible(newindex); + + #endregion + + //触发事件 + _imageListView.OnSelectedItemChanged(); + } + } + + _imageListView.NeedPaint(); + } + + public void OnKeyUp(KeyEventArgs e) + { + //Refresh(); + } + + #endregion + + #region 私有方法 + + private void Refresh() + { + _imageListView.Refresh(); + } + + /// + /// Calculates the maximum number of rows and columns + /// that can be fully displayed. + /// + private void CalculateGrid() + { + Rectangle itemArea = this.ItemsArea; + //_columnCount = (int)System.Math.Floor((float)itemArea.Width / (float)_itemSizeWithMargin.Width); + _rowCount = (int)System.Math.Floor((float)itemArea.Height / (float)_itemHeightWithMargin); + + //if (_columnCount < 1) _columnCount = 1; + if (_rowCount < 1) _rowCount = 1; + } + + /// + /// 计算当前可见项的index范围 + /// + private void CalculateVisibleItemsRange() + { + Rectangle itemsArea = this.ItemsArea; + + //这里必须把控件的内部Padding值考虑进来 + //_visibleOffset 是相对于 ItemsArea 的,此处要得到相对于整个控件可视区域的 offSet + //因为显示的图片项即使超出了 ItemsArea ,但还是在可视区域内,还是完全可见的,在计算时需要考虑 + //ItemsArea.Location.Y - ItemsBounds.Location.Y 实际上就是Padding + //但是这样写逻辑上好些,因为实际意义在于 ItemsArea 和 ItemsBounds 之间的区域也是可以显示内容的,在意义上与Padding无关 + + int offSet = _itemsAreaOffset - (ItemsArea.Location.Y - ItemsBounds.Location.Y); + if (offSet < 0) + offSet = 0; + + int itemAreaHeight = ItemsBounds.Height; + + _firstPartiallyVisible = (int)System.Math.Floor((float)offSet / (float)_itemHeightWithMargin); + _lastPartiallyVisible = (int)System.Math.Ceiling((float)(offSet + itemAreaHeight) / (float)_itemHeightWithMargin) - 1; + + if (_firstPartiallyVisible < 0) _firstPartiallyVisible = 0; + if (_firstPartiallyVisible > _imageListView.Items.Count - 1) _firstPartiallyVisible = _imageListView.Items.Count - 1; + if (_lastPartiallyVisible < 0) _lastPartiallyVisible = 0; + if (_lastPartiallyVisible > _imageListView.Items.Count - 1) _lastPartiallyVisible = _imageListView.Items.Count - 1; + + _firstVisible = (int)System.Math.Ceiling((float)offSet / (float)_itemHeightWithMargin); + _lastVisible = (int)System.Math.Floor((float)(offSet + itemAreaHeight) / (float)_itemHeightWithMargin) - 1; + + if (_firstVisible < 0) _firstVisible = 0; + if (_firstVisible > _imageListView.Items.Count - 1) _firstVisible = _imageListView.Items.Count - 1; + if (_lastVisible < 0) _lastVisible = 0; + if (_lastVisible > _imageListView.Items.Count - 1) _lastVisible = _imageListView.Items.Count - 1; + } + + /// + /// 更新滚动条状态 + /// + private void UpdateScrollBars() + { + if (_imageListView.Items.Count > 0) + { + _vScrollBar.Minimum = 0; + _vScrollBar.Maximum = Math.Max(0, + (int)Math.Ceiling( + (float)_imageListView.Items.Count) * _itemHeightWithMargin - 1); + _vScrollBar.LargeChange = ItemsArea.Height; + _vScrollBar.SmallChange = _itemHeightWithMargin; + + bool vScrollRequired = (_imageListView.Items.Count > 0) && + (_rowCount < _imageListView.Items.Count); + _vScrollBar.Visible = vScrollRequired; + + //此处重新计算滚动条的滚动值 + //当滚动条出现,并滚动到底部时,改变控件的高度,就是向下拉大窗体 + //已经绘制的项下面会开始出现空白,就是因为滚动条的值还是旧值,_itemsAreaOffset也没有变化 + //除非用鼠标点一下滚动条,否则滚动条的 ValueChanged 事件也不会触发 + //所以绘制出的项的起始Y轴是不对的,必须在此重新计算滚动条的Value值 + if (_itemsAreaOffset > _vScrollBar.Maximum - _vScrollBar.LargeChange + 1) + { + _vScrollBar.Value = _vScrollBar.Maximum - _vScrollBar.LargeChange + 1; + _itemsAreaOffset = _vScrollBar.Value; + } + } + else + { + _vScrollBar.Visible = false; + _vScrollBar.Value = 0; + _vScrollBar.Minimum = 0; + _vScrollBar.Maximum = 0; + } + } + + /// + /// 创建框选框 + /// + /// + private Rectangle CreateSelectionRectangle() + { + Point mousePoint = _imageListView.PointToClient(Cursor.Position); + Point lastMouseDownLocation = _imageListView.LastMouseDownLocation; + + #region 说明 + + //当框选的同时,滚动滚动条 + //计算offset: + //由于可视区域和项的一般显示区域之间有个padding,而滚动条是以内部区域为标准的 + //所以当滚动条开始滚动时,可能项还是全部显示在可视范围内的(padding区也可以显示) + //那么此时 _itemsBoundsOffset 还是 0,而按下鼠标时 _mouseDownOffset 记录的也是当时的 _itemsBoundsOffset + //那么在计算 SelectionRectangle 的 Y 坐标时, + //如果直接用 _itemsBoundsOffset 参与计算,就会产生一个和padding有关的误差 + //如 lastMouseDownLocation.Y - (viewOffset - _mouseDownOffset) ,假如此时向下滚动了一点 + //但所有的项还在可视范围内,那么 就会是 lastMouseDownLocation.Y - (0 - 0) + //SelectionRectangle 的 Y 坐标就差生了误差 + //解决的办法是使用 _itemsAreaOffset(既滚动条的Value),使框框的Y坐标与滚动条同步滚动即可 + + #endregion + + int viewOffset = _itemsAreaOffset; + Point pt1 = new Point(lastMouseDownLocation.X, lastMouseDownLocation.Y - (viewOffset - _mouseItemsAreaOffset)); + Point pt2 = new Point(mousePoint.X, mousePoint.Y); + Rectangle rect = new Rectangle(Math.Min(pt1.X, pt2.X), Math.Min(pt1.Y, pt2.Y), + Math.Abs(pt1.X - pt2.X), Math.Abs(pt1.Y - pt2.Y)); + + return rect; + } + + /// + /// 根据矩形区域选择项 + /// + /// + private void SelectItemsByRectangle(Rectangle rect) + { + int viewOffset = _itemsAreaOffset; + + Point pt1 = new Point(SelectionRectangle.Left, SelectionRectangle.Top); + Point pt2 = new Point(SelectionRectangle.Right, SelectionRectangle.Bottom); + + //- ItemsArea.Y 和 - ItemsArea.X + //是因为,选择框的是以整个控件可视区域为坐标系的,而绘制的项是在Padding区内的 + //那么就需要修正或者说同步这个偏差,才能得到正确的行列 + int startRow = (int)Math.Floor((float)(Math.Min(pt1.Y, pt2.Y) + viewOffset - ItemsArea.Y) / + (float)this._itemHeightWithMargin); + int endRow = (int)Math.Floor((float)(Math.Max(pt1.Y, pt2.Y) + viewOffset - ItemsArea.Y) / + (float)this._itemHeightWithMargin); + //int startCol = (int)Math.Floor((float)(Math.Min(pt1.X, pt2.X) - ItemsArea.X) / + // (float)this._itemSizeWithMargin.Width); + //int endCol = (int)Math.Floor((float)(Math.Max(pt1.X, pt2.X) - ItemsArea.X) / + // (float)this._itemSizeWithMargin.Width); + + //行不能这样判断,因为_rowCount表示的只是控件可视范围内的可视行数 + //在框选时,框会跨越可视区域的,这里的endRow要的是实际的项所在行数 + //列不存在这个问题,因为不支持水平滚动 + //if (endRow >= _rowCount) + // endRow = _rowCount -1; + //if (endCol >= _columnCount) + // endCol = _columnCount - 1; + //if (startCol < 0) + // startCol = 0; + + //创建一个应该被选定的项的index数组 + int itemsCount = _imageListView.Items.Count; + List selectItemsIndex = new List(); + for (int i = startRow; i <= endRow; i++) + { + int index = i; + if (index >= 0 && index < itemsCount) + selectItemsIndex.Add(index); + + //for (int j = startCol; j <= endCol; j++) + //{ + // int index = i * _columnCount + j; + // if (index >= 0 && index < itemsCount) + // selectItemsIndex.Add(index); + //} + } + + //如果当前没有按下Shift键,那么 + //判断当前选定的项中有没有不在框选区内的,如果有将其取消选定 + if (ShiftKey == false) + { + List currentSlectedItems = _imageListView.GetSelectedItems(); + foreach (var item in currentSlectedItems) + { + if (selectItemsIndex.Contains(item.Index) == false) + item.Selected = false; + } + } + + ShengListViewItemCollection allItems = _imageListView.Items; + //使框选区内的项都处于选中状态 + foreach (var index in selectItemsIndex) + { + if (allItems[index].Selected == false) + allItems[index].Selected = true; + } + + //debug + StartRow = startRow; + EndRow = endRow; + //StartCol = startCol; + //EndCol = endCol; + } + + /// + /// 应用导航键,如上下左右,返回应用导航键之后的项的坐标 + /// + private int ApplyNavKey(int index, Keys key) + { + int itemsCount = _imageListView.Items.Count; + + if (key == Keys.Up && index > 0) + index -= 1; + else if (key == Keys.Down && index < itemsCount - 1) + index += 1; + else if (key == Keys.Left && index > 0) + index--; + else if (key == Keys.Right && index < itemsCount - 1) + index++; + else if (key == Keys.PageUp && index >= (_rowCount - 1)) + index -= (_rowCount - 1); + else if (key == Keys.PageDown && index < itemsCount - (_rowCount - 1)) + index += (_rowCount - 1); + else if (key == Keys.Home) + index = 0; + else if (key == Keys.End) + index = itemsCount - 1; + + if (index < 0) + index = 0; + else if (index > itemsCount - 1) + index = itemsCount - 1; + + return index; + } + + /// + /// 使指定下标的项处于可见状态 + /// + /// + public void EnsureVisible(int itemIndex) + { + int itemCount = _imageListView.Items.Count; + if (itemCount == 0) return; + if (itemIndex < 0 || itemIndex >= itemCount) return; + + // Already visible? + Rectangle bounds = this.ItemsBounds; + Rectangle itemBounds = GetItemBounds(itemIndex); + + if (bounds.Contains(itemBounds) == false) + { + int delta = 0; + if (itemBounds.Top < bounds.Top) + delta = bounds.Top - itemBounds.Top; + else + { + int topItemIndex = itemIndex - (_rowCount - 1) ; + if (topItemIndex < 0) topItemIndex = 0; + delta = bounds.Top - GetItemBounds(topItemIndex).Top; + } + int newYOffset = this._itemsBoundsOffset - delta; + if (newYOffset > _vScrollBar.Maximum - _vScrollBar.LargeChange + 1) + newYOffset = _vScrollBar.Maximum - _vScrollBar.LargeChange + 1; + if (newYOffset < _vScrollBar.Minimum) + newYOffset = _vScrollBar.Minimum; + //mViewOffset.X = 0; + //mViewOffset.Y = newYOffset; + //hScrollBar.Value = 0; + _vScrollBar.Value = newYOffset; + } + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewRenderer.cs b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewRenderer.cs new file mode 100644 index 0000000..0f18da2 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewRenderer.cs @@ -0,0 +1,328 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; +using Sheng.Winform.Controls.Drawing; + +namespace Sheng.Winform.Controls +{ + /// + /// 默认渲染器,不绘制项的实际内容,但是绘制DEBUG信息 + /// + public class ShengListViewRenderer + { + #region 受保护的成员 + + private bool _disposed = false; + protected bool Disposed + { + get { return _disposed; } + } + + private int _radius = 2; + protected int Radius + { + get { return _radius; } + } + + #endregion + + #region 公开属性 + + internal ShengListViewTheme Theme { get; set; } + + protected ShengListViewLayoutManager _layoutManager; + internal ShengListViewLayoutManager LayoutManager { get { return _layoutManager; } } + + #region 构造 + + public ShengListViewRenderer(ShengListViewLayoutManager layoutManager) + { + _layoutManager = layoutManager; + } + + #endregion + + #endregion + + #region 公开方法 + + public void Render(Graphics graphics) + { + if (LayoutManager.Suspend) + return; + + if (_disposed) return; + + RenderBackground(graphics); + + RenderItems(graphics); + + RenderSelectionRectangle(graphics); + + DrawForeground(graphics); + } + + public void RenderItem(Graphics g, ShengListViewItem item) + { + if (LayoutManager.Suspend) + return; + + if (LayoutManager.IsItemVisible(item) == ShengListViewItemVisibility.NotVisible) + return; + + DrawItem(g, item); + } + + #endregion + + #region 受保护方法 + + internal void Dispose() + { + Theme = null; + } + + /// + /// 用于子类重写时删除相应的缓存 + /// + /// + internal virtual void OnItemsRemoved(List items) + { + + } + + //不要直接调用这些Draw方法,internal的目的只是为了子类能够重写 + + /// + /// 绘制项的背景 + /// + /// The System.Drawing.Graphics to draw on. + /// The client coordinates of the item area. + internal virtual void DrawBackground(Graphics g, Rectangle bounds) + { + // Clear the background + g.Clear(Theme.BackColor); + } + + /// + /// 绘制最终的前景 + /// + /// + /// + internal virtual void DrawForeground(Graphics g) + { + //输出debug信息 + g.SetClip(LayoutManager.ClientArea); + g.DrawRectangle(Pens.Green, LayoutManager.ItemsArea); + + Color brushColor = Color.FromArgb(150, Color.Black); + using (SolidBrush brush = new SolidBrush(brushColor)) + { + g.FillRectangle(brush, new Rectangle(0, 0, 500, 50)); + } + string debugInfo = "ShiftKey:" + LayoutManager.ShiftKey.ToString() + + ",ControlKey:" + LayoutManager.ControlKey.ToString() + Environment.NewLine; + debugInfo += "SelectionRectangle:" + LayoutManager.SelectionRectangle.ToString() + Environment.NewLine; + debugInfo += "StartRow:" + LayoutManager.StartRow + ",EndRow:" + LayoutManager.EndRow;// +",StartCol:" + LayoutManager.StartCol + ",EndCol:" + LayoutManager.EndCol; + + g.DrawString(debugInfo, SystemFonts.DefaultFont, Brushes.White, LayoutManager.ClientArea); + } + + /// + /// 绘制选择边框 + /// + /// The System.Drawing.Graphics to draw on. + /// The client coordinates of the selection rectangle. + internal virtual void DrawSelectionRectangle(Graphics g, Rectangle selection) + { + if (LayoutManager.Suspend) + return; + + using (SolidBrush brush = new SolidBrush(Theme.SelectionRectangleColor)) + using (Pen pen = new Pen(Theme.SelectionRectangleBorderColor)) + { + g.FillRectangle(brush, selection); + g.DrawRectangle(pen, selection); + } + } + + /// + /// 绘制项的边框 + /// + /// + /// + internal virtual void DrawItemBorder(Graphics g, Rectangle bounds, ShengListViewItem item) + { + if (item.Hovered || item.Selected) + { + Rectangle backgroundRect = bounds; + backgroundRect.Width -= 1; + backgroundRect.Height -= 1; + + using (Pen pWhite128 = new Pen(Color.FromArgb(128, Theme.ItemBorderColor))) + { + // ImageListViewUtility.DrawRoundedRectangle(g, pWhite128, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, _radius); + g.DrawPath(pWhite128, DrawingTool.RoundedRect(backgroundRect, _radius)); + } + } + } + + /// + /// 绘制项 + /// + /// + /// + /// + /// + internal virtual void DrawItem(Graphics g, ShengListViewItem item) + { + Rectangle bounds = LayoutManager.GetItemBounds(item); + g.SetClip(bounds); + + DrawItemBackground(g, bounds); + + Rectangle backgroundRect = bounds; + backgroundRect.Width -= 1; + backgroundRect.Height -= 1; + + // Paint background Selected + if ((LayoutManager.Focused && ((item.State & ShengListViewItemState.Selected) == ShengListViewItemState.Selected)) || + (LayoutManager.Focused == false && ((item.State & ShengListViewItemState.Selected) == ShengListViewItemState.Selected) && ((item.State & ShengListViewItemState.Hovered) == ShengListViewItemState.Hovered))) + { + using (Brush bSelected = new LinearGradientBrush(backgroundRect, Theme.SelectedColorStart, Theme.SelectedColorEnd, LinearGradientMode.Vertical)) + { + // ImageListViewUtility.FillRoundedRectangle(g, bSelected, bounds, 4); + g.FillPath(bSelected, DrawingTool.RoundedRect(backgroundRect, _radius)); + + } + } + // Paint background unfocused + else if (LayoutManager.Focused == false && ((item.State & ShengListViewItemState.Selected) == ShengListViewItemState.Selected)) + { + using (Brush bGray64 = new LinearGradientBrush(backgroundRect, Theme.UnFocusedColorStart, Theme.UnFocusedColorEnd, LinearGradientMode.Vertical)) + { + // ImageListViewUtility.FillRoundedRectangle(g, bGray64, bounds, 4); + g.FillPath(bGray64, DrawingTool.RoundedRect(backgroundRect, _radius)); + } + } + + // Paint background Hovered + //如果正处于框选状态,不绘制Hover状态,减小闪烁 + if (LayoutManager.MouseSelecting == false && (item.State & ShengListViewItemState.Hovered) == ShengListViewItemState.Hovered) + { + using (Brush bHovered = new LinearGradientBrush(backgroundRect, Theme.HoverColorStart, Theme.HoverColorEnd, LinearGradientMode.Vertical)) + { + // ImageListViewUtility.FillRoundedRectangle(g, bHovered, bounds, 4); + g.FillPath(bHovered, DrawingTool.RoundedRect(backgroundRect, _radius)); + } + } + + DrawItemBorder(g, bounds, item); + + // Focus rectangle + if (LayoutManager.Focused && ((item.State & ShengListViewItemState.Focused) == ShengListViewItemState.Focused)) + { + ControlPaint.DrawFocusRectangle(g, bounds); + } + + DrawItemContent(g, bounds, item); + } + + /// + /// 绘制项的背景 + /// + /// + /// + internal virtual void DrawItemBackground(Graphics g, Rectangle bounds) + { + // Paint background + using (Brush bItemBack = new SolidBrush(Theme.ItemBackColor)) + { + g.FillRectangle(bItemBack, bounds); + } + } + + /// + /// 绘制项的内容 + /// + /// + /// + /// + internal virtual void DrawItemContent(Graphics g, Rectangle bounds, ShengListViewItem item) + { + //显示debug信息 + string debugInfo = item.Index + Environment.NewLine + + bounds.ToString() + Environment.NewLine + + item.State.ToString(); + g.DrawString(debugInfo, SystemFonts.DefaultFont, Brushes.Black, bounds); + } + + #endregion + + #region 私有方法 + + /// + /// 绘制背景 + /// + /// + private void RenderBackground(Graphics g) + { + if (LayoutManager.Suspend) + return; + + g.SetClip(LayoutManager.ClientArea); + DrawBackground(g, LayoutManager.ClientArea); + } + + /// + /// 绘制当前所有可见项 + /// + /// + private void RenderItems(Graphics g) + { + if (LayoutManager.Suspend) + return; + + // Is the control empty? + if (LayoutManager.IsEmpty) + return; + + // No items visible? + if (LayoutManager.NoneItemVisible) + return; + + List items = LayoutManager.GetVisibleItems(); + foreach (ShengListViewItem item in items) + { + RenderItem(g, item); + } + } + + /// + /// Renders the selection rectangle. + /// + /// The graphics to draw on. + private void RenderSelectionRectangle(Graphics g) + { + if (LayoutManager.Suspend) + return; + + if (LayoutManager.MouseSelecting == false) + return; + + Rectangle sel = LayoutManager.SelectionRectangle; + if (sel.Height > 0 && sel.Width > 0) + { + g.SetClip(LayoutManager.ClientArea); + + DrawSelectionRectangle(g, sel); + } + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewStandardLayoutManager.cs b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewStandardLayoutManager.cs new file mode 100644 index 0000000..6fbc018 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewStandardLayoutManager.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sheng.Winform.Controls +{ + class ShengListViewStandardLayoutManager : ShengListViewLayoutManager + { + public ShengListViewStandardLayoutManager(ShengListView imageListView) + : base(imageListView) + { + this.ItemHeight = 24; + this.Renderer = new ShengListViewStandardRenderer(this); + this.Renderer.Theme = imageListView.Theme; + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewStandardRenderer.cs b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewStandardRenderer.cs new file mode 100644 index 0000000..52f52a1 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewStandardRenderer.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; + +namespace Sheng.Winform.Controls +{ + /// + /// 默认渲染器,以类似微软ListView的方式按行绘制项,只绘制简单的文本 + /// + class ShengListViewStandardRenderer : ShengListViewRenderer + { + #region 私有成员 + + /// + /// 字的高度是否已初始化 + /// 在第一次绘制时,测量文本的高度 + /// + bool _headerHeightInited = false; + + int _headerHeight; + Size _itemPadding = new Size(8, 4); + Rectangle _headerBounds; + StringFormat _itemHeaderStringFormat = new StringFormat(); + + #endregion + + #region 构造 + + public ShengListViewStandardRenderer(ShengListViewLayoutManager layoutManager) + : base(layoutManager) + { + layoutManager.ItemHeight = 24; + + //_itemHeaderStringFormat.Alignment = StringAlignment.Center; + _itemHeaderStringFormat.FormatFlags = StringFormatFlags.LineLimit| StringFormatFlags.NoWrap; + } + + #endregion + + #region 受保护的方法 + + internal override void DrawForeground(Graphics g) + { + + } + + internal override void DrawItemContent(Graphics g, Rectangle bounds, ShengListViewItem item) + { + string header = LayoutManager.GetItemText(item.Value); + if (String.IsNullOrEmpty(header)) + return; + + if (_headerHeightInited == false) + { + SizeF headerSize = g.MeasureString(header, Theme.ItemHeaderFont); + _headerHeight = (int)Math.Ceiling(headerSize.Height); + + _headerHeightInited = true; + } + + #region 绘制文本 + + _headerBounds = new Rectangle(); + _headerBounds.X = _itemPadding.Width; + _headerBounds.Y = _itemPadding.Height; + _headerBounds.Width = bounds.Width; + _headerBounds.Height = _headerHeight; + _headerBounds.Offset(bounds.Location); + + if (String.IsNullOrEmpty(header) == false) + { + using (SolidBrush brush = new SolidBrush(Theme.ItemHeaderColor)) + { + g.DrawString(header, Theme.ItemHeaderFont, brush, _headerBounds, _itemHeaderStringFormat); + } + } + + #endregion + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewTheme.cs b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewTheme.cs new file mode 100644 index 0000000..6233e0d --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengListView/Layout/ShengListViewTheme.cs @@ -0,0 +1,154 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel; +using System.Drawing; + +namespace Sheng.Winform.Controls +{ + public class ShengListViewTheme + { + private Font _itemHeaderFont = SystemFonts.DefaultFont; + public Font ItemHeaderFont + { + get { return _itemHeaderFont; } + set { _itemHeaderFont = value; } + } + + private Color _itemHeaderColor = SystemColors.WindowText; + public Color ItemHeaderColor + { + get { return _itemHeaderColor; } + set { _itemHeaderColor = value; } + } + + private Color _itemDescriptioniColor = SystemColors.GrayText; + public Color ItemDescriptioniColor + { + get { return _itemDescriptioniColor; } + set { _itemDescriptioniColor = value; } + } + + private Color _itemBackColor = SystemColors.Window; + /// + /// 项的背景色 + /// + public Color ItemBackColor + { + get { return _itemBackColor; } + set { _itemBackColor = value; } + } + + private Color _backColor = SystemColors.Window; + /// + /// 控件背景色 + /// + public Color BackColor + { + get { return _backColor; } + set { _backColor = value; } + } + + private Color _itemBorderColor = Color.FromArgb(64, SystemColors.GrayText); + /// + /// 项的边框色 + /// + public Color ItemBorderColor + { + get { return _itemBorderColor; } + set { _itemBorderColor = value; } + } + + private Color _selectionRectangleColor = Color.FromArgb(128, SystemColors.Highlight); + /// + /// 选择框颜色 + /// + public Color SelectionRectangleColor + { + get { return _selectionRectangleColor; } + set { _selectionRectangleColor = value; } + } + + private Color _selectionRectangleBorderColor = SystemColors.Highlight; + /// + /// 选择框的边框色 + /// + public Color SelectionRectangleBorderColor + { + get { return _selectionRectangleBorderColor; } + set { _selectionRectangleBorderColor = value; } + } + + private Color _selectedColorStart = Color.FromArgb(16, SystemColors.Highlight); + /// + /// 当控件具有焦点时选定项的背景色 + /// + public Color SelectedColorStart + { + get { return _selectedColorStart; } + set { _selectedColorStart = value; } + } + + private Color _selectedColorEnd = Color.FromArgb(128, SystemColors.Highlight); + public Color SelectedColorEnd + { + get { return _selectedColorEnd; } + set { _selectedColorEnd = value; } + } + + private Color _unFocusedColorStart = Color.FromArgb(16, SystemColors.GrayText); + /// + /// 控件失去焦点时选定项的背景色 + /// + public Color UnFocusedColorStart + { + get { return _unFocusedColorStart; } + set { _unFocusedColorStart = value; } + } + + private Color _unFocusedColorEnd = Color.FromArgb(64, SystemColors.GrayText); + public Color UnFocusedColorEnd + { + get { return _unFocusedColorEnd; } + set { _unFocusedColorEnd = value; } + } + + private Color _hoverColorStart = Color.FromArgb(8, SystemColors.Highlight); + /// + /// 热点项的背景色 + /// + public Color HoverColorStart + { + get { return _hoverColorStart; } + set { _hoverColorStart = value; } + } + + private Color _hoverColorEnd = Color.FromArgb(64, SystemColors.Highlight); + public Color HoverColorEnd + { + get { return _hoverColorEnd; } + set { _hoverColorEnd = value; } + } + + private Color _imageInnerBorderColor = Color.FromArgb(128, Color.White); + /// + /// 图像内边框颜色 + /// + public Color ImageInnerBorderColor + { + get { return _imageInnerBorderColor; } + set { _imageInnerBorderColor = value; } + } + + private Color _imageOuterBorderColor = Color.FromArgb(128, Color.Gray); + /// + /// 图像外边框颜色 + /// + public Color ImageOuterBorderColor + { + get { return _imageOuterBorderColor; } + set { _imageOuterBorderColor = value; } + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengListView/ShengListView.cs b/Source/ryControls/Sheng.Winform.Controls/ShengListView/ShengListView.cs new file mode 100644 index 0000000..45da2eb --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengListView/ShengListView.cs @@ -0,0 +1,878 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Windows.Forms.VisualStyles; +using System.Drawing; +using System.Diagnostics; +using System.Reflection; +using Sheng.Winform.Controls.Kernal; +using System.Collections; + +namespace Sheng.Winform.Controls +{ + public class ShengListView : Control + { + #region 常量 + + /// + /// Creates a control with a border. + /// + private const int WS_BORDER = 0x00800000; + /// + /// Specifies that the control has a border with a sunken edge. + /// + private const int WS_EX_CLIENTEDGE = 0x00000200; + + #endregion + + #region 私有成员 + + private bool _suspendLayout = false; + public bool Suspend + { + get { return _suspendLayout; } + } + + /// + /// 是否需要在调用 ResumeLayout 时重绘 + /// + private bool _needPaint = false; + + private ShengListViewLayoutManager _layoutManager; + + /// + /// 为项扩展的用于呈现的属性 + /// + private Dictionary _extendMember = new Dictionary(); + + //ToolTip _toolTip = new ToolTip(); + + //private System.Timers.Timer lazyRefreshTimer; + + #endregion + + #region 公开属性 + + /// + /// Gets whether the shift key is down. + /// + internal bool ShiftKey { get; private set; } + /// + /// Gets whether the control key is down. + /// + internal bool ControlKey { get; private set; } + + /// + /// 鼠标左键是否处于按下状态 + /// + internal bool LeftButton { get; private set; } + + /// + /// 鼠标右键是否处于按下状态 + /// + internal bool RightButton { get; private set; } + + internal bool AnyMouseButton + { + get { return LeftButton || RightButton; } + } + + //debug public + /// + /// 鼠标最后点击的位置 + /// + internal Point LastMouseDownLocation { get; private set; } + + private ShengListViewItem _hoveredItem; + /// + /// 当前鼠标经过的项 + /// + internal ShengListViewItem HoveredItem + { + get { return _hoveredItem; } + private set + { + ShengListViewItem oldHoveredItem = _hoveredItem; + ShengListViewItem newHoveredItem = value; + + _hoveredItem = value; + + if (oldHoveredItem != null && oldHoveredItem != newHoveredItem) + { + oldHoveredItem.Hovered = false; + } + + if (newHoveredItem != null) + newHoveredItem.Hovered = true; + + if (oldHoveredItem != newHoveredItem) + { + NeedPaint(); + } + } + } + + private ShengListViewLayoutMode _layoutMode; + public ShengListViewLayoutMode LayoutMode + { + get { return _layoutMode; } + set + { + _layoutMode = value; + ShengListViewLayoutManager layoutManager; + switch (_layoutMode) + { + case ShengListViewLayoutMode.Standard: + layoutManager = new ShengListViewStandardLayoutManager(this); + break; + case ShengListViewLayoutMode.Descriptive: + layoutManager = new ShengListViewDescriptiveLayoutManager(this); + break; + default: + layoutManager = new ShengListViewLayoutManager(this); + Debug.Assert(false, "没这ListViewRenderer"); + break; + } + + SetLayoutManager(layoutManager); + } + } + + private BorderStyle _borderStyle = BorderStyle.Fixed3D; + public BorderStyle BorderStyle + { + get { return _borderStyle; } + set { _borderStyle = value; } + } + + private ShengListViewTheme _theme = new ShengListViewTheme(); + /// + /// 配色方案 + /// + public ShengListViewTheme Theme + { + get + { + return _theme; + } + set + { + _theme = value; + Refresh(); + } + } + + /// + /// 当前布局中项的高度 + /// + public int ItemHeight + { + get { return _layoutManager.ItemHeightWithMargin; } + } + + private bool _allowMultiSelection = false; + public bool AllowMultiSelection + { + get { return _allowMultiSelection; } + set { _allowMultiSelection = value; } + } + + /// + /// 是否没有任何项 + /// + public bool IsEmpty + { + get + { + return Items.Count == 0; + } + } + + private ShengListViewItemCollection _items = new ShengListViewItemCollection(); + public ShengListViewItemCollection Items + { + get { return _items; } + set { _items = value; } + } + + /// + /// 获取当前具有输入焦点的项 + /// + public ShengListViewItem FocusedItem + { + get + { + foreach (var item in _items) + { + if (item.Focused) + return item; + } + + return null; + } + } + + /// + /// 默认的用于呈现为项中文本的Property + /// + public string DisplayMember + { + get; + set; + } + + #endregion + + #region 构造 + + public ShengListView() + { + SetStyle(ControlStyles.ResizeRedraw, true); + SetStyle(ControlStyles.OptimizedDoubleBuffer, true); + SetStyle(ControlStyles.Selectable, true); + + this.Padding = new System.Windows.Forms.Padding(10); + + _items.Owner = this; + + //设置一个默认布局 + this.LayoutMode = ShengListViewLayoutMode.Standard; + + //_layoutManager = new ListViewLayoutManager(this); + + //lazyRefreshTimer = new System.Timers.Timer(); + //lazyRefreshTimer.Interval = 10; + //lazyRefreshTimer.Enabled = false; + //lazyRefreshTimer.Elapsed += lazyRefreshTimer_Tick; + //lazyRefreshCallback = new RefreshDelegateInternal(Refresh); + } + + //delegate void RefreshDelegateInternal(); + //private RefreshDelegateInternal lazyRefreshCallback; + //void lazyRefreshTimer_Tick(object sender, EventArgs e) + //{ + // if (IsHandleCreated && IsDisposed == false) + // BeginInvoke(lazyRefreshCallback); + // lazyRefreshTimer.Stop(); + //} + + #endregion + + #region 方法 + + #region internal + + /// + /// 更改了选择的项 + /// + internal void OnSelectedItemChanged() + { + if (SelectedItemChanaged != null) + { + SelectedItemChanaged(this, new EventArgs()); + } + } + + /// + /// 双击项 + /// + /// + internal void OnItemDoubleClick(ShengListViewItem item) + { + if (ItemDoubleClick != null) + { + ItemDoubleClick(this, new ShengListViewItemDoubleClickEventArgs(item)); + } + } + + internal void OnItemsRemoved(List items) + { + _layoutManager.OnItemsRemoved(items); + + if (ItemsRemoved != null) + { + ItemsRemoved(this, new ShengListViewItemsRemovedEventArgs(items)); + } + } + + /// + /// 请求在下次调用 ResumeLayout 时重绘 + /// + internal void NeedPaint() + { + _needPaint = true; + } + + internal void RenderItem(ShengListViewItem item) + { + if (Suspend == false) + { + _layoutManager.RenderItem(this.CreateGraphics(), item); + } + } + + internal object GetItemPropertyValue(object itemValue, string propertyName) + { + if (itemValue == null || String.IsNullOrEmpty(propertyName)) + { + Debug.Assert(false, "itemValue 或 propertyName 为空"); + throw new ArgumentNullException(); + } + + return ReflectionPool.GetPropertyValue(itemValue, propertyName); + + } + + internal string GetItemText(object itemValue) + { + Debug.Assert(itemValue != null, "itemValue 为 null"); + + if (itemValue == null) + return String.Empty; + + if (ItemTextGetting != null) + { + ShengListViewGetItemTextEventArgs args = new ShengListViewGetItemTextEventArgs(itemValue); + ItemTextGetting(this, args); + if (String.IsNullOrEmpty(args.Text) == false) + return args.Text; + } + + if (String.IsNullOrEmpty(DisplayMember)) + { + return itemValue.ToString(); + } + else + { + return GetItemText(itemValue, DisplayMember); + } + } + + internal string GetItemText(object itemValue, string propertyName) + { + Debug.Assert(itemValue != null && String.IsNullOrEmpty(propertyName) == false, "itemValue 为 null"); + + object text = GetItemPropertyValue(itemValue, propertyName); + if (text == null) + return String.Empty; + else + return text.ToString(); + } + + /// + /// 获取当前选中的所有项 + /// + /// + internal List GetSelectedItems() + { + List items = new List(); + + foreach (var item in _items) + { + if (item.Selected) + items.Add(item); + } + + return items; + } + + #endregion + + #region public + + public void AddExtendMember(IShengListViewExtendMember member) + { + Dictionary extendMembers = member.GetExtendMembers(); + foreach (var item in extendMembers) + { + SetExtendMember(item.Key, item.Value); + } + } + + /// + /// 设置扩展属性供特定LayoutEngine使用 + /// 如果指定的 ExtendMember 已存在,覆盖之 + /// 用String.Empty 或 null 做为 propertyName传入,表示删除指定的 member + /// + /// + /// + public void SetExtendMember(string member, string propertyName) + { + if (String.IsNullOrEmpty(member)) + { + Debug.Assert(false, "member 为空"); + throw new ArgumentNullException(); + } + + if (String.IsNullOrEmpty(propertyName)) + { + _extendMember.Remove(member); + } + else + { + if (_extendMember.Keys.Contains(member)) + { + _extendMember[member] = propertyName; + } + else + { + _extendMember.Add(member, propertyName); + } + } + } + + public bool ContainerExtendMember(string member) + { + if (String.IsNullOrEmpty(member) ) + { + Debug.Assert(false, "member 为空"); + throw new ArgumentNullException(); + } + + return _extendMember.Keys.Contains(member); + } + + public string GetExtendMember(string member) + { + if (ContainerExtendMember(member) == false) + { + Debug.Assert(false, "指定的 member 不存在" + member); + throw new ArgumentOutOfRangeException(); + } + + return _extendMember[member]; + } + + /// + /// 恢复正常的布局逻辑。 + /// + public new void ResumeLayout() + { + _suspendLayout = false; + + if (_needPaint) + { + this.Refresh(); + _needPaint = false; + } + + base.ResumeLayout(); + } + + public new void ResumeLayout(bool refreshNow) + { + _suspendLayout = false; + + if (refreshNow) + { + this.Refresh(); + _needPaint = false; + } + else + { + ResumeLayout(); + } + + base.ResumeLayout(refreshNow); + } + + /// + /// 临时挂起控件的布局逻辑。 + /// + public new void SuspendLayout() + { + _suspendLayout = true; + + base.SuspendLayout(); + } + + public override void Refresh() + { + if (_suspendLayout) + return; + + base.Refresh(); + } + + /// + /// 获取当前选中项所绑定的对象 + /// 如果没有选中项,返回null,如果选中多项,返回选中项集合中的第一个 + /// + /// + public object GetSelectedValue() + { + List selectedItems = GetSelectedItems(); + if (selectedItems.Count == 0) + return null; + + return selectedItems[0].Value; + } + + /// + /// 根据指定的绑定项对象 + /// 设置当前列表中选定的项 + /// + /// + public void SetSelectedValue(object obj) + { + if (obj == null) + { + ClearSelect(); + return; + } + + var items = (from item in _items where item.Value == obj select item).ToList(); + if (items.Count == 0) + { + Debug.Assert(false, "没有指定的项"); + return; + } + + var oldSelectedItems = GetSelectedItems(); + + //这里为什么用foreach + //考虑到多个项绑定到同一个对象的情况,不过理论上讲不应该出现这种情况 + SuspendLayout(); + ClearSelect(); + foreach (var item in items) + { + item.Selected = true; + } + ResumeLayout(); + + if (items.SequenceEqual(oldSelectedItems) == false) + OnSelectedItemChanged(); + } + + /// + /// 获取当前选中的所有项的绑定对象集合 + /// 如果当前没有选中任何项,返回空集合 + /// + /// + public List GetSelectedValues() + { + List selectedValues = new List(); + + List selectedItems = GetSelectedItems(); + + foreach (var item in selectedItems) + { + selectedValues.Add(item.Value); + } + + return selectedValues; + } + + /// + /// 取消所有项的选择 + /// + public void ClearSelect() + { + bool suspend = false; + if (this.Suspend == false) + { + this.SuspendLayout(); + suspend = true; + } + + foreach (var selectedItem in GetSelectedItems()) + { + selectedItem.Selected = false; + } + + if (suspend) + this.ResumeLayout(); + } + + public void DataBind(IList list) + { + if (list == null) + { + Debug.Assert(false, "list 为 null"); + throw new ArgumentNullException(); + } + + SuspendLayout(); + Items.Clear(); + foreach (var item in list) + { + this.Items.Add(new ShengListViewItem(item)); + } + ResumeLayout(); + } + + public void Clear() + { + SuspendLayout(); + Items.Clear(); + ResumeLayout(); + } + + #endregion + + #region private + + private void Hover(Point location) + { + ShengListViewHitInfo hitInfo = _layoutManager.HitTest(location); + if (hitInfo.ItemHit) + { + HoveredItem = Items[hitInfo.ItemIndex]; + } + else + { + HoveredItem = null; + } + } + + private void SetLayoutManager(ShengListViewLayoutManager layoutManager) + { + if (_layoutManager == layoutManager) + return; + + if (_layoutManager != null) + _layoutManager.Dispose(); + + _layoutManager = layoutManager; + + Refresh(); + } + + #endregion + + #region protected + + /// + /// 获取创建控件句柄时所需要的创建参数 + /// + protected override CreateParams CreateParams + { + get + { + //设置控件的边框样式 + CreateParams p = base.CreateParams; + p.Style &= ~WS_BORDER; + p.ExStyle &= ~WS_EX_CLIENTEDGE; + if (_borderStyle == BorderStyle.Fixed3D) + p.ExStyle |= WS_EX_CLIENTEDGE; + else if (_borderStyle == BorderStyle.FixedSingle) + p.Style |= WS_BORDER; + return p; + } + } + + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + + //_layoutManager.Update(); + } + + #region Mouse + + protected override void OnMouseDown(MouseEventArgs e) + { + SuspendLayout(); + + if (Focused == false) + Focus(); + + LeftButton = (e.Button & MouseButtons.Left) == MouseButtons.Left; + RightButton = (e.Button & MouseButtons.Right) == MouseButtons.Right; + + LastMouseDownLocation = e.Location; + + _layoutManager.MouseDown(e); + + ResumeLayout(); + + base.OnMouseDown(e); + } + + protected override void OnMouseUp(MouseEventArgs e) + { + if ((e.Button & MouseButtons.Left) == MouseButtons.Left) + LeftButton = false; + if ((e.Button & MouseButtons.Right) == MouseButtons.Right) + RightButton = false; + + SuspendLayout(); + + _layoutManager.MouseUp(e); + + ResumeLayout(); + + //显示上下文菜单 + bool rightButton = (e.Button & MouseButtons.Right) == MouseButtons.Right; + if (rightButton && this.ContextMenuStrip != null) + { + this.ContextMenuStrip.Show(this.PointToScreen(e.Location)); + } + + base.OnMouseUp(e); + } + + protected override void OnMouseMove(MouseEventArgs e) + { + // if (_toolTip.Active) + // _toolTip.Hide(this); + + SuspendLayout(); + + //如果处于框选状态,不处理Hover + if (_layoutManager.MouseSelecting == false) + { + Hover(e.Location); + } + + _layoutManager.MouseMove(e); + + ResumeLayout(); + + base.OnMouseMove(e); + } + + protected override void OnMouseWheel(MouseEventArgs e) + { + SuspendLayout(); + + _layoutManager.OnMouseWheel(e); + + Hover(e.Location); + + NeedPaint(); + ResumeLayout(); + + base.OnMouseWheel(e); + } + + protected override void OnMouseDoubleClick(MouseEventArgs e) + { + if (ItemDoubleClick != null) + { + ShengListViewHitInfo hitInfo = _layoutManager.HitTest(e.Location); + if (hitInfo.ItemHit) + { + ShengListViewItem item = Items[hitInfo.ItemIndex]; + OnItemDoubleClick(item); + } + } + + base.OnMouseDoubleClick(e); + } + + protected override void OnMouseHover(EventArgs e) + { + //Point toolTipPoint = this.PointToClient(Cursor.Position); + //_toolTip.Show("ff", this, toolTipPoint); + + base.OnMouseHover(e); + } + + #endregion + + #region Key + + protected override bool IsInputKey(Keys keyData) + { + if ((keyData & Keys.Left) == Keys.Left || + (keyData & Keys.Right) == Keys.Right || + (keyData & Keys.Up) == Keys.Up || + (keyData & Keys.Down) == Keys.Down) + return true; + else + return base.IsInputKey(keyData); + } + + protected override void OnKeyDown(KeyEventArgs e) + { + ShiftKey = (e.Modifiers & Keys.Shift) == Keys.Shift; + ControlKey = (e.Modifiers & Keys.Control) == Keys.Control; + + _layoutManager.OnKeyDown(e); + + base.OnKeyDown(e); + } + + protected override void OnKeyUp(KeyEventArgs e) + { + ShiftKey = (e.Modifiers & Keys.Shift) == Keys.Shift; + ControlKey = (e.Modifiers & Keys.Control) == Keys.Control; + + _layoutManager.OnKeyUp(e); + + base.OnKeyUp(e); + } + + #endregion + + #region Focus + + protected override void OnGotFocus(EventArgs e) + { + base.OnGotFocus(e); + Refresh(); + } + + protected override void OnLostFocus(EventArgs e) + { + base.OnLostFocus(e); + Refresh(); + } + + #endregion + + #region Paint + + protected override void OnPaint(PaintEventArgs e) + { + if (_layoutManager != null) + { + _layoutManager.Render(e.Graphics); + } + + //Size size1 = new Size(100, 100); + //Size size2 = new Size(50, 50); + //e.Graphics.DrawRectangle(Pens.Black, new Rectangle(new Point(10, 10), size1)); + //size1 = Size.Add(size1, size2); + //e.Graphics.DrawRectangle(Pens.Red, new Rectangle(new Point(10, 10), size1)); + } + + #endregion + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + } + + #endregion + + #endregion + + #region 事件 + + /// + /// 更改了选择的项 + /// + public event EventHandler SelectedItemChanaged; + + /// + /// 双击项 + /// + public event EventHandler ItemDoubleClick; + + /// + /// 项被删除 + /// + public event EventHandler ItemsRemoved; + + /// + /// 通过外能事件获取用于绘制项的文本 + /// + public event EventHandler ItemTextGetting; + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengListView/ShengListViewColor.cs b/Source/ryControls/Sheng.Winform.Controls/ShengListView/ShengListViewColor.cs new file mode 100644 index 0000000..acfbf16 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengListView/ShengListViewColor.cs @@ -0,0 +1,775 @@ +using System.ComponentModel; +using System.Drawing; +using System; +using System.Reflection; +using System.Collections.Generic; + +namespace Sheng.Winform.Controls +{ + /// + /// Represents the color palette of the image list view. + /// + public class ShengListViewColor + { + #region Member Variables + // control background color + Color mControlBackColor; + + // item colors + Color mBackColor; + Color mBorderColor; + Color mUnFocusedColor1; + Color mUnFocusedColor2; + Color mUnFocusedBorderColor; + Color mUnFocusedForeColor; + Color mForeColor; + Color mHoverColor1; + Color mHoverColor2; + Color mHoverBorderColor; + Color mInsertionCaretColor; + Color mSelectedColor1; + Color mSelectedColor2; + Color mSelectedBorderColor; + Color mSelectedForeColor; + + // thumbnail & pane + Color mImageInnerBorderColor; + Color mImageOuterBorderColor; + + // details view + Color mCellForeColor; + Color mColumnHeaderBackColor1; + Color mColumnHeaderBackColor2; + Color mColumnHeaderForeColor; + Color mColumnHeaderHoverColor1; + Color mColumnHeaderHoverColor2; + Color mColumnSelectColor; + Color mColumnSeparatorColor; + Color mAlternateBackColor; + Color mAlternateCellForeColor; + + // pane + Color mPaneBackColor; + Color mPaneSeparatorColor; + Color mPaneLabelColor; + + // selection rectangle + Color mSelectionRectangleColor1; + Color mSelectionRectangleColor2; + Color mSelectionRectangleBorderColor; + #endregion + + #region Properties + /// + /// Gets or sets the background color of the ImageListView control. + /// + [Category("Appearance"), Description("Gets or sets the background color of the ImageListView control.")] + [DefaultValue(typeof(Color), "Window")] + public Color ControlBackColor + { + get { return mControlBackColor; } + set { mControlBackColor = value; } + } + /// + /// Gets or sets the background color of the ImageListViewItem. + /// + [Category("Appearance"), Description("Gets or sets the background color of the ImageListViewItem.")] + [DefaultValue(typeof(Color), "Window")] + public Color BackColor + { + get { return mBackColor; } + set { mBackColor = value; } + } + /// + /// Gets or sets the background color of alternating cells in Details View. + /// + [Category("Appearance Details View"), Description("Gets or sets the background color of alternating cells in Details View.")] + [DefaultValue(typeof(Color), "Window")] + public Color AlternateBackColor + { + get { return mAlternateBackColor; } + set { mAlternateBackColor = value; } + } + /// + /// Gets or sets the border color of the ImageListViewItem. + /// + [Category("Appearance"), Description("Gets or sets the border color of the ImageListViewItem.")] + [DefaultValue(typeof(Color), "64, 128, 128, 128")] + public Color BorderColor + { + get { return mBorderColor; } + set { mBorderColor = value; } + } + /// + /// Gets or sets the foreground color of the ImageListViewItem. + /// + [Category("Appearance"), Description("Gets or sets the foreground color of the ImageListViewItem.")] + [DefaultValue(typeof(Color), "ControlText")] + public Color ForeColor + { + get { return mForeColor; } + set { mForeColor = value; } + } + /// + /// Gets or sets the background gradient color1 of the ImageListViewItem if the control is not focused. + /// + [Category("Appearance"), Description("Gets or sets the background gradient color1 of the ImageListViewItem if the control is not focused.")] + [DefaultValue(typeof(Color), "16, 128, 128, 128")] + public Color UnFocusedColor1 + { + get { return mUnFocusedColor1; } + set { mUnFocusedColor1 = value; } + } + /// + /// Gets or sets the background gradient color2 of the ImageListViewItem if the control is not focused. + /// + [Category("Appearance"), Description("Gets or sets the background gradient color2 of the ImageListViewItem if the control is not focused.")] + [DefaultValue(typeof(Color), "64, 128, 128, 128")] + public Color UnFocusedColor2 + { + get { return mUnFocusedColor2; } + set { mUnFocusedColor2 = value; } + } + /// + /// Gets or sets the border color of the ImageListViewItem if the control is not focused. + /// + [Category("Appearance"), Description("Gets or sets the border color of the ImageListViewItem if the control is not focused.")] + [DefaultValue(typeof(Color), "128, 128, 128, 128")] + public Color UnFocusedBorderColor + { + get { return mUnFocusedBorderColor; } + set { mUnFocusedBorderColor = value; } + } + /// + /// Gets or sets the fore color of the ImageListViewItem if the control is not focused. + /// + [Category("Appearance"), Description("Gets or sets the fore color of the ImageListViewItem if the control is not focused.")] + [DefaultValue(typeof(Color), "ControlText")] + public Color UnFocusedForeColor + { + get { return mUnFocusedForeColor; } + set { mUnFocusedForeColor = value; } + } + /// + /// Gets or sets the background gradient color1 if the ImageListViewItem is hovered. + /// + [Category("Appearance"), Description("Gets or sets the background gradient color1 if the ImageListViewItem is hovered.")] + [DefaultValue(typeof(Color), "8, 10, 36, 106")] + public Color HoverColor1 + { + get { return mHoverColor1; } + set { mHoverColor1 = value; } + } + /// + /// Gets or sets the background gradient color2 if the ImageListViewItem is hovered. + /// + [Category("Appearance"), Description("Gets or sets the background gradient color2 if the ImageListViewItem is hovered.")] + [DefaultValue(typeof(Color), "64, 10, 36, 106")] + public Color HoverColor2 + { + get { return mHoverColor2; } + set { mHoverColor2 = value; } + } + /// + /// Gets or sets the border color of the ImageListViewItem if the item is hovered. + /// + [Category("Appearance"), Description("Gets or sets the border color of the ImageListViewItem if the item is hovered.")] + [DefaultValue(typeof(Color), "64, 10, 36, 106")] + public Color HoverBorderColor + { + get { return mHoverBorderColor; } + set { mHoverBorderColor = value; } + } + /// + /// Gets or sets the color of the insertion caret. + /// + [Category("Appearance"), Description("Gets or sets the color of the insertion caret.")] + [DefaultValue(typeof(Color), "Highlight")] + public Color InsertionCaretColor + { + get { return mInsertionCaretColor; } + set { mInsertionCaretColor = value; } + } + /// + /// Gets or sets the background gradient color1 if the ImageListViewItem is selected. + /// + [Category("Appearance"), Description("Gets or sets the background gradient color1 if the ImageListViewItem is selected.")] + [DefaultValue(typeof(Color), "16, 10, 36, 106")] + public Color SelectedColor1 + { + get { return mSelectedColor1; } + set { mSelectedColor1 = value; } + } + /// + /// Gets or sets the background gradient color2 if the ImageListViewItem is selected. + /// + [Category("Appearance"), Description("Gets or sets the background gradient color2 if the ImageListViewItem is selected.")] + [DefaultValue(typeof(Color), "128, 10, 36, 106")] + public Color SelectedColor2 + { + get { return mSelectedColor2; } + set { mSelectedColor2 = value; } + } + /// + /// Gets or sets the border color of the ImageListViewItem if the item is selected. + /// + [Category("Appearance"), Description("Gets or sets the border color of the ImageListViewItem if the item is selected.")] + [DefaultValue(typeof(Color), "128, 10, 36, 106")] + public Color SelectedBorderColor + { + get { return mSelectedBorderColor; } + set { mSelectedBorderColor = value; } + } + /// + /// Gets or sets the fore color of the ImageListViewItem if the item is selected. + /// + [Category("Appearance"), Description("Gets or sets the fore color of the ImageListViewItem if the item is selected.")] + [DefaultValue(typeof(Color), "ControlText")] + public Color SelectedForeColor + { + get { return mSelectedForeColor; } + set { mSelectedForeColor = value; } + } + /// + /// Gets or sets the background gradient color1 of the column header. + /// + [Category("Appearance Details View"), Description("Gets or sets the cells background color1 of the column header.")] + [DefaultValue(typeof(Color), "32, 212, 208, 200")] + public Color ColumnHeaderBackColor1 + { + get { return mColumnHeaderBackColor1; } + set { mColumnHeaderBackColor1 = value; } + } + /// + /// Gets or sets the background gradient color2 of the column header. + /// + [Category("Appearance Details View"), Description("Gets or sets the cells background color2 of the column header.")] + [DefaultValue(typeof(Color), "196, 212, 208, 200")] + public Color ColumnHeaderBackColor2 + { + get { return mColumnHeaderBackColor2; } + set { mColumnHeaderBackColor2 = value; } + } + /// + /// Gets or sets the background hover gradient color1 of the column header. + /// + [Category("Appearance Details View"), Description("Gets or sets the background hover color1 of the column header.")] + [DefaultValue(typeof(Color), "16, 10, 36, 106")] + public Color ColumnHeaderHoverColor1 + { + get { return mColumnHeaderHoverColor1; } + set { mColumnHeaderHoverColor1 = value; } + } + /// + /// Gets or sets the background hover gradient color2 of the column header. + /// + [Category("Appearance Details View"), Description("Gets or sets the background hover color2 of the column header.")] + [DefaultValue(typeof(Color), "64, 10, 36, 106")] + public Color ColumnHeaderHoverColor2 + { + get { return mColumnHeaderHoverColor2; } + set { mColumnHeaderHoverColor2 = value; } + } + /// + /// Gets or sets the cells foreground color of the column header text. + /// + [Category("Appearance Details View"), Description("Gets or sets the cells foreground color of the column header text.")] + [DefaultValue(typeof(Color), "WindowText")] + public Color ColumnHeaderForeColor + { + get { return mColumnHeaderForeColor; } + set { mColumnHeaderForeColor = value; } + } + /// + /// Gets or sets the cells background color if column is selected in Details View. + /// + [Category("Appearance Details View"), Description("Gets or sets the cells background color if column is selected in Details View.")] + [DefaultValue(typeof(Color), "16, 128, 128, 128")] + public Color ColumnSelectColor + { + get { return mColumnSelectColor; } + set { mColumnSelectColor = value; } + } + /// + /// Gets or sets the color of the separator in Details View. + /// + [Category("Appearance Details View"), Description("Gets or sets the color of the separator in Details View.")] + [DefaultValue(typeof(Color), "32, 128, 128, 128")] + public Color ColumnSeparatorColor + { + get { return mColumnSeparatorColor; } + set { mColumnSeparatorColor = value; } + } + /// + /// Gets or sets the foreground color of the cell text in Details View. + /// + [Category("Appearance Details View"), Description("Gets or sets the foreground color of the cell text in Details View.")] + [DefaultValue(typeof(Color), "ControlText")] + public Color CellForeColor + { + get { return mCellForeColor; } + set { mCellForeColor = value; } + } + /// + /// Gets or sets the foreground color of alternating cells text in Details View. + /// + [Category("Appearance Details View"), Description("Gets or sets the foreground color of alternating cells text in Details View.")] + [DefaultValue(typeof(Color), "ControlText")] + public Color AlternateCellForeColor + { + get { return mAlternateCellForeColor; } + set { mAlternateCellForeColor = value; } + } + /// + /// Gets or sets the background color of the image pane. + /// + [Category("Appearance Pane View"), Description("Gets or sets the background color of the image pane.")] + [DefaultValue(typeof(Color), "16, 128, 128, 128")] + public Color PaneBackColor + { + get { return mPaneBackColor; } + set { mPaneBackColor = value; } + } + /// + /// Gets or sets the separator line color between image pane and thumbnail view. + /// + [Category("Appearance Pane View"), Description("Gets or sets the separator line color between image pane and thumbnail view.")] + [DefaultValue(typeof(Color), "128, 128, 128, 128")] + public Color PaneSeparatorColor + { + get { return mPaneSeparatorColor; } + set { mPaneSeparatorColor = value; } + } + /// + /// Gets or sets the color of labels in pane view. + /// + [Category("Appearance Pane View"), Description("Gets or sets the color of labels in pane view.")] + [DefaultValue(typeof(Color), "196, 0, 0, 0")] + public Color PaneLabelColor + { + get { return mPaneLabelColor; } + set { mPaneLabelColor = value; } + } + /// + /// Gets or sets the image inner border color for thumbnails and pane. + /// + [Category("Appearance Image"), Description("Gets or sets the image inner border color for thumbnails and pane.")] + [DefaultValue(typeof(Color), "128, 255, 255, 255")] + public Color ImageInnerBorderColor + { + get { return mImageInnerBorderColor; } + set { mImageInnerBorderColor = value; } + } + /// + /// Gets or sets the image outer border color for thumbnails and pane. + /// + [Category("Appearance Image"), Description("Gets or sets the image outer border color for thumbnails and pane.")] + [DefaultValue(typeof(Color), "128, 128, 128, 128")] + public Color ImageOuterBorderColor + { + get { return mImageOuterBorderColor; } + set { mImageOuterBorderColor = value; } + } + /// + /// Gets or sets the background color1 of the selection rectangle. + /// + [Category("Appearance"), Description("Gets or sets the background color1 of the selection rectangle.")] + [DefaultValue(typeof(Color), "128, 10, 36, 106")] + public Color SelectionRectangleColor1 + { + get { return mSelectionRectangleColor1; } + set { mSelectionRectangleColor1 = value; } + } + /// + /// Gets or sets the background color2 of the selection rectangle. + /// + [Category("Appearance"), Description("Gets or sets the background color2 of the selection rectangle.")] + [DefaultValue(typeof(Color), "128, 10, 36, 106")] + public Color SelectionRectangleColor2 + { + get { return mSelectionRectangleColor2; } + set { mSelectionRectangleColor2 = value; } + } + /// + /// Gets or sets the color of the selection rectangle border. + /// + [Category("Appearance"), Description("Gets or sets the color of the selection rectangle border.")] + [DefaultValue(typeof(Color), "Highlight")] + public Color SelectionRectangleBorderColor + { + get { return mSelectionRectangleBorderColor; } + set { mSelectionRectangleBorderColor = value; } + } + #endregion + + #region Constructors + /// + /// Initializes a new instance of the ImageListViewColor class. + /// + public ShengListViewColor() + { + // control + mControlBackColor = SystemColors.Window; + + // item + mBackColor = SystemColors.Window; + mForeColor = SystemColors.ControlText; + + mBorderColor = Color.FromArgb(64, SystemColors.GrayText); + + mUnFocusedColor1 = Color.FromArgb(16, SystemColors.GrayText); + mUnFocusedColor2 = Color.FromArgb(64, SystemColors.GrayText); + mUnFocusedBorderColor = Color.FromArgb(128, SystemColors.GrayText); + mUnFocusedForeColor = SystemColors.ControlText; + + mHoverColor1 = Color.FromArgb(8, SystemColors.Highlight); + mHoverColor2 = Color.FromArgb(64, SystemColors.Highlight); + mHoverBorderColor = Color.FromArgb(64, SystemColors.Highlight); + + mSelectedColor1 = Color.FromArgb(16, SystemColors.Highlight); + mSelectedColor2 = Color.FromArgb(128, SystemColors.Highlight); + mSelectedBorderColor = Color.FromArgb(128, SystemColors.Highlight); + mSelectedForeColor = SystemColors.ControlText; + + mInsertionCaretColor = SystemColors.Highlight; + + // thumbnails + mImageInnerBorderColor = Color.FromArgb(128, Color.White); + mImageOuterBorderColor = Color.FromArgb(128, Color.Gray); + + // details view + mColumnHeaderBackColor1 = Color.FromArgb(32, SystemColors.Control); + mColumnHeaderBackColor2 = Color.FromArgb(196, SystemColors.Control); + mColumnHeaderHoverColor1 = Color.FromArgb(16, SystemColors.Highlight); + mColumnHeaderHoverColor2 = Color.FromArgb(64, SystemColors.Highlight); + mColumnHeaderForeColor = SystemColors.WindowText; + mColumnSelectColor = Color.FromArgb(16, SystemColors.GrayText); + mColumnSeparatorColor = Color.FromArgb(32, SystemColors.GrayText); + mCellForeColor = SystemColors.ControlText; + mAlternateBackColor = SystemColors.Window; + mAlternateCellForeColor = SystemColors.ControlText; + + // image pane + mPaneBackColor = Color.FromArgb(16, SystemColors.GrayText); + mPaneSeparatorColor = Color.FromArgb(128, SystemColors.GrayText); + mPaneLabelColor = Color.FromArgb(196, Color.Black); + + // selection rectangle + mSelectionRectangleColor1 = Color.FromArgb(128, SystemColors.Highlight); + mSelectionRectangleColor2 = Color.FromArgb(128, SystemColors.Highlight); + mSelectionRectangleBorderColor = SystemColors.Highlight; + } + + /// + /// Initializes a new instance of the ImageListViewColor class + /// from its string representation. + /// + /// String representation of the object. + public ShengListViewColor(string definition) + : this() + { + try + { + // First check if the color matches a predefined color setting + foreach (MemberInfo info in typeof(ShengListViewColor).GetMembers(BindingFlags.Static | BindingFlags.Public)) + { + if (info.MemberType == MemberTypes.Property) + { + PropertyInfo propertyInfo = (PropertyInfo)info; + if (propertyInfo.PropertyType == typeof(ShengListViewColor)) + { + // If the color setting is equal to a preset value + // return the preset + if (definition == string.Format("({0})", propertyInfo.Name) || + definition == propertyInfo.Name) + { + ShengListViewColor presetValue = (ShengListViewColor)propertyInfo.GetValue(null, null); + CopyFrom(presetValue); + return; + } + } + } + } + + // Convert color values + foreach (string line in definition.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries)) + { + // Read the color setting + string[] pair = line.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries); + string name = pair[0].Trim(); + Color color = Color.FromName(pair[1].Trim()); + // Set the property value + PropertyInfo property = typeof(ShengListViewColor).GetProperty(name); + property.SetValue(this, color, null); + } + } + catch + { + throw new ArgumentException("Invalid string format", "definition"); + } + } + #endregion + + #region InstanceMethods + /// + /// Copies color values from the given object. + /// + /// The source object. + public void CopyFrom(ShengListViewColor source) + { + foreach (PropertyInfo info in typeof(ShengListViewColor).GetProperties()) + { + // Walk through color properties + if (info.PropertyType == typeof(Color)) + { + Color color = (Color)info.GetValue(source, null); + info.SetValue(this, color, null); + } + } + } + #endregion + + #region Static Members + /// + /// Represents the default color theme. + /// + public static ShengListViewColor Default { get { return ShengListViewColor.GetDefaultTheme(); } } + /// + /// Represents the noir color theme. + /// + public static ShengListViewColor Noir { get { return ShengListViewColor.GetNoirTheme(); } } + /// + /// Represents the mandarin color theme. + /// + public static ShengListViewColor Mandarin { get { return ShengListViewColor.GetMandarinTheme(); } } + + /// + /// Sets the color palette to default colors. + /// + private static ShengListViewColor GetDefaultTheme() + { + return new ShengListViewColor(); + } + /// + /// Sets the color palette to mandarin colors. + /// + private static ShengListViewColor GetMandarinTheme() + { + ShengListViewColor c = new ShengListViewColor(); + + // control + c.ControlBackColor = Color.White; + + // item + c.BackColor = Color.White; + c.ForeColor = Color.FromArgb(60, 60, 60); + c.BorderColor = Color.FromArgb(187, 190, 183); + + c.UnFocusedColor1 = Color.FromArgb(235, 235, 235); + c.UnFocusedColor2 = Color.FromArgb(217, 217, 217); + c.UnFocusedBorderColor = Color.FromArgb(168, 169, 161); + c.UnFocusedForeColor = Color.FromArgb(40, 40, 40); + + c.HoverColor1 = Color.Transparent; + c.HoverColor2 = Color.Transparent; + c.HoverBorderColor = Color.Transparent; + + c.SelectedColor1 = Color.FromArgb(244, 125, 77); + c.SelectedColor2 = Color.FromArgb(235, 110, 60); + c.SelectedBorderColor = Color.FromArgb(240, 119, 70); + c.SelectedForeColor = Color.White; + + c.InsertionCaretColor = Color.FromArgb(240, 119, 70); + + // thumbnails & pane + c.ImageInnerBorderColor = Color.Transparent; + c.ImageOuterBorderColor = Color.White; + + // details view + c.CellForeColor = Color.FromArgb(60, 60, 60); + c.ColumnHeaderBackColor1 = Color.FromArgb(247, 247, 247); + c.ColumnHeaderBackColor2 = Color.FromArgb(235, 235, 235); + c.ColumnHeaderHoverColor1 = Color.White; + c.ColumnHeaderHoverColor2 = Color.FromArgb(245, 245, 245); + c.ColumnHeaderForeColor = Color.FromArgb(60, 60, 60); + c.ColumnSelectColor = Color.FromArgb(34, 128, 128, 128); + c.ColumnSeparatorColor = Color.FromArgb(106, 128, 128, 128); + c.mAlternateBackColor = Color.FromArgb(234, 234, 234); + c.mAlternateCellForeColor = Color.FromArgb(40, 40, 40); + + // image pane + c.PaneBackColor = Color.White; + c.PaneSeparatorColor = Color.FromArgb(216, 216, 216); + c.PaneLabelColor = Color.FromArgb(156, 156, 156); + + // selection rectangle + c.SelectionRectangleColor1 = Color.FromArgb(64, 240, 116, 68); + c.SelectionRectangleColor2 = Color.FromArgb(64, 240, 116, 68); + c.SelectionRectangleBorderColor = Color.FromArgb(240, 119, 70); + + return c; + } + /// + /// Sets the color palette to noir colors. + /// + private static ShengListViewColor GetNoirTheme() + { + ShengListViewColor c = new ShengListViewColor(); + + // control + c.ControlBackColor = Color.Black; + + // item + c.BackColor = Color.FromArgb(0x31, 0x31, 0x31); + c.ForeColor = Color.LightGray; + + c.BorderColor = Color.DarkGray; + + c.UnFocusedColor1 = Color.FromArgb(16, SystemColors.GrayText); + c.UnFocusedColor2 = Color.FromArgb(64, SystemColors.GrayText); + c.UnFocusedBorderColor = Color.FromArgb(128, SystemColors.GrayText); + c.UnFocusedForeColor = Color.LightGray; + + c.HoverColor1 = Color.FromArgb(64, Color.White); + c.HoverColor2 = Color.FromArgb(16, Color.White); + c.HoverBorderColor = Color.FromArgb(64, SystemColors.Highlight); + + c.SelectedColor1 = Color.FromArgb(64, 96, 160); + c.SelectedColor2 = Color.FromArgb(64, 64, 96, 160); + c.SelectedBorderColor = Color.FromArgb(128, SystemColors.Highlight); + c.SelectedForeColor = Color.LightGray; + + c.InsertionCaretColor = Color.FromArgb(96, 144, 240); + + // thumbnails & pane + c.ImageInnerBorderColor = Color.FromArgb(128, Color.White); + c.ImageOuterBorderColor = Color.FromArgb(128, Color.Gray); + + // details view + c.CellForeColor = Color.WhiteSmoke; + c.ColumnHeaderBackColor1 = Color.FromArgb(32, 128, 128, 128); + c.ColumnHeaderBackColor2 = Color.FromArgb(196, 128, 128, 128); + c.ColumnHeaderHoverColor1 = Color.FromArgb(64, 96, 144, 240); + c.ColumnHeaderHoverColor2 = Color.FromArgb(196, 96, 144, 240); + c.ColumnHeaderForeColor = Color.White; + c.ColumnSelectColor = Color.FromArgb(96, 128, 128, 128); + c.ColumnSeparatorColor = Color.Gold; + c.AlternateBackColor = Color.FromArgb(0x31, 0x31, 0x31); + c.AlternateCellForeColor = Color.WhiteSmoke; + + // image pane + c.PaneBackColor = Color.FromArgb(0x31, 0x31, 0x31); + c.PaneSeparatorColor = Color.Gold; + c.PaneLabelColor = SystemColors.GrayText; + + // selection rectangke + c.SelectionRectangleColor1 = Color.FromArgb(160, 96, 144, 240); + c.SelectionRectangleColor2 = Color.FromArgb(32, 96, 144, 240); + c.SelectionRectangleBorderColor = Color.FromArgb(64, 96, 144, 240); + + return c; + } + #endregion + + #region System.Object Overrides + /// + /// Determines whether all color values of the specified + /// ImageListViewColor are equal to this instance. + /// + /// The object to compare with this instance. + /// true if the two instances have the same color values; + /// otherwise false. + public override bool Equals(object obj) + { + if (obj == null) + throw new NullReferenceException(); + + ShengListViewColor other = obj as ShengListViewColor; + if (other == null) return false; + + foreach (PropertyInfo info in typeof(ShengListViewColor).GetProperties()) + { + // Walk through color properties + if (info.PropertyType == typeof(Color)) + { + // Compare colors + Color color1 = (Color)info.GetValue(this, null); + Color color2 = (Color)info.GetValue(other, null); + + if (color1 != color2) return false; + } + } + + return true; + } + /// + /// Returns a hash code for this instance. + /// + /// + /// A hash code for this instance, suitable for use in + /// hashing algorithms and data structures like a hash table. + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Returns a string that represents this instance. + /// + /// + /// A string that represents this instance. + /// + public override string ToString() + { + ShengListViewColor colors = this; + + // First check if the color matches a predefined color setting + foreach (MemberInfo info in typeof(ShengListViewColor).GetMembers(BindingFlags.Static | BindingFlags.Public)) + { + if (info.MemberType == MemberTypes.Property) + { + PropertyInfo propertyInfo = (PropertyInfo)info; + if (propertyInfo.PropertyType == typeof(ShengListViewColor)) + { + ShengListViewColor presetValue = (ShengListViewColor)propertyInfo.GetValue(null, null); + // If the color setting is equal to a preset value + // return the name of the preset + if (colors.Equals(presetValue)) + return string.Format("({0})", propertyInfo.Name); + } + } + } + + // Serialize all colors which are different from the default setting + List lines = new List(); + foreach (PropertyInfo info in typeof(ShengListViewColor).GetProperties()) + { + // Walk through color properties + if (info.PropertyType == typeof(Color)) + { + // Get property name + string name = info.Name; + // Get the current value + Color color = (Color)info.GetValue(colors, null); + // Find the default value atribute + Attribute[] attributes = (Attribute[])info.GetCustomAttributes(typeof(DefaultValueAttribute), false); + if (attributes.Length != 0) + { + // Get the default value + DefaultValueAttribute attribute = (DefaultValueAttribute)attributes[0]; + Color defaultColor = (Color)attribute.Value; + // Serialize only if colors are different + if (color != defaultColor) + { + lines.Add(string.Format("{0} = {1}", name, color.Name)); + } + } + } + } + + return string.Join("; ", lines.ToArray()); + } + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengListView/ShengListViewHitInfo.cs b/Source/ryControls/Sheng.Winform.Controls/ShengListView/ShengListViewHitInfo.cs new file mode 100644 index 0000000..d4261fe --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengListView/ShengListViewHitInfo.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Sheng.Winform.Controls +{ + /// + /// 测试坐标 + /// + public class ShengListViewHitInfo + { + /// + /// 项的坐标 + /// + public int ItemIndex { get; private set; } + + /// + /// 是否点击了项 + /// + public bool ItemHit { get; private set; } + + public ShengListViewHitInfo(int itemIndex,bool itemHit) + { + ItemIndex = itemIndex; + ItemHit = itemHit; + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengListView/ShengListViewItem.cs b/Source/ryControls/Sheng.Winform.Controls/ShengListView/ShengListViewItem.cs new file mode 100644 index 0000000..a4d828b --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengListView/ShengListViewItem.cs @@ -0,0 +1,135 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; + +namespace Sheng.Winform.Controls +{ + public class ShengListViewItem + { + #region 私有成员 + + + #endregion + + #region 受保护的成员 + + private ShengListViewItemCollection _ownerCollection; + internal ShengListViewItemCollection OwnerCollection + { + get { return _ownerCollection; } + set { _ownerCollection = value; } + } + + #endregion + + #region 公开属性 + + public int Index + { + get + { + return _ownerCollection.IndexOf(this); + } + } + + private ShengListViewItemState _state = ShengListViewItemState.None; + /// + /// 该项当前的选中状态 + /// + public ShengListViewItemState State + { + get { return _state; } + } + + public bool Selected + { + get + { + return (_state & ShengListViewItemState.Selected) == ShengListViewItemState.Selected; + } + set + { + bool selected = Selected; + + if (value) + _state = _state | ShengListViewItemState.Selected; + else + _state = _state ^ ShengListViewItemState.Selected; + + if (selected != Selected) + Render(); + } + } + + public bool Hovered + { + get + { + return (_state & ShengListViewItemState.Hovered) == ShengListViewItemState.Hovered; + } + set + { + bool hovered = Hovered; + + if (value) + _state = _state | ShengListViewItemState.Hovered; + else + _state = _state ^ ShengListViewItemState.Hovered; + + if (hovered != Hovered) + Render(); + } + } + + public bool Focused + { + get + { + return (_state & ShengListViewItemState.Focused) == ShengListViewItemState.Focused; + } + set + { + bool focused = Focused; + + if (value) + _state = _state | ShengListViewItemState.Focused; + else + _state = _state ^ ShengListViewItemState.Focused; + + if (focused != Focused) + Render(); + } + } + + private object _value; + /// + /// 所绑定的对象 + /// + public object Value + { + get { return _value; } + } + + #endregion + + #region 构造 + + public ShengListViewItem(object value) + { + _value = value; + } + + #endregion + + #region 私有方法 + + private void Render() + { + _ownerCollection.Owner.RenderItem(this); + } + + #endregion + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/ShengListView/ShengListViewItemCollection.cs b/Source/ryControls/Sheng.Winform.Controls/ShengListView/ShengListViewItemCollection.cs new file mode 100644 index 0000000..c2e3c5a --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/ShengListView/ShengListViewItemCollection.cs @@ -0,0 +1,310 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Collections; + +namespace Sheng.Winform.Controls +{ + public class ShengListViewItemCollection : CollectionBase, IList + { + #region 基本方法和属性 + + public ShengListViewItemCollection() + { + } + + public ShengListViewItemCollection(ShengListViewItemCollection value) + { + this.AddRange(value); + } + + public ShengListViewItemCollection(ShengListViewItem[] value) + { + this.AddRange(value); + } + + public ShengListViewItem this[int index] + { + get + { + return ((ShengListViewItem)(List[index])); + } + set + { + List[index] = value; + } + } + + public int Add(ShengListViewItem value) + { + value.OwnerCollection = this; + int index = List.Add(value); + _owner.Refresh(); + return index; + } + + public void AddRange(ShengListViewItem[] value) + { + _owner.SuspendLayout(); + + for (int i = 0; (i < value.Length); i = (i + 1)) + { + this.Add(value[i]); + } + + _owner.ResumeLayout(true); + } + + public void AddRange(ShengListViewItemCollection value) + { + _owner.SuspendLayout(); + + for (int i = 0; (i < value.Count); i = (i + 1)) + { + this.Add(value[i]); + } + + _owner.ResumeLayout(true); + } + + public bool Contains(ShengListViewItem value) + { + return List.Contains(value); + } + + public void CopyTo(ShengListViewItem[] array, int index) + { + List.CopyTo(array, index); + } + + public int IndexOf(ShengListViewItem value) + { + return List.IndexOf(value); + } + + public void Insert(int index, ShengListViewItem value) + { + value.OwnerCollection = this; + List.Insert(index, value); + } + + public void Remove(ShengListViewItem value) + { + value.OwnerCollection = null; + List.Remove(value); + _owner.Refresh(); + + _owner.OnItemsRemoved(new List() { value }); + } + + public void Remove(List items) + { + _owner.SuspendLayout(); + + foreach (var item in items) + { + item.OwnerCollection = null; + List.Remove(item); + } + + _owner.ResumeLayout(true); + + _owner.OnItemsRemoved(items); + } + + protected override void OnClear() + { + _owner.SuspendLayout(); + base.OnClear(); + _owner.ResumeLayout(true); + } + + #endregion + + #region 加的方法和属性 + + private ShengListView _owner; + internal ShengListView Owner + { + get { return _owner; } + set { _owner = value; } + } + + public ShengListViewItem[] ToArray() + { + return this.ToList().ToArray(); + } + + public List ToList() + { + List list = new List(); + + foreach (ShengListViewItem e in this) + { + list.Add(e); + } + + return list; + } + + /// + /// 将指定的事件移动到(紧邻)另一个事件之前 + /// + /// + /// + public void PreTo(ShengListViewItem targetEvent, ShengListViewItem referEvent) + { + if (targetEvent == null || referEvent == null) + return; + + if (this.Contains(targetEvent) == false || this.Contains(referEvent) == false) + return; + + //这里不能因为目标事件是最顶过就直接返回 + //因为此方法的目的是把目标事件放在指定事件 紧挨着 的 前面 一个,而不是前面的任意位置 + //有可能目标事件index是0,指定事件是3,那么此方法要把目标事件的index变为2 + //如果指定事件已经是最顶个了,直接返回 + //int targetIndex = this.IndexOf(targetEvent); + //if (targetIndex == 0) + // return; + + int referIndex = this.IndexOf(referEvent); + + //如果目标事件在指定事件之前的某个位置,这里不能先直接remove目标事件 + //因为这样会使指定事件提前一个index,此时在referIndex上insert,就跑到指定事件后面去了 + //如果目标事件本身在指定事件之后,则无此问题 + //先判断如果在前,就 referIndex--,再insert + + if (this.IndexOf(targetEvent) < referIndex) + referIndex--; + + this.Remove(targetEvent); + this.Insert(referIndex, targetEvent); + } + + /// + /// 将指定的事件移动到(紧邻)另一个事件之后 + /// + /// + /// + public void NextTo(ShengListViewItem targetEvent, ShengListViewItem referEvent) + { + if (targetEvent == null || referEvent == null) + return; + + if (this.Contains(targetEvent) == false || this.Contains(referEvent) == false) + return; + + //如果指定事件已经是最后个了,直接返回 + //int targetIndex = this.IndexOf(targetEvent); + //if (targetIndex == this.Count - 1) + // return; + + int referIndex = this.IndexOf(referEvent); + + //这里在remove之前,也要先判断目标事件是在指定事件之前还是之后 + //如果在指定事件之后,那么referIndex++,不然就insert到指定事件前面了 + if (this.IndexOf(targetEvent) > referIndex) + referIndex++; + + this.Remove(targetEvent); + this.Insert(referIndex, targetEvent); + } + + #endregion + + #region ImageListViewItemEnumerator + + [Serializable] + public class ImageListViewItemEnumerator : object, IEnumerator, IEnumerator + { + private IEnumerator baseEnumerator; + + private IEnumerable temp; + + public ImageListViewItemEnumerator(ShengListViewItemCollection mappings) + { + this.temp = ((IEnumerable)(mappings)); + this.baseEnumerator = temp.GetEnumerator(); + } + + public ShengListViewItem Current + { + get + { + return ((ShengListViewItem)(baseEnumerator.Current)); + } + } + + object IEnumerator.Current + { + get + { + return baseEnumerator.Current; + } + } + + public bool MoveNext() + { + return baseEnumerator.MoveNext(); + } + + bool IEnumerator.MoveNext() + { + return baseEnumerator.MoveNext(); + } + + public void Reset() + { + baseEnumerator.Reset(); + } + + void IEnumerator.Reset() + { + baseEnumerator.Reset(); + } + + #region IDisposable 成员 + + public void Dispose() + { + + } + + #endregion + } + + #endregion + + #region ICollection 成员 + + void ICollection.Add(ShengListViewItem item) + { + this.Add(item); + } + + public bool IsReadOnly + { + get { return false; } + } + + bool ICollection.Remove(ShengListViewItem item) + { + this.Remove(item); + return true; + } + + #endregion + + #region IEnumerable 成员 + + public new IEnumerator GetEnumerator() + { + return new ImageListViewItemEnumerator(this); + } + + #endregion + } +} + diff --git a/Source/ryControls/Sheng.Winform.Controls/Win32/DwmApi.cs b/Source/ryControls/Sheng.Winform.Controls/Win32/DwmApi.cs new file mode 100644 index 0000000..71cb1c6 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Win32/DwmApi.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Runtime.InteropServices; +using System.Drawing; + +namespace Sheng.Winform.Controls.Win32 +{ + public class DwmApi + { + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern void DwmEnableBlurBehindWindow(IntPtr hWnd, DWM_BLURBEHIND pBlurBehind); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, MARGINS pMargins); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern bool DwmIsCompositionEnabled(); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern void DwmGetColorizationColor( + out int pcrColorization, + [MarshalAs(UnmanagedType.Bool)]out bool pfOpaqueBlend); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern void DwmEnableComposition(bool bEnable); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern IntPtr DwmRegisterThumbnail(IntPtr dest, IntPtr source); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern void DwmUnregisterThumbnail(IntPtr hThumbnail); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern void DwmUpdateThumbnailProperties(IntPtr hThumbnail, DWM_THUMBNAIL_PROPERTIES props); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern void DwmQueryThumbnailSourceSize(IntPtr hThumbnail, out Size size); + + [StructLayout(LayoutKind.Sequential)] + public class DWM_THUMBNAIL_PROPERTIES + { + public uint dwFlags; + public RECT rcDestination; + public RECT rcSource; + public byte opacity; + [MarshalAs(UnmanagedType.Bool)] + public bool fVisible; + [MarshalAs(UnmanagedType.Bool)] + public bool fSourceClientAreaOnly; + + public const uint DWM_TNP_RECTDESTINATION = 0x00000001; + public const uint DWM_TNP_RECTSOURCE = 0x00000002; + public const uint DWM_TNP_OPACITY = 0x00000004; + public const uint DWM_TNP_VISIBLE = 0x00000008; + public const uint DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010; + } + + [StructLayout(LayoutKind.Sequential)] + public class MARGINS + { + public int cxLeftWidth, cxRightWidth, cyTopHeight, cyBottomHeight; + + public MARGINS(int left, int top, int right, int bottom) + { + cxLeftWidth = left; cyTopHeight = top; + cxRightWidth = right; cyBottomHeight = bottom; + } + } + + [StructLayout(LayoutKind.Sequential)] + public class DWM_BLURBEHIND + { + public uint dwFlags; + [MarshalAs(UnmanagedType.Bool)] + public bool fEnable; + public IntPtr hRegionBlur; + [MarshalAs(UnmanagedType.Bool)] + public bool fTransitionOnMaximized; + + public const uint DWM_BB_ENABLE = 0x00000001; + public const uint DWM_BB_BLURREGION = 0x00000002; + public const uint DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004; + } + + [StructLayout(LayoutKind.Sequential)] + public struct RECT + { + public int left, top, right, bottom; + + public RECT(int left, int top, int right, int bottom) + { + this.left = left; this.top = top; this.right = right; this.bottom = bottom; + } + } + + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Win32/ExplorerTreeView.cs b/Source/ryControls/Sheng.Winform.Controls/Win32/ExplorerTreeView.cs new file mode 100644 index 0000000..3638a7e --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Win32/ExplorerTreeView.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Runtime.InteropServices; +using System.Windows.Forms; + +namespace Sheng.Winform.Controls.Win32 +{ + public class ExplorerTreeView + { + const int TV_FIRST = 0x1100; + const int TVM_SETEXTENDEDSTYLE = TV_FIRST + 44; + const int TVM_GETEXTENDEDSTYLE = TV_FIRST + 45; + const int TVS_EX_FADEINOUTEXPANDOS = 0x0040; + const int TVS_EX_DOUBLEBUFFER = 0x0004; + + [DllImport("uxtheme.dll", CharSet = CharSet.Auto)] + public extern static int SetWindowTheme(IntPtr hWnd, string subAppName, string subIdList); + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public extern static IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); + + private static int TreeView_GetExtendedStyle(IntPtr handle) + { + IntPtr ptr = SendMessage(handle, TVM_GETEXTENDEDSTYLE, IntPtr.Zero, IntPtr.Zero); + return ptr.ToInt32(); + } + + private static void TreeView_SetExtendedStyle(IntPtr handle, int extendedStyle, int mask) + { + SendMessage(handle, TVM_SETEXTENDEDSTYLE, new IntPtr(mask), new IntPtr(extendedStyle)); + } + + // Modify a WinForms TreeView control to use the new Explorer style theme + public static void ApplyTreeViewThemeStyles(TreeView treeView) + { + if (treeView == null) + { + throw new ArgumentNullException("treeView"); + } + + treeView.HotTracking = true; + treeView.ShowLines = false; + + IntPtr hwnd = treeView.Handle; + SetWindowTheme(hwnd, "Explorer", null); + int exstyle = TreeView_GetExtendedStyle(hwnd); + exstyle |= TVS_EX_DOUBLEBUFFER | TVS_EX_FADEINOUTEXPANDOS; + TreeView_SetExtendedStyle(hwnd, exstyle, 0); + } + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Win32/Kernel32.cs b/Source/ryControls/Sheng.Winform.Controls/Win32/Kernel32.cs new file mode 100644 index 0000000..f131025 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Win32/Kernel32.cs @@ -0,0 +1,17 @@ +using System.Text; +using System.Runtime.InteropServices; + +namespace Sheng.Winform.Controls.Win32 +{ + public static class Kernel32 + { + [DllImport("kernel32")] + public static extern long WritePrivateProfileString(string section, + string key, string val, string filePath); + + [DllImport("kernel32")] + public static extern int GetPrivateProfileString(string section, + string key, string def, StringBuilder retVal, + int size, string filePath); + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Win32/Shell32.cs b/Source/ryControls/Sheng.Winform.Controls/Win32/Shell32.cs new file mode 100644 index 0000000..d0fd5b4 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Win32/Shell32.cs @@ -0,0 +1,14 @@ +using System; +using System.Runtime.InteropServices; + +namespace Sheng.Winform.Controls.Win32 +{ + public static class Shell32 + { + public const int SHCNE_ASSOCCHANGED = 0x08000000; + public const int SHCNF_IDLIST = 0x0; + + [DllImport("shell32.dll")] + public static extern void SHChangeNotify(int wEventId, int uFlags, IntPtr dwItem1, IntPtr dwItem2); + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Win32/User32.cs b/Source/ryControls/Sheng.Winform.Controls/Win32/User32.cs new file mode 100644 index 0000000..e5ac151 --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Win32/User32.cs @@ -0,0 +1,67 @@ +using System; +using System.Runtime.InteropServices; + +namespace Sheng.Winform.Controls.Win32 +{ + public static class User32 + { + //WM_COPYDATA消息所要求的数据结构 + public struct CopyDataStruct + { + public IntPtr dwData; + public int cbData; + + [MarshalAs(UnmanagedType.LPStr)] + public string lpData; + } + + public const int WM_COPYDATA = 0x004A; + + /// + /// 通过窗口的标题来查找窗口的句柄 + /// + /// + /// + /// + [DllImport("User32.dll", EntryPoint = "FindWindow")] + public static extern int FindWindow(string lpClassName, string lpWindowName); + + /// + /// 发送 Windows 消息 + /// + /// + /// + /// + /// + /// + [DllImport("User32.dll", EntryPoint = "SendMessage")] + public static extern int SendMessage + ( + int hWnd, // 目标窗口的句柄 + int Msg, // 在这里是WM_COPYDATA + int wParam, // 第一个消息参数 + ref CopyDataStruct lParam // 第二个消息参数 + ); + + + public const int SC_RESTORE = 0xF120; //还原 + public const int SC_MOVE = 0xF010; //移动 + public const int SC_SIZE = 0xF000; //大小 + public const int SC_MINIMIZE = 0xF020; //最小化 + public const int SC_MAXIMIZE = 0xF030; //最大化 + public const int SC_CLOSE = 0xF060; //关闭 + + public const int MF_DISABLE = 0x1; + public const int MF_ENABLE = 0x0; + + [DllImport("user32.dll")] + public static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert); + + [DllImport("user32.dll")] + public static extern int EnableMenuItem(IntPtr hMenu, int wIDEnableItem, int wEnable); + + public const int WM_PAINT = 0x000f; + public const int WM_ERASEBKGND = 0x0014; + public const int WM_NCPAINT = 0x0085; + } +} diff --git a/Source/ryControls/Sheng.Winform.Controls/Win32/WinMessage.cs b/Source/ryControls/Sheng.Winform.Controls/Win32/WinMessage.cs new file mode 100644 index 0000000..b6079ab --- /dev/null +++ b/Source/ryControls/Sheng.Winform.Controls/Win32/WinMessage.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Diagnostics; + +namespace Sheng.Winform.Controls.Win32 +{ + public static class WinMessage + { + /// + /// 发送消息,只能传递一个自定义的消息ID和消息字符串,想传一个结构,但没成功 + /// + /// 目标进程名称,如果有多个,则给每个都发送 + /// 自定义数据,可以通过这个来决定如何解析下面的strMsg + /// 传递的消息,是一个字符串 + public static void SendMessage(string destProcessName, int msgID, string strMsg) + { + if (strMsg == null) + return; + + //按进程名称查找,同名称的进程可能有许多,所以返回的是一个数组 + Process[] foundProcess = Process.GetProcessesByName(destProcessName); + foreach (Process p in foundProcess) + { + int toWindowHandler = p.MainWindowHandle.ToInt32(); + if (toWindowHandler != 0) + { + User32.CopyDataStruct cds; + cds.dwData = (IntPtr)msgID; //这里可以传入一些自定义的数据,但只能是4字节整数 + cds.lpData = strMsg; //消息字符串 + cds.cbData = System.Text.Encoding.Default.GetBytes(strMsg).Length + 1; //注意,这里的长度是按字节来算的 + + //发送方的窗口的句柄, 由于本系统中的接收方不关心是该消息是从哪个窗口发出的,所以就直接填0了 + int fromWindowHandler = 0; + User32.SendMessage(toWindowHandler, User32.WM_COPYDATA, fromWindowHandler, ref cds); + } + } + } + + /// + /// 接收消息,得到消息字符串 + /// + /// System.Windows.Forms.Message m + /// 接收到的消息字符串 + public static string ReceiveMessage(ref System.Windows.Forms.Message m) + { + if (m.Msg == User32.WM_COPYDATA) + { + User32.CopyDataStruct cds = (User32.CopyDataStruct)m.GetLParam(typeof(User32.CopyDataStruct)); + return cds.lpData; + } + else + { + return String.Empty; + } + } + } +} diff --git a/Source/ryControls/ryControlsV4.csproj b/Source/ryControls/ryControlsV4.csproj index 44c2e5b..046406a 100644 --- a/Source/ryControls/ryControlsV4.csproj +++ b/Source/ryControls/ryControlsV4.csproj @@ -23,6 +23,7 @@ 4 AnyCPU ..\..\Bin\Debug\CommonControls\.NET4\ryControls.xml + true none @@ -32,6 +33,7 @@ prompt 4 ..\..\Bin\Release\CommonControls\.NET4\ryControls.xml + true true @@ -445,6 +447,86 @@ ChinaCalendar.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Component + + + Popup.cs + + + + Component + + + PopupComboBox.cs + + + Component + + + PopupControlComboBoxBase.cs + + + + + + + + Component + + + + + + + + + + + + + + + Component + + + + + + + + + + + Form @@ -578,6 +660,7 @@ ChinaCalendar.cs + frmColorConvert.cs @@ -618,6 +701,9 @@ + + +