├── WSN.Ants.Controls
├── ClassDiagram3.cd
├── Resources
│ └── loading.gif
├── WSNCheckBox
│ ├── Check.png
│ ├── Check_c.png
│ ├── Check_d.png
│ ├── Check_c_d.png
│ ├── Indeterminate.png
│ └── Indeterminate_d.png
├── WSNTipForm
│ ├── closeH.png
│ ├── closeN.png
│ ├── WSNTipForm.resx
│ ├── WSNTipForm.Designer.cs
│ └── WSNTipForm.cs
├── WSNRadioButton
│ ├── Check.png
│ ├── Check_c.png
│ ├── Check_d.png
│ ├── Check_c_d.png
│ └── WSNRadioButton.cs
├── WSNSearchBox
│ ├── searchH.png
│ └── searchN.png
├── WSNTabControl
│ ├── TabIcons.bmp
│ ├── Win32.cs
│ └── WSNTabControl.cs
├── WSNAngleSelector
│ ├── WSNAngleSelector.cs
│ ├── WSNAngleAltitudeSelector.cs
│ ├── WSNAngleSelector.Designer.cs
│ ├── WSNAngleAltitudeSelector.Designer.cs
│ ├── WSNAngleSelector.resx
│ └── WSNAngleAltitudeSelector.resx
├── obj
│ └── Debug
│ │ └── DesignTimeResolveAssemblyReferencesInput.cache
├── WSN.Ants.Controls.csproj.vspscc
├── WSNSpliterContainer
│ ├── HistTest.cs
│ ├── SpliterPanelState.cs
│ └── CollapsePanel.cs
├── WSNContextMenuStrip
│ └── WSNContextMenuStrip.cs
├── Properties
│ └── AssemblyInfo.cs
├── ControlState.cs
├── WSNToolStrip
│ ├── ToolStripRenderStyle.cs
│ └── WSNToolStrip.cs
├── RoundStyle.cs
├── WSNAutoCompleteTextBox
│ ├── AutoCompleteTrigger.cs
│ ├── TriggerState.cs
│ ├── Messages.cs
│ ├── TextLengthTrigger.cs
│ ├── ShortCutTrigger.cs
│ ├── WSNAutoCompletePanel.cs
│ ├── AutoCompleteTriggerCollection.cs
│ ├── WinHook.cs
│ └── WSNAutoCompleteListBox.cs
├── WsnRangeSlideBar
│ └── EnumClass.cs
├── SmoothingModeGraphics.cs
├── WSNButton
│ └── WSNButtonImageTable.cs
├── BrushParameter.cs
├── TypeConverters
│ ├── BrushParameterConverter.cs
│ └── FaceStyleConverter.cs
├── CheckImageTable.cs
├── Resource.Designer.cs
├── ClassDiagram4.cd
├── WSNPanel
│ ├── WSNItemLayoutPanel.cs
│ └── WSNPanel.cs
├── FaceStyle.cs
├── Resource.resx
├── WSNTimeSlidePicker
│ ├── TimeSlideHook.cs
│ └── WSNTimeSlidePicker.cs
├── WSNToolTips
│ └── WSNToolTipManager.cs
├── WSNDataGridView
│ └── WSNDataGridViewTextImageColumn.cs
├── GraphicsPathHelper.cs
├── ClassDiagram1.cd
└── WSNTextBox
│ └── WSNTextBox.cs
├── control_1.png
├── control_2.png
├── control_3.png
├── ClassDiagram4.png
└── README.md
/WSN.Ants.Controls/ClassDiagram3.cd:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/control_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/control_1.png
--------------------------------------------------------------------------------
/control_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/control_2.png
--------------------------------------------------------------------------------
/control_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/control_3.png
--------------------------------------------------------------------------------
/ClassDiagram4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/ClassDiagram4.png
--------------------------------------------------------------------------------
/WSN.Ants.Controls/Resources/loading.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/Resources/loading.gif
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNCheckBox/Check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNCheckBox/Check.png
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNTipForm/closeH.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNTipForm/closeH.png
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNTipForm/closeN.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNTipForm/closeN.png
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNCheckBox/Check_c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNCheckBox/Check_c.png
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNCheckBox/Check_d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNCheckBox/Check_d.png
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNRadioButton/Check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNRadioButton/Check.png
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNSearchBox/searchH.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNSearchBox/searchH.png
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNSearchBox/searchN.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNSearchBox/searchN.png
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNCheckBox/Check_c_d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNCheckBox/Check_c_d.png
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNRadioButton/Check_c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNRadioButton/Check_c.png
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNRadioButton/Check_d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNRadioButton/Check_d.png
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNTabControl/TabIcons.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNTabControl/TabIcons.bmp
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNCheckBox/Indeterminate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNCheckBox/Indeterminate.png
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNRadioButton/Check_c_d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNRadioButton/Check_c_d.png
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNCheckBox/Indeterminate_d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNCheckBox/Indeterminate_d.png
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNAngleSelector/WSNAngleSelector.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNAngleSelector/WSNAngleSelector.cs
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNAngleSelector/WSNAngleAltitudeSelector.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/WSNAngleSelector/WSNAngleAltitudeSelector.cs
--------------------------------------------------------------------------------
/WSN.Ants.Controls/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/houyhea/winform-control-lib/HEAD/WSN.Ants.Controls/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSN.Ants.Controls.csproj.vspscc:
--------------------------------------------------------------------------------
1 | ""
2 | {
3 | "FILE_VERSION" = "9237"
4 | "ENLISTMENT_CHOICE" = "NEVER"
5 | "PROJECT_FILE_RELATIVE_PATH" = ""
6 | "NUMBER_OF_EXCLUDED_FILES" = "0"
7 | "ORIGINAL_PROJECT_FILE_PATH" = ""
8 | "NUMBER_OF_NESTED_PROJECTS" = "0"
9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
10 | }
11 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNSpliterContainer/HistTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WSN.Ants.Controls.WSNSpliterContainer
7 | {
8 | internal enum HistTest
9 | {
10 | None,
11 | Button,
12 | Spliter
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | winform-control-lib
2 | ===================
3 |
4 | 曾经在一个winform项目中开发的一套UI控件库
5 |
6 | 类图:
7 | 
8 |
9 | 效果图:
10 | 
11 |
12 | 
13 | 
14 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNSpliterContainer/SpliterPanelState.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WSN.Ants.Controls.WSNSpliterContainer
7 | {
8 | ///
9 | /// SpliterPanel面板状态
10 | ///
11 | public enum SpliterPanelState
12 | {
13 | ///
14 | /// 折叠的
15 | ///
16 | Collapsed = 0,
17 | ///
18 | /// 打开的
19 | ///
20 | Expanded = 1,
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNContextMenuStrip/WSNContextMenuStrip.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 |
7 | namespace WSN.Ants.Controls.WSNContextMenuStrip
8 | {
9 | ///
10 | /// WSN控件:
11 | /// WSNContextMenuStrip
12 | ///
13 | public class WSNContextMenuStrip:ContextMenuStrip
14 | {
15 | public WSNContextMenuStrip()
16 | {
17 | this.Renderer = new ContextMenuRender();
18 | }
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过下列属性集
6 | // 控制。更改这些属性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("WSN.Ants.Controls")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 |
12 | // 将 ComVisible 设置为 false 使此程序集中的类型
13 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
14 | // 则将该类型上的 ComVisible 属性设置为 true。
15 | [assembly: ComVisible(false)]
16 |
17 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
18 | [assembly: Guid("feca8dcd-4ba9-470d-b289-2a963aae9eca")]
19 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNSpliterContainer/CollapsePanel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WSN.Ants.Controls.WSNSpliterContainer
7 | {
8 | ///
9 | /// 折叠的面板
10 | ///
11 | public enum CollapsePanel
12 | {
13 | ///
14 | /// 无
15 | ///
16 | None = 0,
17 | ///
18 | /// Panel1
19 | ///
20 | Panel1 = 1,
21 | ///
22 | /// Panel2
23 | ///
24 | Panel2 = 2,
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/ControlState.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WSN.Ants.Controls
7 | {
8 | ///
9 | /// 控件的状态。
10 | ///
11 | public enum ControlState
12 | {
13 | ///
14 | /// 正常
15 | ///
16 | Normal,
17 | ///
18 | /// 鼠标进入
19 | ///
20 | Hover,
21 | ///
22 | /// 鼠标按下
23 | ///
24 | Pressed,
25 | ///
26 | /// 获得焦点
27 | ///
28 | Focused,
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNToolStrip/ToolStripRenderStyle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WSN.Ants.Controls.WSNToolStrip
7 | {
8 | ///
9 | /// 工具栏外观样式枚举
10 | ///
11 | public enum ToolStripRenderStyle
12 | {
13 | ///
14 | /// 通用样式
15 | ///
16 | NormalRender = 0,
17 | ///
18 | /// 状态栏样式
19 | ///
20 | StatusRender,
21 | ///
22 | /// 视频窗口顶部标题栏样式
23 | ///
24 | VideoTitleBar,
25 | ///
26 | /// 视频窗口底部工具栏样式
27 | ///
28 | VideoToolBar,
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/RoundStyle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WSN.Ants.Controls
7 | {
8 | ///
9 | /// 建立圆角路径的样式。
10 | ///
11 | public enum RoundStyle
12 | {
13 | ///
14 | /// 四个角都不是圆角。
15 | ///
16 | None = 0,
17 | ///
18 | /// 四个角都为圆角。
19 | ///
20 | All = 1,
21 | ///
22 | /// 左边两个角为圆角。
23 | ///
24 | Left = 2,
25 | ///
26 | /// 右边两个角为圆角。
27 | ///
28 | Right = 3,
29 | ///
30 | /// 上边两个角为圆角。
31 | ///
32 | Top = 4,
33 | ///
34 | /// 下边两个角为圆角。
35 | ///
36 | Bottom = 5
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNAutoCompleteTextBox/AutoCompleteTrigger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace WSN.Ants.Controls.WSNAutoCompleteTextBox
5 | {
6 | ///
7 | /// 自动完成状态触发器
8 | ///
9 | [Serializable]
10 | public abstract class AutoCompleteTrigger
11 | {
12 | ///
13 | /// 获取文本改变后触发器状态
14 | ///
15 | /// 改变后的文本
16 | /// 触发器状态
17 | public virtual TriggerState OnTextChanged(string text)
18 | {
19 | return TriggerState.None;
20 | }
21 | ///
22 | /// 获取按下按钮后触发器状态
23 | ///
24 | /// 按钮
25 | /// 触发器状态
26 | public virtual TriggerState OnCommandKey(Keys keyData)
27 | {
28 | return TriggerState.None;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WsnRangeSlideBar/EnumClass.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WSN.Ants.Controls.WsnRangeSlideBar
7 | {
8 | ///
9 | /// 激活类型
10 | ///
11 | public enum ActiveMarkType
12 | {
13 | ///
14 | /// 没有激活控制条。
15 | ///
16 | none,
17 | ///
18 | /// 激活左边控制条。
19 | ///
20 | left,
21 | ///
22 | /// 激活右边控制条。
23 | ///
24 | right,
25 | ///
26 | /// 激活中间控制条。
27 | ///
28 | middle
29 | };
30 |
31 | ///
32 | /// 选择显示模式
33 | ///
34 | public enum SelectShowMode
35 | {
36 | ///
37 | /// 整型选择模式。
38 | ///
39 | TInteger,
40 | ///
41 | /// 时间选择模式。
42 | ///
43 | TDateTime
44 | };
45 | }
46 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNAutoCompleteTextBox/TriggerState.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WSN.Ants.Controls.WSNAutoCompleteTextBox
7 | {
8 | ///
9 | /// 触发器状态
10 | ///
11 | [Serializable]
12 | public enum TriggerState : int
13 | {
14 | ///
15 | /// 无状态
16 | ///
17 | None = 0,
18 | ///
19 | /// 显示
20 | ///
21 | Show = 1,
22 | ///
23 | /// 显示并使用
24 | ///
25 | ShowAndConsume = 2,
26 | ///
27 | /// 隐藏
28 | ///
29 | Hide = 3,
30 | ///
31 | /// 隐藏并使用
32 | ///
33 | HideAndConsume = 4,
34 | ///
35 | /// 选择
36 | ///
37 | Select = 5,
38 | ///
39 | /// 选择并使用
40 | ///
41 | SelectAndConsume = 6
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNAutoCompleteTextBox/Messages.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WSN.Ants.Controls.WSNAutoCompleteTextBox
7 | {
8 | public class Messages
9 | {
10 | private Messages()
11 | { }
12 |
13 | public const int WM_PARENTNOTIFY = 0x210;
14 | public const int WM_RBUTTONDBLCLK = 0x206;
15 | public const int WM_RBUTTONDOWN = 0x204;
16 | public const int WM_RBUTTONUP = 0x205;
17 | public const int WM_LBUTTONDBLCLK = 0x203;
18 | public const int WM_LBUTTONDOWN = 0x201;
19 | public const int WM_LBUTTONUP = 0x202;
20 | public const int WM_MBUTTONDBLCLK = 0x209;
21 | public const int WM_MBUTTONDOWN = 0x207;
22 | public const int WM_MBUTTONUP = 0x208;
23 | public const int WM_NCLBUTTONDOWN = 0x00A1;
24 | public const int WM_NCLBUTTONUP = 0x00A2;
25 | public const int WM_NCLBUTTONDBLCLK = 0x00A3;
26 | public const int WM_NCRBUTTONDOWN = 0x00A4;
27 | public const int WM_NCRBUTTONUP = 0x00A5;
28 | public const int WM_NCRBUTTONDBLCLK = 0x00A6;
29 | public const int WM_NCMBUTTONDOWN = 0x00A7;
30 | public const int WM_NCMBUTTONUP = 0x00A8;
31 | public const int WM_NCMBUTTONDBLCLK = 0x00A9;
32 | public const int WM_SIZE = 0x0005;
33 | public const int WM_MOVE = 0x0003;
34 |
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/SmoothingModeGraphics.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing.Drawing2D;
6 | using System.Drawing;
7 |
8 | namespace WSN.Ants.Controls
9 | {
10 | ///
11 | /// 平滑绘图图面类
12 | ///
13 | public class SmoothingModeGraphics : IDisposable
14 | {
15 | private SmoothingMode _oldMode;
16 | private Graphics _graphics;
17 | ///
18 | /// 构造函数:
19 | /// 创建SmoothingModeGraphics,默认平滑处理模式为消除锯齿的呈现
20 | ///
21 | /// 绘图图面
22 | public SmoothingModeGraphics(Graphics graphics)
23 | : this(graphics, SmoothingMode.AntiAlias)
24 | {
25 | }
26 | ///
27 | /// 构造函数:
28 | /// 创建SmoothingModeGraphics
29 | ///
30 | /// 绘图图面
31 | /// 平滑处理模式
32 | public SmoothingModeGraphics(Graphics graphics, SmoothingMode newMode)
33 | {
34 | _graphics = graphics;
35 | _oldMode = graphics.SmoothingMode;
36 | graphics.SmoothingMode = newMode;
37 | }
38 |
39 | #region IDisposable 成员
40 |
41 | public void Dispose()
42 | {
43 | _graphics.SmoothingMode = _oldMode;
44 | }
45 |
46 | #endregion
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNAutoCompleteTextBox/TextLengthTrigger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WSN.Ants.Controls.WSNAutoCompleteTextBox
7 | {
8 | ///
9 | /// 文本长度改变触发器
10 | /// 继承自AutoCompleteTrigger
11 | ///
12 | [Serializable]
13 | public class TextLengthTrigger : AutoCompleteTrigger
14 | {
15 | private int textLength = 2;
16 | ///
17 | /// 文本长度
18 | /// 初始默认为:2
19 | ///
20 | public int TextLength
21 | {
22 | get
23 | {
24 | return this.textLength;
25 | }
26 | set
27 | {
28 | this.textLength = value;
29 | }
30 | }
31 | ///
32 | /// 新建文本长度改变触发器
33 | ///
34 | public TextLengthTrigger()
35 | {
36 | }
37 | ///
38 | /// 新建文本长度改变触发器
39 | ///
40 | /// 文本长度
41 | public TextLengthTrigger(int length)
42 | {
43 | this.textLength = length;
44 | }
45 |
46 | public override TriggerState OnTextChanged(string text)
47 | {
48 | if (text.Length >= this.TextLength)
49 | return TriggerState.Show;
50 | else if (text.Length < this.TextLength)
51 | return TriggerState.Hide;
52 |
53 | return TriggerState.None;
54 | }
55 |
56 |
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNButton/WSNButtonImageTable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 |
7 | namespace WSN.Ants.Controls.WSNButton
8 | {
9 | ///
10 | /// 但按钮是图片模式时,该类保存各状态下的图片
11 | ///
12 | ///
13 | /// 以下示例展示如何使用WSNButtonImageTable
14 | ///
15 | ///
16 | public class WSNButtonImageTable
17 | {
18 | private Image _imageNormal;
19 | private Image _imageHover;
20 | private Image _imageChecked;
21 | private Image _imageDisalbed;
22 | ///
23 | /// 禁用状态的图片
24 | ///
25 | public Image ImageDisalbed
26 | {
27 | get { return _imageDisalbed; }
28 | set { _imageDisalbed = value; }
29 | }
30 |
31 | ///
32 | /// 选择状态的图片
33 | ///
34 | public Image ImageChecked
35 | {
36 | get { return _imageChecked; }
37 | set { _imageChecked = value; }
38 | }
39 |
40 | ///
41 | /// 鼠标停留状态的图片
42 | ///
43 | public Image ImageHover
44 | {
45 | get { return _imageHover; }
46 | set { _imageHover = value; }
47 | }
48 |
49 | ///
50 | /// 普通状态的图片
51 | ///
52 | public Image ImageNormal
53 | {
54 | get { return _imageNormal; }
55 | set { _imageNormal = value; }
56 | }
57 |
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/BrushParameter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using System.Drawing.Drawing2D;
7 | using System.ComponentModel;
8 | using WSN.Ants.Controls.TypeConverters;
9 |
10 | namespace WSN.Ants.Controls
11 | {
12 | ///
13 | /// 画刷参数
14 | ///
15 | [TypeConverter(typeof(BrushParameterConverter))]
16 | public class BrushParameter
17 | {
18 | Color _color1;
19 | Color _color2;
20 | LinearGradientMode _mode ;
21 |
22 | ///
23 | /// 画刷渐变样式
24 | ///
25 | [Description("画刷渐变样式")]
26 | public LinearGradientMode Mode
27 | {
28 | get { return _mode; }
29 | set { _mode = value; }
30 | }
31 | ///
32 | /// 画刷渐变颜色2
33 | ///
34 | [Description("画刷渐变颜色2")]
35 | public Color Color2
36 | {
37 | get { return _color2; }
38 | set { _color2 = value; }
39 | }
40 | ///
41 | /// 画刷渐变颜色1
42 | ///
43 | [Description("画刷渐变颜色1")]
44 | public Color Color1
45 | {
46 | get { return _color1; }
47 | set { _color1 = value; }
48 | }
49 |
50 | #region 构造函数
51 | public BrushParameter(Color color1, Color color2, LinearGradientMode linarMode)
52 | {
53 | _color1 = color1;
54 | _color2 = color2;
55 | _mode = linarMode;
56 | }
57 | public BrushParameter()
58 | {
59 | _color1 = Color.Black;
60 | _color2 = Color.Empty;
61 | _mode = LinearGradientMode.Vertical;
62 |
63 | }
64 | #endregion
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNAngleSelector/WSNAngleSelector.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WSN.Ants.Controls.WSNAngleSelector
2 | {
3 | partial class WSNAngleSelector
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.SuspendLayout();
32 | //
33 | // AngleSelector
34 | //
35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
37 | this.Name = "AngleSelector";
38 | this.Size = new System.Drawing.Size(40, 40);
39 | this.Load += new System.EventHandler(this.AngleSelector_Load);
40 | this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.AngleSelector_MouseMove);
41 | this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.AngleSelector_MouseDown);
42 | this.SizeChanged += new System.EventHandler(this.AngleSelector_SizeChanged);
43 | this.ResumeLayout(false);
44 |
45 | }
46 |
47 | #endregion
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNAngleSelector/WSNAngleAltitudeSelector.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WSN.Ants.Controls.WSNAngleAltitudeSelector
2 | {
3 | partial class WSNAngleAltitudeSelector
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.SuspendLayout();
32 | //
33 | // AngleAltitudeSelector
34 | //
35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
37 | this.Name = "AngleAltitudeSelector";
38 | this.Size = new System.Drawing.Size(40, 40);
39 | this.Load += new System.EventHandler(this.AngleAltitudeSelector_Load);
40 | this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.AngleAltitudeSelector_MouseMove);
41 | this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.AngleAltitudeSelector_MouseDown);
42 | this.SizeChanged += new System.EventHandler(this.AngleAltitudeSelector_SizeChanged);
43 | this.ResumeLayout(false);
44 |
45 | }
46 |
47 | #endregion
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/TypeConverters/BrushParameterConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ComponentModel;
6 | using System.Globalization;
7 | using System.ComponentModel.Design.Serialization;
8 |
9 | namespace WSN.Ants.Controls.TypeConverters
10 | {
11 | class BrushParameterConverter : TypeConverter
12 | {
13 | public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
14 | {
15 | return false;
16 | //if (sourceType == typeof(String)) return true;
17 |
18 | //return base.CanConvertFrom(context, sourceType);
19 | }
20 |
21 | public override bool CanConvertTo(ITypeDescriptorContext context,
22 | System.Type destinationType)
23 | {
24 | return false;
25 |
26 | //if (destinationType == typeof(String)) return true;
27 |
28 | //if (destinationType == typeof(InstanceDescriptor)) return true;
29 |
30 | //return base.CanConvertTo(context, destinationType);
31 | }
32 | public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture,
33 | object value, System.Type destinationType)
34 | {
35 | return "画刷参数";
36 |
37 | // return base.ConvertTo(context, culture, value, destinationType);
38 | }
39 |
40 | public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
41 | {
42 | return base.ConvertFrom(context, culture, value);
43 | }
44 |
45 | public override bool GetPropertiesSupported(ITypeDescriptorContext context)
46 | {
47 | return true;
48 | }
49 |
50 | public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
51 | {
52 | return TypeDescriptor.GetProperties(typeof(BrushParameter), attributes);
53 | }
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNAutoCompleteTextBox/ShortCutTrigger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 |
5 | namespace WSN.Ants.Controls.WSNAutoCompleteTextBox
6 | {
7 | ///
8 | /// 快捷键触发器
9 | /// 继承自AutoCompleteTrigger
10 | ///
11 | [Serializable]
12 | public class ShortCutTrigger : AutoCompleteTrigger
13 | {
14 | private Keys shortCut = Keys.None;
15 | ///
16 | /// 快捷键
17 | /// 默认为:Keys.None
18 | ///
19 | public Keys ShortCut
20 | {
21 | get
22 | {
23 | return this.shortCut;
24 | }
25 | set
26 | {
27 | this.shortCut = value;
28 | }
29 | }
30 |
31 | private TriggerState result = TriggerState.None;
32 | ///
33 | /// 触发器状态
34 | ///
35 | public TriggerState ResultState
36 | {
37 | get
38 | {
39 | return this.result;
40 | }
41 | set
42 | {
43 | this.result = value;
44 | }
45 | }
46 | ///
47 | /// 新建快捷键触发器
48 | ///
49 | public ShortCutTrigger()
50 | {
51 | }
52 | ///
53 | /// 新建快捷键触发器
54 | ///
55 | /// 触发该触发器的快捷键
56 | /// 触发该触发器后触发器的状态
57 | public ShortCutTrigger(Keys shortCutKeys, TriggerState resultState)
58 | {
59 | this.shortCut = shortCutKeys;
60 | this.result = resultState;
61 | }
62 | ///
63 | /// 获取按下按钮后触发器状态
64 | ///
65 | /// 按钮
66 | /// 触发器状态
67 | public override TriggerState OnCommandKey(Keys keyData)
68 | {
69 | if (keyData == this.ShortCut)
70 | return this.ResultState;
71 |
72 | return TriggerState.None;
73 | }
74 |
75 |
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/CheckImageTable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 |
7 | namespace WSN.Ants.Controls
8 | {
9 | ///
10 | /// 单选框各状态图片列表
11 | ///
12 | public class CheckImageTable
13 | {
14 | private Image _checkedImage;
15 | private Image _unCheckedImage;
16 | private Image _checkedImageDisabled;
17 | private Image _unCheckedImageDisabled;
18 | private Image _IndeterminateImage;
19 | private Image _IndeterminateImageDisabled;
20 |
21 | ///
22 | /// 选中状态图片(可用状态)
23 | ///
24 | public Image CheckedImage
25 | {
26 | get { return _checkedImage; }
27 | set { _checkedImage = value; }
28 | }
29 | ///
30 | /// 未选中状态图片(可用状态)
31 | ///
32 | public Image UnCheckedImage
33 | {
34 | get { return _unCheckedImage; }
35 | set { _unCheckedImage = value; }
36 | }
37 | ///
38 | /// 选中状态图片(禁用状态)
39 | ///
40 | public Image CheckedImageDisabled
41 | {
42 | get { return _checkedImageDisabled; }
43 | set { _checkedImageDisabled = value; }
44 | }
45 | ///
46 | /// 未选中状态图片(禁用状态)
47 | ///
48 | public Image UnCheckedImageDisabled
49 | {
50 | get { return _unCheckedImageDisabled; }
51 | set { _unCheckedImageDisabled = value; }
52 | }
53 | ///
54 | /// 不确定状态图片(可用状态)
55 | ///
56 | public Image IndeterminateImage
57 | {
58 | get { return _IndeterminateImage; }
59 | set { _IndeterminateImage = value; }
60 | }
61 | ///
62 | /// 不确定状态图片(禁用状态)
63 | ///
64 | public Image IndeterminateImageDisabled
65 | {
66 | get { return _IndeterminateImageDisabled; }
67 | set { _IndeterminateImageDisabled = value; }
68 | }
69 |
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNAutoCompleteTextBox/WSNAutoCompletePanel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Drawing;
7 | using System.Drawing.Drawing2D;
8 | using System.ComponentModel;
9 |
10 | namespace WSN.Ants.Controls.WSNAutoCompleteTextBox
11 | {
12 | public partial class WSNAutoCompleteTextBox : WSNTextBox.WSNTextBox
13 | {
14 | ///
15 | /// WSN控件:
16 | /// WSNAutoCompletePanel
17 | ///
18 | public class WSNAutoCompletePanel : Panel
19 | {
20 | ///
21 | /// 控件属性:
22 | /// 获取或设置边框颜色
23 | ///
24 | public Color BorderColor { get; set; }
25 |
26 | ///
27 | /// 新建控件 WSNAutoCompletePanel
28 | ///
29 | public WSNAutoCompletePanel()
30 | {
31 | SetStyle(ControlStyles.UserPaint, true);
32 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
33 | SetStyle(ControlStyles.ResizeRedraw, true);
34 | SetStyle(ControlStyles.SupportsTransparentBackColor, true);
35 | BackColor = Color.Transparent;
36 |
37 | BorderColor = Color.FromArgb(179,179,179);
38 | }
39 |
40 | protected override void OnPaint(PaintEventArgs e)
41 | {
42 | Graphics g = e.Graphics;
43 | g.SmoothingMode = SmoothingMode.HighQuality;
44 |
45 |
46 | using (SolidBrush br = new SolidBrush(Color.White))
47 | {
48 | g.FillRectangle(br, ClientRectangle);
49 | }
50 |
51 |
52 |
53 |
54 | #region 画border
55 | Rectangle r = ClientRectangle;
56 | r.Width -= 1;
57 | r.Height -= 1;
58 |
59 | using (Pen p = new Pen(BorderColor))
60 | {
61 |
62 | g.DrawRectangle(p, r);
63 | }
64 |
65 |
66 | #endregion
67 |
68 | }
69 | }
70 |
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNToolStrip/WSNToolStrip.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 |
7 | namespace WSN.Ants.Controls.WSNToolStrip
8 | {
9 | ///
10 | /// WSN控件:
11 | /// WSNToolStrip
12 | ///
13 | ///
14 | /// 以下示例展示如何使用WSNToolStrip
15 | ///
16 | ///
17 | public class WSNToolStrip:ToolStrip
18 | {
19 | private ToolStripRenderStyle _renderStyle = ToolStripRenderStyle.NormalRender;
20 |
21 | #region 构造函数
22 | ///
23 | /// 构造函数:
24 | /// 创建WSNToolStrip
25 | ///
26 | public WSNToolStrip()
27 | {
28 | SetRender();
29 | }
30 | #endregion
31 |
32 | ///
33 | /// 控件属性:
34 | /// 获取或设置工具栏外观样式
35 | ///
36 | public ToolStripRenderStyle RenderStyle
37 | {
38 | get { return _renderStyle; }
39 | set {
40 | _renderStyle = value;
41 | SetRender();
42 | }
43 | }
44 |
45 |
46 | #region 私有方法
47 | private void SetRender()
48 | {
49 | ToolStripRenderer render = null;
50 | switch (RenderStyle)
51 | {
52 | case ToolStripRenderStyle.NormalRender:
53 | render=new WSNNormToolStripRender();
54 | break;
55 | case ToolStripRenderStyle.StatusRender:
56 | render = new WSNStatusToolStipRender();
57 | break;
58 | case ToolStripRenderStyle.VideoTitleBar:
59 | render = new WSNVideoTitleBarToolStripRender();
60 | break;
61 | case ToolStripRenderStyle.VideoToolBar:
62 | render = new WSNVideoToolBarToolStripRender();
63 | break;
64 | default:
65 | render = new WSNNormToolStripRender();
66 | break;
67 |
68 | }
69 | this.Renderer = render;
70 | this.Invalidate();
71 | }
72 |
73 | #endregion
74 |
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/Resource.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.1
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace WSN.Ants.Controls {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resource {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resource() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WSN.Ants.Controls.Resource", typeof(Resource).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 使用此强类型资源类,为所有资源查找
51 | /// 重写当前线程的 CurrentUICulture 属性。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | internal static System.Drawing.Bitmap loading {
64 | get {
65 | object obj = ResourceManager.GetObject("loading", resourceCulture);
66 | return ((System.Drawing.Bitmap)(obj));
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/ClassDiagram4.cd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | WSNAutoCompleteTextBox\WinHook.cs
14 |
15 |
16 |
17 |
18 | WSNAutoCompleteTextBox\WSNAutoCompleteListBox.cs
19 |
20 |
21 |
22 |
23 | WSNAutoCompleteTextBox\WSNAutoCompleteListBox.cs
24 |
25 |
26 |
27 |
28 | WSNAutoCompleteTextBox\WSNAutoCompletePanel.cs
29 |
30 |
31 |
32 |
33 | WSNAutoCompleteTextBox\WSNAutoCompleteTextBox.cs
34 |
35 |
36 |
37 |
38 | DADgAgQAAoQASIKEUAAMAGAACCAGggAFACAkCWREhUA=
39 | WSNAutoCompleteTextBox\WinHook.cs
40 |
41 |
42 |
43 |
44 |
45 | AAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAACAAAAAA=
46 | WSNAutoCompleteTextBox\WSNAutoCompleteTextBox.cs
47 |
48 |
49 |
50 |
51 |
52 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAACAAAAAA=
53 | WSNAutoCompleteTextBox\WSNAutoCompleteTextBox.cs
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNPanel/WSNItemLayoutPanel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Windows.Forms.Layout;
7 | using System.Drawing;
8 |
9 | namespace WSN.Ants.Controls.WSNPanel
10 | {
11 | ///
12 | /// WSN控件:
13 | /// WSNItemLayoutPanel
14 | ///
15 | ///
16 | /// 以下示例展示如何使用WSNItemLayoutPanel
17 | ///
18 | ///
19 | public class WSNItemLayoutPanel : Panel
20 | {
21 | private WSNItemLayoutEngine itemLayoutEnigne;
22 |
23 | ///
24 | /// 创建WSNItemLayoutPanel
25 | ///
26 | public WSNItemLayoutPanel()
27 | {
28 | this.DoubleBuffered = true;
29 | SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
30 | }
31 |
32 | ///
33 | /// 控件属性:
34 | /// 获取布局引擎
35 | ///
36 | public override LayoutEngine LayoutEngine
37 | {
38 | get
39 | {
40 | if (itemLayoutEnigne == null)
41 | {
42 | itemLayoutEnigne = new WSNItemLayoutEngine();
43 | }
44 | return itemLayoutEnigne;
45 | }
46 | }
47 | }
48 | ///
49 | /// 布局引擎WSNItemLayoutEngine
50 | ///
51 | public class WSNItemLayoutEngine : LayoutEngine
52 | {
53 | ///
54 | /// 布局
55 | ///
56 | /// 容器
57 | /// Layout事件数据
58 | /// 是否成功 true-是 false-否
59 | public override bool Layout(object container, LayoutEventArgs layoutEventArgs)
60 | {
61 | Control parent = container as Control;
62 |
63 | Rectangle parentClientRectangle = parent.ClientRectangle;
64 | Point nextControlLocation = parentClientRectangle.Location;
65 | int parentWidth = parentClientRectangle.Width;
66 |
67 | foreach (Control c in parent.Controls)
68 | {
69 | if (!c.Visible)
70 | {
71 | continue;
72 | }
73 |
74 | nextControlLocation.Offset(c.Margin.Left, 0);
75 |
76 | c.Location = nextControlLocation;
77 |
78 | if (c.Location.X + c.Width * 2 > parentWidth)
79 | {
80 | nextControlLocation.X = parentClientRectangle.X;
81 | nextControlLocation.Y += c.Height;
82 | }
83 | else
84 | {
85 | nextControlLocation.X += c.Width;
86 | }
87 | }
88 |
89 | return false;
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNAutoCompleteTextBox/AutoCompleteTriggerCollection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Windows.Forms;
4 | using System.ComponentModel.Design;
5 |
6 | namespace WSN.Ants.Controls.WSNAutoCompleteTextBox
7 | {
8 | ///
9 | /// 自动完成状态触发器的集合
10 | ///
11 | [Serializable]
12 | public class AutoCompleteTriggerCollection : CollectionBase
13 | {
14 | ///
15 | /// 自动完成状态触发器集合的编辑器
16 | ///
17 | public class AutoCompleteTriggerCollectionEditor : CollectionEditor
18 | {
19 | ///
20 | /// 新建编辑器
21 | ///
22 | /// 触发器对应的类型
23 | public AutoCompleteTriggerCollectionEditor(Type type)
24 | : base(type)
25 | {
26 | }
27 |
28 | protected override bool CanSelectMultipleInstances()
29 | {
30 | return false;
31 | }
32 |
33 | protected override Type[] CreateNewItemTypes()
34 | {
35 | return new Type[] { typeof(ShortCutTrigger) };
36 | }
37 |
38 | protected override Type CreateCollectionItemType()
39 | {
40 | return typeof(ShortCutTrigger);
41 | }
42 | }
43 | ///
44 | /// 根据索引查找对应触发器
45 | ///
46 | /// 索引
47 | /// 返回的触发器
48 | public AutoCompleteTrigger this[int index]
49 | {
50 | get
51 | {
52 | return this.InnerList[index] as AutoCompleteTrigger;
53 | }
54 | }
55 | ///
56 | /// 将添加的单个触发器添加到集合中
57 | ///
58 | /// 单个触发器
59 | public void Add(AutoCompleteTrigger item)
60 | {
61 | this.InnerList.Add(item);
62 | }
63 |
64 | ///
65 | /// 从集合中移除特定触发器的第一个匹配项
66 | ///
67 | /// 要移除的触发器
68 | public void Remove(AutoCompleteTrigger item)
69 | {
70 | this.InnerList.Remove(item);
71 | }
72 |
73 | ///
74 | /// 获取文本改变后触发器状态
75 | ///
76 | /// 改变后的文本
77 | /// 触发器状态
78 | public virtual TriggerState OnTextChanged(string text)
79 | {
80 | foreach (AutoCompleteTrigger trigger in this.InnerList)
81 | {
82 | TriggerState state = trigger.OnTextChanged(text);
83 | if (state != TriggerState.None)
84 | {
85 | return state;
86 | }
87 | }
88 | return TriggerState.None;
89 | }
90 | ///
91 | /// 获取按下按钮后触发器状态
92 | ///
93 | /// 按钮
94 | /// 触发器状态
95 | public virtual TriggerState OnCommandKey(Keys keyData)
96 | {
97 | foreach (AutoCompleteTrigger trigger in this.InnerList)
98 | {
99 | TriggerState state = trigger.OnCommandKey(keyData);
100 | if (state != TriggerState.None)
101 | {
102 | return state;
103 | }
104 | }
105 | return TriggerState.None;
106 | }
107 |
108 |
109 |
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNAutoCompleteTextBox/WinHook.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Drawing;
7 |
8 | namespace WSN.Ants.Controls.WSNAutoCompleteTextBox
9 | {
10 | public partial class WSNAutoCompleteTextBox : WSNTextBox.WSNTextBox
11 | {
12 | private class WinHook : NativeWindow
13 | {
14 | private WSNAutoCompleteTextBox tb;
15 |
16 | public WinHook(WSNAutoCompleteTextBox tbox)
17 | {
18 | this.tb = tbox;
19 | }
20 |
21 |
22 | protected override void WndProc(ref Message m)
23 | {
24 | switch (m.Msg)
25 | {
26 | case Messages.WM_LBUTTONDOWN:
27 | case Messages.WM_LBUTTONDBLCLK:
28 | case Messages.WM_MBUTTONDOWN:
29 | case Messages.WM_MBUTTONDBLCLK:
30 | case Messages.WM_RBUTTONDOWN:
31 | case Messages.WM_RBUTTONDBLCLK:
32 | case Messages.WM_NCLBUTTONDOWN:
33 | case Messages.WM_NCMBUTTONDOWN:
34 | case Messages.WM_NCRBUTTONDOWN:
35 | {
36 | //Form form = tb.FindForm();
37 | Control form = tb.Parent;
38 | if (form != null)
39 | {
40 |
41 | Point p = form.PointToScreen(new Point((int)m.LParam));
42 | Point p2 = tb.PointToScreen(new Point(0, 0));
43 | Rectangle rect = new Rectangle(p2, tb.Size);
44 | if (!rect.Contains(p))
45 | {
46 | tb.HideList();
47 | }
48 | }
49 | } break;
50 | case Messages.WM_SIZE:
51 | case Messages.WM_MOVE:
52 | {
53 | tb.HideList();
54 | }
55 | break;
56 | // This is the message that gets sent when a childcontrol gets activity
57 | case Messages.WM_PARENTNOTIFY:
58 | {
59 | switch ((int)m.WParam)
60 | {
61 | case Messages.WM_LBUTTONDOWN:
62 | case Messages.WM_LBUTTONDBLCLK:
63 | case Messages.WM_MBUTTONDOWN:
64 | case Messages.WM_MBUTTONDBLCLK:
65 | case Messages.WM_RBUTTONDOWN:
66 | case Messages.WM_RBUTTONDBLCLK:
67 | case Messages.WM_NCLBUTTONDOWN:
68 | case Messages.WM_NCMBUTTONDOWN:
69 | case Messages.WM_NCRBUTTONDOWN:
70 | {
71 | // Same thing as before
72 | //Form form = tb.FindForm();
73 | Control form = tb.Parent;
74 | if (form != null)
75 | {
76 | Point p = form.PointToScreen(new Point((int)m.LParam));
77 | Point p2 = tb.PointToScreen(new Point(0, 0));
78 | Rectangle rect = new Rectangle(p2, tb.Size);
79 | if (!rect.Contains(p))
80 | {
81 | tb.HideList();
82 | }
83 | }
84 | } break;
85 | }
86 | }
87 | break;
88 | }
89 |
90 | base.WndProc(ref m);
91 | }
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/FaceStyle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using WSN.Ants.Controls.TypeConverters;
6 | using System.ComponentModel;
7 |
8 | namespace WSN.Ants.Controls
9 | {
10 | ///
11 | /// 控件的外观相关样式,包括背景不同状态的样式,边框的样式,text的样式
12 | ///
13 | [TypeConverter(typeof(FaceStyleConverter))]
14 | public class FaceStyle
15 | {
16 | BrushParameter _backCheckedStyle=new BrushParameter();
17 | BrushParameter _backDisabledStyle = new BrushParameter();
18 | BrushParameter _backHoverStyle = new BrushParameter();
19 | BrushParameter _backNormalStyle = new BrushParameter();
20 |
21 | BrushParameter _borderCheckedStyle = new BrushParameter();
22 | BrushParameter _borderDisabledStyle = new BrushParameter();
23 | BrushParameter _borderHoverStyle = new BrushParameter();
24 | BrushParameter _borderNormalStyle = new BrushParameter();
25 |
26 | BrushParameter _textCheckedStyle = new BrushParameter();
27 | BrushParameter _textDisabledStyle = new BrushParameter();
28 | BrushParameter _textHoverStyle = new BrushParameter();
29 | BrushParameter _textNormalStyle = new BrushParameter();
30 |
31 | ///
32 | /// 文本正常状态样式
33 | ///
34 | [Description("文本正常状态样式")]
35 | public BrushParameter TextNormalStyle
36 | {
37 | get { return _textNormalStyle; }
38 | set { _textNormalStyle = value; }
39 | }
40 | ///
41 | /// 文本Hover状态样式
42 | ///
43 | [Description("文本Hover状态样式")]
44 | public BrushParameter TextHoverStyle
45 | {
46 | get { return _textHoverStyle; }
47 | set { _textHoverStyle = value; }
48 | }
49 | ///
50 | /// 文本禁用状态样式
51 | ///
52 | [Description("文本禁用状态样式")]
53 | public BrushParameter TextDisabledStyle
54 | {
55 | get { return _textDisabledStyle; }
56 | set { _textDisabledStyle = value; }
57 | }
58 | ///
59 | /// 文本选中状态样式
60 | ///
61 | [Description("文本选中状态样式")]
62 | public BrushParameter TextCheckedStyle
63 | {
64 | get { return _textCheckedStyle; }
65 | set { _textCheckedStyle = value; }
66 | }
67 |
68 | ///
69 | /// 边框正常状态样式
70 | ///
71 | [Description("边框正常状态样式")]
72 | public BrushParameter BorderNormalStyle
73 | {
74 | get { return _borderNormalStyle; }
75 | set { _borderNormalStyle = value; }
76 | }
77 | ///
78 | /// 边框Hover状态样式
79 | ///
80 | [Description("边框Hover状态样式")]
81 | public BrushParameter BorderHoverStyle
82 | {
83 | get { return _borderHoverStyle; }
84 | set { _borderHoverStyle = value; }
85 | }
86 | ///
87 | /// 边框禁用状态样式
88 | ///
89 | [Description("边框禁用状态样式")]
90 | public BrushParameter BorderDisabledStyle
91 | {
92 | get { return _borderDisabledStyle; }
93 | set { _borderDisabledStyle = value; }
94 | }
95 | ///
96 | /// 边框选中状态样式
97 | ///
98 | [Description("边框选中状态样式")]
99 | public BrushParameter BorderCheckedStyle
100 | {
101 | get { return _borderCheckedStyle; }
102 | set { _borderCheckedStyle = value; }
103 | }
104 | ///
105 | /// 背景正常状态样式
106 | ///
107 | [Description("背景正常状态样式")]
108 | public BrushParameter BackNormalStyle
109 | {
110 | get { return _backNormalStyle; }
111 | set { _backNormalStyle = value; }
112 | }
113 | ///
114 | /// 背景Hover状态样式
115 | ///
116 | [Description("背景Hover状态样式")]
117 | public BrushParameter BackHoverStyle
118 | {
119 | get { return _backHoverStyle; }
120 | set { _backHoverStyle = value; }
121 | }
122 | ///
123 | /// 背景禁用状态样式
124 | ///
125 | [Description("背景禁用状态样式")]
126 | public BrushParameter BackDisabledStyle
127 | {
128 | get { return _backDisabledStyle; }
129 | set { _backDisabledStyle = value; }
130 | }
131 | ///
132 | /// 背景选中状态样式
133 | ///
134 | [Description("背景选中状态样式")]
135 | public BrushParameter BackCheckedStyle
136 | {
137 | get { return _backCheckedStyle; }
138 | set { _backCheckedStyle = value; }
139 | }
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/TypeConverters/FaceStyleConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ComponentModel;
6 | using System.Globalization;
7 | using System.ComponentModel.Design.Serialization;
8 |
9 | namespace WSN.Ants.Controls.TypeConverters
10 | {
11 | ///
12 | /// 外观样式转换器
13 | ///
14 | /// 提供一种将值的类型转换为其他外观样式以及访问标准值和子属性的统一方法。
15 | ///
16 | /// 以下示例展示如何使用FaceStyleConverter
17 | ///
18 | ///
19 | public class FaceStyleConverter : TypeConverter
20 | {
21 | ///
22 | /// 返回该转换器是否可以使用指定的上下文将给定类型的对象转换为此转换器的类型。
23 | ///
24 | /// 提供格式上下文。
25 | /// 表示要转换的类型。
26 | ///
27 | /// 返回结果:
28 | /// 如果该转换器能够执行转换,则为 true;否则为 false。
29 | ///
30 | public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
31 | {
32 | return false;
33 |
34 | //if (sourceType == typeof(String)) return true;
35 |
36 | //return base.CanConvertFrom(context, sourceType);
37 | }
38 | ///
39 | /// 返回此转换器是否可以使用指定的上下文将该对象转换为指定的外观样式类型。
40 | ///
41 | /// 提供格式上下文。
42 | /// 表示要转换到的外观样式类型。
43 | ///
44 | /// 返回结果:
45 | /// 如果该转换器能够执行转换,则为 true;否则为 false。
46 | ///
47 | public override bool CanConvertTo(ITypeDescriptorContext context,
48 | System.Type destinationType)
49 | {
50 | return false;
51 |
52 | //if (destinationType == typeof(String)) return true;
53 |
54 | //if (destinationType == typeof(InstanceDescriptor)) return true;
55 |
56 | //return base.CanConvertTo(context, destinationType);
57 | }
58 | ///
59 | /// 使用指定的上下文和区域性信息将给定的值对象转换为指定的外观样式类型。
60 | ///
61 | /// 提供格式上下文。
62 | ///
63 | /// 用作当前区域性的 System.Globalization.CultureInfo。
64 | /// 如果传递 null,则采用当前区域性。
65 | /// 要转换的 System.Object。
66 | /// value 参数要转换成的 System.Type。
67 | ///
68 | /// 返回结果:
69 | /// 表示转换的 value 的 System.Object。
70 | ///
71 | /// 当destinationType参数为NULL时抛出
72 | /// 当不能进行转换时抛出
73 | public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture,
74 | object value, System.Type destinationType)
75 | {
76 | return "UI参数";
77 |
78 | //return base.ConvertTo(context, culture, value, destinationType);
79 | }
80 | ///
81 | /// 使用指定的上下文和区域性信息将给定的对象转换为此转换器的外观样式类型。
82 | ///
83 | /// 提供格式上下文。
84 | /// 用作当前区域性的 System.Globalization.CultureInfo。
85 | /// 要转换的 System.Object。
86 | /// 返回结果:
87 | /// 表示转换的 value 的 System.Object。
88 | ///
89 | /// 当不能进行转换时抛出
90 | public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
91 | {
92 | return base.ConvertFrom(context, culture, value);
93 | }
94 | ///
95 | /// 使用指定的上下文返回该对象是否支持属性 (Property)。
96 | ///
97 | /// 提供格式上下文。
98 | ///
99 | /// 返回结果:
100 | /// 如果应调用 System.ComponentModel.TypeConverter.GetProperties(System.Object) 来查找此对象的属性,
101 | /// 则为true;否则为 false。
102 | ///
103 | public override bool GetPropertiesSupported(ITypeDescriptorContext context)
104 | {
105 | return true;
106 | }
107 | ///
108 | /// 使用指定的上下文和属性 (Attribute) 返回由 value 参数指定的数组类型的属性 (Property) 的集合。
109 | ///
110 | /// 提供格式上下文。
111 | /// 一个 System.Object,指定要为其获取属性的数组类型。
112 | /// 用作筛选器的 System.Attribute 类型数组。
113 | ///
114 | /// 返回结果:
115 | /// 具有为此数据类型公开的属性的 System.ComponentModel.PropertyDescriptorCollection;
116 | /// 或者如果没有属性,则为null。
117 | ///
118 | public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
119 | {
120 | return TypeDescriptor.GetProperties(typeof(FaceStyle), attributes);
121 | }
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNAutoCompleteTextBox/WSNAutoCompleteListBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using System.Drawing.Drawing2D;
7 | using System.ComponentModel;
8 | using System.Windows.Forms;
9 | namespace WSN.Ants.Controls.WSNAutoCompleteTextBox
10 | {
11 | public partial class WSNAutoCompleteTextBox : WSNTextBox.WSNTextBox
12 | {
13 | private class WSNAutoCompleteListBox : ListBox
14 | {
15 | public Color SelectBackColor { get; set; }
16 |
17 | ///
18 | /// 自画item前事件。用户可以在这里设置显示的Text
19 | ///
20 | public event EventHandler DrawingItem;
21 | private void OnDrawingItem(WSNAutoCompleteListBoxDrawingItemEventArgs e)
22 | {
23 | if (DrawingItem != null)
24 | {
25 | DrawingItem(this, e);
26 |
27 | }
28 |
29 | }
30 |
31 |
32 | public WSNAutoCompleteListBox()
33 | : base()
34 | {
35 | base.DrawMode = DrawMode.OwnerDrawFixed;
36 | SelectBackColor = Color.FromArgb(217, 217, 217);
37 | }
38 |
39 | protected override void OnDrawItem(DrawItemEventArgs e)
40 | {
41 | base.OnDrawItem(e);
42 | if (Items.Count <= 0)
43 | return;
44 |
45 | if (e.Index != -1)
46 | {
47 |
48 | Color bColor = e.BackColor;
49 |
50 | if ((e.State & DrawItemState.Selected)
51 | == DrawItemState.Selected)
52 | {
53 | e.Graphics.FillRectangle(new SolidBrush(SelectBackColor), e.Bounds);
54 | }
55 | else
56 | {
57 | Color backColor;
58 | backColor = Color.White;
59 | using (SolidBrush brush = new SolidBrush(Color.White))
60 | {
61 | e.Graphics.FillRectangle(brush, e.Bounds);
62 | }
63 | }
64 | #region 设置显示Text
65 |
66 | //提供一个委托接口,让外面改变显示的文本
67 | WSNAutoCompleteListBoxDrawingItemEventArgs drawingItemEventArgs = new WSNAutoCompleteListBoxDrawingItemEventArgs(GetItemText(Items[e.Index]), Items[e.Index]);
68 | OnDrawingItem(drawingItemEventArgs);
69 |
70 | #endregion
71 |
72 |
73 |
74 | TextFormatFlags formatFlags = TextFormatFlags.VerticalCenter;
75 | if (RightToLeft == RightToLeft.Yes)
76 | {
77 | formatFlags |= TextFormatFlags.RightToLeft;
78 | }
79 | else
80 | {
81 | formatFlags |= TextFormatFlags.Left;
82 | }
83 |
84 | TextRenderer.DrawText(
85 | e.Graphics,
86 | drawingItemEventArgs.Text,
87 | Font,
88 | new Rectangle((e.Bounds.Width > 5) ? (e.Bounds.X + 5) : (e.Bounds.X), e.Bounds.Y, e.Bounds.Width, e.Bounds.Height),
89 | ForeColor,
90 | formatFlags);
91 | }
92 | }
93 |
94 | //protected override void OnMouseMove(MouseEventArgs e)
95 | //{
96 | // base.OnMouseMove(e);
97 | // Point mousePoint = new Point(e.X, e.Y);
98 |
99 | // for (int i = 0; i < Items.Count; i++)
100 | // {
101 | // Rectangle itemRect = GetItemRectangle(i);
102 | // if (itemRect.Contains(mousePoint))
103 | // {
104 | // SelectedIndex = i;
105 | // return;
106 | // }
107 | // }
108 |
109 | //}
110 | }
111 | ///
112 | /// 自画item前事件参数类
113 | ///
114 | public class WSNAutoCompleteListBoxDrawingItemEventArgs : EventArgs
115 | {
116 | ///
117 | /// 事件源:
118 | /// 当前ITEM
119 | ///
120 | public object Item { get; set; }
121 |
122 | ///
123 | /// 事件数据:
124 | /// 显示的Text
125 | ///
126 | public string Text{get;set;}
127 |
128 | ///
129 | /// 新建自画item前事件参数类
130 | ///
131 | /// 显示的Text
132 | /// 当前ITEM
133 | public WSNAutoCompleteListBoxDrawingItemEventArgs(string text, object item)
134 | {
135 | this.Text = text;
136 | Item = item;
137 |
138 |
139 | }
140 |
141 | }
142 |
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNAngleSelector/WSNAngleSelector.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNAngleSelector/WSNAngleAltitudeSelector.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNTipForm/WSNTipForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNTabControl/Win32.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Runtime.InteropServices;
7 | using System.Drawing;
8 |
9 | namespace WSN.Ants.Controls.WSNTabControl
10 | {
11 | internal class Win32
12 | {
13 | /*
14 | * GetWindow() Constants
15 | */
16 | public const int GW_HWNDFIRST = 0;
17 | public const int GW_HWNDLAST = 1;
18 | public const int GW_HWNDNEXT = 2;
19 | public const int GW_HWNDPREV = 3;
20 | public const int GW_OWNER = 4;
21 | public const int GW_CHILD = 5;
22 |
23 | public const int WM_NCCALCSIZE = 0x83;
24 | public const int WM_WINDOWPOSCHANGING = 0x46;
25 | public const int WM_PAINT = 0xF;
26 | public const int WM_CREATE = 0x1;
27 | public const int WM_NCCREATE = 0x81;
28 | public const int WM_NCPAINT = 0x85;
29 | public const int WM_PRINT = 0x317;
30 | public const int WM_DESTROY = 0x2;
31 | public const int WM_SHOWWINDOW = 0x18;
32 | public const int WM_SHARED_MENU = 0x1E2;
33 | public const int HC_ACTION = 0;
34 | public const int WH_CALLWNDPROC = 4;
35 | public const int GWL_WNDPROC = -4;
36 |
37 | public Win32()
38 | {
39 | //
40 | // TODO: Add constructor logic here
41 | //
42 | }
43 |
44 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
45 | public static extern IntPtr GetWindowDC(IntPtr handle);
46 |
47 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
48 | public static extern IntPtr ReleaseDC(IntPtr handle, IntPtr hDC);
49 |
50 | [DllImport("Gdi32.dll", CharSet = CharSet.Auto)]
51 | public static extern IntPtr CreateCompatibleDC(IntPtr hdc);
52 |
53 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
54 | public static extern int GetClassName(IntPtr hwnd, char[] className, int maxCount);
55 |
56 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
57 | public static extern IntPtr GetWindow(IntPtr hwnd, int uCmd);
58 |
59 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
60 | public static extern bool IsWindowVisible(IntPtr hwnd);
61 |
62 | [DllImport("user32", CharSet = CharSet.Auto)]
63 | public static extern int GetClientRect(IntPtr hwnd, ref RECT lpRect);
64 |
65 | [DllImport("user32", CharSet = CharSet.Auto)]
66 | public static extern int GetClientRect(IntPtr hwnd, [In, Out] ref Rectangle rect);
67 |
68 | [DllImport("user32", CharSet = CharSet.Auto)]
69 | public static extern bool MoveWindow(IntPtr hwnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
70 |
71 | [DllImport("user32", CharSet = CharSet.Auto)]
72 | public static extern bool UpdateWindow(IntPtr hwnd);
73 |
74 | [DllImport("user32", CharSet = CharSet.Auto)]
75 | public static extern bool InvalidateRect(IntPtr hwnd, ref Rectangle rect, bool bErase);
76 |
77 | [DllImport("user32", CharSet = CharSet.Auto)]
78 | public static extern bool ValidateRect(IntPtr hwnd, ref Rectangle rect);
79 |
80 | [DllImport("user32.dll", CharSet = CharSet.Auto)]
81 | internal static extern bool GetWindowRect(IntPtr hWnd, [In, Out] ref Rectangle rect);
82 |
83 | [StructLayout(LayoutKind.Sequential)]
84 | public struct RECT
85 | {
86 | public int Left;
87 | public int Top;
88 | public int Right;
89 | public int Bottom;
90 | }
91 |
92 | [StructLayout(LayoutKind.Sequential)]
93 | public struct WINDOWPOS
94 | {
95 | public IntPtr hwnd;
96 | public IntPtr hwndAfter;
97 | public int x;
98 | public int y;
99 | public int cx;
100 | public int cy;
101 | public uint flags;
102 | }
103 |
104 | [StructLayout(LayoutKind.Sequential)]
105 | public struct NCCALCSIZE_PARAMS
106 | {
107 | public RECT rgc;
108 | public WINDOWPOS wndpos;
109 | }
110 | }
111 |
112 | #region SubClass Classing Handler Class
113 | internal class SubClass : System.Windows.Forms.NativeWindow
114 | {
115 | public delegate int SubClassWndProcEventHandler(ref System.Windows.Forms.Message m);
116 | public event SubClassWndProcEventHandler SubClassedWndProc;
117 | private bool IsSubClassed = false;
118 |
119 | public SubClass(IntPtr Handle, bool _SubClass)
120 | {
121 | base.AssignHandle(Handle);
122 | this.IsSubClassed = _SubClass;
123 | }
124 |
125 | public bool SubClassed
126 | {
127 | get { return this.IsSubClassed; }
128 | set { this.IsSubClassed = value; }
129 | }
130 |
131 | protected override void WndProc(ref Message m)
132 | {
133 | if (this.IsSubClassed)
134 | {
135 | if (OnSubClassedWndProc(ref m) != 0)
136 | return;
137 | }
138 | base.WndProc(ref m);
139 | }
140 |
141 | public void CallDefaultWndProc(ref Message m)
142 | {
143 | base.WndProc(ref m);
144 | }
145 |
146 | #region HiWord Message Cracker
147 | public int HiWord(int Number)
148 | {
149 | return ((Number >> 16) & 0xffff);
150 | }
151 | #endregion
152 |
153 | #region LoWord Message Cracker
154 | public int LoWord(int Number)
155 | {
156 | return (Number & 0xffff);
157 | }
158 | #endregion
159 |
160 | #region MakeLong Message Cracker
161 | public int MakeLong(int LoWord, int HiWord)
162 | {
163 | return (HiWord << 16) | (LoWord & 0xffff);
164 | }
165 | #endregion
166 |
167 | #region MakeLParam Message Cracker
168 | public IntPtr MakeLParam(int LoWord, int HiWord)
169 | {
170 | return (IntPtr)((HiWord << 16) | (LoWord & 0xffff));
171 | }
172 | #endregion
173 |
174 | private int OnSubClassedWndProc(ref Message m)
175 | {
176 | if (SubClassedWndProc != null)
177 | {
178 | return this.SubClassedWndProc(ref m);
179 | }
180 |
181 | return 0;
182 | }
183 | }
184 | #endregion
185 | }
186 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/Resource.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | Resources\loading.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNTimeSlidePicker/TimeSlideHook.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Drawing;
7 |
8 | namespace WSN.Ants.Controls.WSNTimeSlidePicker
9 | {
10 | public partial class WSNTimeSlidePicker : TextBox
11 | {
12 | private const int WA_INACTIVE = 0;
13 |
14 | private class TimeSlideHook : NativeWindow
15 | {
16 | private class Messages
17 | {
18 | private Messages()
19 | { }
20 |
21 | public const int WM_PARENTNOTIFY = 0x210;
22 | public const int WM_RBUTTONDBLCLK = 0x206;
23 | public const int WM_RBUTTONDOWN = 0x204;
24 | public const int WM_RBUTTONUP = 0x205;
25 | public const int WM_LBUTTONDBLCLK = 0x203;
26 | public const int WM_LBUTTONDOWN = 0x201;
27 | public const int WM_LBUTTONUP = 0x202;
28 | public const int WM_MBUTTONDBLCLK = 0x209;
29 | public const int WM_MBUTTONDOWN = 0x207;
30 | public const int WM_MBUTTONUP = 0x208;
31 | public const int WM_NCLBUTTONDOWN = 0x00A1;
32 | public const int WM_NCLBUTTONUP = 0x00A2;
33 | public const int WM_NCLBUTTONDBLCLK = 0x00A3;
34 | public const int WM_NCRBUTTONDOWN = 0x00A4;
35 | public const int WM_NCRBUTTONUP = 0x00A5;
36 | public const int WM_NCRBUTTONDBLCLK = 0x00A6;
37 | public const int WM_NCMBUTTONDOWN = 0x00A7;
38 | public const int WM_NCMBUTTONUP = 0x00A8;
39 | public const int WM_NCMBUTTONDBLCLK = 0x00A9;
40 | public const int WM_SIZE = 0x0005;
41 | public const int WM_MOVE = 0x0003;
42 | public const int WM_KILLFOCUS = 0x0008;
43 | public const int WM_ACTIVATE = 0x0006;
44 |
45 |
46 |
47 | }
48 |
49 | private WSNTimeSlidePicker tb;
50 |
51 | public TimeSlideHook(WSNTimeSlidePicker tbox)
52 | {
53 | this.tb = tbox;
54 | }
55 |
56 |
57 | protected override void WndProc(ref Message m)
58 | {
59 | switch (m.Msg)
60 | {
61 | case Messages.WM_LBUTTONDOWN:
62 | case Messages.WM_LBUTTONDBLCLK:
63 | case Messages.WM_MBUTTONDOWN:
64 | case Messages.WM_MBUTTONDBLCLK:
65 | case Messages.WM_RBUTTONDOWN:
66 | case Messages.WM_RBUTTONDBLCLK:
67 | case Messages.WM_NCLBUTTONDOWN:
68 | case Messages.WM_NCMBUTTONDOWN:
69 | case Messages.WM_NCRBUTTONDOWN:
70 | {
71 | //Control form = tb.FindForm();
72 | //if (form == null)
73 | Control form = tb.Parent;
74 | if (form != null)
75 | {
76 | Point p = form.PointToScreen(new Point((int)m.LParam));
77 | Point p2 = tb.PointToScreen(new Point(0, 0));
78 | Rectangle rect = new Rectangle(p2, tb.Size);
79 | if (!rect.Contains(p))
80 | {
81 | tb.HideDropDown();
82 | }
83 | }
84 | } break;
85 |
86 |
87 | case Messages.WM_ACTIVATE:
88 | {
89 | // test if window is being activated
90 | if (LOWORD16(m.LParam.ToInt32()) == WA_INACTIVE)
91 | {
92 | tb.HideDropDown();
93 | }
94 | }
95 | break;
96 | case Messages.WM_KILLFOCUS:
97 | case Messages.WM_SIZE:
98 | case Messages.WM_MOVE:
99 | {
100 | tb.HideDropDown();
101 | }
102 | break;
103 | // This is the message that gets sent when a childcontrol gets activity
104 | case Messages.WM_PARENTNOTIFY:
105 | {
106 | switch ((int)m.WParam)
107 | {
108 | case Messages.WM_LBUTTONDOWN:
109 | case Messages.WM_LBUTTONDBLCLK:
110 | case Messages.WM_MBUTTONDOWN:
111 | case Messages.WM_MBUTTONDBLCLK:
112 | case Messages.WM_RBUTTONDOWN:
113 | case Messages.WM_RBUTTONDBLCLK:
114 | case Messages.WM_NCLBUTTONDOWN:
115 | case Messages.WM_NCMBUTTONDOWN:
116 | case Messages.WM_NCRBUTTONDOWN:
117 | {
118 | // Same thing as before
119 | //Control form = tb.FindForm();
120 | // if (form == null)
121 | Control form = tb.Parent;
122 | if (form != null)
123 | {
124 | Point p = form.PointToScreen(new Point((int)m.LParam));
125 | Point p2 = tb.PointToScreen(new Point(0, 0));
126 | Rectangle rect = new Rectangle(p2, tb.Size);
127 | if (!rect.Contains(p))
128 | {
129 | tb.HideDropDown();
130 | }
131 | }
132 | } break;
133 | }
134 | }
135 | break;
136 | }
137 |
138 | base.WndProc(ref m);
139 | }
140 |
141 |
142 |
143 | ///
144 | /// 获取低16位,这里要先转化成INT16型,这样才能防止负数不被转换的问题
145 | ///
146 | ///
147 | ///
148 | public static Int16 LOWORD16(int value)
149 | {
150 |
151 | Int16 v = (Int16)(value & 0xFFFF);
152 | return v;
153 | }
154 |
155 | public static int HIWORD(int value)
156 | {
157 | return value >> 16;
158 | }
159 | ///
160 | /// 获取高16位,这里要先转化成INT16型,这样才能防止负数不被转换的问题
161 | ///
162 | ///
163 | ///
164 | public static Int16 HIWORD16(int value)
165 | {
166 | Int16 v = (Int16)(value >> 16);
167 | return v;
168 |
169 | }
170 | }
171 | }
172 | }
173 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNToolTips/WSNToolTipManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Drawing;
7 |
8 | namespace WSN.Ants.Controls.WSNToolTips
9 | {
10 | ///
11 | /// WSN控件:
12 | /// WSNToolTipManager悬浮提示框管理
13 | ///
14 | public class WSNToolTipManager : IDisposable
15 | {
16 | #region 字段
17 |
18 | private WSNToolTip wsnToolTip;
19 | private IntPtr pOwner;
20 | private static WSNToolTipManager instance;
21 |
22 | #endregion
23 |
24 | #region 属性
25 | ///
26 | /// 单例模式
27 | ///
28 | public static WSNToolTipManager Instance
29 | {
30 | get
31 | {
32 | if (instance == null)
33 | {
34 | instance = new WSNToolTipManager();
35 | }
36 | return instance;
37 | }
38 | }
39 |
40 | #endregion
41 |
42 | #region 构造函数
43 | ///
44 | /// 构造函数
45 | /// 创建WSNToolTipManager
46 | ///
47 | public WSNToolTipManager()
48 | {
49 | wsnToolTip = new WSNToolTip();
50 | pOwner = IntPtr.Zero;
51 | }
52 |
53 | #endregion
54 |
55 | #region 公共函数
56 |
57 | ///
58 | /// 不带图标悬浮提示
59 | ///
60 | /// 关联控件
61 | /// 提示文本
62 | /// 提示标题
63 | /// 是否气泡
64 | /// 显示位置
65 | /// 提示宽度
66 | public void Show(Control Owner, string text, string title, bool IsBallon, TipPosition position, int width)
67 | {
68 | try
69 | {
70 | if (!wsnToolTip.IsVisible())
71 | {
72 | Reset();
73 | pOwner = Owner.Handle;
74 |
75 | wsnToolTip.BallonStyle = IsBallon;
76 | wsnToolTip.UseVisualStyle = true;
77 | wsnToolTip.MultiLine = true;
78 | wsnToolTip.MaximumWidth = width;
79 | wsnToolTip.Opacity = 0.85F;
80 | wsnToolTip.CloseButton = false;
81 | wsnToolTip.ShowAlways = true;
82 | wsnToolTip.AutoPopDelay = 5000;
83 | wsnToolTip.Position = position;
84 |
85 | if (IsBallon)
86 | {
87 | wsnToolTip.CustomStyle = TipStyle.Gradient;
88 | wsnToolTip.GradientType = GradientStyle.VerticalTube;
89 | wsnToolTip.GradientStartColor = Color.White;
90 | wsnToolTip.GradientEndColor = Color.FromArgb(0xC0D8DD);
91 | }
92 |
93 | wsnToolTip.SetToolTip(Owner, text);
94 |
95 | if (title != null)
96 | {
97 | wsnToolTip.SetTipTitle(pOwner, title);
98 | }
99 | }
100 | }
101 | catch
102 | {
103 | throw;
104 | }
105 | }
106 |
107 | ///
108 | /// 带默认图标悬浮提示
109 | ///
110 | /// 关联控件
111 | /// OsIcon默认图标
112 | /// 提示文本
113 | /// 提示标题
114 | /// 是否气泡
115 | /// 显示位置
116 | /// 提示宽度
117 | public void Show(Control Owner, OsIcon icon, string text, string title, bool IsBallon, TipPosition position, int width)
118 | {
119 | try
120 | {
121 | if (!wsnToolTip.IsVisible())
122 | {
123 | Reset();
124 | pOwner = Owner.Handle;
125 |
126 | wsnToolTip.BallonStyle = IsBallon;
127 | wsnToolTip.UseVisualStyle = false;
128 | wsnToolTip.CloseButton = false;
129 | wsnToolTip.MultiLine = true;
130 | wsnToolTip.MaximumWidth = width;
131 |
132 | wsnToolTip.SetToolTip(Owner, text);
133 |
134 | if (title != null)
135 | {
136 | wsnToolTip.SetTipTitle(title, icon);
137 | }
138 | }
139 |
140 | }
141 | catch
142 | {
143 | throw;
144 | }
145 | }
146 | ///
147 | /// 隐藏提示框
148 | ///
149 | /// 提示框的父控件
150 | public void HideToolTip(Control Owner)
151 | {
152 | try
153 | {
154 | if (wsnToolTip.IsVisible())
155 | {
156 | wsnToolTip.RemoveTip(wsnToolTip.Handle);
157 | wsnToolTip.Hide();
158 | }
159 | }
160 | catch
161 | {
162 | throw;
163 | }
164 | }
165 | ///
166 | /// 释放资源
167 | ///
168 | public void Dispose()
169 | {
170 | try
171 | {
172 | wsnToolTip.Dispose();
173 | wsnToolTip = null;
174 | instance = null;
175 | }
176 | catch
177 | {
178 | return;
179 | }
180 | }
181 |
182 | #endregion
183 |
184 | #region 私有函数
185 |
186 | ///
187 | /// 重设参数
188 | ///
189 | private void Reset()
190 | {
191 | try
192 | {
193 | if (pOwner != IntPtr.Zero)
194 | {
195 | wsnToolTip.RemoveTip(pOwner);
196 | }
197 | wsnToolTip.BorderColor = Color.FromKnownColor(KnownColor.ButtonShadow);
198 | wsnToolTip.CenterTip = false;
199 | wsnToolTip.Clickable = false;
200 | //wsnToolTip.CloseButton = false;
201 | //wsnToolTip.CustomStyle = TipStyle.Default;
202 | //wsnToolTip.ForeColor = Color.Black;
203 | //wsnToolTip.GradientEndColor = Color.LightGray;
204 | //wsnToolTip.GradientStartColor = Color.White;
205 | //wsnToolTip.GradientType = GradientStyle.VerticalTube;
206 | wsnToolTip.MaximumWidth = 150;
207 | wsnToolTip.MultiLine = false;
208 | wsnToolTip.Opacity = 0.6f;
209 | wsnToolTip.RightToLeft = false;
210 | wsnToolTip.ShowAlways = false;
211 | wsnToolTip.TitleColor = Color.Black;
212 | wsnToolTip.UseAnimation = false;
213 | wsnToolTip.UseFading = true;
214 | wsnToolTip.UseVisualStyle = false;
215 | wsnToolTip.Size = new Size(0, 0);
216 | wsnToolTip.FadePulseColor = Color.LimeGreen;
217 |
218 | }
219 | catch
220 | {
221 | throw;
222 | }
223 | }
224 |
225 | #endregion
226 |
227 | }
228 | }
229 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNDataGridView/WSNDataGridViewTextImageColumn.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.ComponentModel;
7 | using System.Drawing;
8 |
9 | namespace WSN.Ants.Controls.WSNDataGridView
10 | {
11 | ///
12 | /// WSN控件:
13 | /// WSNDataGridView列
14 | ///
15 | /// 承载了WSNDataGridViewTextImageCell的一个集合
16 | ///
17 | /// 以下示例展示如何使用WSNDataGridViewTextImageColumn
18 | ///
19 | ///
20 | public class WSNDataGridViewTextImageColumn : DataGridViewTextBoxColumn
21 | {
22 | ///
23 | /// 创建WSNDataGridViewTextImageColumn
24 | ///
25 | public WSNDataGridViewTextImageColumn()
26 | {
27 | this.CellTemplate = new WSNDataGridViewTextImageCell();
28 | }
29 |
30 | #region 属性
31 | [Category("自定义属性")]
32 | [Description("显示文本")]
33 | [DisplayName("显示文本")]
34 | ///
35 | /// 控件属性:
36 | /// 获取或设置显示文本
37 | ///
38 | public string Text
39 | {
40 | get
41 | {
42 | if (this.ImageButtonCellTemplate == null)
43 | {
44 | throw new InvalidOperationException("ImageButtonCellTemplate为空.");
45 | }
46 | return this.ImageButtonCellTemplate.Text;
47 | }
48 | set
49 | {
50 | if (this.ImageButtonCellTemplate == null)
51 | {
52 | throw new InvalidOperationException("ImageButtonCellTemplate为空.");
53 | }
54 | this.ImageButtonCellTemplate.Text = value;
55 | if (this.DataGridView != null)
56 | {
57 | DataGridViewRowCollection dataGridViewRows = this.DataGridView.Rows;
58 | int rowCount = dataGridViewRows.Count;
59 | for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
60 | {
61 | DataGridViewRow dataGridViewRow = dataGridViewRows.SharedRow(rowIndex);
62 | WSNDataGridViewTextImageCell dataGridViewCell = dataGridViewRow.Cells[this.Index] as WSNDataGridViewTextImageCell;
63 | if (dataGridViewCell != null)
64 | {
65 | dataGridViewCell.SetText(rowIndex, value);
66 | }
67 | }
68 | this.DataGridView.InvalidateColumn(this.Index);
69 | }
70 |
71 | }
72 | }
73 |
74 | [Category("自定义属性")]
75 | [Description("显示图片.normal状态")]
76 | [DisplayName("显示Normal图片")]
77 | ///
78 | /// 控件属性:
79 | /// 获取或设置显示图片NORMAL
80 | ///
81 | public Image NormalImage
82 | {
83 | get
84 | {
85 | if (this.ImageButtonCellTemplate == null)
86 | {
87 | throw new InvalidOperationException("ImageButtonCellTemplate为空.");
88 | }
89 | return this.ImageButtonCellTemplate.NormalImage;
90 | }
91 | set
92 | {
93 | if (this.ImageButtonCellTemplate == null)
94 | {
95 | throw new InvalidOperationException("ImageButtonCellTemplate为空.");
96 | }
97 | this.ImageButtonCellTemplate.NormalImage = value;
98 | if (this.DataGridView != null)
99 | {
100 | DataGridViewRowCollection dataGridViewRows = this.DataGridView.Rows;
101 | int rowCount = dataGridViewRows.Count;
102 | for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
103 | {
104 | DataGridViewRow dataGridViewRow = dataGridViewRows.SharedRow(rowIndex);
105 | WSNDataGridViewTextImageCell dataGridViewCell = dataGridViewRow.Cells[this.Index] as WSNDataGridViewTextImageCell;
106 | if (dataGridViewCell != null)
107 | {
108 | dataGridViewCell.SetNormalImage(rowIndex, value);
109 | }
110 | }
111 | this.DataGridView.InvalidateColumn(this.Index);
112 | }
113 |
114 | }
115 | }
116 |
117 |
118 |
119 | [Category("自定义属性")]
120 | [Description("显示图片.hover状态")]
121 | [DisplayName("显示Hover图片")]
122 | ///
123 | /// 控件属性:
124 | /// 获取或设置显示图片HOVER
125 | ///
126 | public Image HoverImage
127 | {
128 | get
129 | {
130 | if (this.ImageButtonCellTemplate == null)
131 | {
132 | throw new InvalidOperationException("ImageButtonCellTemplate为空.");
133 | }
134 | return this.ImageButtonCellTemplate.HoverImage;
135 | }
136 | set
137 | {
138 | if (this.ImageButtonCellTemplate == null)
139 | {
140 | throw new InvalidOperationException("ImageButtonCellTemplate为空.");
141 | }
142 | this.ImageButtonCellTemplate.HoverImage = value;
143 | if (this.DataGridView != null)
144 | {
145 | DataGridViewRowCollection dataGridViewRows = this.DataGridView.Rows;
146 | int rowCount = dataGridViewRows.Count;
147 | for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
148 | {
149 | DataGridViewRow dataGridViewRow = dataGridViewRows.SharedRow(rowIndex);
150 | WSNDataGridViewTextImageCell dataGridViewCell = dataGridViewRow.Cells[this.Index] as WSNDataGridViewTextImageCell;
151 | if (dataGridViewCell != null)
152 | {
153 | dataGridViewCell.SetHoverImage(rowIndex, value);
154 | }
155 | }
156 | this.DataGridView.InvalidateColumn(this.Index);
157 | }
158 |
159 | }
160 | }
161 | #endregion
162 | ///
163 | /// 控件属性:
164 | /// 获取或设置单元格样式
165 | ///
166 | ///
167 | /// 当赋值时,值不为null且该值不是WSNDataGridViewTextImageCell类型时抛出
168 | ///
169 | public override DataGridViewCell CellTemplate
170 | {
171 | get
172 | {
173 | return base.CellTemplate;
174 | }
175 | set
176 | {
177 | if (value != null &&
178 | !value.GetType().IsAssignableFrom(typeof(WSNDataGridViewTextImageCell)))
179 | {
180 | throw new InvalidCastException("必须是 WSNDataGridViewTextImageCell 类型");
181 | }
182 | base.CellTemplate = value;
183 | }
184 | }
185 | private WSNDataGridViewTextImageCell ImageButtonCellTemplate
186 | {
187 | get
188 | {
189 | return (WSNDataGridViewTextImageCell)this.CellTemplate;
190 | }
191 | }
192 | }
193 |
194 | }
195 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNTipForm/WSNTipForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WSN.Ants.Controls.WSNTipForm
2 | {
3 | partial class WSNTipForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.components = new System.ComponentModel.Container();
32 | WSN.Ants.Controls.FaceStyle faceStyle1 = new WSN.Ants.Controls.FaceStyle();
33 | WSN.Ants.Controls.BrushParameter brushParameter1 = new WSN.Ants.Controls.BrushParameter();
34 | WSN.Ants.Controls.BrushParameter brushParameter2 = new WSN.Ants.Controls.BrushParameter();
35 | WSN.Ants.Controls.BrushParameter brushParameter3 = new WSN.Ants.Controls.BrushParameter();
36 | WSN.Ants.Controls.BrushParameter brushParameter4 = new WSN.Ants.Controls.BrushParameter();
37 | WSN.Ants.Controls.BrushParameter brushParameter5 = new WSN.Ants.Controls.BrushParameter();
38 | WSN.Ants.Controls.BrushParameter brushParameter6 = new WSN.Ants.Controls.BrushParameter();
39 | WSN.Ants.Controls.BrushParameter brushParameter7 = new WSN.Ants.Controls.BrushParameter();
40 | WSN.Ants.Controls.BrushParameter brushParameter8 = new WSN.Ants.Controls.BrushParameter();
41 | WSN.Ants.Controls.BrushParameter brushParameter9 = new WSN.Ants.Controls.BrushParameter();
42 | WSN.Ants.Controls.WSNButton.WSNButtonImageTable wsnButtonImageTable1 = new WSN.Ants.Controls.WSNButton.WSNButtonImageTable();
43 | this.timer1 = new System.Windows.Forms.Timer(this.components);
44 | this.closeButton = new WSN.Ants.Controls.WSNButton.WSNButton();
45 | this.SuspendLayout();
46 | //
47 | // timer1
48 | //
49 | this.timer1.Interval = 1000;
50 | this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
51 | //
52 | // closeButton
53 | //
54 | this.closeButton.Anchor = System.Windows.Forms.AnchorStyles.None;
55 | this.closeButton.BackColor = System.Drawing.Color.Transparent;
56 | this.closeButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
57 | this.closeButton.Checked = false;
58 | brushParameter1.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(214)))), ((int)(((byte)(125)))));
59 | brushParameter1.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(241)))), ((int)(((byte)(211)))));
60 | brushParameter1.Mode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
61 | faceStyle1.BackCheckedStyle = brushParameter1;
62 | brushParameter2.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(241)))), ((int)(((byte)(241)))), ((int)(((byte)(241)))));
63 | brushParameter2.Color2 = System.Drawing.Color.Empty;
64 | brushParameter2.Mode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
65 | faceStyle1.BackDisabledStyle = brushParameter2;
66 | faceStyle1.BackHoverStyle = brushParameter1;
67 | brushParameter3.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(226)))), ((int)(((byte)(226)))), ((int)(((byte)(226)))));
68 | brushParameter3.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(245)))), ((int)(((byte)(245)))), ((int)(((byte)(245)))));
69 | brushParameter3.Mode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
70 | faceStyle1.BackNormalStyle = brushParameter3;
71 | brushParameter4.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(153)))), ((int)(((byte)(0)))));
72 | brushParameter4.Color2 = System.Drawing.Color.Empty;
73 | brushParameter4.Mode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
74 | faceStyle1.BorderCheckedStyle = brushParameter4;
75 | brushParameter5.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
76 | brushParameter5.Color2 = System.Drawing.Color.Empty;
77 | brushParameter5.Mode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
78 | faceStyle1.BorderDisabledStyle = brushParameter5;
79 | faceStyle1.BorderHoverStyle = brushParameter4;
80 | brushParameter6.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(179)))), ((int)(((byte)(179)))), ((int)(((byte)(179)))));
81 | brushParameter6.Color2 = System.Drawing.Color.Empty;
82 | brushParameter6.Mode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
83 | faceStyle1.BorderNormalStyle = brushParameter6;
84 | brushParameter7.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(156)))), ((int)(((byte)(88)))), ((int)(((byte)(7)))));
85 | brushParameter7.Color2 = System.Drawing.Color.Empty;
86 | brushParameter7.Mode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
87 | faceStyle1.TextCheckedStyle = brushParameter7;
88 | brushParameter8.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(179)))), ((int)(((byte)(179)))), ((int)(((byte)(179)))));
89 | brushParameter8.Color2 = System.Drawing.Color.Empty;
90 | brushParameter8.Mode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
91 | faceStyle1.TextDisabledStyle = brushParameter8;
92 | faceStyle1.TextHoverStyle = brushParameter7;
93 | brushParameter9.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(72)))), ((int)(((byte)(72)))), ((int)(((byte)(72)))));
94 | brushParameter9.Color2 = System.Drawing.Color.Empty;
95 | brushParameter9.Mode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
96 | faceStyle1.TextNormalStyle = brushParameter9;
97 | this.closeButton.ControlFaceSchema = faceStyle1;
98 | this.closeButton.FlatAppearance.BorderSize = 0;
99 | this.closeButton.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent;
100 | this.closeButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent;
101 | this.closeButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
102 | this.closeButton.GlassEnable = true;
103 | this.closeButton.ImageMode = true;
104 | wsnButtonImageTable1.ImageChecked = null;
105 | wsnButtonImageTable1.ImageDisalbed = null;
106 | wsnButtonImageTable1.ImageHover = null;
107 | wsnButtonImageTable1.ImageNormal = null;
108 | this.closeButton.ImageTable = wsnButtonImageTable1;
109 | this.closeButton.Location = new System.Drawing.Point(205, 1);
110 | this.closeButton.Name = "closeButton";
111 | this.closeButton.Size = new System.Drawing.Size(75, 23);
112 | this.closeButton.TabIndex = 0;
113 | this.closeButton.Text = "wsnButton1";
114 | this.closeButton.ToolTipText = "";
115 | this.closeButton.UseVisualStyleBackColor = false;
116 | this.closeButton.Click += new System.EventHandler(this.closeButton_Click);
117 | //
118 | // WSNTipForm
119 | //
120 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
121 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
122 | this.ClientSize = new System.Drawing.Size(292, 266);
123 | this.Controls.Add(this.closeButton);
124 | this.Name = "WSNTipForm";
125 | this.Text = "WSNTipForm";
126 | this.Shown += new System.EventHandler(this.WSNTipForm_Shown);
127 | this.ResumeLayout(false);
128 |
129 | }
130 |
131 | #endregion
132 |
133 | private WSNButton.WSNButton closeButton;
134 | private System.Windows.Forms.Timer timer1;
135 | }
136 | }
--------------------------------------------------------------------------------
/WSN.Ants.Controls/GraphicsPathHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Drawing;
5 | using System.Drawing.Drawing2D;
6 |
7 | namespace WSN.Ants.Controls
8 | {
9 | ///
10 | /// 画图路径帮助类
11 | /// GraphicsPathHelper
12 | ///
13 | public static class GraphicsPathHelper
14 | {
15 | ///
16 | /// 建立带有圆角样式的路径。
17 | ///
18 | /// 用来建立路径的矩形。
19 | /// 圆角的大小。
20 | /// 圆角的样式。
21 | /// 是否把矩形长宽减 1,以便画出边框。
22 | /// 建立的路径。
23 | public static GraphicsPath CreatePath(
24 | Rectangle rect, int radius, RoundStyle style, bool correction)
25 | {
26 | GraphicsPath path = new GraphicsPath();
27 | int radiusCorrection = correction ? 1 : 0;
28 | switch (style)
29 | {
30 | case RoundStyle.None:
31 | path.AddRectangle(new Rectangle(rect.X,rect.Y,rect.Width-radiusCorrection,rect.Height-radiusCorrection));
32 | break;
33 | case RoundStyle.All:
34 | path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
35 |
36 | path.AddArc(
37 | rect.Right - radius - radiusCorrection,
38 | rect.Y,
39 | radius,
40 | radius,
41 | 270,
42 | 90);
43 | path.AddArc(
44 | rect.Right - radius - radiusCorrection,
45 | rect.Bottom - radius - radiusCorrection,
46 | radius ,
47 | radius , 0, 90);
48 | path.AddArc(
49 | rect.X,
50 | rect.Bottom - radius - radiusCorrection,
51 | radius,
52 | radius,
53 | 90,
54 | 90);
55 | break;
56 | case RoundStyle.Left:
57 | path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
58 | path.AddLine(
59 | rect.Right - radiusCorrection, rect.Y,
60 | rect.Right - radiusCorrection, rect.Bottom - radiusCorrection);
61 | path.AddArc(
62 | rect.X,
63 | rect.Bottom - radius - radiusCorrection,
64 | radius,
65 | radius,
66 | 90,
67 | 90);
68 | break;
69 | case RoundStyle.Right:
70 | path.AddArc(
71 | rect.Right - radius - radiusCorrection,
72 | rect.Y,
73 | radius,
74 | radius,
75 | 270,
76 | 90);
77 | path.AddArc(
78 | rect.Right - radius - radiusCorrection,
79 | rect.Bottom - radius - radiusCorrection,
80 | radius,
81 | radius,
82 | 0,
83 | 90);
84 | path.AddLine(rect.X, rect.Bottom - radiusCorrection, rect.X, rect.Y);
85 | break;
86 | case RoundStyle.Top:
87 | path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
88 | path.AddArc(
89 | rect.Right - radius - radiusCorrection,
90 | rect.Y,
91 | radius,
92 | radius,
93 | 270,
94 | 90);
95 | path.AddLine(
96 | rect.Right - radiusCorrection, rect.Bottom - radiusCorrection,
97 | rect.X, rect.Bottom - radiusCorrection);
98 | break;
99 | case RoundStyle.Bottom:
100 | path.AddArc(
101 | rect.Right - radius - radiusCorrection,
102 | rect.Bottom - radius - radiusCorrection,
103 | radius,
104 | radius,
105 | 0,
106 | 90);
107 | path.AddArc(
108 | rect.X,
109 | rect.Bottom - radius - radiusCorrection,
110 | radius,
111 | radius,
112 | 90,
113 | 90);
114 | path.AddLine(rect.X, rect.Y, rect.Right - radiusCorrection, rect.Y);
115 | break;
116 | }
117 | path.CloseFigure();
118 |
119 | return path;
120 | }
121 |
122 |
123 |
124 |
125 | ///
126 | /// 建立带有圆角样式的路径。取横向一半顶部(用于按钮玻璃效果)
127 | ///
128 | /// 用来建立路径的矩形。
129 | /// 圆角的大小。
130 | /// 圆角的样式。
131 | /// 是否把矩形长宽减 1,以便画出边框。
132 | /// 建立的路径。
133 | public static GraphicsPath CreatePathHalf(
134 | Rectangle rect, int radius, RoundStyle style, bool correction)
135 | {
136 | GraphicsPath path = new GraphicsPath();
137 | int radiusCorrection = correction ? 1 : 0;
138 | switch (style)
139 | {
140 | case RoundStyle.None:
141 | path.AddRectangle(new Rectangle(rect.X, rect.Y, rect.Width - radiusCorrection, rect.Height/2 - radiusCorrection));
142 | break;
143 | case RoundStyle.All:
144 | //顺时针
145 | path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
146 |
147 | path.AddArc(
148 | rect.Right - radius - radiusCorrection,
149 | rect.Y,
150 | radius,
151 | radius,
152 | 270,
153 | 90);
154 | path.AddLine(rect.Right - radiusCorrection,
155 | rect.Y + rect.Height / 2 - radiusCorrection,
156 | rect.X,
157 | rect.Y + rect.Height / 2 - radiusCorrection);
158 |
159 |
160 | break;
161 | case RoundStyle.Left:
162 | path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
163 |
164 | path.AddLine(
165 | rect.Right - radiusCorrection, rect.Y,
166 | rect.Right - radiusCorrection, rect.Y + rect.Height / 2 - radiusCorrection);
167 | path.AddLine(
168 | rect.Right - radiusCorrection, rect.Y + rect.Height / 2 - radiusCorrection,
169 | rect.X, rect.Y + rect.Height / 2 - radiusCorrection);
170 |
171 | break;
172 | case RoundStyle.Right:
173 | path.AddArc(
174 | rect.Right - radius - radiusCorrection,
175 | rect.Y,
176 | radius,
177 | radius,
178 | 270,
179 | 90);
180 | path.AddLine(rect.Right - radiusCorrection, rect.Y + rect.Height / 2 - radiusCorrection,
181 | rect.X, rect.Y + rect.Height / 2 - radiusCorrection);
182 | path.AddLine(rect.X, rect.Y + rect.Height / 2 - radiusCorrection,
183 | rect.X, rect.Y);
184 | break;
185 | case RoundStyle.Top:
186 | path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
187 | path.AddArc(
188 | rect.Right - radius - radiusCorrection,
189 | rect.Y,
190 | radius,
191 | radius,
192 | 270,
193 | 90);
194 | path.AddLine(
195 | rect.Right - radiusCorrection, rect.Y + rect.Height / 2 - radiusCorrection,
196 | rect.X, rect.Y + rect.Height / 2 - radiusCorrection);
197 | break;
198 | case RoundStyle.Bottom:
199 | path.AddRectangle(new Rectangle(rect.X, rect.Y, rect.Width - radiusCorrection, rect.Height / 2 - radiusCorrection));
200 |
201 | break;
202 | }
203 | path.CloseFigure();
204 |
205 | return path;
206 | }
207 | }
208 | }
209 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/ClassDiagram1.cd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | AAAAAAAAAIAAAAAAAgAAAAAAAAAAAAAAAAAAgACQAAA=
7 | BrushParameter.cs
8 |
9 |
10 |
11 |
12 |
13 | AAAAAAAACAAAAAEAAAEAAAAAFAAEAAAgAAAAAIAAAAA=
14 | CheckImageTable.cs
15 |
16 |
17 |
18 |
19 |
20 | oARAQAgBAAAACAQACAAAAEAgAqQAAAAAAJEAQAAEJAA=
21 | FaceStyle.cs
22 |
23 |
24 |
25 |
26 |
27 | AAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
28 | GraphicsPathHelper.cs
29 |
30 |
31 |
32 |
33 |
34 | AAAAAAAAAAAAAAAAAAABEAAAAQCAAAAAAAAAAAAAAIA=
35 |
36 |
37 |
38 |
39 |
40 | AACABAAAIDABIAAAAAIAAAACAAAIQBAIACAAAAAAEIA=
41 | WSNGifBox.cs
42 |
43 |
44 |
45 |
46 |
47 | AACAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAIA=
48 | WSNGroupBox.cs
49 |
50 |
51 |
52 |
53 |
54 | AgCAAAAAACAAAAAARACBAAAAAAAAABBABACgAAAAAIA=
55 | WSNOpaqueProgressLayer.cs
56 |
57 |
58 |
59 |
60 |
61 | DAHIAAQIBgJhBCGAAABACCgAAAAAAoBAIGAAAAICACQ=
62 | WSNButton\WSNButton.cs
63 |
64 |
65 |
66 |
67 |
68 | AAAIAAAAACAQAAAAgAIAAAAAAAAAAAAAAAAAABAEAgA=
69 | WSNButton\WSNButtonImageTable.cs
70 |
71 |
72 |
73 |
74 |
75 | BACAAAAIAAAgAAEQAQBAAAAAAAAAAAAAIAAAAAEGAAQ=
76 | WSNCheckBox\WSNCheckBox.cs
77 |
78 |
79 |
80 |
81 |
82 | AAAoAQAAgAIAoAiAJgAACAAChCMAAECEQAAEFNCQAAA=
83 | WSNContextMenuStrip\ContextMenuRender.cs
84 |
85 |
86 |
87 |
88 |
89 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
90 | WSNContextMenuStrip\WSNContextMenuStrip.cs
91 |
92 |
93 |
94 |
95 |
96 | BACAAAAIAAAgAAEQAQBAAAAAAAAAAAAAIAAAAAEGAAQ=
97 | WSNRadioButton\WSNRadioButton.cs
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | CQWIQAAIQCARAgAAAABACAADAFAAACDAIAASSBECQoQ=
107 | WSNSearchBox\WSNSearchBox.cs
108 |
109 |
110 |
111 |
112 |
113 | DEAAgCgAAgAAAAAIIOCCAEDEAAAAsIAAQAQCAACgAxA=
114 | WSNTabControl\Win32.cs
115 |
116 |
117 |
118 |
119 |
120 | AAAIAAAAAAIEAAABAEAAAAAAQAAAAAAACAAAQAEABAA=
121 | WSNTabControl\Win32.cs
122 |
123 |
124 |
125 |
126 |
127 | AAGAIABJACAAAAABACCAAAQCmBAAAAAYgBAIACABAAA=
128 | WSNTabControl\WSNTabControl.cs
129 |
130 |
131 |
132 |
133 |
134 | AAAggCCAACAAQQAAAEAAAIAAAAAAAAAQAAAAAAgAAAA=
135 | WSNTabControl\WSNTabControlRender.cs
136 |
137 |
138 |
139 |
140 |
141 |
142 | KCFIAAAIAAAgAAAAAEBACAAAAAAAAAAEACAAYCAAAQQ=
143 | WSNTextBox\WSNTextBox.cs
144 |
145 |
146 |
147 |
148 |
149 | AAQACAAAgAAAAAAAIgAAAAAAgAAAAEAACAAAAAEAAAA=
150 | WSNToolStrip\WSNNormToolStripRender.cs
151 |
152 |
153 |
154 |
155 |
156 | AAQACAAAgAAAAAAAIgAAAAAAgAAAAEAAAAAAAAEAAAA=
157 | WSNToolStrip\WSNStatusToolStipRender.cs
158 |
159 |
160 |
161 |
162 |
163 | AAAAACAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAAA=
164 | WSNToolStrip\WSNToolStrip.cs
165 |
166 |
167 |
168 |
169 |
170 | qjHYFBCIgSDgqLiAQADALAAqAFAcCAEAJAEoAAACACQ=
171 | WSNTrackBar\WSNTrackBar.cs
172 |
173 |
174 |
175 |
176 |
177 | AAvAAECCBAAABBoAQjAoAAATAikGAIG0RFAApAwBQEQ=
178 | WSNLoadingBox\WSNLoadingBox.cs
179 |
180 |
181 |
182 |
183 |
184 | AAAAAAAAAAAAgAAAAAAAAAAAAAAIAAAAAQAAAAAEAAA=
185 | ControlState.cs
186 |
187 |
188 |
189 |
190 |
191 | AAAAAAAAAAAAAAAAAAAQAAAAAAAIAAAACICAAAEAAAA=
192 | RoundStyle.cs
193 |
194 |
195 |
196 |
197 |
198 | AAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAARAAAgA=
199 | WSNToolStrip\ToolStripRenderStyle.cs
200 |
201 |
202 |
203 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNTextBox/WSNTextBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.ComponentModel;
7 | using System.Drawing;
8 |
9 | namespace WSN.Ants.Controls.WSNTextBox
10 | {
11 | ///
12 | /// WSN控件:
13 | /// WSNTextBox文本框
14 | ///
15 | ///
16 | /// 以下示例展示如何使用WSNTextBox
17 | ///
18 | ///
19 | public class WSNTextBox : TextBox
20 | {
21 | #region Windows API
22 | ///
23 | /// 获得当前进程,以便重绘控件
24 | ///
25 | ///
26 | ///
27 | [System.Runtime.InteropServices.DllImport("user32.dll")]
28 | static extern IntPtr GetWindowDC(IntPtr hWnd);
29 | [System.Runtime.InteropServices.DllImport("user32.dll")]
30 | static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
31 |
32 | #endregion
33 |
34 | #region 字段
35 | private FaceStyle _controlFaceSchema = new FaceStyle();
36 | private ControlState _controlState;
37 | private RoundStyle _roundStyle = RoundStyle.All;
38 | private int _radius = 8;
39 | private string _emptyTextTip;
40 | private Color _emptyTextTipColor = Color.DarkGray;
41 | #endregion
42 |
43 | #region 属性
44 | ///
45 | /// 控件属性:
46 | /// 获取或设置空文本时显示文本
47 | ///
48 | /// 默认为:"请输入"
49 | [DefaultValue("请输入")]
50 | public string EmptyTextTip
51 | {
52 | get { return _emptyTextTip; }
53 | set
54 | {
55 | _emptyTextTip = value;
56 | base.Invalidate();
57 | }
58 | }
59 | ///
60 | /// 控件属性:
61 | /// 获取或设置空文本时显示文本的颜色
62 | ///
63 | /// 默认为:DarkGray
64 | [DefaultValue(typeof(Color), "DarkGray")]
65 | public Color EmptyTextTipColor
66 | {
67 | get { return _emptyTextTipColor; }
68 | set
69 | {
70 | _emptyTextTipColor = value;
71 | base.Invalidate();
72 | }
73 | }
74 | ///
75 | /// 控件属性:
76 | /// 获取或设置控件外观样式
77 | ///
78 | public FaceStyle ControlFaceSchema
79 | {
80 | get { return _controlFaceSchema; }
81 | set { _controlFaceSchema = value; }
82 | }
83 | ///
84 | /// 控件属性:
85 | /// 获取或设置圆角路径的样式
86 | ///
87 | /// 默认为:四个角都是圆角
88 | [DefaultValue(typeof(RoundStyle), "1")]
89 | public RoundStyle RoundStyle
90 | {
91 | get { return _roundStyle; }
92 | set
93 | {
94 | if (_roundStyle != value)
95 | {
96 | _roundStyle = value;
97 | base.Invalidate();
98 | }
99 | }
100 | }
101 | ///
102 | /// 控件属性:
103 | /// 获取或设置圆角半径
104 | ///
105 | /// 默认为:8
106 | [DefaultValue(8)]
107 | public int Radius
108 | {
109 | get { return _radius; }
110 | set
111 | {
112 | if (_radius != value)
113 | {
114 | _radius = value < 4 ? 4 : value;
115 | base.Invalidate();
116 | }
117 | }
118 | }
119 |
120 | internal ControlState ControlState
121 | {
122 | get { return _controlState; }
123 | set
124 | {
125 | if (_controlState != value)
126 | {
127 | _controlState = value;
128 | base.Invalidate();
129 | }
130 | }
131 | }
132 |
133 |
134 | #endregion
135 |
136 | #region 构造函数
137 | ///
138 | /// 构造函数:
139 | /// 创建WSNTextBox
140 | ///
141 | public WSNTextBox()
142 | {
143 | ControlFaceSchema.BorderNormalStyle.Color1 = Color.FromArgb(179, 179, 179);
144 | ControlFaceSchema.BorderHoverStyle.Color1 = Color.FromArgb(179, 179, 179);
145 | ControlFaceSchema.BorderDisabledStyle.Color1 = Color.FromArgb(100,100,100);
146 | //ControlFaceSchema.BorderDisabledStyle.Color1 = Color.FromArgb(255, 0,0);
147 |
148 | }
149 | #endregion
150 | #region 重载方法
151 | protected override void OnMouseEnter(EventArgs e)
152 | {
153 | base.OnMouseEnter(e);
154 | ControlState = ControlState.Hover;
155 |
156 | }
157 | ///
158 | /// 当鼠标从该控件移开时
159 | ///
160 | ///
161 | protected override void OnMouseLeave(EventArgs e)
162 | {
163 | base.OnMouseLeave(e);
164 | ControlState = ControlState.Normal;
165 | }
166 |
167 | ///
168 | /// 当该控件获得焦点时
169 | ///
170 | ///
171 | protected override void OnGotFocus(EventArgs e)
172 | {
173 | base.OnGotFocus(e);
174 | this.Invalidate();
175 | }
176 | ///
177 | /// 当该控件失去焦点时
178 | ///
179 | ///
180 | protected override void OnLostFocus(EventArgs e)
181 | {
182 |
183 | base.OnLostFocus(e);
184 | this.Invalidate();
185 |
186 | }
187 |
188 | ///
189 | /// 获得操作系统消息
190 | ///
191 | ///
192 | protected override void WndProc(ref Message m)
193 | {
194 |
195 | base.WndProc(ref m);
196 | if (m.Msg == 0xf || m.Msg == 0x133)
197 | {
198 | #region 注释
199 | //拦截系统消息,获得当前控件进程以便重绘。
200 | //一些控件(如TextBox、Button等)是由系统进程绘制,重载OnPaint方法将不起作用.
201 | //所有这里并没有使用重载OnPaint方法绘制TextBox边框。
202 | //
203 | //MSDN:重写 OnPaint 将禁止修改所有控件的外观。
204 | //那些由 Windows 完成其所有绘图的控件(例如 Textbox)从不调用它们的 OnPaint 方法,
205 | //因此将永远不会使用自定义代码。请参见您要修改的特定控件的文档,
206 | //查看 OnPaint 方法是否可用。如果某个控件未将 OnPaint 作为成员方法列出,
207 | //则您无法通过重写此方法改变其外观。
208 | //
209 | //MSDN:要了解可用的 Message.Msg、Message.LParam 和 Message.WParam 值,
210 | //请参考位于 MSDN Library 中的 Platform SDK 文档参考。可在 Platform SDK(“Core SDK”一节)
211 | //下载中包含的 windows.h 头文件中找到实际常数值,该文件也可在 MSDN 上找到。
212 | #endregion
213 | IntPtr hDC = GetWindowDC(m.HWnd);
214 | if (hDC.ToInt32() == 0)
215 | {
216 | return;
217 | }
218 | System.Drawing.Graphics g = Graphics.FromHdc(hDC);
219 |
220 | #region 画边框
221 | if (this.BorderStyle != BorderStyle.None)
222 | {
223 |
224 | //边框Width为1个像素
225 | System.Drawing.Pen pen = new Pen(ControlFaceSchema.BorderNormalStyle.Color1, 1);
226 |
227 | if (this.Enabled)
228 | {
229 | if (ControlState == ControlState.Hover)
230 | {
231 | pen.Color = ControlFaceSchema.BorderHoverStyle.Color1;
232 | }
233 | else
234 | {
235 | if (this.Focused)
236 | {
237 | pen.Color = ControlFaceSchema.BorderHoverStyle.Color1;
238 | }
239 | else
240 | {
241 | pen.Color = ControlFaceSchema.BorderNormalStyle.Color1;
242 | }
243 | }
244 | }
245 | else
246 | {
247 | pen.Color = ControlFaceSchema.BorderDisabledStyle.Color1;
248 | }
249 |
250 | //绘制边框
251 | g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
252 | g.DrawRectangle(pen, 0, 0, this.Width - 1, this.Height - 1);
253 | pen.Dispose();
254 | }
255 | #endregion
256 |
257 | #region 画水印提示
258 | if (Text.Length == 0
259 | && !string.IsNullOrEmpty(_emptyTextTip)
260 | && !Focused
261 | && Enabled)
262 | {
263 | TextFormatFlags format =
264 | TextFormatFlags.EndEllipsis |
265 | TextFormatFlags.VerticalCenter;
266 |
267 | if (RightToLeft == RightToLeft.Yes)
268 | {
269 | format |= TextFormatFlags.RightToLeft | TextFormatFlags.Right;
270 | }
271 |
272 | TextRenderer.DrawText(
273 | g,
274 | _emptyTextTip,
275 | Font,
276 | base.ClientRectangle,
277 | _emptyTextTipColor,
278 | format);
279 | }
280 |
281 | #endregion
282 |
283 |
284 | //返回结果
285 | m.Result = IntPtr.Zero;
286 | //释放
287 | ReleaseDC(m.HWnd, hDC);
288 | g.Dispose();
289 | }
290 | }
291 | #endregion
292 | }
293 | }
294 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNTimeSlidePicker/WSNTimeSlidePicker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Drawing;
7 | using System.Text.RegularExpressions;
8 | using System.ComponentModel;
9 |
10 | namespace WSN.Ants.Controls.WSNTimeSlidePicker
11 | {
12 | ///
13 | /// WSN控件:
14 | /// WSNTimeSlidePicker
15 | ///
16 | ///
17 | /// 以下示例展示如何使用WSNTimeSlidePicker
18 | ///
19 | ///
20 | public partial class WSNTimeSlidePicker : TextBox
21 | {
22 | private WSNPopupControlHost.WSNPopupControlHost host;
23 | private WSNTrackBar.WSNTrackBar bar;
24 | private TimeSlideHook hook;
25 | private Color backNormalColor;
26 | private Timer timer;
27 | private int blinkCount;
28 | private bool blink;
29 |
30 | private int blinkTotalCount;
31 |
32 | ///
33 | /// 控件属性:
34 | /// 获取时间(小时)
35 | ///
36 | public int Hours
37 | {
38 | get
39 | {
40 | int h= GetHours();
41 | if (h >= 24)
42 | h = 0;
43 | if (h < 0)
44 | h = 0;
45 | return h;
46 | }
47 | }
48 | ///
49 | /// 控件属性:
50 | /// 获取时间(分钟)
51 | ///
52 | public int Minutes
53 | {
54 | get
55 | {
56 | int m= GetMinutes();
57 | if (m >= 60)
58 | m = 0;
59 | if (m < 0)
60 | m = 0;
61 | return m;
62 | }
63 | }
64 | ///
65 | /// 控件属性:
66 | /// 获取秒数
67 | ///
68 | public int Seconds
69 | {
70 | get
71 | {
72 | int s=GetSeconds();
73 | if (s >= 60)
74 | s = 0;
75 | if (s < 0)
76 | s = 0;
77 | return s;
78 | }
79 | }
80 |
81 | private int GetSeconds()
82 | {
83 | return bar.Value % (60 * 60) % 60;
84 | }
85 |
86 | private int GetMinutes()
87 | {
88 | return (bar.Value % (60 * 60)) / 60;
89 | }
90 |
91 | private int GetHours()
92 | {
93 | return bar.Value / (60 * 60);
94 |
95 | }
96 | ///
97 | /// bar是否在显示状态
98 | ///
99 | public bool IsSlidePopUp
100 | {
101 | get
102 | {
103 | return host.Visible;
104 | }
105 | }
106 | ///
107 | /// 控件属性:
108 | /// 获取或设置Blink总数
109 | ///
110 | /// 默认为:6
111 | [DefaultValue(6)]
112 | public int BlinkTotalCount
113 | {
114 | get { return blinkTotalCount; }
115 | set { blinkTotalCount = value; }
116 | }
117 | ///
118 | /// 控件属性:
119 | /// 获取或设置正常情况下的背景色
120 | ///
121 | /// 默认为:"255,255,255"
122 | [DefaultValue("255,255,255")]
123 | public Color BackNormalColor
124 | {
125 | get
126 | {
127 | return backNormalColor;
128 | }
129 | set
130 | {
131 | backNormalColor = value;
132 | this.BackColor = value;
133 | }
134 | }
135 | ///
136 | /// 控件属性:
137 | /// 获取或设置出错情况下的背景色
138 | ///
139 | /// 默认为:"255,211,115"
140 | private Color backErrorColor;
141 | [DefaultValue("255,211,115")]
142 | public Color BackErrorColor
143 | {
144 | get { return backErrorColor; }
145 | set { backErrorColor = value; }
146 | }
147 | ///
148 | /// 控件属性:
149 | /// 获取或设置下拉边框颜色
150 | ///
151 | /// 默认为:"179, 179, 179"
152 | [DefaultValue("179, 179, 179")]
153 | public Color DropDownBorderColor
154 | {
155 | get
156 | {
157 | if (host == null)
158 | return Color.Empty;
159 | return host.BorderColor;
160 |
161 | }
162 | set
163 | {
164 | if (host != null)
165 | {
166 | host.BorderColor = value;
167 | }
168 | }
169 | }
170 |
171 |
172 | ///
173 | /// 构造函数:
174 | /// 创建,WSNTimeSlidePicker
175 | ///
176 | public WSNTimeSlidePicker()
177 | {
178 | bar = new WSNTrackBar.WSNTrackBar();
179 | bar.Minimum = 0;
180 | bar.Maximum = 24 * 60 * 60-1;
181 | bar.SmallChange = 60;
182 | BackErrorColor = Color.FromArgb(255, 211, 115);
183 | backNormalColor = Color.White;
184 |
185 | timer = new Timer();
186 | timer.Interval = 200;
187 | BlinkTotalCount = 6;
188 | timer.Tick += new EventHandler(timer_Tick);
189 | blinkCount = 0;
190 |
191 | //this.bar.Value = 0;
192 |
193 | bar.Orientation = Orientation.Vertical;
194 | host = new WSNPopupControlHost.WSNPopupControlHost(bar);
195 | //host.ChangeRegion = true;//设置显示区域。
196 |
197 | //host.Opacity = 0.8F;//设置透明度。
198 | host.CanResize = false;//设置可以改变大小。
199 | host.OpenFocused = false;//把焦点设置到弹出窗体上。
200 | host.AutoClose = false;
201 |
202 | this.Click += new EventHandler(WSNTimeSlidePicker_Click);
203 | bar.ValueChanged += new EventHandler(bar_ValueChanged);
204 | this.Validating += new System.ComponentModel.CancelEventHandler(WSNTimeSlidePicker_Validating);
205 | this.TextChanged += new EventHandler(WSNTimeSlidePicker_TextChanged);
206 | this.Text = "23:59:59";
207 |
208 | }
209 |
210 | void timer_Tick(object sender, EventArgs e)
211 | {
212 | blinkCount++;
213 | if (blinkCount > BlinkTotalCount)
214 | {
215 | StopBlink();
216 |
217 | }
218 | else
219 | {
220 | blink = !blink;
221 | this.BackColor = blink ? BackNormalColor : BackErrorColor;
222 | }
223 | }
224 |
225 | void WSNTimeSlidePicker_TextChanged(object sender, EventArgs e)
226 | {
227 | bool b = IsTime(this.Text.Trim());
228 | if (!b)
229 | {
230 | StartBlink();
231 | }
232 | else
233 | {
234 | this.bar.Value = Time2TrackValue(this.Text);
235 |
236 | }
237 | }
238 | private void StopBlink()
239 | {
240 | timer.Enabled = false;
241 | this.BackColor = BackNormalColor;
242 | }
243 | private void StartBlink()
244 | {
245 | timer.Enabled = true;
246 | blinkCount = 0;
247 | blink = true;
248 | }
249 |
250 | void WSNTimeSlidePicker_Validating(object sender, System.ComponentModel.CancelEventArgs e)
251 | {
252 | bool b = IsTime(this.Text.Trim());
253 | if (!b)
254 | {
255 | StartBlink();
256 | e.Cancel = true;
257 | }
258 |
259 | }
260 |
261 | void bar_ValueChanged(object sender, EventArgs e)
262 | {
263 | int v = bar.Value;
264 | //if (v == bar.Maximum)
265 | // v = 0;
266 | this.Text = TrackValue2Time(v);
267 | }
268 |
269 | private string TrackValue2Time(int value)
270 | {
271 | int h = value / (60 * 60);
272 | int m = (value % (60 * 60)) / 60;
273 | int s = value % (60 * 60) % 60;
274 |
275 | return string.Format("{0:D2}:{1:D2}:{2:D2}", h, m, s);
276 |
277 | }
278 | private int Time2TrackValue(string time)
279 | {
280 |
281 | try
282 | {
283 | string[] strs = time.Split(':');
284 | int h = int.Parse(strs[0]);
285 | int m = int.Parse(strs[1]);
286 | int s = int.Parse(strs[2]);
287 | return h * 60 * 60 + m * 60 + s;
288 | }
289 | catch
290 | {
291 | return 0;
292 | }
293 |
294 | }
295 |
296 | void WSNTimeSlidePicker_Click(object sender, EventArgs e)
297 | {
298 | ShowDropDown();
299 | }
300 |
301 | ///
302 | /// 显示下拉选项
303 | ///
304 | public void ShowDropDown()
305 | {
306 | Point thisP = this.Location;
307 | host.Show(this, new Point(this.Width, -bar.Height / 4));
308 | if (this.hook == null)
309 | {
310 | this.hook = new TimeSlideHook(this);
311 | if (this.Parent != null)
312 | {
313 | this.hook.AssignHandle(this.Parent.Handle);
314 | }
315 | }
316 | }
317 |
318 |
319 |
320 |
321 |
322 | public void HideDropDown()
323 | {
324 |
325 | if (this.hook != null)
326 | this.hook.ReleaseHandle();
327 | this.hook = null;
328 | host.Close();
329 | }
330 | ///
331 | /// 是否为时间型字符串
332 | ///
333 | /// 时间字符串(15:00:00)
334 | ///
335 | public static bool IsTime(string StrSource)
336 | {
337 | return Regex.IsMatch(
338 | StrSource,
339 | @"^((20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d)$");
340 | }
341 | }
342 | }
343 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNPanel/WSNPanel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Drawing.Drawing2D;
7 | using System.Drawing;
8 | using System.ComponentModel;
9 |
10 | namespace WSN.Ants.Controls.WSNPanel
11 | {
12 | ///
13 | /// WSN控件:
14 | /// WSNPanel面板
15 | ///
16 | ///
17 | /// 以下示例展示如何使用WSNPanel
18 | ///
19 | ///
20 | public class WSNPanel : Panel
21 | {
22 | #region 字段
23 | private FaceStyle controlSchema=new FaceStyle();
24 | private RoundStyle roundStyle = RoundStyle.All;
25 | private int radius = 8;
26 |
27 | #endregion
28 |
29 | #region 属性
30 | ///
31 | /// 控件属性:
32 | /// 获取或设置圆角半径
33 | ///
34 | /// 默认为:8
35 | [DefaultValue(8)]
36 | public int Radius
37 | {
38 | get { return radius; }
39 | set
40 | {
41 | if (radius != value)
42 | {
43 | radius = value < 4 ? 4 : value;
44 | SetReion();
45 | base.Invalidate();
46 | }
47 | }
48 | }
49 | ///
50 | /// 控件属性:
51 | /// 获取或设置圆角样式
52 | ///
53 | /// 默认为:四个角都是圆角
54 | [DefaultValue(typeof(RoundStyle), "1")]
55 | public RoundStyle RoundStyle
56 | {
57 | get { return roundStyle; }
58 | set
59 | {
60 | if (roundStyle != value)
61 | {
62 | roundStyle = value;
63 | SetReion();
64 | base.Invalidate();
65 | }
66 | }
67 | }
68 | ///
69 | /// 控件属性:
70 | /// 获取或设置控件外观样式 FaceStyle
71 | ///
72 | public FaceStyle ControlSchema
73 | {
74 | get { return controlSchema; }
75 | set { controlSchema = value; }
76 | }
77 | #endregion
78 |
79 | #region 构造函数
80 | ///
81 | /// 创建WSNPanel面板
82 | ///
83 | public WSNPanel()
84 | {
85 | SetStyle(ControlStyles.UserPaint, true);
86 | SetStyle(ControlStyles.AllPaintingInWmPaint, true);
87 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
88 | SetStyle(ControlStyles.ResizeRedraw, true);
89 | SetStyle(ControlStyles.SupportsTransparentBackColor, true);
90 | BackColor = Color.Transparent;
91 |
92 | InitColor();
93 | }
94 | #endregion
95 |
96 | #region 私有方法
97 |
98 | private void InitColor()
99 | {
100 | controlSchema.BackNormalStyle.Color1 = Color.FromArgb(255, 255, 255);
101 | controlSchema.BackNormalStyle.Color2 = Color.FromArgb(215, 215, 215);
102 | controlSchema.BackNormalStyle.Mode = LinearGradientMode.Vertical;
103 |
104 | controlSchema.BorderNormalStyle.Color1 = Color.FromArgb(179, 179, 179);
105 | controlSchema.BorderNormalStyle.Color2 = Color.Empty;
106 |
107 |
108 | }
109 | private void SetReion()
110 | {
111 |
112 | if (base.Region != null)
113 | {
114 | base.Region.Dispose();
115 | }
116 | using (GraphicsPath path =
117 | GraphicsPathHelper.CreatePath(ClientRectangle, Radius, RoundStyle, false))
118 | {
119 | base.Region = new Region(path);
120 | }
121 |
122 | }
123 |
124 | #endregion
125 |
126 | #region 重载方法
127 | protected override void OnCreateControl()
128 | {
129 | base.OnCreateControl();
130 | SetReion();
131 | }
132 |
133 | protected override void OnSizeChanged(EventArgs e)
134 | {
135 | base.OnSizeChanged(e);
136 | SetReion();
137 | }
138 | protected override void OnPaint(PaintEventArgs e)
139 | {
140 | //base.OnPaint(e);
141 | Graphics g = e.Graphics;
142 | g.SmoothingMode = SmoothingMode.HighQuality;
143 |
144 |
145 | using (GraphicsPath path =
146 | GraphicsPathHelper.CreatePath(ClientRectangle, Radius, RoundStyle, false))
147 | {
148 | if (controlSchema.BackNormalStyle.Color2 != Color.Empty
149 | && controlSchema.BackNormalStyle.Color1 != controlSchema.BackNormalStyle.Color2)
150 | {
151 | if (ClientRectangle.Width > 0 && ClientRectangle.Height > 0)
152 | {
153 | using (LinearGradientBrush br = new LinearGradientBrush(ClientRectangle, controlSchema.BackNormalStyle.Color1, controlSchema.BackNormalStyle.Color2, controlSchema.BackNormalStyle.Mode))
154 | {
155 | g.FillPath(br, path);
156 | }
157 | }
158 | }
159 | else
160 | {
161 | using (SolidBrush br = new SolidBrush(controlSchema.BackNormalStyle.Color1))
162 | {
163 | g.FillPath(br, path);
164 | }
165 |
166 | }
167 |
168 | }
169 |
170 |
171 | #region 画border
172 | Rectangle r = ClientRectangle;
173 | //r.Width -= 1;
174 | //r.Height -= 1;
175 | using (GraphicsPath path =
176 | GraphicsPathHelper.CreatePath(r, Radius, RoundStyle, true))
177 | {
178 | using (Pen p = new Pen(controlSchema.BorderNormalStyle.Color1))
179 | {
180 |
181 | g.DrawPath(p, path);
182 | }
183 | }
184 |
185 | if (controlSchema.BorderNormalStyle.Color2 != Color.Empty
186 | && controlSchema.BorderNormalStyle.Color2 != controlSchema.BorderNormalStyle.Color1)
187 | {
188 | r.Inflate(-1, -1);
189 | using (GraphicsPath path = GraphicsPathHelper.CreatePath(
190 | r, radius, roundStyle, true))
191 | {
192 | using (Pen pen = new Pen(controlSchema.BorderNormalStyle.Color2))
193 | {
194 | g.DrawPath(pen, path);
195 | }
196 | }
197 | }
198 | #endregion
199 |
200 |
201 | #region 画背景图片
202 | if(BackgroundImage!=null)
203 | {
204 | switch (BackgroundImageLayout)
205 | {
206 | case ImageLayout.None:
207 | g.DrawImageUnscaled(BackgroundImage,
208 | ClientRectangle.X,
209 | ClientRectangle.Y,
210 | BackgroundImage.Width,
211 | BackgroundImage.Height);
212 | break;
213 | case ImageLayout.Tile:
214 | using (TextureBrush Txbrus = new TextureBrush(BackgroundImage))
215 | {
216 | Txbrus.WrapMode = WrapMode.Tile;
217 |
218 | g.FillRectangle(Txbrus, new Rectangle(0, 0, ClientRectangle.Width - 1, ClientRectangle.Height - 1));
219 |
220 | }
221 | break;
222 | case ImageLayout.Center:
223 |
224 | int xx = (ClientRectangle.Width - BackgroundImage.Width) / 2;
225 | int yy = (ClientRectangle.Height - BackgroundImage.Height) / 2;
226 | g.DrawImage(BackgroundImage, new Rectangle(xx, yy, BackgroundImage.Width, BackgroundImage.Height), new Rectangle(0, 0, BackgroundImage.Width, BackgroundImage.Height), GraphicsUnit.Pixel);
227 |
228 |
229 |
230 | break;
231 | case ImageLayout.Stretch:
232 |
233 | g.DrawImage(BackgroundImage, new Rectangle(0, 0, ClientRectangle.Width, ClientRectangle.Height), new Rectangle(0, 0, BackgroundImage.Width, BackgroundImage.Height), GraphicsUnit.Pixel);
234 |
235 |
236 | break;
237 |
238 | case ImageLayout.Zoom:
239 | {
240 | double tm = 0.0;
241 | int W = BackgroundImage.Width;
242 | int H = BackgroundImage.Height;
243 | if (W > ClientRectangle.Width)
244 | {
245 | tm = ClientRectangle.Width / BackgroundImage.Width;
246 | W = (int)(W * tm);
247 | H = (int)(H * tm);
248 | }
249 | if (H > ClientRectangle.Height)
250 | {
251 | tm = ClientRectangle.Height / H;
252 | W = (int)(W * tm);
253 | H = (int)(H * tm);
254 | }
255 | using (Bitmap tmpBP = new Bitmap(W, H))
256 | {
257 | using (Graphics G2 = Graphics.FromImage(tmpBP))
258 | {
259 | G2.DrawImage(BackgroundImage, new Rectangle(0, 0, W, H), new Rectangle(0, 0, BackgroundImage.Width, BackgroundImage.Height), GraphicsUnit.Pixel);
260 |
261 | int xxx = (ClientRectangle.Width - W) / 2;
262 | int yyy = (ClientRectangle.Height - H) / 2;
263 | g.DrawImage(tmpBP, new Rectangle(xxx, yyy, W, H), new Rectangle(0, 0, W, H), GraphicsUnit.Pixel);
264 |
265 | }
266 | }
267 | }
268 | break;
269 |
270 | }
271 |
272 | }
273 |
274 | #endregion
275 |
276 |
277 | }
278 | #endregion
279 |
280 | }
281 | }
282 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNTipForm/WSNTipForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using System.Drawing.Drawing2D;
10 |
11 | namespace WSN.Ants.Controls.WSNTipForm
12 | {
13 | ///
14 | /// WSN控件:
15 | /// WSNTipForm
16 | ///
17 | ///
18 | /// 以下示例展示如何使用WSNTipForm
19 | ///
20 | ///
21 | public partial class WSNTipForm : Form
22 | {
23 | #region 常量
24 | const int WM_MOUSEACTIVATE = 0x21;
25 | const int MA_NOACTIVATE = 3;
26 |
27 | const int WM_NCHITTEST = 0x0084;
28 | const int HTCAPTION = 2;
29 | const int HTCLIENT = 1;
30 |
31 |
32 |
33 | //
34 | // non client mouse
35 | const int WM_NCMOUSEMOVE = 0x00A0;
36 | const int WM_NCLBUTTONDOWN = 0x00A1;
37 | const int WM_NCLBUTTONUP = 0x00A2;
38 | const int WM_NCLBUTTONDBLCLK = 0x00A3;
39 | const int WM_NCRBUTTONDOWN = 0x00A4;
40 | const int WM_NCRBUTTONUP = 0x00A5;
41 | const int WM_NCRBUTTONDBLCLK = 0x00A6;
42 | const int WM_NCMBUTTONDOWN = 0x00A7;
43 | const int WM_NCMBUTTONUP = 0x00A8;
44 | const int WM_NCMBUTTONDBLCLK = 0x00A9;
45 | #endregion
46 |
47 | #region 字段
48 |
49 | private bool closeBox = true;
50 | private Size closeBoxOffset = new Size(5, 5);
51 |
52 | private int radius = 4;
53 | private bool autoClose = false;
54 | private int interval = 1000;
55 |
56 | private Color borderColor = Color.FromArgb(179, 179, 179);
57 | private BrushParameter backColorSchma = new BrushParameter(Color.FromArgb(255, 255, 255), Color.FromArgb(221, 221, 221), LinearGradientMode.Vertical);
58 |
59 | public BrushParameter BackColorSchma
60 | {
61 | get { return backColorSchma; }
62 | set { backColorSchma = value; }
63 | }
64 |
65 | public Color BorderColor
66 | {
67 | get { return borderColor; }
68 | set { borderColor = value; }
69 | }
70 | #endregion
71 |
72 | #region 属性
73 | ///
74 | /// 控件属性:
75 | /// 获取或设置时间间隔(以毫秒为单位)。
76 | ///
77 | /// 默认为:1000
78 | [DefaultValue("1000")]
79 | public int Interval
80 | {
81 | get { return interval; }
82 | set { interval = value; timer1.Interval = Interval; }
83 | }
84 | ///
85 | /// 控件属性:
86 | /// 获取或设置是否自动关闭
87 | ///
88 | /// 默认为:false
89 | [DefaultValue(false)]
90 | public bool AutoClose
91 | {
92 | get { return autoClose; }
93 | set { autoClose = value; }
94 | }
95 |
96 | ///
97 | /// 控件属性:
98 | /// 获取或设置窗体边框样式
99 | ///
100 | public new FormBorderStyle FormBorderStyle
101 | {
102 | get
103 | {
104 | return base.FormBorderStyle;
105 | }
106 | set
107 | {
108 | base.FormBorderStyle = FormBorderStyle.None;
109 | }
110 | }
111 | ///
112 | /// 控件属性:
113 | /// 获取或设置圆角半径
114 | ///
115 | /// 值大于等于2,小于2的值会自动更改为2
116 | public int Radius
117 | {
118 | get { return radius; }
119 | set
120 | {
121 | if (radius != value)
122 | {
123 | radius = value < 2 ? 2 : value;
124 | SetReion();
125 | base.Invalidate();
126 | }
127 | }
128 | }
129 | ///
130 | /// 控件属性:
131 | /// 获取或设置关闭按钮的偏移位置
132 | ///
133 | public Size CloseBoxOffset
134 | {
135 | get { return closeBoxOffset; }
136 | set { closeBoxOffset = value; }
137 | }
138 | ///
139 | /// 控件属性:
140 | /// 获取或设置是否显示关闭按钮
141 | ///
142 | public bool CloseBox
143 | {
144 | get { return closeBox; }
145 | set { closeBox = value; closeButton.Visible = closeBox; }
146 | }
147 | #endregion
148 |
149 | #region 构造函数
150 | ///
151 | /// 构造函数:
152 | /// 创建WSNTipForm
153 | ///
154 | public WSNTipForm()
155 | {
156 | InitializeComponent();
157 | SetStyles();
158 | Init();
159 | }
160 | #endregion
161 |
162 | #region 私有方法
163 | private void WSNTipForm_Shown(object sender, EventArgs e)
164 | {
165 | timer1.Enabled = autoClose;
166 | }
167 |
168 | private void timer1_Tick(object sender, EventArgs e)
169 | {
170 | timer1.Enabled = false;
171 | Close();
172 | }
173 |
174 | private void SetStyles()
175 | {
176 | this.SetStyle(ControlStyles.UserPaint, true);
177 | this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
178 | this.SetStyle(ControlStyles.ResizeRedraw, true);
179 | this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
180 | this.SetStyle(ControlStyles.ContainerControl, true);
181 |
182 |
183 |
184 | }
185 | private void Init()
186 | {
187 | this.ShowInTaskbar = false;
188 | //this.TopMost = true;
189 |
190 | SetCloseButton();
191 |
192 |
193 | base.FormBorderStyle = FormBorderStyle.None;
194 | base.ControlBox = false;
195 | base.MaximizeBox = false;
196 | base.MinimizeBox = false;
197 |
198 | }
199 |
200 |
201 |
202 | protected void SetCloseButton()
203 | {
204 | closeButton.Visible = CloseBox;
205 | closeButton.Width = 26;
206 | closeButton.Height = 25;
207 | closeButton.ImageTable.ImageNormal = new Bitmap(typeof(WSNTipForm), "closeN.png");
208 | closeButton.ImageTable.ImageHover = new Bitmap(typeof(WSNTipForm), "closeH.png");
209 | closeButton.ImageTable.ImageChecked = closeButton.ImageTable.ImageHover;
210 | closeButton.ImageTable.ImageDisalbed = closeButton.ImageTable.ImageNormal;
211 |
212 | closeButton.Location = new Point(this.Width - closeButton.Width - CloseBoxOffset.Width - 5, CloseBoxOffset.Height);
213 |
214 | }
215 |
216 | void closeButton_Click(object sender, EventArgs e)
217 | {
218 | timer1.Enabled = false;
219 | this.Close();
220 | }
221 | protected void SetReion()
222 | {
223 |
224 | if (base.Region != null)
225 | {
226 | base.Region.Dispose();
227 | }
228 | base.Region = CreateRegion();
229 | }
230 |
231 | protected Region CreateRegion()
232 | {
233 | Rectangle rect = ClientRectangle;
234 |
235 | using (GraphicsPath path = CreatePath(
236 | rect,
237 | Radius))
238 | {
239 | return new Region(path);
240 | }
241 | }
242 |
243 | protected GraphicsPath CreatePath(Rectangle rect, int radius)
244 | {
245 | GraphicsPath path = new GraphicsPath();
246 | path.AddLine(new Point(rect.X, rect.Y + radius), new Point(rect.X + radius, rect.Y));
247 | path.AddLine(new Point(rect.X + radius, rect.Y), new Point(rect.Right - radius, rect.Y));
248 | path.AddLine(new Point(rect.Right - radius, rect.Y), new Point(rect.Right, rect.Y + radius));
249 | path.AddLine(new Point(rect.Right, rect.Y + radius), new Point(rect.Right, rect.Bottom - radius));
250 | path.AddLine(new Point(rect.Right, rect.Bottom - radius), new Point(rect.Right - radius, rect.Bottom));
251 | path.AddLine(new Point(rect.Right - radius, rect.Bottom), new Point(rect.X + radius, rect.Bottom));
252 | path.AddLine(new Point(rect.X + radius, rect.Bottom), new Point(rect.X, rect.Bottom - radius));
253 | path.AddLine(new Point(rect.X, rect.Bottom - radius), new Point(rect.X, rect.Y + radius));
254 | path.CloseFigure();
255 |
256 | return path;
257 | }
258 | #endregion
259 |
260 | #region 重载方法
261 | protected override void OnCreateControl()
262 | {
263 | base.OnCreateControl();
264 | SetReion();
265 | }
266 |
267 | protected override void OnSizeChanged(EventArgs e)
268 | {
269 | base.OnSizeChanged(e);
270 | SetReion();
271 | closeButton.Location = new Point(this.Width - closeButton.Width - CloseBoxOffset.Width - 5, CloseBoxOffset.Height);
272 | }
273 | protected override void OnPaint(PaintEventArgs e)
274 | {
275 |
276 | Graphics g = e.Graphics;
277 | g.SmoothingMode = SmoothingMode.AntiAlias;
278 | Rectangle rect = ClientRectangle;
279 | if (ClientRectangle.Height > 0 && ClientRectangle.Width > 0)
280 | {
281 | using (LinearGradientBrush br = new LinearGradientBrush(ClientRectangle, backColorSchma.Color1, backColorSchma.Color2, backColorSchma.Mode))
282 | {
283 | g.FillRectangle(br, rect);
284 | }
285 | }
286 | using (Pen pen = new Pen(borderColor))
287 | {
288 | Rectangle r = rect;
289 | r.Width -= 1; r.Height -= 1;
290 | using (GraphicsPath path = CreatePath(r, Radius))
291 | {
292 | g.DrawPath(pen, path);
293 | }
294 | }
295 |
296 | }
297 |
298 | protected override void WndProc(ref Message m)
299 | {
300 | if (m.Msg == WM_MOUSEACTIVATE)
301 | {
302 | m.Result = new System.IntPtr(MA_NOACTIVATE);
303 | return;
304 | }
305 |
306 |
307 |
308 | switch (m.Msg)
309 | {
310 | case WM_NCHITTEST:
311 | base.WndProc(ref m);
312 | if (m.Result == (IntPtr)HTCLIENT)
313 | m.Result = (IntPtr)HTCAPTION;
314 |
315 | break;
316 | case WM_NCLBUTTONDBLCLK:
317 | case WM_NCRBUTTONDOWN:
318 | case WM_NCRBUTTONUP:
319 | case WM_NCRBUTTONDBLCLK:
320 | case WM_NCMBUTTONDBLCLK:
321 | break;
322 | default:
323 | base.WndProc(ref m);
324 | break;
325 |
326 | }
327 |
328 | }
329 | #endregion
330 |
331 |
332 |
333 |
334 |
335 | }
336 |
337 | }
338 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNRadioButton/WSNRadioButton.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using System.Windows.Forms;
7 | using System.Drawing.Drawing2D;
8 |
9 |
10 | namespace WSN.Ants.Controls.WSNRadioButton
11 | {
12 | ///
13 | /// WSN控件:
14 | /// WSNRadioButton按钮
15 | ///
16 | ///
17 | /// 以下示例展示如何使用WSNRadioButton
18 | ///
19 | ///
20 | public class WSNRadioButton : RadioButton
21 | {
22 |
23 | #region 字段
24 | private ControlState _controlState;
25 |
26 | private Cursor _oldCursor;
27 | private static readonly ContentAlignment RightAlignment =
28 | ContentAlignment.TopRight |
29 | ContentAlignment.BottomRight |
30 | ContentAlignment.MiddleRight;
31 | private static readonly ContentAlignment LeftAligbment =
32 | ContentAlignment.TopLeft |
33 | ContentAlignment.BottomLeft |
34 | ContentAlignment.MiddleLeft;
35 |
36 |
37 |
38 | private CheckImageTable _checkImageTable = new CheckImageTable();
39 |
40 |
41 | #endregion
42 |
43 | #region 属性
44 | ///
45 | /// 控件属性:
46 | /// 获取或设置按钮显示图片列表
47 | ///
48 | public CheckImageTable CheckImageTable
49 | {
50 | get { return _checkImageTable; }
51 | set { _checkImageTable = value; }
52 | }
53 |
54 |
55 |
56 |
57 | ///
58 | /// 控件属性:
59 | /// 获取或设置控件状态
60 | ///
61 | internal ControlState ControlState
62 | {
63 | get { return _controlState; }
64 | set { _controlState = value; }
65 | }
66 | protected virtual int DefaultCheckButtonWidth
67 | {
68 | get { return 16; }
69 | }
70 | #endregion
71 |
72 | #region 构造函数
73 | ///
74 | /// 创建WSNRadioButton
75 | ///
76 | public WSNRadioButton()
77 | : base()
78 | {
79 |
80 | SetStyle(
81 | ControlStyles.UserPaint |
82 | ControlStyles.AllPaintingInWmPaint |
83 | ControlStyles.OptimizedDoubleBuffer |
84 | ControlStyles.ResizeRedraw |
85 | ControlStyles.SupportsTransparentBackColor, true);
86 | this.BackColor = Color.Transparent;
87 |
88 | //载入图片
89 | CheckImageTable.CheckedImage = new Bitmap(typeof(WSNRadioButton), "Check_c.png");
90 | CheckImageTable.CheckedImageDisabled = new Bitmap(typeof(WSNRadioButton), "Check_c_d.png");
91 |
92 | CheckImageTable.UnCheckedImage = new Bitmap(typeof(WSNRadioButton), "Check.png");
93 | CheckImageTable.UnCheckedImageDisabled = new Bitmap(typeof(WSNRadioButton), "Check_d.png");
94 |
95 | ControlState = ControlState.Normal;
96 | _oldCursor = this.Cursor;
97 | }
98 |
99 |
100 | #endregion
101 |
102 | #region 重载方法
103 | protected override void OnMouseEnter(EventArgs e)
104 | {
105 | base.OnMouseEnter(e);
106 | _oldCursor = this.Cursor;
107 | ControlState = ControlState.Hover;
108 | Cursor = Cursors.Hand;
109 |
110 | }
111 |
112 |
113 | protected override void OnMouseLeave(EventArgs e)
114 | {
115 | base.OnMouseLeave(e);
116 | ControlState = ControlState.Normal;
117 | Cursor = _oldCursor;
118 | }
119 |
120 | protected override void OnMouseDown(MouseEventArgs e)
121 | {
122 | base.OnMouseDown(e);
123 | if (e.Button == MouseButtons.Left && e.Clicks == 1)
124 | {
125 | ControlState = ControlState.Pressed;
126 | }
127 | //Checked = !Checked;
128 | this.Invalidate();
129 | }
130 |
131 | protected override void OnMouseUp(MouseEventArgs e)
132 | {
133 | base.OnMouseUp(e);
134 | if (e.Button == MouseButtons.Left && e.Clicks == 1)
135 | {
136 | if (ClientRectangle.Contains(e.Location))
137 | {
138 | ControlState = ControlState.Hover;
139 | }
140 | else
141 | {
142 | ControlState = ControlState.Normal;
143 | }
144 | }
145 | }
146 |
147 |
148 | protected override void OnPaint(PaintEventArgs e)
149 | {
150 | base.OnPaint(e);
151 | base.OnPaintBackground(e);
152 |
153 | Graphics g = e.Graphics;
154 | Rectangle checkButtonRect;
155 | Rectangle textRect;
156 |
157 |
158 | g.SmoothingMode = SmoothingMode.AntiAlias;
159 | CalculateRect(out checkButtonRect, out textRect);
160 |
161 |
162 | //开始画UI元素
163 | Image img = CheckImageTable.UnCheckedImage;
164 | if (Enabled)
165 | {
166 | img = Checked ? CheckImageTable.CheckedImage : CheckImageTable.UnCheckedImage;
167 | }
168 | else
169 | {
170 | img = Checked ? CheckImageTable.CheckedImageDisabled : CheckImageTable.UnCheckedImageDisabled;
171 | }
172 | if (img != null)
173 | {
174 |
175 | //g.DrawImageUnscaled(img, base.ClientRectangle.X, base.ClientRectangle.Y, img.Width, img.Height);
176 | g.DrawImageUnscaled(img, checkButtonRect);
177 | }
178 |
179 |
180 |
181 | Color textColor = Enabled ? ForeColor : SystemColors.GrayText;
182 | TextRenderer.DrawText(
183 | g,
184 | Text,
185 | Font,
186 | textRect,
187 | textColor,
188 | GetTextFormatFlags(TextAlign, RightToLeft == RightToLeft.Yes));
189 |
190 |
191 |
192 | }
193 |
194 | #endregion
195 |
196 | #region 私有方法
197 | private void CalculateRect(
198 | out Rectangle checkButtonRect, out Rectangle textRect)
199 | {
200 | checkButtonRect = new Rectangle(
201 | 0, 0, DefaultCheckButtonWidth, DefaultCheckButtonWidth);
202 | textRect = Rectangle.Empty;
203 | bool bCheckAlignLeft = (int)(LeftAligbment & CheckAlign) != 0;
204 | bool bCheckAlignRight = (int)(RightAlignment & CheckAlign) != 0;
205 | bool bRightToLeft = RightToLeft == RightToLeft.Yes;
206 |
207 |
208 |
209 | if ((bCheckAlignLeft && !bRightToLeft) ||
210 | (bCheckAlignRight && bRightToLeft))
211 | {
212 | switch (CheckAlign)
213 | {
214 | case ContentAlignment.TopRight:
215 | case ContentAlignment.TopLeft:
216 | checkButtonRect.Y = 2;
217 | break;
218 | case ContentAlignment.MiddleRight:
219 | case ContentAlignment.MiddleLeft:
220 | checkButtonRect.Y = (Height - DefaultCheckButtonWidth) / 2;
221 | break;
222 | case ContentAlignment.BottomRight:
223 | case ContentAlignment.BottomLeft:
224 | checkButtonRect.Y = Height - DefaultCheckButtonWidth - 2;
225 | break;
226 | }
227 |
228 | checkButtonRect.X = 0;
229 |
230 | textRect = new Rectangle(
231 | checkButtonRect.Right + 2,
232 | 0,
233 | Width - checkButtonRect.Right - 4,
234 | Height);
235 | }
236 | else if ((bCheckAlignRight && !bRightToLeft)
237 | || (bCheckAlignLeft && bRightToLeft))
238 | {
239 | switch (CheckAlign)
240 | {
241 | case ContentAlignment.TopLeft:
242 | case ContentAlignment.TopRight:
243 | checkButtonRect.Y = 2;
244 | break;
245 | case ContentAlignment.MiddleLeft:
246 | case ContentAlignment.MiddleRight:
247 | checkButtonRect.Y = (Height - DefaultCheckButtonWidth) / 2;
248 | break;
249 | case ContentAlignment.BottomLeft:
250 | case ContentAlignment.BottomRight:
251 | checkButtonRect.Y = Height - DefaultCheckButtonWidth - 2;
252 | break;
253 | }
254 |
255 | checkButtonRect.X = Width - DefaultCheckButtonWidth - 0;
256 |
257 | textRect = new Rectangle(
258 | 2, 0, Width - DefaultCheckButtonWidth - 6, Height);
259 | }
260 | else
261 | {
262 | switch (CheckAlign)
263 | {
264 | case ContentAlignment.TopCenter:
265 | checkButtonRect.Y = 2;
266 | textRect.Y = checkButtonRect.Bottom + 2;
267 | textRect.Height = Height - DefaultCheckButtonWidth - 6;
268 | break;
269 | case ContentAlignment.MiddleCenter:
270 | checkButtonRect.Y = (Height - DefaultCheckButtonWidth) / 2;
271 | textRect.Y = 0;
272 | textRect.Height = Height;
273 | break;
274 | case ContentAlignment.BottomCenter:
275 | checkButtonRect.Y = Height - DefaultCheckButtonWidth - 2;
276 | textRect.Y = 0;
277 | textRect.Height = Height - DefaultCheckButtonWidth - 6;
278 | break;
279 | }
280 |
281 | checkButtonRect.X = (Width - DefaultCheckButtonWidth) / 2;
282 |
283 | textRect.X = 2;
284 | textRect.Width = Width - 4;
285 | }
286 | }
287 | internal static TextFormatFlags GetTextFormatFlags(
288 | ContentAlignment alignment,
289 | bool rightToleft)
290 | {
291 | TextFormatFlags flags = TextFormatFlags.WordBreak |
292 | TextFormatFlags.SingleLine;
293 | if (rightToleft)
294 | {
295 | flags |= TextFormatFlags.RightToLeft | TextFormatFlags.Right;
296 | }
297 |
298 | switch (alignment)
299 | {
300 | case ContentAlignment.BottomCenter:
301 | flags |= TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter;
302 | break;
303 | case ContentAlignment.BottomLeft:
304 | flags |= TextFormatFlags.Bottom | TextFormatFlags.Left;
305 | break;
306 | case ContentAlignment.BottomRight:
307 | flags |= TextFormatFlags.Bottom | TextFormatFlags.Right;
308 | break;
309 | case ContentAlignment.MiddleCenter:
310 | flags |= TextFormatFlags.HorizontalCenter |
311 | TextFormatFlags.VerticalCenter;
312 | break;
313 | case ContentAlignment.MiddleLeft:
314 | flags |= TextFormatFlags.VerticalCenter | TextFormatFlags.Left;
315 | break;
316 | case ContentAlignment.MiddleRight:
317 | flags |= TextFormatFlags.VerticalCenter | TextFormatFlags.Right;
318 | break;
319 | case ContentAlignment.TopCenter:
320 | flags |= TextFormatFlags.Top | TextFormatFlags.HorizontalCenter;
321 | break;
322 | case ContentAlignment.TopLeft:
323 | flags |= TextFormatFlags.Top | TextFormatFlags.Left;
324 | break;
325 | case ContentAlignment.TopRight:
326 | flags |= TextFormatFlags.Top | TextFormatFlags.Right;
327 | break;
328 | }
329 | return flags;
330 | }
331 | #endregion
332 |
333 | }
334 | }
335 |
--------------------------------------------------------------------------------
/WSN.Ants.Controls/WSNTabControl/WSNTabControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Drawing;
7 | using System.ComponentModel;
8 | using System.ComponentModel.Design;
9 | using System.Drawing.Design;
10 |
11 | namespace WSN.Ants.Controls.WSNTabControl
12 | {
13 | ///
14 | /// WSN控件:
15 | /// WSNTabControl
16 | ///
17 | ///
18 | /// 以下示例展示如何使用WSNTabControl
19 | ///
20 | ///
21 | [ToolboxBitmap(typeof(System.Windows.Forms.TabControl))]
22 | public class WSNTabControl : TabControl
23 | {
24 | #region 字段
25 | ///
26 | /// Required designer variable.
27 | ///
28 | private System.ComponentModel.Container components = null;
29 | private SubClass scUpDown = null;
30 | private bool bUpDown; // true when the button UpDown is required
31 | //private ImageList leftRightImages = null;
32 | private const int nMargin = 5;
33 |
34 | private WSNTabControlRender _render;
35 |
36 | #endregion
37 |
38 | #region 属性
39 | ///
40 | /// 控件属性:
41 | /// 获取WSNTabControl的子页面
42 | ///
43 | [Editor(typeof(TabpageExCollectionEditor), typeof(UITypeEditor))]
44 | public new TabPageCollection TabPages
45 | {
46 | get
47 | {
48 | return base.TabPages;
49 | }
50 | }
51 | ///
52 | /// 控件属性:
53 | /// 获取或设置是否可以显示一行以上选项卡
54 | ///
55 | [Browsable(false)]
56 | new public bool Multiline
57 | {
58 | get { return base.Multiline; }
59 | set { base.Multiline = false; }
60 | }
61 | ///
62 | /// 控件属性:
63 | /// 获取或设置WSNTabControl的渲染器
64 | ///
65 | public WSNTabControlRender Render
66 | {
67 | get
68 | {
69 | if (_render == null)
70 | {
71 | _render = new WSNTabControlRender(this);
72 | }
73 | return _render;
74 |
75 | }
76 | set
77 | {
78 | _render = value;
79 | this.Invalidate();
80 | }
81 | }
82 |
83 | #endregion
84 |
85 | #region 构造函数
86 | ///
87 | /// 创建WSNTabControl
88 | ///
89 | public WSNTabControl()
90 | {
91 | // This call is required by the Windows.Forms Form Designer.
92 | InitializeComponent();
93 |
94 | // double buffering
95 |
96 | this.SetStyle(ControlStyles.UserPaint, true);
97 | this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
98 | this.SetStyle(ControlStyles.DoubleBuffer, true);
99 | this.SetStyle(ControlStyles.ResizeRedraw, true);
100 | this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
101 |
102 | bUpDown = false;
103 |
104 | this.ControlAdded += new ControlEventHandler(WSNTabControl_ControlAdded);
105 | this.ControlRemoved += new ControlEventHandler(WSNTabControl_ControlRemoved);
106 | this.SelectedIndexChanged += new EventHandler(WSNTabControl_SelectedIndexChanged);
107 |
108 | }
109 | #endregion
110 |
111 |
112 | #region 重载方法
113 | ///
114 | /// Clean up any resources being used.
115 | ///
116 | protected override void Dispose(bool disposing)
117 | {
118 | if (disposing)
119 | {
120 | if (components != null)
121 | {
122 | components.Dispose();
123 | }
124 |
125 | //leftRightImages.Dispose();
126 | }
127 | base.Dispose(disposing);
128 | }
129 | protected override void OnCreateControl()
130 | {
131 | base.OnCreateControl();
132 |
133 | FindUpDown();
134 | }
135 | protected override void OnMouseMove(MouseEventArgs e)
136 | {
137 | base.OnMouseMove(e);
138 | base.Invalidate();
139 | }
140 |
141 | protected override void OnMouseLeave(EventArgs e)
142 | {
143 | base.OnMouseLeave(e);
144 | base.Invalidate();
145 | }
146 | protected override void OnPaint(PaintEventArgs e)
147 | {
148 | base.OnPaint(e);
149 | DrawControl(e.Graphics);
150 | }
151 |
152 | internal void DrawControl(Graphics g)
153 | {
154 | if (!Visible)
155 | return;
156 |
157 | Rectangle TabControlArea = this.ClientRectangle;
158 | Rectangle TabArea = this.DisplayRectangle;
159 |
160 | // fill client area
161 | Render.RenderControlBackground(g, TabControlArea);
162 |
163 | // draw panel border
164 | //这里必须在外面inflate,否则在函数里做inflate会尺寸不对。
165 | int nDelta = SystemInformation.Border3DSize.Width;
166 | TabArea.Inflate(nDelta, nDelta);
167 |
168 | Render.RenderTabPanelBorder(g, TabArea);
169 |
170 | // clip region for drawing tabs
171 | Region rsaved = g.Clip;
172 | ClipDrawingTabsRegion(g, TabControlArea, TabArea);
173 |
174 |
175 | // draw tabs
176 | Point cursorPoint = PointToClient(MousePosition);
177 | for (int i = 0; i < this.TabCount; i++)
178 | {
179 | Point cusorPoint = PointToClient(MousePosition);
180 | Rectangle recBounds = this.GetTabRect(i);
181 | bool bHovered = recBounds.Contains(cusorPoint);
182 |
183 | Render.DrawTab(g, this.TabPages[i], i, bHovered);
184 | }
185 |
186 | g.Clip = rsaved;
187 |
188 |
189 | Render.DrawCoverBorderAreas(g, TabArea);
190 |
191 |
192 | }
193 |
194 | private void ClipDrawingTabsRegion(Graphics g, Rectangle TabControlArea, Rectangle TabArea)
195 | {
196 |
197 | Rectangle rreg = TabControlArea;
198 |
199 | int nWidth = TabArea.Width + nMargin;
200 | if (bUpDown)
201 | {
202 | // exclude updown control for painting
203 | if (Win32.IsWindowVisible(scUpDown.Handle))
204 | {
205 | Rectangle rupdown = new Rectangle();
206 | Win32.GetWindowRect(scUpDown.Handle, ref rupdown);
207 | Rectangle rupdown2 = this.RectangleToClient(rupdown);
208 |
209 | nWidth = rupdown2.X;
210 | }
211 | }
212 | //rreg = new Rectangle(TabArea.Left, TabControlArea.Top, nWidth - nMargin, TabControlArea.Height);
213 |
214 | switch (Alignment)
215 | {
216 | case TabAlignment.Top:
217 | rreg = new Rectangle(TabArea.Left, TabControlArea.Top, nWidth - nMargin, TabControlArea.Height);
218 | break;
219 | case TabAlignment.Bottom:
220 | rreg = new Rectangle(TabArea.Left, TabControlArea.Top, nWidth - nMargin, TabControlArea.Height);
221 | break;
222 | case TabAlignment.Left:
223 | rreg = TabControlArea;
224 | break;
225 | case TabAlignment.Right:
226 | rreg = TabControlArea;
227 | break;
228 |
229 | }
230 |
231 | g.SetClip(rreg);
232 |
233 |
234 | }
235 |
236 | #endregion
237 |
238 |
239 | ///
240 | /// Required method for Designer support - do not modify
241 | /// the contents of this method with the code editor.
242 | ///
243 | private void InitializeComponent()
244 | {
245 | components = new System.ComponentModel.Container();
246 | }
247 | private void WSNTabControl_SelectedIndexChanged(object sender, EventArgs e)
248 | {
249 | FindUpDown();
250 | UpdateUpDown();
251 | }
252 |
253 |
254 |
255 | private void WSNTabControl_ControlRemoved(object sender, ControlEventArgs e)
256 | {
257 | FindUpDown();
258 | UpdateUpDown();
259 | }
260 |
261 | private void WSNTabControl_ControlAdded(object sender, ControlEventArgs e)
262 | {
263 | FindUpDown();
264 | UpdateUpDown();
265 | }
266 |
267 | private void FindUpDown()
268 | {
269 | if (this == null || this.IsDisposed)
270 | return;
271 |
272 | bool bFound = false;
273 |
274 | // find the UpDown control
275 | IntPtr pWnd = Win32.GetWindow(this.Handle, Win32.GW_CHILD);
276 |
277 | while (pWnd != IntPtr.Zero)
278 | {
279 | //----------------------------
280 | // Get the window class name
281 | char[] className = new char[33];
282 |
283 | int length = Win32.GetClassName(pWnd, className, 32);
284 |
285 | string s = new string(className, 0, length);
286 | //----------------------------
287 |
288 | if (s == "msctls_updown32")
289 | {
290 | bFound = true;
291 |
292 | if (!bUpDown)
293 | {
294 | //----------------------------
295 | // Subclass it
296 | this.scUpDown = new SubClass(pWnd, true);
297 | this.scUpDown.SubClassedWndProc += new SubClass.SubClassWndProcEventHandler(scUpDown_SubClassedWndProc);
298 | //----------------------------
299 |
300 | bUpDown = true;
301 | }
302 | break;
303 | }
304 |
305 | pWnd = Win32.GetWindow(pWnd, Win32.GW_HWNDNEXT);
306 | }
307 |
308 | if ((!bFound) && (bUpDown))
309 | bUpDown = false;
310 | }
311 |
312 | private void UpdateUpDown()
313 | {
314 | if (bUpDown)
315 | {
316 | if (Win32.IsWindowVisible(scUpDown.Handle))
317 | {
318 | Rectangle rect = new Rectangle();
319 |
320 | Win32.GetClientRect(scUpDown.Handle, ref rect);
321 | Win32.InvalidateRect(scUpDown.Handle, ref rect, true);
322 | }
323 | }
324 | }
325 |
326 |
327 | #region scUpDown_SubClassedWndProc Event Handler
328 |
329 | private int scUpDown_SubClassedWndProc(ref Message m)
330 | {
331 | switch (m.Msg)
332 | {
333 | case Win32.WM_PAINT:
334 | {
335 | //------------------------
336 | // redraw
337 | IntPtr hDC = Win32.GetWindowDC(scUpDown.Handle);
338 | Graphics g = Graphics.FromHdc(hDC);
339 |
340 | Render.DrawUpDownButtonIcons(g, scUpDown);
341 |
342 | g.Dispose();
343 | Win32.ReleaseDC(scUpDown.Handle, hDC);
344 | //------------------------
345 |
346 | // return 0 (processed)
347 | m.Result = IntPtr.Zero;
348 |
349 | //------------------------
350 | // validate current rect
351 | Rectangle rect = new Rectangle();
352 |
353 | Win32.GetClientRect(scUpDown.Handle, ref rect);
354 | Win32.ValidateRect(scUpDown.Handle, ref rect);
355 | //------------------------
356 | }
357 | return 1;
358 | }
359 |
360 | return 0;
361 | }
362 |
363 | #endregion
364 |
365 | #region TabpageExCollectionEditor
366 |
367 | internal class TabpageExCollectionEditor : CollectionEditor
368 | {
369 | public TabpageExCollectionEditor(System.Type type)
370 | : base(type)
371 | {
372 | }
373 |
374 | protected override Type CreateCollectionItemType()
375 | {
376 | return typeof(TabPage);
377 | }
378 | }
379 |
380 | #endregion
381 |
382 | }
383 | }
384 |
--------------------------------------------------------------------------------