├── .gitattributes
├── .gitignore
├── DemoApp
├── App.config
├── DemoApp.csproj
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ ├── Settings.settings
│ └── app.manifest
├── Resources
│ ├── MeckEd-PayPal-donate-button.png
│ └── beg_with_border.png
├── frmAbout.Designer.cs
├── frmAbout.cs
├── frmAbout.resx
├── frmMain.Designer.cs
├── frmMain.cs
└── frmMain.resx
├── ModernUIForm.sln
├── NetDimension.WinForm
├── Internal
│ ├── ChromeDecorator.cs
│ ├── ChromeShadowElement.cs
│ └── FormChrome.cs
├── ModernUIForm.cs
├── NetDimension.WinForm.csproj
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Resources
│ └── ShadowTemplate.png
└── Utils
│ ├── FormStyleHelper.cs
│ ├── LockBitmap.cs
│ ├── Win32APIs.cs
│ ├── Win32Types.cs
│ └── WindowMessages.cs
├── README.md
└── SystemInfoPrograme
├── App.config
├── Program.cs
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── SystemInfoBrowserForm.cs
└── SystemInfoPrograme.csproj
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | project.fragment.lock.json
46 | artifacts/
47 |
48 | *_i.c
49 | *_p.c
50 | *_i.h
51 | *.ilk
52 | *.meta
53 | *.obj
54 | *.pch
55 | *.pdb
56 | *.pgc
57 | *.pgd
58 | *.rsp
59 | *.sbr
60 | *.tlb
61 | *.tli
62 | *.tlh
63 | *.tmp
64 | *.tmp_proj
65 | *.log
66 | *.vspscc
67 | *.vssscc
68 | .builds
69 | *.pidb
70 | *.svclog
71 | *.scc
72 |
73 | # Chutzpah Test files
74 | _Chutzpah*
75 |
76 | # Visual C++ cache files
77 | ipch/
78 | *.aps
79 | *.ncb
80 | *.opendb
81 | *.opensdf
82 | *.sdf
83 | *.cachefile
84 | *.VC.db
85 | *.VC.VC.opendb
86 |
87 | # Visual Studio profiler
88 | *.psess
89 | *.vsp
90 | *.vspx
91 | *.sap
92 |
93 | # TFS 2012 Local Workspace
94 | $tf/
95 |
96 | # Guidance Automation Toolkit
97 | *.gpState
98 |
99 | # ReSharper is a .NET coding add-in
100 | _ReSharper*/
101 | *.[Rr]e[Ss]harper
102 | *.DotSettings.user
103 |
104 | # JustCode is a .NET coding add-in
105 | .JustCode
106 |
107 | # TeamCity is a build add-in
108 | _TeamCity*
109 |
110 | # DotCover is a Code Coverage Tool
111 | *.dotCover
112 |
113 | # NCrunch
114 | _NCrunch_*
115 | .*crunch*.local.xml
116 | nCrunchTemp_*
117 |
118 | # MightyMoose
119 | *.mm.*
120 | AutoTest.Net/
121 |
122 | # Web workbench (sass)
123 | .sass-cache/
124 |
125 | # Installshield output folder
126 | [Ee]xpress/
127 |
128 | # DocProject is a documentation generator add-in
129 | DocProject/buildhelp/
130 | DocProject/Help/*.HxT
131 | DocProject/Help/*.HxC
132 | DocProject/Help/*.hhc
133 | DocProject/Help/*.hhk
134 | DocProject/Help/*.hhp
135 | DocProject/Help/Html2
136 | DocProject/Help/html
137 |
138 | # Click-Once directory
139 | publish/
140 |
141 | # Publish Web Output
142 | *.[Pp]ublish.xml
143 | *.azurePubxml
144 | # TODO: Comment the next line if you want to checkin your web deploy settings
145 | # but database connection strings (with potential passwords) will be unencrypted
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
150 | # checkin your Azure Web App publish settings, but sensitive information contained
151 | # in these scripts will be unencrypted
152 | PublishScripts/
153 |
154 | # NuGet Packages
155 | *.nupkg
156 | # The packages folder can be ignored because of Package Restore
157 | **/packages/*
158 | # except build/, which is used as an MSBuild target.
159 | !**/packages/build/
160 | # Uncomment if necessary however generally it will be regenerated when needed
161 | #!**/packages/repositories.config
162 | # NuGet v3's project.json files produces more ignoreable files
163 | *.nuget.props
164 | *.nuget.targets
165 |
166 | # Microsoft Azure Build Output
167 | csx/
168 | *.build.csdef
169 |
170 | # Microsoft Azure Emulator
171 | ecf/
172 | rcf/
173 |
174 | # Windows Store app package directories and files
175 | AppPackages/
176 | BundleArtifacts/
177 | Package.StoreAssociation.xml
178 | _pkginfo.txt
179 |
180 | # Visual Studio cache files
181 | # files ending in .cache can be ignored
182 | *.[Cc]ache
183 | # but keep track of directories ending in .cache
184 | !*.[Cc]ache/
185 |
186 | # Others
187 | ClientBin/
188 | ~$*
189 | *~
190 | *.dbmdl
191 | *.dbproj.schemaview
192 | *.jfm
193 | *.pfx
194 | *.publishsettings
195 | node_modules/
196 | orleans.codegen.cs
197 |
198 | # Since there are multiple workflows, uncomment next line to ignore bower_components
199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
200 | #bower_components/
201 |
202 | # RIA/Silverlight projects
203 | Generated_Code/
204 |
205 | # Backup & report files from converting an old project file
206 | # to a newer Visual Studio version. Backup files are not needed,
207 | # because we have git ;-)
208 | _UpgradeReport_Files/
209 | Backup*/
210 | UpgradeLog*.XML
211 | UpgradeLog*.htm
212 |
213 | # SQL Server files
214 | *.mdf
215 | *.ldf
216 |
217 | # Business Intelligence projects
218 | *.rdl.data
219 | *.bim.layout
220 | *.bim_*.settings
221 |
222 | # Microsoft Fakes
223 | FakesAssemblies/
224 |
225 | # GhostDoc plugin setting file
226 | *.GhostDoc.xml
227 |
228 | # Node.js Tools for Visual Studio
229 | .ntvs_analysis.dat
230 |
231 | # Visual Studio 6 build log
232 | *.plg
233 |
234 | # Visual Studio 6 workspace options file
235 | *.opt
236 |
237 | # Visual Studio LightSwitch build output
238 | **/*.HTMLClient/GeneratedArtifacts
239 | **/*.DesktopClient/GeneratedArtifacts
240 | **/*.DesktopClient/ModelManifest.xml
241 | **/*.Server/GeneratedArtifacts
242 | **/*.Server/ModelManifest.xml
243 | _Pvt_Extensions
244 |
245 | # Paket dependency manager
246 | .paket/paket.exe
247 | paket-files/
248 |
249 | # FAKE - F# Make
250 | .fake/
251 |
252 | # JetBrains Rider
253 | .idea/
254 | *.sln.iml
255 |
256 | # CodeRush
257 | .cr/
258 |
259 | # Python Tools for Visual Studio (PTVS)
260 | __pycache__/
261 | *.pyc
--------------------------------------------------------------------------------
/DemoApp/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/DemoApp/DemoApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {38F8D053-1CC7-414F-9D2E-785E5B735251}
8 | Exe
9 | DemoApp
10 | DemoApp
11 | v4.0
12 | 512
13 | true
14 |
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 | false
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 | false
36 |
37 |
38 |
39 | Properties\app.manifest
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | Form
60 |
61 |
62 | frmAbout.cs
63 |
64 |
65 | Form
66 |
67 |
68 | frmMain.cs
69 |
70 |
71 |
72 |
73 | frmAbout.cs
74 |
75 |
76 | frmMain.cs
77 |
78 |
79 | ResXFileCodeGenerator
80 | Resources.Designer.cs
81 |
82 |
83 |
84 | SettingsSingleFileGenerator
85 | Settings.Designer.cs
86 |
87 |
88 | True
89 | True
90 | Resources.resx
91 |
92 |
93 | True
94 | Settings.settings
95 | True
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 | {51bbbade-6d5e-42fa-a873-c1e11765a29f}
104 | NetDimension.WinForm
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/DemoApp/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace DemoApp
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// 应用程序的主入口点。
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new frmMain());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/DemoApp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("DemoApp")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Net Dimension Studio")]
12 | [assembly: AssemblyProduct("DemoApp")]
13 | [assembly: AssemblyCopyright("Copyright © Net Dimension Studio 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("38f8d053-1cc7-414f-9d2e-785e5b735251")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/DemoApp/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace DemoApp.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
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 Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
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("DemoApp.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
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 | ///
64 | /// Looks up a localized resource of type System.Drawing.Bitmap.
65 | ///
66 | internal static System.Drawing.Bitmap beg_with_border {
67 | get {
68 | object obj = ResourceManager.GetObject("beg_with_border", resourceCulture);
69 | return ((System.Drawing.Bitmap)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// Looks up a localized resource of type System.Drawing.Bitmap.
75 | ///
76 | internal static System.Drawing.Bitmap MeckEd_PayPal_donate_button {
77 | get {
78 | object obj = ResourceManager.GetObject("MeckEd-PayPal-donate-button", resourceCulture);
79 | return ((System.Drawing.Bitmap)(obj));
80 | }
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/DemoApp/Properties/Resources.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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\MeckEd-PayPal-donate-button.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
125 | ..\Resources\beg_with_border.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
126 |
127 |
--------------------------------------------------------------------------------
/DemoApp/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace DemoApp.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/DemoApp/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/DemoApp/Properties/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
52 |
53 |
54 |
55 | PerMonitorV2
56 | true
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/DemoApp/Resources/MeckEd-PayPal-donate-button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NetDimension/WinForm-ModernUI/cae63f4acc7846290bebdebc6121a9863a543d09/DemoApp/Resources/MeckEd-PayPal-donate-button.png
--------------------------------------------------------------------------------
/DemoApp/Resources/beg_with_border.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NetDimension/WinForm-ModernUI/cae63f4acc7846290bebdebc6121a9863a543d09/DemoApp/Resources/beg_with_border.png
--------------------------------------------------------------------------------
/DemoApp/frmAbout.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace DemoApp
2 | {
3 | partial class frmAbout
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 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 窗体设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要修改
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.button1 = new System.Windows.Forms.Button();
32 | this.pictureBox1 = new System.Windows.Forms.PictureBox();
33 | this.button2 = new System.Windows.Forms.Button();
34 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
35 | this.SuspendLayout();
36 | //
37 | // button1
38 | //
39 | this.button1.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
40 | this.button1.BackColor = System.Drawing.Color.Transparent;
41 | this.button1.BackgroundImage = global::DemoApp.Properties.Resources.MeckEd_PayPal_donate_button;
42 | this.button1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
43 | this.button1.Location = new System.Drawing.Point(137, 410);
44 | this.button1.Name = "button1";
45 | this.button1.Padding = new System.Windows.Forms.Padding(10);
46 | this.button1.Size = new System.Drawing.Size(203, 104);
47 | this.button1.TabIndex = 1;
48 | this.button1.UseVisualStyleBackColor = false;
49 | this.button1.Click += new System.EventHandler(this.button1_Click);
50 | //
51 | // pictureBox1
52 | //
53 | this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
54 | | System.Windows.Forms.AnchorStyles.Left)
55 | | System.Windows.Forms.AnchorStyles.Right)));
56 | this.pictureBox1.BackgroundImage = global::DemoApp.Properties.Resources.beg_with_border;
57 | this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
58 | this.pictureBox1.Location = new System.Drawing.Point(9, 12);
59 | this.pictureBox1.Name = "pictureBox1";
60 | this.pictureBox1.Size = new System.Drawing.Size(458, 381);
61 | this.pictureBox1.TabIndex = 0;
62 | this.pictureBox1.TabStop = false;
63 | this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
64 | //
65 | // button2
66 | //
67 | this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
68 | | System.Windows.Forms.AnchorStyles.Right)));
69 | this.button2.Location = new System.Drawing.Point(138, 534);
70 | this.button2.Name = "button2";
71 | this.button2.Size = new System.Drawing.Size(201, 44);
72 | this.button2.TabIndex = 2;
73 | this.button2.Text = "确定";
74 | this.button2.UseVisualStyleBackColor = true;
75 | this.button2.Click += new System.EventHandler(this.button2_Click);
76 | //
77 | // frmAbout
78 | //
79 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
80 | this.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(85)))), ((int)(((byte)(50)))), ((int)(((byte)(138)))));
81 | this.ClientSize = new System.Drawing.Size(478, 598);
82 | this.Controls.Add(this.button2);
83 | this.Controls.Add(this.button1);
84 | this.Controls.Add(this.pictureBox1);
85 | this.Font = new System.Drawing.Font("Microsoft YaHei", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
86 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
87 | this.Location = new System.Drawing.Point(0, 0);
88 | this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
89 | this.Name = "frmAbout";
90 | this.ShadowColor = System.Drawing.Color.FromArgb(((int)(((byte)(134)))), ((int)(((byte)(95)))), ((int)(((byte)(197)))));
91 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
92 | this.Text = "ModernUI Demo Application";
93 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
94 | this.ResumeLayout(false);
95 |
96 | }
97 |
98 | #endregion
99 |
100 | private System.Windows.Forms.PictureBox pictureBox1;
101 | private System.Windows.Forms.Button button1;
102 | private System.Windows.Forms.Button button2;
103 | }
104 | }
105 |
106 |
--------------------------------------------------------------------------------
/DemoApp/frmAbout.cs:
--------------------------------------------------------------------------------
1 | using NetDimension.WinForm;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Data;
6 | using System.Drawing;
7 | using System.Linq;
8 | using System.Runtime.InteropServices;
9 | using System.Text;
10 | using System.Threading.Tasks;
11 | using System.Windows.Forms;
12 |
13 | namespace DemoApp
14 | {
15 | public partial class frmAbout : ModernUIForm
16 | {
17 | [DllImport("user32.dll")]
18 | public static extern bool ReleaseCapture();
19 | [DllImport("user32.dll")]
20 | public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
21 | public const int WM_SYSCOMMAND = 0x0112;
22 | public const int SC_MOVE = 0xF010;
23 | public const int HTCAPTION = 0x0002;
24 |
25 | public frmAbout()
26 | {
27 | InitializeComponent();
28 | }
29 |
30 | private void button1_Click(object sender, EventArgs e)
31 | {
32 | System.Diagnostics.Process.Start("https://www.paypal.me/mrjson");
33 | }
34 |
35 | private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
36 | {
37 | ReleaseCapture();
38 | SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
39 | }
40 |
41 | private void button2_Click(object sender, EventArgs e)
42 | {
43 | this.Close();
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/DemoApp/frmAbout.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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/DemoApp/frmMain.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace DemoApp
2 | {
3 | partial class frmMain
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 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
32 | this.label1 = new System.Windows.Forms.Label();
33 | this.button1 = new System.Windows.Forms.Button();
34 | this.label2 = new System.Windows.Forms.Label();
35 | this.button2 = new System.Windows.Forms.Button();
36 | this.button3 = new System.Windows.Forms.Button();
37 | this.button4 = new System.Windows.Forms.Button();
38 | this.button5 = new System.Windows.Forms.Button();
39 | this.button6 = new System.Windows.Forms.Button();
40 | this.SuspendLayout();
41 | //
42 | // label1
43 | //
44 | this.label1.AutoSize = true;
45 | this.label1.Font = new System.Drawing.Font("Microsoft YaHei", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
46 | this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(85)))), ((int)(((byte)(50)))), ((int)(((byte)(138)))));
47 | this.label1.Location = new System.Drawing.Point(12, 16);
48 | this.label1.Name = "label1";
49 | this.label1.Size = new System.Drawing.Size(421, 31);
50 | this.label1.TabIndex = 0;
51 | this.label1.Text = "NetDimension ModernUI Container";
52 | this.label1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label1_MouseDown);
53 | //
54 | // button1
55 | //
56 | this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
57 | this.button1.Location = new System.Drawing.Point(483, 351);
58 | this.button1.Name = "button1";
59 | this.button1.Size = new System.Drawing.Size(103, 35);
60 | this.button1.TabIndex = 1;
61 | this.button1.Text = "Close (&C)";
62 | this.button1.UseVisualStyleBackColor = true;
63 | this.button1.Click += new System.EventHandler(this.button1_Click);
64 | //
65 | // label2
66 | //
67 | this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
68 | | System.Windows.Forms.AnchorStyles.Left)
69 | | System.Windows.Forms.AnchorStyles.Right)));
70 | this.label2.Location = new System.Drawing.Point(13, 71);
71 | this.label2.Name = "label2";
72 | this.label2.Size = new System.Drawing.Size(573, 249);
73 | this.label2.TabIndex = 2;
74 | this.label2.Text = resources.GetString("label2.Text");
75 | //
76 | // button2
77 | //
78 | this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
79 | this.button2.Location = new System.Drawing.Point(390, 351);
80 | this.button2.Name = "button2";
81 | this.button2.Size = new System.Drawing.Size(87, 35);
82 | this.button2.TabIndex = 3;
83 | this.button2.Text = "GitHub";
84 | this.button2.UseVisualStyleBackColor = true;
85 | this.button2.Click += new System.EventHandler(this.button2_Click);
86 | //
87 | // button3
88 | //
89 | this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
90 | this.button3.Location = new System.Drawing.Point(12, 351);
91 | this.button3.Name = "button3";
92 | this.button3.Size = new System.Drawing.Size(178, 35);
93 | this.button3.TabIndex = 4;
94 | this.button3.Text = "DONATE ME!";
95 | this.button3.UseVisualStyleBackColor = true;
96 | this.button3.Click += new System.EventHandler(this.button3_Click);
97 | //
98 | // button4
99 | //
100 | this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
101 | this.button4.AutoSize = true;
102 | this.button4.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
103 | this.button4.Location = new System.Drawing.Point(505, 12);
104 | this.button4.Name = "button4";
105 | this.button4.Size = new System.Drawing.Size(41, 35);
106 | this.button4.TabIndex = 5;
107 | this.button4.Text = "M";
108 | this.button4.UseVisualStyleBackColor = true;
109 | this.button4.Click += new System.EventHandler(this.button4_Click);
110 | //
111 | // button5
112 | //
113 | this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
114 | this.button5.AutoSize = true;
115 | this.button5.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
116 | this.button5.Location = new System.Drawing.Point(552, 12);
117 | this.button5.Name = "button5";
118 | this.button5.Size = new System.Drawing.Size(34, 35);
119 | this.button5.TabIndex = 6;
120 | this.button5.Text = "X";
121 | this.button5.UseVisualStyleBackColor = true;
122 | this.button5.Click += new System.EventHandler(this.button5_Click);
123 | //
124 | // button6
125 | //
126 | this.button6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
127 | this.button6.AutoSize = true;
128 | this.button6.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
129 | this.button6.Location = new System.Drawing.Point(468, 12);
130 | this.button6.Name = "button6";
131 | this.button6.Size = new System.Drawing.Size(31, 35);
132 | this.button6.TabIndex = 7;
133 | this.button6.Text = "_";
134 | this.button6.UseVisualStyleBackColor = true;
135 | this.button6.Click += new System.EventHandler(this.button6_Click);
136 | //
137 | // frmMain
138 | //
139 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
140 | this.BackColor = System.Drawing.Color.White;
141 | this.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(85)))), ((int)(((byte)(50)))), ((int)(((byte)(138)))));
142 | this.ClientSize = new System.Drawing.Size(598, 398);
143 | this.Controls.Add(this.button6);
144 | this.Controls.Add(this.button5);
145 | this.Controls.Add(this.button4);
146 | this.Controls.Add(this.button3);
147 | this.Controls.Add(this.button2);
148 | this.Controls.Add(this.label2);
149 | this.Controls.Add(this.button1);
150 | this.Controls.Add(this.label1);
151 | this.Font = new System.Drawing.Font("Microsoft YaHei", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
152 | this.Name = "frmMain";
153 | this.ShadowColor = System.Drawing.Color.FromArgb(((int)(((byte)(134)))), ((int)(((byte)(95)))), ((int)(((byte)(197)))));
154 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
155 | this.Text = "frmMain";
156 | this.ResumeLayout(false);
157 | this.PerformLayout();
158 |
159 | }
160 |
161 | #endregion
162 |
163 | private System.Windows.Forms.Label label1;
164 | private System.Windows.Forms.Button button1;
165 | private System.Windows.Forms.Label label2;
166 | private System.Windows.Forms.Button button2;
167 | private System.Windows.Forms.Button button3;
168 | private System.Windows.Forms.Button button4;
169 | private System.Windows.Forms.Button button5;
170 | private System.Windows.Forms.Button button6;
171 | }
172 | }
--------------------------------------------------------------------------------
/DemoApp/frmMain.cs:
--------------------------------------------------------------------------------
1 | using NetDimension.WinForm;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Data;
6 | using System.Diagnostics;
7 | using System.Drawing;
8 | using System.Linq;
9 | using System.Runtime.InteropServices;
10 | using System.Text;
11 | using System.Threading.Tasks;
12 | using System.Windows.Forms;
13 |
14 | namespace DemoApp
15 | {
16 | public partial class frmMain : ModernUIForm
17 | {
18 | [DllImport("user32.dll")]
19 | public static extern bool ReleaseCapture();
20 | [DllImport("user32.dll")]
21 | public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
22 | public const int WM_SYSCOMMAND = 0x0112;
23 | public const int SC_MOVE = 0xF010;
24 | public const int HTCAPTION = 0x0002;
25 |
26 | public frmMain()
27 | {
28 | InitializeComponent();
29 | //this.FormBorderStyle = FormBorderStyle.Sizable;
30 | //this.WindowState = FormWindowState.Maximized;
31 | //this.StartPosition = FormStartPosition.CenterScreen;
32 | }
33 |
34 | private void button1_Click(object sender, EventArgs e)
35 | {
36 | this.Close();
37 | }
38 |
39 | private void label1_MouseDown(object sender, MouseEventArgs e)
40 | {
41 | ReleaseCapture();
42 | SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
43 | }
44 |
45 | private void button3_Click(object sender, EventArgs e)
46 | {
47 | frmAbout AboutForm = new frmAbout();
48 | AboutForm.ShowDialog(this);
49 |
50 | }
51 |
52 | private void button2_Click(object sender, EventArgs e)
53 | {
54 | Process.Start("https://github.com/NetDimension/WinForm-ModernUI");
55 |
56 | //this.Scale(new SizeF(1.25f, 1.25f));
57 | }
58 |
59 | private void button4_Click(object sender, EventArgs e)
60 | {
61 | this.WindowState = (this.WindowState == FormWindowState.Normal ? FormWindowState.Maximized : FormWindowState.Normal);
62 | }
63 |
64 | private void button6_Click(object sender, EventArgs e)
65 | {
66 | this.WindowState = FormWindowState.Minimized;
67 |
68 | }
69 |
70 | private void button5_Click(object sender, EventArgs e)
71 | {
72 | this.Close();
73 | }
74 |
75 |
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/DemoApp/frmMain.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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | This is a ModernUI-like form skin. It's used by my anothor project named NanUI which can design User-Interface of a WinForm Application by using HTML/CSS3/Javascript.
122 |
123 | The shadow effect of this window is DropShadow.
124 | Click button below to see another shadow effect.
125 |
126 |
--------------------------------------------------------------------------------
/ModernUIForm.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29411.108
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetDimension.WinForm", "NetDimension.WinForm\NetDimension.WinForm.csproj", "{51BBBADE-6D5E-42FA-A873-C1E11765A29F}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoApp", "DemoApp\DemoApp.csproj", "{38F8D053-1CC7-414F-9D2E-785E5B735251}"
9 | EndProject
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2020720D-78DF-45E1-B6BF-DB64039C3179}"
11 | ProjectSection(SolutionItems) = preProject
12 | README.md = README.md
13 | EndProjectSection
14 | EndProject
15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemInfoPrograme", "SystemInfoPrograme\SystemInfoPrograme.csproj", "{58FD5123-C625-4DB3-BE02-8CD6AC5A26D7}"
16 | EndProject
17 | Global
18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
19 | Debug|Any CPU = Debug|Any CPU
20 | Release|Any CPU = Release|Any CPU
21 | EndGlobalSection
22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
23 | {51BBBADE-6D5E-42FA-A873-C1E11765A29F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {51BBBADE-6D5E-42FA-A873-C1E11765A29F}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {51BBBADE-6D5E-42FA-A873-C1E11765A29F}.Release|Any CPU.ActiveCfg = Release|Any CPU
26 | {51BBBADE-6D5E-42FA-A873-C1E11765A29F}.Release|Any CPU.Build.0 = Release|Any CPU
27 | {38F8D053-1CC7-414F-9D2E-785E5B735251}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28 | {38F8D053-1CC7-414F-9D2E-785E5B735251}.Debug|Any CPU.Build.0 = Debug|Any CPU
29 | {38F8D053-1CC7-414F-9D2E-785E5B735251}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {38F8D053-1CC7-414F-9D2E-785E5B735251}.Release|Any CPU.Build.0 = Release|Any CPU
31 | {58FD5123-C625-4DB3-BE02-8CD6AC5A26D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32 | {58FD5123-C625-4DB3-BE02-8CD6AC5A26D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
33 | {58FD5123-C625-4DB3-BE02-8CD6AC5A26D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
34 | {58FD5123-C625-4DB3-BE02-8CD6AC5A26D7}.Release|Any CPU.Build.0 = Release|Any CPU
35 | EndGlobalSection
36 | GlobalSection(SolutionProperties) = preSolution
37 | HideSolutionNode = FALSE
38 | EndGlobalSection
39 | GlobalSection(ExtensibilityGlobals) = postSolution
40 | SolutionGuid = {53561E65-4D2B-4DFD-9182-B969D5615A30}
41 | EndGlobalSection
42 | EndGlobal
43 |
--------------------------------------------------------------------------------
/NetDimension.WinForm/Internal/ChromeDecorator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows.Forms;
9 | using static NetDimension.WinForm.Win32;
10 |
11 | namespace NetDimension.WinForm
12 | {
13 | internal static class CONSTS
14 | {
15 | internal const string CLASS_NAME = "NetDimensionChromeShadowWindow";
16 |
17 | }
18 |
19 | internal enum ShadowDockPositon
20 | {
21 | Left = 0,
22 | Top = 1,
23 | Right = 2,
24 | Bottom = 3
25 |
26 | }
27 |
28 | internal delegate void FormShadowResizeEventHandler(object sender, FormShadowResizeArgs args);
29 | internal class FormShadowResizeArgs : EventArgs
30 | {
31 | private readonly ShadowDockPositon _side;
32 | private readonly HitTest _mode;
33 | private readonly Point _point;
34 |
35 | public ShadowDockPositon Side
36 | {
37 | get { return _side; }
38 | }
39 |
40 | public Point ScreenPoint
41 | {
42 | get
43 | {
44 | return _point;
45 | }
46 | }
47 |
48 | public HitTest Mode
49 | {
50 | get { return _mode; }
51 | }
52 |
53 | internal FormShadowResizeArgs(ShadowDockPositon side, HitTest mode, Point point)
54 | {
55 | _side = side;
56 | _mode = mode;
57 | _point = point;
58 | }
59 | }
60 |
61 | internal class ChromeDecorator : NativeWindow
62 | {
63 | [StructLayout(LayoutKind.Sequential)]
64 | public struct ANIMATIONINFO
65 | {
66 | public uint cbSize;
67 | public int iMinAnimate;
68 | };
69 |
70 | [DllImport("user32", SetLastError = true)]
71 | [return: MarshalAs(UnmanagedType.Bool)]
72 | public static extern bool SystemParametersInfo(uint uiAction,
73 | uint uiParam,
74 | ref ANIMATIONINFO pvParam,
75 | uint fWinIni);
76 |
77 | public static uint SPIF_SENDCHANGE = 0x02;
78 | public static uint SPI_SETANIMATION = 0x0049;
79 | public static uint SPI_GETANIMATION = 0x0048;
80 |
81 |
82 | private IntPtr parentWindowHWnd => parentWindow.Handle;
83 | private Form parentWindow;
84 |
85 | private ChromeShadowElement topFormShadow;
86 | private ChromeShadowElement leftFormShadow;
87 | private ChromeShadowElement bottomFormShadow;
88 | private ChromeShadowElement rightFormShadow;
89 |
90 | private WINDOWPOS lastLocation;
91 |
92 | private readonly List shadows = new List();
93 | private Color shadowColor = Color.Black;
94 |
95 | private bool isEnabled;
96 | private bool isFocused = false;
97 | private bool isWindowMinimized = false;
98 | private bool isAnimationDelayed = false;
99 |
100 | private bool isInitialized = false;
101 |
102 | private Bitmap[] cachedImages;
103 |
104 | internal Bitmap ActiveBitmapTemplate => cachedImages?[1];
105 | internal Bitmap InactiveBitmapTemplate => cachedImages?[2];
106 |
107 | internal bool Resizable => parentWindow.FormBorderStyle == FormBorderStyle.SizableToolWindow || parentWindow.FormBorderStyle == FormBorderStyle.Sizable;
108 |
109 | public Color ShadowColor
110 | {
111 | get
112 | {
113 | return shadowColor;
114 | }
115 |
116 | set
117 | {
118 | shadowColor = value;
119 |
120 |
121 | InitializeBitmapCache();
122 |
123 |
124 |
125 | if (!isInitialized) return;
126 |
127 | foreach (var sideShadow in shadows)
128 | {
129 | sideShadow.UpdateShadow();
130 | }
131 | }
132 | }
133 |
134 | public bool IsInitialized => isInitialized;
135 | public bool IsEnabled => isEnabled;
136 | public void InitializeShadows()
137 | {
138 | topFormShadow = new ChromeShadowElement(ShadowDockPositon.Top, parentWindowHWnd, this);
139 | leftFormShadow = new ChromeShadowElement(ShadowDockPositon.Left, parentWindowHWnd, this);
140 | bottomFormShadow = new ChromeShadowElement(ShadowDockPositon.Bottom, parentWindowHWnd, this);
141 | rightFormShadow = new ChromeShadowElement(ShadowDockPositon.Right, parentWindowHWnd, this);
142 |
143 | shadows.Add(topFormShadow);
144 | shadows.Add(leftFormShadow);
145 | shadows.Add(bottomFormShadow);
146 | shadows.Add(rightFormShadow);
147 |
148 | User32.ShowWindow(topFormShadow.Handle, ShowWindowStyles.SW_SHOWNOACTIVATE);
149 | User32.ShowWindow(leftFormShadow.Handle, ShowWindowStyles.SW_SHOWNOACTIVATE);
150 | User32.ShowWindow(bottomFormShadow.Handle, ShowWindowStyles.SW_SHOWNOACTIVATE);
151 | User32.ShowWindow(rightFormShadow.Handle, ShowWindowStyles.SW_SHOWNOACTIVATE);
152 |
153 | topFormShadow.ExternalResizeEnable = Resizable;
154 | leftFormShadow.ExternalResizeEnable = Resizable;
155 | bottomFormShadow.ExternalResizeEnable = Resizable;
156 | rightFormShadow.ExternalResizeEnable = Resizable;
157 |
158 |
159 | isInitialized = true;
160 |
161 | AssignHandle(parentWindowHWnd);
162 |
163 | AlignSideShadowToTopMost();
164 |
165 | ShadowColor = shadowColor;
166 |
167 |
168 | }
169 |
170 | public void Enable(bool enable)
171 | {
172 | if (isEnabled && !enable)
173 | {
174 | ShowBorder(false);
175 | UnregisterEvents();
176 | }
177 | else if (!isEnabled && enable)
178 | {
179 | RegisterEvents();
180 | if (parentWindow != null)
181 | {
182 |
183 |
184 | UpdateSizes(parentWindow.Width, parentWindow.Height);
185 |
186 |
187 | UpdateLocations(new WINDOWPOS
188 | {
189 | x = parentWindow.Left,
190 | y = parentWindow.Top,
191 | cx = parentWindow.Width,
192 | cy = parentWindow.Height,
193 | flags = (uint)SetWindowPosFlags.SWP_SHOWWINDOW
194 | });
195 |
196 | }
197 | }
198 |
199 | isEnabled = enable;
200 | }
201 |
202 | public void SetOwner(IntPtr owner)
203 | {
204 | foreach (ChromeShadowElement sideShadow in shadows)
205 | {
206 | sideShadow.SetOwner(owner);
207 | }
208 | }
209 | public void SetFocus()
210 | {
211 | if (!isEnabled) return;
212 | UpdateFocus(true);
213 | }
214 | public void KillFocus()
215 | {
216 | if (!isEnabled) return;
217 |
218 | UpdateFocus(false);
219 | }
220 |
221 | public ChromeDecorator(Form window, bool enable = true)
222 | {
223 | //ANIMATIONINFO ai = new ANIMATIONINFO();
224 | //ai.cbSize =(uint)Marshal.SizeOf(ai);
225 | //ai.iMinAnimate = 400; // turn all animation off
226 | //SystemParametersInfo(SPI_GETANIMATION, (uint)Marshal.SizeOf(typeof(ANIMATIONINFO)), ref ai, 0);
227 |
228 | parentWindow = window;
229 | isEnabled = enable;
230 |
231 | cachedImages = new Bitmap[3];
232 | cachedImages[0] = Properties.Resources.ShadowTemplate;
233 |
234 | InitializeBitmapCache();
235 | }
236 |
237 | private void InitializeBitmapCache()
238 | {
239 | var rawImage = cachedImages[0];
240 | var activeImageCore = cachedImages[1] = (Bitmap)rawImage.Clone();
241 | var inactiveImageCore = cachedImages[2] = (Bitmap)rawImage.Clone();
242 | BlendBitmapWithColor(activeImageCore, ShadowColor);
243 | BlendBitmapWithColor(inactiveImageCore, ShadowColor, 0.6f);
244 | }
245 |
246 | private void BlendBitmapWithColor(Bitmap source, Color color, float alphaDepth = 1f)
247 | {
248 | var rect = new Rectangle(0, 0, source.Width, source.Height);
249 | if (alphaDepth > 1) alphaDepth = 1;
250 |
251 | var bmp = new LockBitmap(source);
252 | bmp.LockBits();
253 |
254 | for (var y = rect.Top; y < rect.Bottom; y++)
255 | {
256 | for (var x = rect.Left; x < rect.Right; x++)
257 | {
258 | var targetColor = bmp.GetPixel(x, y);
259 |
260 | var alpha = Convert.ToByte(targetColor.A * alphaDepth);
261 |
262 | var r = color.R;
263 | var g = color.G;
264 | var b = color.B;
265 |
266 | bmp.SetPixel(x, y, Color.FromArgb(alpha, r, g, b));
267 | }
268 | }
269 |
270 | bmp.UnlockBits();
271 | }
272 |
273 | protected override void WndProc(ref Message m)
274 | {
275 |
276 | if (!isEnabled || IsDisposed)
277 | {
278 | base.WndProc(ref m);
279 | return;
280 | }
281 | var msg = (WindowsMessages)m.Msg;
282 |
283 |
284 | switch (msg)
285 | {
286 |
287 | case WindowsMessages.WM_WINDOWPOSCHANGED:
288 | lastLocation = (WINDOWPOS)Marshal.PtrToStructure(m.LParam, typeof(WINDOWPOS));
289 | WindowPosChanged(lastLocation);
290 | base.WndProc(ref m);
291 | break;
292 | case WindowsMessages.WM_ACTIVATEAPP:
293 | {
294 | var className = new StringBuilder(256);
295 |
296 | if (m.LParam != IntPtr.Zero && User32.GetClassName(m.LParam, className, className.Capacity) != 0)
297 | {
298 | var hWndShadow = m.LParam;
299 | var name = className.ToString();
300 | if (name.StartsWith(CONSTS.CLASS_NAME) && isFocused && shadows.Exists(p => p.Handle == hWndShadow))
301 | {
302 | return;
303 | }
304 | }
305 |
306 |
307 | if (m.WParam == Win32.FALSE)
308 | {
309 | isFocused = false;
310 | KillFocus();
311 | }
312 | else
313 | {
314 | isFocused = true;
315 | SetFocus();
316 | }
317 |
318 | }
319 | break;
320 |
321 | case WindowsMessages.WM_SIZE:
322 |
323 | base.WndProc(ref m);
324 |
325 | Size(m.WParam, m.LParam);
326 |
327 | break;
328 | default:
329 | base.WndProc(ref m);
330 | break;
331 | }
332 |
333 | }
334 |
335 | private void DestroyShadows()
336 | {
337 |
338 | CloseShadows();
339 |
340 | parentWindow = null;
341 | }
342 |
343 | private void RegisterEvents()
344 | {
345 | foreach (var sideShadow in shadows)
346 | {
347 | sideShadow.MouseDown += HandleSideMouseDown;
348 | }
349 |
350 | if (parentWindow != null)
351 | {
352 | parentWindow.VisibleChanged += HandleWindowVisibleChanged;
353 | }
354 | }
355 |
356 | private void HandleWindowVisibleChanged(object sender, EventArgs e)
357 | {
358 | ShowBorder(parentWindow.Visible);
359 | }
360 |
361 | private void UnregisterEvents()
362 | {
363 | foreach (var sideShadow in shadows)
364 | {
365 | sideShadow.MouseDown -= HandleSideMouseDown;
366 | }
367 |
368 | if (parentWindow != null)
369 | {
370 | parentWindow.VisibleChanged -= HandleWindowVisibleChanged;
371 | }
372 | }
373 |
374 | private void HandleSideMouseDown(object sender, FormShadowResizeArgs e)
375 | {
376 | if (e.Mode == HitTest.HTNOWHERE || e.Mode == HitTest.HTCAPTION)
377 | {
378 | return;
379 | }
380 |
381 | if (Resizable)
382 | {
383 | User32.SendMessage(parentWindowHWnd, (uint)WindowsMessages.WM_SYSCOMMAND, (IntPtr)(GetSizeMode(e.Mode)), IntPtr.Zero);
384 | }
385 |
386 | }
387 |
388 |
389 | private int GetSizeMode(HitTest handles)
390 | {
391 | switch (handles)
392 | {
393 | case HitTest.HTNOWHERE:
394 | case HitTest.HTCAPTION:
395 | return 0;
396 | case HitTest.HTLEFT:
397 | return (int)ResizeDirection.Left;
398 | case HitTest.HTRIGHT:
399 | return (int)ResizeDirection.Right;
400 | case HitTest.HTTOP:
401 | return (int)ResizeDirection.Top;
402 | case HitTest.HTTOPLEFT:
403 | return (int)ResizeDirection.TopLeft;
404 | case HitTest.HTTOPRIGHT:
405 | return (int)ResizeDirection.TopRight;
406 | case HitTest.HTBOTTOM:
407 | return (int)ResizeDirection.Bottom;
408 | case HitTest.HTBOTTOMLEFT:
409 | return (int)ResizeDirection.BottomLeft;
410 | case HitTest.HTBOTTOMRIGHT:
411 | return (int)ResizeDirection.BottomRight;
412 | default:
413 | return 0;
414 | }
415 |
416 | }
417 |
418 | private void CloseShadows()
419 | {
420 | foreach (var sideShadow in shadows)
421 | {
422 | sideShadow.Close();
423 | }
424 |
425 | shadows.Clear();
426 |
427 | topFormShadow = null;
428 | bottomFormShadow = null;
429 | leftFormShadow = null;
430 | rightFormShadow = null;
431 | }
432 |
433 | private void ShowBorder(bool show)
434 | {
435 | var action = new Action(() =>
436 | {
437 |
438 | foreach (var sideShadow in shadows)
439 | {
440 | sideShadow.Show(show);
441 | }
442 |
443 | if (show)
444 | {
445 | isWindowMinimized = false;
446 | }
447 | });
448 |
449 | if (show == true && isWindowMinimized)
450 | {
451 | if (isAnimationDelayed)
452 | {
453 | return;
454 | }
455 |
456 | isAnimationDelayed = true;
457 | Task.Factory.StartNew(() =>
458 | {
459 | System.Threading.Thread.Sleep(300);
460 | if (isAnimationDelayed)
461 | parentWindow.Invoke(new MethodInvoker(action));
462 |
463 | isAnimationDelayed = false;
464 |
465 | });
466 |
467 | }
468 | else
469 | {
470 | action();
471 |
472 | isAnimationDelayed = false;
473 | }
474 |
475 | }
476 |
477 | private void UpdateFocus(bool isFocused)
478 | {
479 | foreach (var sideShadow in shadows)
480 | {
481 | sideShadow.ParentWindowIsFocused = isFocused;
482 | }
483 |
484 |
485 | }
486 |
487 | private void UpdateSizes(int width, int height)
488 | {
489 | foreach (var sideShadow in shadows)
490 | {
491 | sideShadow.SetSize(width, height);
492 | }
493 | }
494 |
495 | private void UpdateLocations(WINDOWPOS location)
496 | {
497 | foreach (var sideShadow in shadows)
498 | {
499 | sideShadow.SetLocation(location);
500 | }
501 |
502 | if ((location.flags & (uint)SetWindowPosFlags.SWP_HIDEWINDOW) != 0)
503 | {
504 | ShowBorder(false);
505 | }
506 | else if ((location.flags & (uint)SetWindowPosFlags.SWP_SHOWWINDOW) != 0)
507 | {
508 | ShowBorder(true);
509 | }
510 | }
511 |
512 | private void AlignSideShadowToTopMost()
513 | {
514 | if (shadows == null)
515 | {
516 | return;
517 | }
518 |
519 | foreach (var sideShadow in shadows)
520 | {
521 | sideShadow.UpdateZOrder();
522 | }
523 | }
524 |
525 |
526 |
527 |
528 | private void WindowPosChanged(WINDOWPOS location)
529 | {
530 | if (!isEnabled) return;
531 | UpdateLocations(location);
532 | }
533 |
534 |
535 | private void Size(IntPtr wParam, IntPtr lParam)
536 | {
537 | int width = (int)User32.LOWORD(lParam);
538 | int height = (int)User32.HIWORD(lParam);
539 |
540 | if (!isEnabled) return;
541 |
542 | if ((int)wParam == 2 || (int)wParam == 1) // maximized/minimized
543 | {
544 |
545 | if ((int)wParam == 1)
546 | {
547 | }
548 |
549 | isWindowMinimized = true;
550 |
551 |
552 | ShowBorder(false);
553 |
554 | }
555 | else
556 | {
557 | var rect = new RECT();
558 |
559 | User32.GetWindowRect(parentWindow.TopLevelControl != null ? parentWindow.TopLevelControl.Handle : parentWindow.Handle, ref rect);
560 |
561 | UpdateSizes(rect.right - rect.left, rect.bottom - rect.top);
562 | ShowBorder(true);
563 |
564 | }
565 | }
566 |
567 |
568 | #region Dispose
569 |
570 | private bool _isDisposed;
571 |
572 | ///
573 | /// IsDisposed status
574 | ///
575 | public bool IsDisposed
576 | {
577 | get { return _isDisposed; }
578 | }
579 |
580 | ///
581 | /// Standard Dispose
582 | ///
583 | public void Dispose()
584 | {
585 | Dispose(true);
586 | GC.SuppressFinalize(this);
587 | }
588 |
589 | ///
590 | /// Dispose
591 | ///
592 | /// True if disposing, false otherwise
593 | protected virtual void Dispose(bool disposing)
594 | {
595 | if (!_isDisposed)
596 | {
597 | if (disposing)
598 | {
599 | // release unmanaged resources
600 | }
601 |
602 | _isDisposed = true;
603 |
604 | DestroyShadows();
605 |
606 | UnregisterEvents();
607 |
608 | this.ReleaseHandle();
609 |
610 | parentWindow = null;
611 | }
612 | }
613 |
614 | #endregion
615 |
616 | }
617 | }
618 |
--------------------------------------------------------------------------------
/NetDimension.WinForm/Internal/ChromeShadowElement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using static NetDimension.WinForm.Win32;
9 |
10 | namespace NetDimension.WinForm
11 | {
12 |
13 |
14 | internal class ChromeShadowElement : IDisposable
15 | {
16 | private GCHandle gcHandle;
17 |
18 | #region private
19 |
20 | private const int CORNER_AREA = 20;
21 |
22 | private const int ERROR_CLASS_ALREADY_EXISTS = 1410;
23 | private bool _disposed;
24 | private IntPtr _handle;
25 | private readonly IntPtr _parentHandle;
26 | private readonly ChromeDecorator _decorator;
27 |
28 | private WndProcHandler _wndProcDelegate;
29 |
30 | const int AcSrcOver = 0x00;
31 | const int AcSrcAlpha = 0x01;
32 |
33 | private const int Size = 20;
34 | private readonly ShadowDockPositon _side;
35 | private const SetWindowPosFlags NoSizeNoMove = (SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOMOVE);
36 |
37 | private bool _parentWindowIsFocused;
38 |
39 | private BLENDFUNCTION _blend;
40 | private POINT _ptZero = new POINT(0, 0);
41 | private readonly Color _transparent = Color.FromArgb(0);
42 |
43 | private readonly IntPtr _noTopMost = new IntPtr(-2);
44 | private readonly IntPtr _yesTopMost = new IntPtr(-1);
45 |
46 | #endregion
47 |
48 | #region constuctor
49 |
50 | //Bitmap[] cachedImages;
51 |
52 | protected IntPtr Region { get; set; } = IntPtr.Zero;
53 |
54 |
55 | internal ChromeShadowElement(ShadowDockPositon side, IntPtr parent, ChromeDecorator decorator)
56 | {
57 | _side = side;
58 | _parentHandle = parent;
59 | _decorator = decorator;
60 |
61 | _blend = new BLENDFUNCTION
62 | {
63 | BlendOp = AcSrcOver,
64 | BlendFlags = 0,
65 | SourceConstantAlpha = 255,
66 | AlphaFormat = AcSrcAlpha
67 | };
68 |
69 | CreateWindow($"{CONSTS.CLASS_NAME}_{side}_{parent}");
70 | }
71 |
72 | internal void SetOwner(IntPtr owner)
73 | {
74 | User32.SetWindowLong(_handle, GetWindowLongFlags.GWL_HWNDPARENT, owner);
75 | }
76 |
77 | #endregion
78 |
79 | #region internal
80 |
81 | internal bool ExternalResizeEnable { get; set; }
82 |
83 | internal event FormShadowResizeEventHandler MouseDown;
84 |
85 |
86 | internal void SetSize(int width, int height)
87 | {
88 | if (_side == ShadowDockPositon.Top || _side == ShadowDockPositon.Bottom)
89 | {
90 | height = Size;
91 | width = width + Size * 2;
92 | }
93 | else
94 | {
95 | width = Size;
96 | }
97 |
98 | const SetWindowPosFlags flags = (SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOACTIVATE);
99 | User32.SetWindowPos(_handle, new IntPtr(-2), 0, 0, width, height, flags);
100 | Render();
101 | }
102 |
103 | internal void SetLocation(WINDOWPOS pos)
104 | {
105 | int left = 0;
106 | int top = 0;
107 | switch (_side)
108 | {
109 | case ShadowDockPositon.Top:
110 | left = pos.x - Size;
111 | top = pos.y - Size;
112 | break;
113 | case ShadowDockPositon.Bottom:
114 | left = pos.x - Size;
115 | top = pos.y + pos.cy;
116 | break;
117 | case ShadowDockPositon.Left:
118 | left = pos.x - Size;
119 | top = pos.y;
120 | break;
121 | case ShadowDockPositon.Right:
122 | left = pos.x + pos.cx;
123 | top = pos.y;
124 | break;
125 | }
126 |
127 | UpdateZOrder(left, top, (int)(SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE));
128 | }
129 |
130 | internal void UpdateZOrder(int left, int top, int flags)
131 | {
132 | User32.SetWindowPos(_handle, !IsTopMost ? _noTopMost : _yesTopMost, left, top, 0, Size, (SetWindowPosFlags)flags);
133 | }
134 |
135 | internal void UpdateZOrder()
136 | {
137 | User32.SetWindowPos(_handle, !IsTopMost ? _noTopMost : _yesTopMost, 0, 0, 0, Size, NoSizeNoMove | SetWindowPosFlags.SWP_NOACTIVATE);
138 | }
139 |
140 |
141 |
142 | public void UpdateShadow()
143 | {
144 | Render();
145 | }
146 |
147 |
148 | internal IntPtr Handle
149 | {
150 | get { return _handle; }
151 | }
152 |
153 | internal bool ParentWindowIsFocused
154 | {
155 | set
156 | {
157 | var needRefresh = false;
158 | if (_parentWindowIsFocused != value)
159 | {
160 | needRefresh = true;
161 | }
162 | _parentWindowIsFocused = value;
163 | User32.SetWindowPos(_handle, _parentHandle, 0, 0, 0, Size, NoSizeNoMove | SetWindowPosFlags.SWP_NOACTIVATE);
164 |
165 | if (needRefresh)
166 | Render();
167 | }
168 | }
169 |
170 | internal bool IsTopMost { get; set; }
171 |
172 | internal void Show(bool show)
173 | {
174 | const int swShowNoActivate = 4;
175 | User32.ShowWindow(_handle, (short)(show ? swShowNoActivate : 0));
176 | }
177 |
178 | internal void Close()
179 | {
180 | if (Region != IntPtr.Zero)
181 | {
182 | Gdi32.SetWindowRgn(Handle, IntPtr.Zero, false);
183 | Gdi32.DeleteObject(Region);
184 | }
185 | User32.CloseWindow(_handle);
186 | User32.SetParent((int)_handle, 0);
187 | User32.DestroyWindow(_handle);
188 | }
189 |
190 | #endregion
191 |
192 | #region private
193 |
194 | private void CreateWindow(string className)
195 | {
196 | if (className == null) throw new Exception("class_name is null");
197 | if (className == String.Empty) throw new Exception("class_name is empty");
198 |
199 | _wndProcDelegate = CustomWndProc;
200 |
201 | gcHandle = GCHandle.Alloc(_wndProcDelegate);
202 |
203 | WNDCLASS windClass = new WNDCLASS
204 | {
205 | lpszClassName = className,
206 | lpfnWndProc = Marshal.GetFunctionPointerForDelegate(_wndProcDelegate)
207 | };
208 |
209 | ushort classAtom = User32.RegisterClassW(ref windClass);
210 |
211 | int lastError = Marshal.GetLastWin32Error();
212 |
213 | if (classAtom == 0 && lastError != ERROR_CLASS_ALREADY_EXISTS)
214 | {
215 | throw new Exception("Could not register window class");
216 | }
217 |
218 | const UInt32 extendedStyle = (UInt32)(
219 | WindowExStyles.WS_EX_LEFT |
220 | WindowExStyles.WS_EX_LTRREADING |
221 | WindowExStyles.WS_EX_RIGHTSCROLLBAR |
222 | WindowExStyles.WS_EX_TOOLWINDOW);
223 |
224 | const UInt32 style = (UInt32)(
225 | WindowStyles.WS_CLIPSIBLINGS |
226 | WindowStyles.WS_CLIPCHILDREN |
227 | WindowStyles.WS_POPUP);
228 |
229 | var owner = User32.GetWindow(_parentHandle, 4);
230 |
231 | // Create window
232 | _handle = User32.CreateWindowExW(
233 | extendedStyle,
234 | className,
235 | className,
236 | style,
237 | 0,
238 | 0,
239 | 0,
240 | 0,
241 | IntPtr.Zero,
242 | IntPtr.Zero,
243 | IntPtr.Zero,
244 | IntPtr.Zero
245 | );
246 |
247 | if (_handle == IntPtr.Zero)
248 | {
249 | return;
250 | }
251 |
252 | uint styles = User32.GetWindowLong(_handle, GetWindowLongFlags.GWL_EXSTYLE);
253 | styles = styles | (uint)WindowExStyles.WS_EX_LAYERED /*| WS_EX_NOACTIVATE | WS_EX_TRANSPARENT*/;
254 | User32.SetWindowLong(_handle, GetWindowLongFlags.GWL_EXSTYLE, styles);
255 | }
256 |
257 | private IntPtr CustomWndProc(IntPtr hWnd, uint message, IntPtr wParam, IntPtr lParam)
258 | {
259 |
260 | var msg = (WindowsMessages)message;
261 |
262 |
263 | if (msg == WindowsMessages.WM_LBUTTONDOWN)
264 | {
265 | var point = GetPostionFromPtr(lParam);
266 | User32.ClientToScreen(hWnd, ref point);
267 | CastMouseDown(new Point(point.x,point.y));
268 | }
269 |
270 | if (msg == WindowsMessages.WM_SETFOCUS)
271 | {
272 | User32.PostMessage(_parentHandle, message, hWnd, IntPtr.Zero);
273 | }
274 |
275 |
276 | if (msg == WindowsMessages.WM_SETCURSOR)
277 | {
278 | SetCursor();
279 | return new IntPtr(1);
280 | }
281 |
282 | return User32.DefWindowProcW(hWnd, message, wParam, lParam);
283 | }
284 |
285 |
286 |
287 | private Bitmap GetBitmap(int width, int height)
288 | {
289 | Bitmap bmp;
290 | switch (_side)
291 | {
292 | case ShadowDockPositon.Top:
293 | case ShadowDockPositon.Bottom:
294 | bmp = new Bitmap(width, Size, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
295 | break;
296 | case ShadowDockPositon.Left:
297 | case ShadowDockPositon.Right:
298 | bmp = new Bitmap(Size, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
299 | break;
300 | default:
301 | throw new ArgumentOutOfRangeException();
302 | }
303 |
304 | RECT windowRect = new RECT();
305 | User32.GetWindowRect(_parentHandle, ref windowRect);
306 | Bitmap cachedBmp = _parentWindowIsFocused ? _decorator.ActiveBitmapTemplate : _decorator.InactiveBitmapTemplate;
307 |
308 | lock (cachedBmp)
309 | {
310 | using (var g = Graphics.FromImage(bmp))
311 | {
312 | switch (_side)
313 | {
314 | case ShadowDockPositon.Left:
315 | {
316 | var srcNearCornerRect = new Rectangle(0, 20, 20, 40);
317 | var srcFarCornerRect = new Rectangle(0, 130, 20, 40);
318 | var srcRect = new Rectangle(0, 60, 20, 20);
319 |
320 | var destNearCornerRect = new Rectangle(0, 0, 20, 40);
321 | var destFarCornerRect = new Rectangle(0, height - 40, 20, 40);
322 | var destRect = new Rectangle(0, 40, 20, height - 40 * 2);
323 |
324 | g.SetClip(destNearCornerRect);
325 | g.DrawImage(cachedBmp, destNearCornerRect, srcNearCornerRect, GraphicsUnit.Pixel);
326 | g.ResetClip();
327 |
328 | g.SetClip(destFarCornerRect);
329 | g.DrawImage(cachedBmp, destFarCornerRect, srcFarCornerRect, GraphicsUnit.Pixel);
330 | g.ResetClip();
331 |
332 | g.ExcludeClip(destNearCornerRect);
333 | g.ExcludeClip(destFarCornerRect);
334 | g.DrawImage(cachedBmp, destRect, srcRect, GraphicsUnit.Pixel);
335 | g.ResetClip();
336 |
337 | }
338 | break;
339 | case ShadowDockPositon.Right:
340 | {
341 | var srcNearCornerRect = new Rectangle(cachedBmp.Width - 20, 20, 20, 40);
342 | var srcFarCornerRect = new Rectangle(cachedBmp.Width - 20, 130, 20, 40);
343 | var srcRect = new Rectangle(cachedBmp.Width - 20, 60, 20, 20);
344 |
345 | var destNearCornerRect = new Rectangle(width - 20, 0, 20, 40);
346 | var destFarCornerRect = new Rectangle(width - 20, height - 40, 20, 40);
347 | var destRect = new Rectangle(width - 20, 40, 20, height - 40 * 2);
348 |
349 | g.SetClip(destNearCornerRect);
350 | g.DrawImage(cachedBmp, destNearCornerRect, srcNearCornerRect, GraphicsUnit.Pixel);
351 | g.ResetClip();
352 |
353 | g.SetClip(destFarCornerRect);
354 | g.DrawImage(cachedBmp, destFarCornerRect, srcFarCornerRect, GraphicsUnit.Pixel);
355 | g.ResetClip();
356 |
357 | g.ExcludeClip(destNearCornerRect);
358 | g.ExcludeClip(destFarCornerRect);
359 | g.DrawImage(cachedBmp, destRect, srcRect, GraphicsUnit.Pixel);
360 | g.ResetClip();
361 |
362 |
363 | }
364 | break;
365 |
366 | case ShadowDockPositon.Top:
367 | {
368 | var srcNearCornerRect = new Rectangle(0, 0, 40, 20);
369 | var srcFarCornerRect = new Rectangle(200, 0, 40, 20);
370 | var srcRect = new Rectangle(40, 0, 160, 20);
371 |
372 | var destNearCornerRect = new Rectangle(0, 0, 40, 20);
373 | var destFarCornerRect = new Rectangle(width - 40, 0, 40, 20);
374 | var destRect = new Rectangle(40, 0, width - 40 * 2, 20);
375 |
376 | g.SetClip(destNearCornerRect);
377 | g.DrawImage(cachedBmp, destNearCornerRect, srcNearCornerRect, GraphicsUnit.Pixel);
378 | g.ResetClip();
379 |
380 | g.SetClip(destFarCornerRect);
381 | g.DrawImage(cachedBmp, destFarCornerRect, srcFarCornerRect, GraphicsUnit.Pixel);
382 | g.ResetClip();
383 |
384 | g.ExcludeClip(destNearCornerRect);
385 | g.ExcludeClip(destFarCornerRect);
386 | g.DrawImage(cachedBmp, destRect, srcRect, GraphicsUnit.Pixel);
387 | g.ResetClip();
388 | }
389 | break;
390 | case ShadowDockPositon.Bottom:
391 | {
392 | var srcNearCornerRect = new Rectangle(0, cachedBmp.Height - 20, 40, 20);
393 | var srcFarCornerRect = new Rectangle(200, cachedBmp.Height - 20, 40, 20);
394 | var srcRect = new Rectangle(40, cachedBmp.Height - 20, 160, 20);
395 |
396 | var destNearCornerRect = new Rectangle(0, height - 20, 40, 20);
397 | var destFarCornerRect = new Rectangle(width - 40, height - 20, 40, 20);
398 | var destRect = new Rectangle(40, height - 20, width - 40 * 2, 20);
399 |
400 | g.SetClip(destNearCornerRect);
401 | g.DrawImage(cachedBmp, destNearCornerRect, srcNearCornerRect, GraphicsUnit.Pixel);
402 | g.ResetClip();
403 |
404 | g.SetClip(destFarCornerRect);
405 | g.DrawImage(cachedBmp, destFarCornerRect, srcFarCornerRect, GraphicsUnit.Pixel);
406 | g.ResetClip();
407 |
408 | g.ExcludeClip(destNearCornerRect);
409 | g.ExcludeClip(destFarCornerRect);
410 | g.DrawImage(cachedBmp, destRect, srcRect, GraphicsUnit.Pixel);
411 | g.ResetClip();
412 |
413 |
414 |
415 |
416 | }
417 | break;
418 | }
419 | }
420 |
421 | }
422 |
423 |
424 | return bmp;
425 | }
426 |
427 | private void Render()
428 | {
429 |
430 | ExcludeRegion();
431 | DrawToLayeredWindow();
432 |
433 | }
434 |
435 | private void DrawToLayeredWindow()
436 | {
437 | RECT rect = new RECT();
438 | User32.GetWindowRect(_handle, ref rect);
439 |
440 | int width = rect.right - rect.left;
441 | int height = rect.bottom - rect.top;
442 |
443 | if (width == 0 || height == 0) return;
444 |
445 | POINT newLocation = new POINT(rect.left, rect.top);
446 | SIZE newSize = new SIZE(width, height);
447 | IntPtr screenDc = User32.GetDC(IntPtr.Zero);
448 | IntPtr memDc = Gdi32.CreateCompatibleDC(screenDc);
449 | using (Bitmap bmp = GetBitmap(width, height))
450 | {
451 | IntPtr hBitmap = bmp.GetHbitmap(_transparent);
452 | IntPtr hOldBitmap = Gdi32.SelectObject(memDc, hBitmap);
453 |
454 |
455 |
456 | User32.UpdateLayeredWindow(_handle, screenDc, ref newLocation, ref newSize, memDc, ref _ptZero, 0, ref _blend, 0x02);
457 |
458 | User32.ReleaseDC(IntPtr.Zero, screenDc);
459 | if (hBitmap != IntPtr.Zero)
460 | {
461 | Gdi32.SelectObject(memDc, hOldBitmap);
462 | Gdi32.DeleteObject(hBitmap);
463 | }
464 | }
465 |
466 | Gdi32.DeleteDC(memDc);
467 | GC.Collect();
468 | }
469 |
470 |
471 | private void ExcludeRegion()
472 | {
473 | if (!ShouldExlcudeRegion) return;
474 | IntPtr hRegion = IntPtr.Zero;
475 | try
476 | {
477 | hRegion = GetRegion();
478 | if (hRegion != IntPtr.Zero)
479 | {
480 | Gdi32.SetWindowRgn(Handle, hRegion, false);
481 | }
482 | if (Region != IntPtr.Zero)
483 | Gdi32.DeleteObject(Region);
484 | Region = hRegion;
485 | }
486 | finally
487 | {
488 | if (hRegion != IntPtr.Zero) Gdi32.DeleteObject(hRegion);
489 | }
490 | }
491 |
492 | private IntPtr GetRegion()
493 | {
494 | IntPtr hShadowReg = IntPtr.Zero;
495 | IntPtr hOwnerReg = IntPtr.Zero;
496 | IntPtr hRegion = IntPtr.Zero;
497 | try
498 | {
499 | var rect = new RECT();
500 | User32.GetWindowRect(_handle, ref rect);
501 | int width = rect.right - rect.left;
502 | int height = rect.bottom - rect.top;
503 |
504 | hShadowReg = Gdi32.CreateRectRgn(0, 0, width, height);
505 | hOwnerReg = Gdi32.CreateRectRgn(GetRegionRect());
506 | hRegion = CombineRgn(hShadowReg, hOwnerReg, 4);
507 | }
508 | finally
509 | {
510 | if (hShadowReg != IntPtr.Zero)
511 | Gdi32.DeleteObject(hShadowReg);
512 | if (hOwnerReg != IntPtr.Zero)
513 | Gdi32.DeleteObject(hOwnerReg);
514 | }
515 | return hRegion;
516 | }
517 |
518 | private bool ShouldExlcudeRegion
519 | {
520 | get
521 | {
522 | var rect = new RECT();
523 | User32.GetWindowRect(_handle, ref rect);
524 | int width = rect.right - rect.left;
525 | int height = rect.bottom - rect.top;
526 | return width != 0 && height != 0;
527 | }
528 | }
529 |
530 | protected Rectangle GetRegionRect()
531 | {
532 | var rect = new RECT();
533 | User32.GetWindowRect(_handle, ref rect);
534 |
535 | int offset = 20;
536 | int width = rect.right - rect.left;
537 | int height = rect.bottom - rect.top;
538 | return new Rectangle(offset, offset, width, height);
539 |
540 |
541 | }
542 |
543 | protected IntPtr CombineRgn(IntPtr hrgnSrc1, IntPtr hrgnSrc2, int fnCombineMode)
544 | {
545 | IntPtr hRegion = Gdi32.CreateRectRgn(Rectangle.Empty);
546 | Gdi32.CombineRgn(hRegion, hrgnSrc1, hrgnSrc2, fnCombineMode);
547 | return hRegion;
548 | }
549 |
550 |
551 |
552 | private void SetCursor()
553 | {
554 | if (!ExternalResizeEnable)
555 | {
556 | return;
557 | }
558 |
559 | IntPtr handle = User32.LoadCursor(IntPtr.Zero, (int)IDC_STANDARD_CURSORS.IDC_HAND);
560 | HitTest mode = GetResizeMode();
561 | switch (mode)
562 | {
563 | case HitTest.HTTOP:
564 | case HitTest.HTBOTTOM:
565 | handle = User32.LoadCursor(IntPtr.Zero, (int)IDC_STANDARD_CURSORS.IDC_SIZENS);
566 | break;
567 | case HitTest.HTLEFT:
568 | case HitTest.HTRIGHT:
569 | handle = User32.LoadCursor(IntPtr.Zero, (int)IDC_STANDARD_CURSORS.IDC_SIZEWE);
570 | break;
571 | case HitTest.HTTOPLEFT:
572 | case HitTest.HTBOTTOMRIGHT:
573 | handle = User32.LoadCursor(IntPtr.Zero, (int)IDC_STANDARD_CURSORS.IDC_SIZENWSE);
574 | break;
575 | case HitTest.HTTOPRIGHT:
576 | case HitTest.HTBOTTOMLEFT:
577 | handle = User32.LoadCursor(IntPtr.Zero, (int)IDC_STANDARD_CURSORS.IDC_SIZENESW);
578 | break;
579 | }
580 |
581 | if (handle != IntPtr.Zero)
582 | {
583 | User32.SetCursor(handle);
584 | }
585 | }
586 |
587 | private void CastMouseDown(Point point)
588 | {
589 |
590 | if (!ExternalResizeEnable)
591 | {
592 | return;
593 | }
594 |
595 | HitTest mode = GetResizeMode();
596 |
597 |
598 |
599 | if (MouseDown != null)
600 | {
601 | FormShadowResizeArgs args = new FormShadowResizeArgs(_side, mode, point);
602 | MouseDown(this, args);
603 | }
604 | }
605 |
606 | private POINT GetRelativeMousePosition()
607 | {
608 | POINT point = new POINT();
609 | User32.GetCursorPos(ref point);
610 | User32.ScreenToClient(_handle, ref point);
611 | return point;
612 | }
613 |
614 | private HitTest GetResizeMode()
615 | {
616 | HitTest mode = HitTest.HTNOWHERE;
617 |
618 | RECT rect = new RECT();
619 | POINT point = GetRelativeMousePosition();
620 | User32.GetWindowRect(_handle, ref rect);
621 | switch (_side)
622 | {
623 | case ShadowDockPositon.Top:
624 | int width = rect.right - rect.left;
625 | if (point.x < CORNER_AREA) mode = HitTest.HTTOPLEFT;
626 | else if (point.x > width - CORNER_AREA) mode = HitTest.HTTOPRIGHT;
627 | else mode = HitTest.HTTOP;
628 | break;
629 | case ShadowDockPositon.Bottom:
630 | width = rect.right - rect.left;
631 | if (point.x < CORNER_AREA) mode = HitTest.HTBOTTOMLEFT;
632 | else if (point.x > width - CORNER_AREA) mode = HitTest.HTBOTTOMRIGHT;
633 | else mode = HitTest.HTBOTTOM;
634 | break;
635 | case ShadowDockPositon.Left:
636 | int height = rect.bottom - rect.top;
637 | if (point.y < CORNER_AREA) mode = HitTest.HTTOPLEFT;
638 | else if (point.y > height - CORNER_AREA) mode = HitTest.HTBOTTOMLEFT;
639 | else mode = HitTest.HTLEFT;
640 | break;
641 | case ShadowDockPositon.Right:
642 | height = rect.bottom - rect.top;
643 | if (point.y < CORNER_AREA) mode = HitTest.HTTOPRIGHT;
644 | else if (point.y > height - CORNER_AREA) mode = HitTest.HTBOTTOMRIGHT;
645 | else mode = HitTest.HTRIGHT;
646 | break;
647 | }
648 |
649 | return mode;
650 | }
651 |
652 | #endregion
653 |
654 | #region Dispose
655 |
656 | public void Dispose()
657 | {
658 | Dispose(true);
659 | GC.SuppressFinalize(this);
660 | }
661 |
662 | private void Dispose(bool disposing)
663 | {
664 | if (_disposed) return;
665 | _disposed = true;
666 | if (_handle == IntPtr.Zero) return;
667 |
668 | User32.DestroyWindow(_handle);
669 | _handle = IntPtr.Zero;
670 | gcHandle.Free();
671 | }
672 |
673 | #endregion
674 |
675 | }
676 | }
677 |
--------------------------------------------------------------------------------
/NetDimension.WinForm/ModernUIForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace NetDimension.WinForm
7 | {
8 | public class ModernUIForm : FormChrome
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/NetDimension.WinForm/NetDimension.WinForm.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {51BBBADE-6D5E-42FA-A873-C1E11765A29F}
8 | Library
9 | NetDimension.WinForm
10 | NetDimension.WinForm.ModernUI
11 | v4.0
12 | 512
13 |
14 |
15 | AnyCPU
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | AnyCPU
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | Form
51 |
52 |
53 |
54 |
55 | Form
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | ResXFileCodeGenerator
65 | Resources.Designer.cs
66 | Designer
67 |
68 |
69 | True
70 | Resources.resx
71 | True
72 |
73 |
74 | SettingsSingleFileGenerator
75 | Settings.Designer.cs
76 |
77 |
78 | True
79 | Settings.settings
80 | True
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/NetDimension.WinForm/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Resources;
2 | using System.Reflection;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | // 有关程序集的一般信息由以下
7 | // 控制。更改这些特性值可修改
8 | // 与程序集关联的信息。
9 | [assembly: AssemblyTitle("NetDimension.WinForm.ModernUI")]
10 | [assembly: AssemblyDescription("Bring your .Net Winform to ModernUI style.")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("Net Dimension Studio")]
13 | [assembly: AssemblyProduct("NetDimension.WinForm.ModernUI")]
14 | [assembly: AssemblyCopyright("Copyright © Net Dimension Studio 2017 all rights resrved.")]
15 | [assembly: AssemblyTrademark("Net Dimension Studio")]
16 | [assembly: AssemblyCulture("")]
17 |
18 | // 将 ComVisible 设置为 false 会使此程序集中的类型
19 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
20 | //请将此类型的 ComVisible 特性设置为 true。
21 | [assembly: ComVisible(false)]
22 |
23 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
24 | [assembly: Guid("51bbbade-6d5e-42fa-a873-c1e11765a29f")]
25 |
26 | // 程序集的版本信息由下列四个值组成:
27 | //
28 | // 主版本
29 | // 次版本
30 | // 生成号
31 | // 修订号
32 | //
33 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
34 | // 方法是按如下所示使用“*”: :
35 | // [assembly: AssemblyVersion("1.0.*")]
36 | [assembly: AssemblyVersion("1.0.*")]
37 | [assembly: AssemblyFileVersion("1.0.0.0")]
38 | [assembly: NeutralResourcesLanguage("zh")]
39 |
--------------------------------------------------------------------------------
/NetDimension.WinForm/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace NetDimension.WinForm.Properties {
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", "15.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
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 Resources() {
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("NetDimension.WinForm.Properties.Resources", typeof(Resources).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 | ///
64 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
65 | ///
66 | internal static System.Drawing.Bitmap ShadowTemplate {
67 | get {
68 | object obj = ResourceManager.GetObject("ShadowTemplate", resourceCulture);
69 | return ((System.Drawing.Bitmap)(obj));
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/NetDimension.WinForm/Properties/Resources.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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\ShadowTemplate.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
--------------------------------------------------------------------------------
/NetDimension.WinForm/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace NetDimension.WinForm.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/NetDimension.WinForm/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/NetDimension.WinForm/Resources/ShadowTemplate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NetDimension/WinForm-ModernUI/cae63f4acc7846290bebdebc6121a9863a543d09/NetDimension.WinForm/Resources/ShadowTemplate.png
--------------------------------------------------------------------------------
/NetDimension.WinForm/Utils/FormStyleHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Forms;
8 |
9 | namespace NetDimension.WinForm
10 | {
11 | public static class FormStyleHelper
12 | {
13 | public static bool IsWindows8OrLower
14 | {
15 | get { return (Environment.OSVersion.Version.Major < 6 || (Environment.OSVersion.Version.Major == 6 && Environment.Version.Minor < 3)); }
16 | }
17 |
18 | public static bool IsWindows81OrHigher
19 | {
20 | get { return (Environment.OSVersion.Version.Major >= 6 || (Environment.OSVersion.Version.Major == 6 && Environment.Version.Minor >= 3)); }
21 | }
22 |
23 | ///
24 | /// Gets the size of the borders requested by the real window.
25 | ///
26 | /// Window style parameters.
27 | /// Border sizing.
28 | public static Padding GetWindowBorders(CreateParams cp)
29 | {
30 | RECT rect = new RECT();
31 |
32 | // Start with a zero sized rectangle
33 | rect.left = 0;
34 | rect.right = 0;
35 | rect.top = 0;
36 | rect.bottom = 0;
37 |
38 |
39 | // Adjust rectangle to add on the borders required
40 | User32.AdjustWindowRectEx(ref rect, cp.Style, false, cp.ExStyle);
41 |
42 | // Return the per side border values
43 | return new Padding(-rect.left, -rect.top, rect.right, rect.bottom);
44 | }
45 |
46 | public static Size ScaleSize(Size value, SizeF scaleFactor)
47 | {
48 | return new Size(
49 | (int)Math.Round(value.Width * scaleFactor.Width, MidpointRounding.AwayFromZero),
50 | (int)Math.Round(value.Height * scaleFactor.Height, MidpointRounding.AwayFromZero));
51 | }
52 |
53 | public static Padding ScalePadding(Padding value, SizeF scaleFactor)
54 | {
55 | MidpointRounding mode = MidpointRounding.AwayFromZero;
56 |
57 | if (scaleFactor.Width < 1f)
58 | {
59 | mode = MidpointRounding.ToEven;
60 | }
61 |
62 |
63 |
64 | return new Padding(
65 | (int)Math.Round(value.Left * scaleFactor.Width, MidpointRounding.AwayFromZero),
66 | (int)Math.Round(value.Top * scaleFactor.Height, MidpointRounding.AwayFromZero),
67 | (int)Math.Round(value.Right * scaleFactor.Width, MidpointRounding.AwayFromZero),
68 | (int)Math.Round(value.Bottom * scaleFactor.Height, MidpointRounding.AwayFromZero));
69 | }
70 |
71 |
72 | ///
73 | /// Discover if the provided Form is currently maximized.
74 | ///
75 | /// Form reference.
76 | /// True if maximized; otherwise false.
77 | public static bool IsFormMaximized(Form f)
78 | {
79 | // Get the current window style (cannot use the
80 | // WindowState property as it can be slightly out of date)
81 | uint style = User32.GetWindowLong(f.Handle, GetWindowLongFlags.GWL_STYLE);
82 |
83 | return ((style &= (uint)WindowStyles.WS_MAXIMIZE) != 0);
84 | }
85 |
86 |
87 | ///
88 | /// Discover if the provided Form is currently minimized.
89 | ///
90 | /// Form reference.
91 | /// True if minimized; otherwise false.
92 | public static bool IsFormMinimized(Form f)
93 | {
94 | // Get the current window style (cannot use the
95 | // WindowState property as it can be slightly out of date)
96 | uint style = User32.GetWindowLong(f.Handle, GetWindowLongFlags.GWL_STYLE);
97 |
98 | return ((style &= (uint)WindowStyles.WS_MINIMIZE) != 0);
99 | }
100 |
101 | ///
102 | /// Gets the real client rectangle of the list.
103 | ///
104 | /// Window handle of the control.
105 | public static Rectangle RealClientRectangle(IntPtr handle)
106 | {
107 | // Grab the actual current size of the window, this is more accurate than using
108 | // the 'this.Size' which is out of date when performing a resize of the window.
109 | RECT windowRect = new RECT();
110 | User32.GetWindowRect(handle, ref windowRect);
111 |
112 | // Create rectangle that encloses the entire window
113 | return new Rectangle(0, 0,
114 | windowRect.right - windowRect.left,
115 | windowRect.bottom - windowRect.top);
116 | }
117 |
118 |
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/NetDimension.WinForm/Utils/LockBitmap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Drawing.Imaging;
5 | using System.Linq;
6 | using System.Runtime.InteropServices;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace NetDimension.WinForm
11 | {
12 | public class LockBitmap
13 | {
14 | Bitmap source = null;
15 | IntPtr Iptr = IntPtr.Zero;
16 | BitmapData bitmapData = null;
17 |
18 | public byte[] Pixels { get; set; }
19 | public int Depth { get; private set; }
20 | public int Width { get; private set; }
21 | public int Height { get; private set; }
22 |
23 | public LockBitmap(Bitmap source)
24 | {
25 | this.source = source;
26 | }
27 |
28 | ///
29 | /// Lock bitmap data
30 | ///
31 | public void LockBits()
32 | {
33 | try
34 | {
35 | // Get width and height of bitmap
36 | Width = source.Width;
37 | Height = source.Height;
38 |
39 | // get total locked pixels count
40 | int PixelCount = Width * Height;
41 |
42 | // Create rectangle to lock
43 | Rectangle rect = new Rectangle(0, 0, Width, Height);
44 |
45 | // get source bitmap pixel format size
46 | Depth = System.Drawing.Bitmap.GetPixelFormatSize(source.PixelFormat);
47 |
48 | // Check if bpp (Bits Per Pixel) is 8, 24, or 32
49 | if (Depth != 8 && Depth != 24 && Depth != 32)
50 | {
51 | throw new ArgumentException("Only 8, 24 and 32 bpp images are supported.");
52 | }
53 |
54 | // Lock bitmap and return bitmap data
55 | bitmapData = source.LockBits(rect, ImageLockMode.ReadWrite,
56 | source.PixelFormat);
57 |
58 | // create byte array to copy pixel values
59 | int step = Depth / 8;
60 | Pixels = new byte[PixelCount * step];
61 | Iptr = bitmapData.Scan0;
62 |
63 | // Copy data from pointer to array
64 | Marshal.Copy(Iptr, Pixels, 0, Pixels.Length);
65 | }
66 | catch (Exception ex)
67 | {
68 | throw ex;
69 | }
70 | }
71 |
72 | ///
73 | /// Unlock bitmap data
74 | ///
75 | public void UnlockBits()
76 | {
77 | try
78 | {
79 | // Copy data from byte array to pointer
80 | Marshal.Copy(Pixels, 0, Iptr, Pixels.Length);
81 |
82 | // Unlock bitmap data
83 | source.UnlockBits(bitmapData);
84 | }
85 | catch (Exception ex)
86 | {
87 | throw ex;
88 | }
89 | }
90 |
91 | ///
92 | /// Get the color of the specified pixel
93 | ///
94 | ///
95 | ///
96 | ///
97 | public Color GetPixel(int x, int y)
98 | {
99 | Color clr = Color.Empty;
100 |
101 | // Get color components count
102 | int cCount = Depth / 8;
103 |
104 | // Get start index of the specified pixel
105 | int i = ((y * Width) + x) * cCount;
106 |
107 | if (i > Pixels.Length - cCount)
108 | throw new IndexOutOfRangeException();
109 |
110 | if (Depth == 32) // For 32 bpp get Red, Green, Blue and Alpha
111 | {
112 | byte b = Pixels[i];
113 | byte g = Pixels[i + 1];
114 | byte r = Pixels[i + 2];
115 | byte a = Pixels[i + 3]; // a
116 | clr = Color.FromArgb(a, r, g, b);
117 | }
118 | if (Depth == 24) // For 24 bpp get Red, Green and Blue
119 | {
120 | byte b = Pixels[i];
121 | byte g = Pixels[i + 1];
122 | byte r = Pixels[i + 2];
123 | clr = Color.FromArgb(r, g, b);
124 | }
125 | if (Depth == 8)
126 | // For 8 bpp get color value (Red, Green and Blue values are the same)
127 | {
128 | byte c = Pixels[i];
129 | clr = Color.FromArgb(c, c, c);
130 | }
131 | return clr;
132 | }
133 |
134 | ///
135 | /// Set the color of the specified pixel
136 | ///
137 | ///
138 | ///
139 | ///
140 | public void SetPixel(int x, int y, Color color)
141 | {
142 | // Get color components count
143 | int cCount = Depth / 8;
144 |
145 | // Get start index of the specified pixel
146 | int i = ((y * Width) + x) * cCount;
147 |
148 | if (Depth == 32) // For 32 bpp set Red, Green, Blue and Alpha
149 | {
150 | Pixels[i] = color.B;
151 | Pixels[i + 1] = color.G;
152 | Pixels[i + 2] = color.R;
153 | Pixels[i + 3] = color.A;
154 | }
155 | if (Depth == 24) // For 24 bpp set Red, Green and Blue
156 | {
157 | Pixels[i] = color.B;
158 | Pixels[i + 1] = color.G;
159 | Pixels[i + 2] = color.R;
160 | }
161 | if (Depth == 8)
162 | // For 8 bpp set color value (Red, Green and Blue values are the same)
163 | {
164 | Pixels[i] = color.B;
165 | }
166 | }
167 | }
168 |
169 | }
170 |
--------------------------------------------------------------------------------
/NetDimension.WinForm/Utils/Win32APIs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace NetDimension.WinForm
6 | {
7 | //你不需要知道这里面发生了什么。
8 | //YOU DO NOT NEED HAVE TO KNOW WHAT IS HAPPEND HERE.
9 |
10 |
11 |
12 |
13 | public class UxTheme
14 | {
15 | [DllImport("uxtheme.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
16 | public static extern int SetWindowTheme(IntPtr hWnd, String pszSubAppName, String pszSubIdList);
17 | }
18 |
19 | public class Shell32
20 | {
21 | public const int ABS_AUTOHIDE = 1;
22 |
23 |
24 | [DllImport("SHELL32", CallingConvention = CallingConvention.StdCall)]
25 | internal static extern int SHAppBarMessage(int dwMessage, ref APPBARDATA pData);
26 | }
27 |
28 | public class Dwm
29 | {
30 | [DllImport("dwmapi.dll")]
31 | public static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);
32 |
33 | [DllImport("dwmapi.dll")]
34 | public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
35 |
36 | [DllImport("dwmapi.dll")]
37 | public static extern int DwmIsCompositionEnabled(ref int pfEnabled);
38 | }
39 |
40 | public class User32
41 | {
42 |
43 | [DllImport("user32.dll", CharSet = CharSet.Auto)]
44 | internal static extern bool TrackMouseEvent(ref TRACKMOUSEEVENTS tme);
45 |
46 | [DllImport("User32.dll")]
47 | internal static extern IntPtr GetParent(IntPtr hWnd);
48 |
49 | [DllImport("User32.dll")]
50 | internal static extern IntPtr GetTopWindow(IntPtr hWnd);
51 | [DllImport("User32.dll")]
52 | internal static extern IntPtr GetWindow(IntPtr hWnd, uint wCmd);
53 | [DllImport("user32.dll")]
54 | internal static extern IntPtr TrackPopupMenu(IntPtr menuHandle, int uFlags, int x, int y, int nReserved, IntPtr hwnd, IntPtr par);
55 |
56 |
57 | [DllImport("user32.dll", CharSet = CharSet.Auto)]
58 | internal static extern void AdjustWindowRectEx(ref RECT rect, int dwStyle, bool hasMenu, int dwExSytle);
59 |
60 | [DllImport("user32.dll")]
61 | public static extern int SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool bRedraw);
62 |
63 | [DllImport("user32.dll")]
64 | public static extern IntPtr DefWindowProc(IntPtr hWnd, WindowsMessages uMsg, IntPtr wParam, IntPtr lParam);
65 |
66 | [DllImport("USER32.dll")]
67 | public static extern bool IsZoomed(IntPtr hwnd);
68 | public static float GetOriginalDeviceScaleFactor(IntPtr hWnd)
69 | {
70 | var hMonitor = MonitorFromWindow(hWnd, (uint)MonitorFromWindowFlags.MONITOR_DEFAULTTONEAREST);
71 |
72 | //这句不能正确的检测Win8和8.1
73 | //if ((System.Environment.OSVersion.Version.Major >= 8 && System.Environment.OSVersion.Version.Minor >= 1) || System.Environment.OSVersion.Version.Major > 8)
74 | try
75 | {
76 | //GetDpiForMonitor(hMonitor, MonitorDpiType.MDT_DEFAULT, out int x, out int y);
77 | GetDpiForMonitor(hMonitor, MonitorDpiType.MDT_DEFAULT, out int x, out int y);
78 | return x / 96f;
79 | }
80 | catch
81 | {
82 | return 1.0f;
83 | }
84 |
85 |
86 | }
87 |
88 | public static int GetOriginalDeviceDpi(IntPtr hWnd)
89 | {
90 | var hMonitor = MonitorFromWindow(hWnd, (uint)MonitorFromWindowFlags.MONITOR_DEFAULTTONEAREST);
91 |
92 | //这句不能正确的检测Win8和8.1
93 | //if ((System.Environment.OSVersion.Version.Major >= 8 && System.Environment.OSVersion.Version.Minor >= 1) || System.Environment.OSVersion.Version.Major > 8)
94 | try
95 | {
96 | //GetDpiForMonitor(hMonitor, MonitorDpiType.MDT_DEFAULT, out int x, out int y);
97 | GetDpiForMonitor(hMonitor, MonitorDpiType.MDT_DEFAULT, out int x, out int y);
98 | return x;
99 | }
100 | catch
101 | {
102 | return 96;
103 | }
104 |
105 |
106 | }
107 |
108 |
109 | [DllImport("Shcore.dll")]
110 | public static extern int GetDpiForMonitor(IntPtr hMonitor, MonitorDpiType dpiType, out int dpiX, out int dpiY);
111 |
112 | [DllImport("user32.dll")]
113 | public static extern IntPtr MonitorFromWindow(IntPtr hWnd, uint dwFlags);
114 |
115 | [DllImport("Shcore.dll")]
116 | public static extern int GetScaleFactorForMonitor(IntPtr hMonitor, ref DeviceScaleFactor pScale);
117 |
118 | [DllImport("Shcore.dll")]
119 | public static extern int GetScaleFactorForMonitor(IntPtr hMonitor, ref int pScale);
120 |
121 | [DllImport("user32.dll")]
122 | public static extern int FillRect(IntPtr hDC, [In] ref RECT lprc, IntPtr hbr);
123 |
124 |
125 | [DllImport("user32.dll")]
126 | public static extern bool InflateRect(ref RECT lprc, int dx, int dy);
127 | [DllImport("user32.dll")]
128 | public static extern int GetSystemMetrics(SystemMetricFlags smIndex);
129 |
130 | [DllImport("user32.dll")]
131 | public static extern bool GetClientRect(IntPtr hWnd, ref RECT lpRect);
132 | [DllImport("user32.dll")]
133 | public static extern IntPtr GetDCEx(IntPtr hwnd, IntPtr hrgnclip, int fdwOptions);
134 |
135 | [DllImport("user32.dll")]
136 | public static extern void DisableProcessWindowsGhosting();
137 | [DllImport("user32.dll")]
138 | [return: MarshalAs(UnmanagedType.Bool)]
139 | public static extern bool RedrawWindow(IntPtr hWnd, IntPtr lprcUpdate, IntPtr hrgnUpdate, uint flags);
140 |
141 | public static void InvalidateWindow(IntPtr hWnd)
142 | {
143 | RedrawWindow(hWnd, IntPtr.Zero, IntPtr.Zero, (int)(RedrawWindowFlags.RDW_FRAME | RedrawWindowFlags.RDW_UPDATENOW | RedrawWindowFlags.RDW_INVALIDATE | RedrawWindowFlags.RDW_ERASE));
144 | }
145 |
146 |
147 | public static void SendFrameChanged(IntPtr hWnd)
148 | {
149 | SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0,
150 | SetWindowPosFlags.SWP_FRAMECHANGED | SetWindowPosFlags.SWP_NOACTIVATE | SetWindowPosFlags.SWP_NOCOPYBITS |
151 | SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOOWNERZORDER | SetWindowPosFlags.SWP_NOREPOSITION |
152 | SetWindowPosFlags.SWP_NOSENDCHANGING | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOZORDER);
153 | }
154 |
155 | [DllImport("user32.dll")]
156 | public static extern IntPtr GetWindowDC(IntPtr hWnd);
157 |
158 | [DllImport("user32.dll")]
159 | public extern static int OffsetRect(ref RECT lpRect, int x, int y);
160 | [DllImport("user32.dll")]
161 | [return: MarshalAs(UnmanagedType.Bool)]
162 | public static extern bool IsWindowVisible(IntPtr hWnd);
163 |
164 | [DllImport("user32.dll", CharSet = CharSet.Auto)]
165 | public extern static bool SetWindowPos(int hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
166 |
167 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
168 | public static extern int SetWindowPos(IntPtr hWnd, IntPtr hWndAfter, int x, int y, int width, int height, SetWindowPosFlags flags);
169 |
170 |
171 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
172 | public static extern int MoveWindow(IntPtr hWnd, int x, int y, int width, int height, bool repaint = false);
173 |
174 | ///
175 | /// ShowWindow function of USER32
176 | ///
177 | [DllImport("user32.dll", CharSet = CharSet.Auto)]
178 | public static extern bool ShowWindow(int hWnd, int nCmdShow);
179 |
180 | ///
181 | /// ShowWindow function of USER32
182 | ///
183 | [DllImport("user32.dll")]
184 | public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
185 |
186 | ///
187 | /// ShowWindow function of USER32
188 | ///
189 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
190 | public static extern int ShowWindow(IntPtr hWnd, short cmdShow);
191 |
192 | [DllImport("user32.dll", SetLastError = true)]
193 | public static extern int CloseWindow(IntPtr hWnd);
194 |
195 | [DllImport("user32.dll")]
196 | public static extern int SetParent(int hWndChild, int hWndParent);
197 |
198 | [DllImport("user32.dll", CharSet = CharSet.Auto)]
199 | public static extern int SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
200 |
201 | [DllImport("user32.dll")]
202 | [return: MarshalAs(UnmanagedType.Bool)]
203 | public static extern bool DestroyWindow(IntPtr hWnd);
204 |
205 | [DllImport("user32.dll", SetLastError = true)]
206 | public static extern UInt16 RegisterClassW([In] ref WNDCLASS lpWndClass);
207 |
208 | [DllImport("user32.dll", SetLastError = true)]
209 | public static extern IntPtr CreateWindowExW(
210 | UInt32 dwExStyle,
211 | [MarshalAs(UnmanagedType.LPWStr)] string lpClassName,
212 | [MarshalAs(UnmanagedType.LPWStr)] string lpWindowName,
213 | UInt32 dwStyle,
214 | Int32 x,
215 | Int32 y,
216 | Int32 nWidth,
217 | Int32 nHeight,
218 | IntPtr hWndParent,
219 | IntPtr hMenu,
220 | IntPtr hInstance,
221 | IntPtr lpParam
222 | );
223 |
224 | [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
225 | internal static extern IntPtr CreateWindowEx(int dwExStyle, IntPtr classAtom, string lpWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam);
226 |
227 | [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
228 | internal static extern IntPtr CreateWindowEx(long dwExStyle, IntPtr classAtom, string lpWindowName, long dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam);
229 |
230 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
231 | public static extern uint GetWindowLong(IntPtr hWnd, GetWindowLongFlags nIndex);
232 |
233 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
234 | public static extern int SetWindowLong(IntPtr hWnd, GetWindowLongFlags nIndex, IntPtr newLong);
235 |
236 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
237 | public static extern int SetWindowLong(IntPtr hWnd, GetWindowLongFlags nIndex, uint newLong);
238 |
239 | [DllImport("user32.dll", SetLastError = true)]
240 | public static extern IntPtr DefWindowProcW(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
241 |
242 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
243 | public static extern bool GetWindowRect(IntPtr hWnd, ref RECT rect);
244 |
245 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
246 | public static extern IntPtr GetDC(IntPtr hWnd);
247 |
248 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
249 | public static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref POINT pptDst, ref SIZE psize, IntPtr hdcSrc, ref POINT pprSrc, Int32 crKey, ref BLENDFUNCTION pblend, Int32 dwFlags);
250 |
251 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
252 | public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDc);
253 |
254 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
255 | public static extern IntPtr LoadCursor(IntPtr hInstance, uint cursor);
256 |
257 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
258 | public static extern IntPtr SetCursor(IntPtr hCursor);
259 |
260 | [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
261 | public static extern int GetCursorPos(ref POINT lpPoint);
262 |
263 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
264 | public static extern bool ScreenToClient(IntPtr hWnd, ref POINT pt);
265 |
266 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
267 | public static extern bool ClientToScreen(IntPtr hWnd, ref POINT lpPoint);
268 |
269 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
270 | public static extern int ShowWindow(IntPtr hWnd, ShowWindowStyles cmdShow);
271 | [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
272 | public static extern int GetClassName(IntPtr hWnd, System.Text.StringBuilder lpClassName, int nMaxCount);
273 | [DllImport("user32.dll")]
274 | public static extern IntPtr GetActiveWindow();
275 | [DllImport("user32.dll")]
276 | public static extern IntPtr GetForegroundWindow();
277 |
278 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
279 | public static extern IntPtr SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
280 |
281 | [DllImport("user32.dll")]
282 | public static extern IntPtr SetCapture(IntPtr hWnd);
283 | [DllImport("User32.dll")]
284 | public static extern bool ReleaseCapture();
285 | [return: MarshalAs(UnmanagedType.Bool)]
286 | [DllImport("user32.dll", SetLastError = true)]
287 | internal static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
288 |
289 | [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
290 | public static extern IntPtr GetSystemMenu(IntPtr windowHandle, bool bReset);
291 |
292 | [DllImport("user32.dll")]
293 | public static extern int TrackPopupMenu(IntPtr hMenu, uint uFlags, int x, int y, int nReserved, IntPtr hWnd, IntPtr prcRect);
294 |
295 |
296 | public static uint LOWORD(IntPtr ptr)
297 | {
298 | return LoWord(ptr);
299 | }
300 |
301 | public static uint HIWORD(IntPtr ptr)
302 | {
303 | return HiWord(ptr);
304 | }
305 |
306 |
307 | public static uint HiWord(IntPtr ptr)
308 | {
309 | if (((uint)ptr & 0x80000000) == 0x80000000)
310 | {
311 | return ((uint)ptr >> 16);
312 | }
313 |
314 | return ((uint)ptr >> 16) & 0xffff;
315 | }
316 |
317 | ///
318 | /// Returns the LOW word from an IntPtr
319 | ///
320 | /// IntPtr
321 | /// LOW Word uint
322 | public static uint LoWord(IntPtr ptr)
323 | {
324 | return (uint)(ptr.ToInt32() & 0xFFFF);
325 | }
326 |
327 |
328 | }
329 |
330 | public class Gdi32
331 | {
332 |
333 | public const int RGN_AND = 1, RGN_OR = 2, RGN_XOR = 3, RGN_DIFF = 4, RGN_COPY = 5;
334 | [DllImport("USER32.dll")]
335 | internal static extern int SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool redraw);
336 | //[DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
337 | //internal static extern int BitBlt(HandleRef hDC, int x, int y, int nWidth, int nHeight, HandleRef hSrcDC, int xSrc, int ySrc, int dwRop);
338 | [DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
339 | internal static extern int BitBlt(IntPtr hDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, uint dwRop);
340 |
341 | [DllImport("gdi32.dll")]
342 | internal static extern bool LPtoDP(IntPtr hdc, [In, Out] POINT[] lpPoints, int nCount);
343 | [DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
344 | internal static extern bool GetViewportOrgEx(IntPtr hDC, ref POINT point);
345 | [DllImport("GDI32.dll")]
346 | internal static extern int ExtSelectClipRgn(IntPtr hdc, IntPtr hrgn, int mode);
347 |
348 | [DllImport("GDI32.dll")]
349 | internal static extern int RestoreDC(IntPtr hdc, int savedDC);
350 | [DllImport("GDI32.dll")]
351 | internal static extern int SaveDC(IntPtr hdc);
352 | [DllImport("GDI32.dll")]
353 | public static extern int GetClipRgn(IntPtr hdc, IntPtr hrgn);
354 | [DllImport("GDI32.dll")]
355 | public static extern int SelectClipRgn(IntPtr hdc, IntPtr hrgn);
356 | [DllImport("gdi32.dll")]
357 | public static extern IntPtr CreatePen(PenStyle fnPenStyle, int nWidth, uint crColor);
358 |
359 | [DllImport("gdi32.dll")]
360 | public static extern IntPtr CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
361 |
362 | public static IntPtr CreateRectRgn(Rectangle rect)
363 | {
364 | return CreateRectRgn(rect.Left, rect.Top, rect.Right, rect.Bottom);
365 | }
366 |
367 | [DllImport("GDI32.dll")]
368 | internal static extern int CombineRgn(IntPtr hrgnDest, IntPtr hrgnSrc1, IntPtr hrgnSrc2, int fnCombineMode);
369 |
370 | [DllImport("gdi32.dll")]
371 | public static extern uint SetBkColor(IntPtr hdc, int crColor);
372 |
373 | [DllImport("gdi32.dll")]
374 | internal extern static int ExcludeClipRect(IntPtr hdc, int x1, int y1, int x2, int y2);
375 |
376 | [DllImport("gdi32.dll")]
377 | public static extern IntPtr CreateSolidBrush([In] uint color);
378 |
379 | [DllImport("gdi32.dll")]
380 | public static extern bool Rectangle(IntPtr hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
381 |
382 | [DllImport("gdi32.dll", EntryPoint = "SelectObject", SetLastError = true)]
383 | public static extern IntPtr SelectObject([In] IntPtr hdc, [In] IntPtr hgdiobj);
384 |
385 | [DllImport("gdi32.dll")]
386 | internal static extern bool StretchBlt(IntPtr hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, IntPtr hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, uint dwRop);
387 |
388 | [DllImport("gdi32.dll", EntryPoint = "DeleteObject")]
389 | [return: MarshalAs(UnmanagedType.Bool)]
390 | public static extern bool DeleteObject([In] IntPtr hObject);
391 |
392 | [DllImport("gdi32.dll", EntryPoint = "CreateCompatibleDC", SetLastError = true)]
393 | public static extern IntPtr CreateCompatibleDC([In] IntPtr hdc);
394 |
395 | [DllImport("gdi32.dll", EntryPoint = "DeleteDC")]
396 | public static extern bool DeleteDC([In] IntPtr hdc);
397 |
398 |
399 | }
400 | }
401 |
--------------------------------------------------------------------------------
/NetDimension.WinForm/Utils/WindowMessages.cs:
--------------------------------------------------------------------------------
1 | namespace NetDimension.WinForm
2 | {
3 | //你不需要知道这里面发生了什么。
4 | //YOU DO NOT NEED HAVE TO KNOW WHAT IS HAPPEND HERE.
5 | public enum WindowsMessages
6 | {
7 | ///
8 | /// Specified WM_NULL enumeration value.
9 | ///
10 | WM_NULL = 0x0000,
11 |
12 | ///
13 | /// Specified WM_CREATE enumeration value.
14 | ///
15 | WM_CREATE = 0x0001,
16 |
17 | ///
18 | /// Specified WM_DESTROY enumeration value.
19 | ///
20 | WM_DESTROY = 0x0002,
21 |
22 | ///
23 | /// Specified WM_MOVE enumeration value.
24 | ///
25 | WM_MOVE = 0x0003,
26 |
27 | ///
28 | /// Specified WM_SIZE enumeration value.
29 | ///
30 | WM_SIZE = 0x0005,
31 |
32 | ///
33 | /// Specified WM_ACTIVATE enumeration value.
34 | ///
35 | WM_ACTIVATE = 0x0006,
36 |
37 | ///
38 | /// Specified WM_SETFOCUS enumeration value.
39 | ///
40 | WM_SETFOCUS = 0x0007,
41 |
42 | ///
43 | /// Specified WM_KILLFOCUS enumeration value.
44 | ///
45 | WM_KILLFOCUS = 0x0008,
46 |
47 | ///
48 | /// Specified WM_ENABLE enumeration value.
49 | ///
50 | WM_ENABLE = 0x000A,
51 |
52 | ///
53 | /// Specified WM_SETREDRAW enumeration value.
54 | ///
55 | WM_SETREDRAW = 0x000B,
56 |
57 | ///
58 | /// Specified WM_SETTEXT enumeration value.
59 | ///
60 | WM_SETTEXT = 0x000C,
61 |
62 | ///
63 | /// Specified WM_GETTEXT enumeration value.
64 | ///
65 | WM_GETTEXT = 0x000D,
66 |
67 | ///
68 | /// Specified WM_GETTEXTLENGTH enumeration value.
69 | ///
70 | WM_GETTEXTLENGTH = 0x000E,
71 |
72 | ///
73 | /// Specified WM_PAINT enumeration value.
74 | ///
75 | WM_PAINT = 0x000F,
76 |
77 | ///
78 | /// Specified WM_CLOSE enumeration value.
79 | ///
80 | WM_CLOSE = 0x0010,
81 |
82 | ///
83 | /// Specified WM_QUERYENDSESSION enumeration value.
84 | ///
85 | WM_QUERYENDSESSION = 0x0011,
86 |
87 | ///
88 | /// Specified WM_QUIT enumeration value.
89 | ///
90 | WM_QUIT = 0x0012,
91 |
92 | ///
93 | /// Specified WM_QUERYOPEN enumeration value.
94 | ///
95 | WM_QUERYOPEN = 0x0013,
96 |
97 | ///
98 | /// Specified WM_ERASEBKGND enumeration value.
99 | ///
100 | WM_ERASEBKGND = 0x0014,
101 |
102 | ///
103 | /// Specified WM_SYSCOLORCHANGE enumeration value.
104 | ///
105 | WM_SYSCOLORCHANGE = 0x0015,
106 |
107 | ///
108 | /// Specified WM_ENDSESSION enumeration value.
109 | ///
110 | WM_ENDSESSION = 0x0016,
111 |
112 | ///
113 | /// Specified WM_SHOWWINDOW enumeration value.
114 | ///
115 | WM_SHOWWINDOW = 0x0018,
116 |
117 | ///
118 | /// Specified WM_WININICHANGE enumeration value.
119 | ///
120 | WM_WININICHANGE = 0x001A,
121 |
122 | ///
123 | /// Specified WM_SETTINGCHANGE enumeration value.
124 | ///
125 | WM_SETTINGCHANGE = 0x001A,
126 |
127 | ///
128 | /// Specified WM_DEVMODECHANGE enumeration value.
129 | ///
130 | WM_DEVMODECHANGE = 0x001B,
131 |
132 | ///
133 | /// Specified WM_ACTIVATEAPP enumeration value.
134 | ///
135 | WM_ACTIVATEAPP = 0x001C,
136 |
137 | ///
138 | /// Specified WM_FONTCHANGE enumeration value.
139 | ///
140 | WM_FONTCHANGE = 0x001D,
141 |
142 | ///
143 | /// Specified WM_TIMECHANGE enumeration value.
144 | ///
145 | WM_TIMECHANGE = 0x001E,
146 |
147 | ///
148 | /// Specified WM_CANCELMODE enumeration value.
149 | ///
150 | WM_CANCELMODE = 0x001F,
151 |
152 | ///
153 | /// Specified WM_SETCURSOR enumeration value.
154 | ///
155 | WM_SETCURSOR = 0x0020,
156 |
157 | ///
158 | /// Specified WM_MOUSEACTIVATE enumeration value.
159 | ///
160 | WM_MOUSEACTIVATE = 0x0021,
161 |
162 | ///
163 | /// Specified WM_CHILDACTIVATE enumeration value.
164 | ///
165 | WM_CHILDACTIVATE = 0x0022,
166 |
167 | ///
168 | /// Specified WM_QUEUESYNC enumeration value.
169 | ///
170 | WM_QUEUESYNC = 0x0023,
171 |
172 | ///
173 | /// Specified WM_GETMINMAXINFO enumeration value.
174 | ///
175 | WM_GETMINMAXINFO = 0x0024,
176 |
177 | ///
178 | /// Specified WM_PAINTICON enumeration value.
179 | ///
180 | WM_PAINTICON = 0x0026,
181 |
182 | ///
183 | /// Specified WM_ICONERASEBKGND enumeration value.
184 | ///
185 | WM_ICONERASEBKGND = 0x0027,
186 |
187 | ///
188 | /// Specified WM_NEXTDLGCTL enumeration value.
189 | ///
190 | WM_NEXTDLGCTL = 0x0028,
191 |
192 | ///
193 | /// Specified WM_SPOOLERSTATUS enumeration value.
194 | ///
195 | WM_SPOOLERSTATUS = 0x002A,
196 |
197 | ///
198 | /// Specified WM_DRAWITEM enumeration value.
199 | ///
200 | WM_DRAWITEM = 0x002B,
201 |
202 | ///
203 | /// Specified WM_MEASUREITEM enumeration value.
204 | ///
205 | WM_MEASUREITEM = 0x002C,
206 |
207 | ///
208 | /// Specified WM_DELETEITEM enumeration value.
209 | ///
210 | WM_DELETEITEM = 0x002D,
211 |
212 | ///
213 | /// Specified WM_VKEYTOITEM enumeration value.
214 | ///
215 | WM_VKEYTOITEM = 0x002E,
216 |
217 | ///
218 | /// Specified WM_CHARTOITEM enumeration value.
219 | ///
220 | WM_CHARTOITEM = 0x002F,
221 |
222 | ///
223 | /// Specified WM_SETFONT enumeration value.
224 | ///
225 | WM_SETFONT = 0x0030,
226 |
227 | ///
228 | /// Specified WM_GETFONT enumeration value.
229 | ///
230 | WM_GETFONT = 0x0031,
231 |
232 | ///
233 | /// Specified WM_SETHOTKEY enumeration value.
234 | ///
235 | WM_SETHOTKEY = 0x0032,
236 |
237 | ///
238 | /// Specified WM_GETHOTKEY enumeration value.
239 | ///
240 | WM_GETHOTKEY = 0x0033,
241 |
242 | ///
243 | /// Specified WM_QUERYDRAGICON enumeration value.
244 | ///
245 | WM_QUERYDRAGICON = 0x0037,
246 |
247 | ///
248 | /// Specified WM_COMPAREITEM enumeration value.
249 | ///
250 | WM_COMPAREITEM = 0x0039,
251 |
252 | ///
253 | /// Specified WM_GETOBJECT enumeration value.
254 | ///
255 | WM_GETOBJECT = 0x003D,
256 |
257 | ///
258 | /// Specified WM_COMPACTING enumeration value.
259 | ///
260 | WM_COMPACTING = 0x0041,
261 |
262 | ///
263 | /// Specified WM_COMMNOTIFY enumeration value.
264 | ///
265 | WM_COMMNOTIFY = 0x0044,
266 |
267 | ///
268 | /// Specified WM_WINDOWPOSCHANGING enumeration value.
269 | ///
270 | WM_WINDOWPOSCHANGING = 0x0046,
271 |
272 | ///
273 | /// Specified WM_WINDOWPOSCHANGED enumeration value.
274 | ///
275 | WM_WINDOWPOSCHANGED = 0x0047,
276 |
277 | ///
278 | /// Specified WM_POWER enumeration value.
279 | ///
280 | WM_POWER = 0x0048,
281 |
282 | ///
283 | /// Specified WM_COPYDATA enumeration value.
284 | ///
285 | WM_COPYDATA = 0x004A,
286 |
287 | ///
288 | /// Specified WM_CANCELJOURNAL enumeration value.
289 | ///
290 | WM_CANCELJOURNAL = 0x004B,
291 |
292 | ///
293 | /// Specified WM_NOTIFY enumeration value.
294 | ///
295 | WM_NOTIFY = 0x004E,
296 |
297 | ///
298 | /// Specified WM_INPUTLANGCHANGEREQUEST enumeration value.
299 | ///
300 | WM_INPUTLANGCHANGEREQUEST = 0x0050,
301 |
302 | ///
303 | /// Specified WM_INPUTLANGCHANGE enumeration value.
304 | ///
305 | WM_INPUTLANGCHANGE = 0x0051,
306 |
307 | ///
308 | /// Specified WM_TCARD enumeration value.
309 | ///
310 | WM_TCARD = 0x0052,
311 |
312 | ///
313 | /// Specified WM_HELP enumeration value.
314 | ///
315 | WM_HELP = 0x0053,
316 |
317 | ///
318 | /// Specified WM_USERCHANGED enumeration value.
319 | ///
320 | WM_USERCHANGED = 0x0054,
321 |
322 | ///
323 | /// Specified WM_NOTIFYFORMAT enumeration value.
324 | ///
325 | WM_NOTIFYFORMAT = 0x0055,
326 |
327 | ///
328 | /// Specified WM_CONTEXTMENU enumeration value.
329 | ///
330 | WM_CONTEXTMENU = 0x007B,
331 |
332 | ///
333 | /// Specified WM_STYLECHANGING enumeration value.
334 | ///
335 | WM_STYLECHANGING = 0x007C,
336 |
337 | ///
338 | /// Specified WM_STYLECHANGED enumeration value.
339 | ///
340 | WM_STYLECHANGED = 0x007D,
341 |
342 | ///
343 | /// Specified WM_DISPLAYCHANGE enumeration value.
344 | ///
345 | WM_DISPLAYCHANGE = 0x007E,
346 |
347 | ///
348 | /// Specified WM_GETICON enumeration value.
349 | ///
350 | WM_GETICON = 0x007F,
351 |
352 | ///
353 | /// Specified WM_SETICON enumeration value.
354 | ///
355 | WM_SETICON = 0x0080,
356 |
357 | ///
358 | /// Specified WM_NCCREATE enumeration value.
359 | ///
360 | WM_NCCREATE = 0x0081,
361 |
362 | ///
363 | /// Specified VK_RMENU enumeration value.
364 | ///
365 | WM_NCDESTROY = 0x0082,
366 |
367 | ///
368 | /// Specified WM_NCCALCSIZE enumeration value.
369 | ///
370 | WM_NCCALCSIZE = 0x0083,
371 |
372 | ///
373 | /// Specified WM_NCHITTEST enumeration value.
374 | ///
375 | WM_NCHITTEST = 0x0084,
376 |
377 | ///
378 | /// Specified WM_NCPAINT enumeration value.
379 | ///
380 | WM_NCPAINT = 0x0085,
381 |
382 | ///
383 | /// Specified WM_NCACTIVATE enumeration value.
384 | ///
385 | WM_NCACTIVATE = 0x0086,
386 |
387 | ///
388 | /// Specified WM_GETDLGCODE enumeration value.
389 | ///
390 | WM_GETDLGCODE = 0x0087,
391 |
392 | ///
393 | /// Specified WM_SYNCPAINT enumeration value.
394 | ///
395 | WM_SYNCPAINT = 0x0088,
396 |
397 | ///
398 | /// Specified WM_NCMOUSEMOVE enumeration value.
399 | ///
400 | WM_NCMOUSEMOVE = 0x00A0,
401 |
402 | ///
403 | /// Specified WM_NCLBUTTONDOWN enumeration value.
404 | ///
405 | WM_NCLBUTTONDOWN = 0x00A1,
406 |
407 | ///
408 | /// Specified WM_NCLBUTTONUP enumeration value.
409 | ///
410 | WM_NCLBUTTONUP = 0x00A2,
411 |
412 | ///
413 | /// Specified WM_NCLBUTTONDBLCLK enumeration value.
414 | ///
415 | WM_NCLBUTTONDBLCLK = 0x00A3,
416 |
417 | ///
418 | /// Specified WM_NCRBUTTONDOWN enumeration value.
419 | ///
420 | WM_NCRBUTTONDOWN = 0x00A4,
421 |
422 | ///
423 | /// Specified WM_NCRBUTTONUP enumeration value.
424 | ///
425 | WM_NCRBUTTONUP = 0x00A5,
426 |
427 | ///
428 | /// Specified WM_NCRBUTTONDBLCLK enumeration value.
429 | ///
430 | WM_NCRBUTTONDBLCLK = 0x00A6,
431 |
432 | ///
433 | /// Specified WM_NCMBUTTONDOWN enumeration value.
434 | ///
435 | WM_NCMBUTTONDOWN = 0x00A7,
436 |
437 | ///
438 | /// Specified WM_NCMBUTTONUP enumeration value.
439 | ///
440 | WM_NCMBUTTONUP = 0x00A8,
441 |
442 | ///
443 | /// Specified WM_NCMBUTTONDBLCLK enumeration value.
444 | ///
445 | WM_NCMBUTTONDBLCLK = 0x00A9,
446 |
447 | ///
448 | /// Specified WM_NCXBUTTONDOWN enumeration value.
449 | ///
450 | WM_NCXBUTTONDOWN = 0x00AB,
451 |
452 | ///
453 | /// Specified WM_NCXBUTTONUP enumeration value.
454 | ///
455 | WM_NCXBUTTONUP = 0x00AC,
456 |
457 | ///
458 | /// Specified WM_KEYDOWN enumeration value.
459 | ///
460 | WM_KEYDOWN = 0x0100,
461 |
462 | ///
463 | /// Specified WM_KEYUP enumeration value.
464 | ///
465 | WM_KEYUP = 0x0101,
466 |
467 | ///
468 | /// Specified WM_CHAR enumeration value.
469 | ///
470 | WM_CHAR = 0x0102,
471 |
472 | ///
473 | /// Specified WM_DEADCHAR enumeration value.
474 | ///
475 | WM_DEADCHAR = 0x0103,
476 |
477 | ///
478 | /// Specified WM_SYSKEYDOWN enumeration value.
479 | ///
480 | WM_SYSKEYDOWN = 0x0104,
481 |
482 | ///
483 | /// Specified WM_SYSKEYUP enumeration value.
484 | ///
485 | WM_SYSKEYUP = 0x0105,
486 |
487 | ///
488 | /// Specified WM_SYSCHAR enumeration value.
489 | ///
490 | WM_SYSCHAR = 0x0106,
491 |
492 | ///
493 | /// Specified WM_SYSDEADCHAR enumeration value.
494 | ///
495 | WM_SYSDEADCHAR = 0x0107,
496 |
497 | ///
498 | /// Specified WM_KEYLAST enumeration value.
499 | ///
500 | WM_KEYLAST = 0x0108,
501 |
502 | ///
503 | /// Specified WM_IME_STARTCOMPOSITION enumeration value.
504 | ///
505 | WM_IME_STARTCOMPOSITION = 0x010D,
506 |
507 | ///
508 | /// Specified WM_IME_ENDCOMPOSITION enumeration value.
509 | ///
510 | WM_IME_ENDCOMPOSITION = 0x010E,
511 |
512 | ///
513 | /// Specified WM_IME_COMPOSITION enumeration value.
514 | ///
515 | WM_IME_COMPOSITION = 0x010F,
516 |
517 | ///
518 | /// Specified WM_IME_KEYLAST enumeration value.
519 | ///
520 | WM_IME_KEYLAST = 0x010F,
521 |
522 | ///
523 | /// Specified WM_INITDIALOG enumeration value.
524 | ///
525 | WM_INITDIALOG = 0x0110,
526 |
527 | ///
528 | /// Specified WM_COMMAND enumeration value.
529 | ///
530 | WM_COMMAND = 0x0111,
531 |
532 | ///
533 | /// Specified WM_SYSCOMMAND enumeration value.
534 | ///
535 | WM_SYSCOMMAND = 0x0112,
536 |
537 | ///
538 | /// Specified WM_TIMER enumeration value.
539 | ///
540 | WM_TIMER = 0x0113,
541 |
542 | ///
543 | /// Specified WM_HSCROLL enumeration value.
544 | ///
545 | WM_HSCROLL = 0x0114,
546 |
547 | ///
548 | /// Specified WM_VSCROLL enumeration value.
549 | ///
550 | WM_VSCROLL = 0x0115,
551 |
552 | ///
553 | /// Specified WM_INITMENU enumeration value.
554 | ///
555 | WM_INITMENU = 0x0116,
556 |
557 | ///
558 | /// Specified WM_INITMENUPOPUP enumeration value.
559 | ///
560 | WM_INITMENUPOPUP = 0x0117,
561 |
562 | ///
563 | /// Specified WM_MENUSELECT enumeration value.
564 | ///
565 | WM_MENUSELECT = 0x011F,
566 |
567 | ///
568 | /// Specified WM_MENUCHAR enumeration value.
569 | ///
570 | WM_MENUCHAR = 0x0120,
571 |
572 | ///
573 | /// Specified WM_ENTERIDLE enumeration value.
574 | ///
575 | WM_ENTERIDLE = 0x0121,
576 |
577 | ///
578 | /// Specified WM_MENURBUTTONUP enumeration value.
579 | ///
580 | WM_MENURBUTTONUP = 0x0122,
581 |
582 | ///
583 | /// Specified WM_MENUDRAG enumeration value.
584 | ///
585 | WM_MENUDRAG = 0x0123,
586 |
587 | ///
588 | /// Specified WM_MENUGETOBJECT enumeration value.
589 | ///
590 | WM_MENUGETOBJECT = 0x0124,
591 |
592 | ///
593 | /// Specified WM_UNINITMENUPOPUP enumeration value.
594 | ///
595 | WM_UNINITMENUPOPUP = 0x0125,
596 |
597 | ///
598 | /// Specified WM_MENUCOMMAND enumeration value.
599 | ///
600 | WM_MENUCOMMAND = 0x0126,
601 |
602 | ///
603 | /// Specified WM_CTLCOLORMSGBOX enumeration value.
604 | ///
605 | WM_CTLCOLORMSGBOX = 0x0132,
606 |
607 | ///
608 | /// Specified WM_CTLCOLOREDIT enumeration value.
609 | ///
610 | WM_CTLCOLOREDIT = 0x0133,
611 |
612 | ///
613 | /// Specified WM_CTLCOLORLISTBOX enumeration value.
614 | ///
615 | WM_CTLCOLORLISTBOX = 0x0134,
616 |
617 | ///
618 | /// Specified WM_CTLCOLORBTN enumeration value.
619 | ///
620 | WM_CTLCOLORBTN = 0x0135,
621 |
622 | ///
623 | /// Specified WM_CTLCOLORDLG enumeration value.
624 | ///
625 | WM_CTLCOLORDLG = 0x0136,
626 |
627 | ///
628 | /// Specified WM_CTLCOLORSCROLLBAR enumeration value.
629 | ///
630 | WM_CTLCOLORSCROLLBAR = 0x0137,
631 |
632 | ///
633 | /// Specified WM_CTLCOLORSTATIC enumeration value.
634 | ///
635 | WM_CTLCOLORSTATIC = 0x0138,
636 |
637 | ///
638 | /// Specified WM_MOUSEMOVE enumeration value.
639 | ///
640 | WM_MOUSEMOVE = 0x0200,
641 |
642 | ///
643 | /// Specified WM_LBUTTONDOWN enumeration value.
644 | ///
645 | WM_LBUTTONDOWN = 0x0201,
646 |
647 | ///
648 | /// Specified WM_LBUTTONUP enumeration value.
649 | ///
650 | WM_LBUTTONUP = 0x0202,
651 |
652 | ///
653 | /// Specified WM_LBUTTONDBLCLK enumeration value.
654 | ///
655 | WM_LBUTTONDBLCLK = 0x0203,
656 |
657 | ///
658 | /// Specified WM_RBUTTONDOWN enumeration value.
659 | ///
660 | WM_RBUTTONDOWN = 0x0204,
661 |
662 | ///
663 | /// Specified WM_RBUTTONUP enumeration value.
664 | ///
665 | WM_RBUTTONUP = 0x0205,
666 |
667 | ///
668 | /// Specified WM_RBUTTONDBLCLK enumeration value.
669 | ///
670 | WM_RBUTTONDBLCLK = 0x0206,
671 |
672 | ///
673 | /// Specified WM_MBUTTONDOWN enumeration value.
674 | ///
675 | WM_MBUTTONDOWN = 0x0207,
676 |
677 | ///
678 | /// Specified WM_MBUTTONUP enumeration value.
679 | ///
680 | WM_MBUTTONUP = 0x0208,
681 |
682 | ///
683 | /// Specified WM_MBUTTONDBLCLK enumeration value.
684 | ///
685 | WM_MBUTTONDBLCLK = 0x0209,
686 |
687 | ///
688 | /// Specified WM_MOUSEWHEEL enumeration value.
689 | ///
690 | WM_MOUSEWHEEL = 0x020A,
691 | WM_NCMOUSELEAVE = 0x02A2,
692 | ///
693 | /// Specified WM_XBUTTONDOWN enumeration value.
694 | ///
695 | WM_XBUTTONDOWN = 0x020B,
696 |
697 | ///
698 | /// Specified WM_XBUTTONUP enumeration value.
699 | ///
700 | WM_XBUTTONUP = 0x020C,
701 |
702 | ///
703 | /// Specified WM_XBUTTONDBLCLK enumeration value.
704 | ///
705 | WM_XBUTTONDBLCLK = 0x020D,
706 |
707 | ///
708 | /// Specified WM_PARENTNOTIFY enumeration value.
709 | ///
710 | WM_PARENTNOTIFY = 0x0210,
711 |
712 | ///
713 | /// Specified WM_ENTERMENULOOP enumeration value.
714 | ///
715 | WM_ENTERMENULOOP = 0x0211,
716 |
717 | ///
718 | /// Specified WM_EXITMENULOOP enumeration value.
719 | ///
720 | WM_EXITMENULOOP = 0x0212,
721 |
722 | ///
723 | /// Specified WM_NEXTMENU enumeration value.
724 | ///
725 | WM_NEXTMENU = 0x0213,
726 |
727 | ///
728 | /// Specified WM_SIZING enumeration value.
729 | ///
730 | WM_SIZING = 0x0214,
731 |
732 | ///
733 | /// Specified WM_CAPTURECHANGED enumeration value.
734 | ///
735 | WM_CAPTURECHANGED = 0x0215,
736 |
737 | ///
738 | /// Specified WM_MOVING enumeration value.
739 | ///
740 | WM_MOVING = 0x0216,
741 |
742 | ///
743 | /// Specified WM_DEVICECHANGE enumeration value.
744 | ///
745 | WM_DEVICECHANGE = 0x0219,
746 |
747 | ///
748 | /// Specified WM_MDICREATE enumeration value.
749 | ///
750 | WM_MDICREATE = 0x0220,
751 |
752 | ///
753 | /// Specified WM_MDIDESTROY enumeration value.
754 | ///
755 | WM_MDIDESTROY = 0x0221,
756 |
757 | ///
758 | /// Specified WM_MDIACTIVATE enumeration value.
759 | ///
760 | WM_MDIACTIVATE = 0x0222,
761 |
762 | ///
763 | /// Specified WM_MDIRESTORE enumeration value.
764 | ///
765 | WM_MDIRESTORE = 0x0223,
766 |
767 | ///
768 | /// Specified WM_MDINEXT enumeration value.
769 | ///
770 | WM_MDINEXT = 0x0224,
771 |
772 | ///
773 | /// Specified WM_MDIMAXIMIZE enumeration value.
774 | ///
775 | WM_MDIMAXIMIZE = 0x0225,
776 |
777 | ///
778 | /// Specified WM_MDITILE enumeration value.
779 | ///
780 | WM_MDITILE = 0x0226,
781 |
782 | ///
783 | /// Specified WM_MDICASCADE enumeration value.
784 | ///
785 | WM_MDICASCADE = 0x0227,
786 |
787 | ///
788 | /// Specified WM_MDIICONARRANGE enumeration value.
789 | ///
790 | WM_MDIICONARRANGE = 0x0228,
791 |
792 | ///
793 | /// Specified WM_MDIGETACTIVE enumeration value.
794 | ///
795 | WM_MDIGETACTIVE = 0x0229,
796 |
797 | ///
798 | /// Specified WM_MDISETMENU enumeration value.
799 | ///
800 | WM_MDISETMENU = 0x0230,
801 |
802 | ///
803 | /// Specified WM_ENTERSIZEMOVE enumeration value.
804 | ///
805 | WM_ENTERSIZEMOVE = 0x0231,
806 |
807 | ///
808 | /// Specified WM_EXITSIZEMOVE enumeration value.
809 | ///
810 | WM_EXITSIZEMOVE = 0x0232,
811 |
812 | ///
813 | /// Specified WM_DROPFILES enumeration value.
814 | ///
815 | WM_DROPFILES = 0x0233,
816 |
817 | ///
818 | /// Specified WM_MDIREFRESHMENU enumeration value.
819 | ///
820 | WM_MDIREFRESHMENU = 0x0234,
821 |
822 | ///
823 | /// Specified WM_IME_SETCONTEXT enumeration value.
824 | ///
825 | WM_IME_SETCONTEXT = 0x0281,
826 |
827 | ///
828 | /// Specified WM_IME_NOTIFY enumeration value.
829 | ///
830 | WM_IME_NOTIFY = 0x0282,
831 |
832 | ///
833 | /// Specified WM_IME_CONTROL enumeration value.
834 | ///
835 | WM_IME_CONTROL = 0x0283,
836 |
837 | ///
838 | /// Specified WM_IME_COMPOSITIONFULL enumeration value.
839 | ///
840 | WM_IME_COMPOSITIONFULL = 0x0284,
841 |
842 | ///
843 | /// Specified WM_IME_SELECT enumeration value.
844 | ///
845 | WM_IME_SELECT = 0x0285,
846 |
847 | ///
848 | /// Specified WM_IME_CHAR enumeration value.
849 | ///
850 | WM_IME_CHAR = 0x0286,
851 |
852 | ///
853 | /// Specified WM_IME_REQUEST enumeration value.
854 | ///
855 | WM_IME_REQUEST = 0x0288,
856 |
857 | ///
858 | /// Specified WM_IME_KEYDOWN enumeration value.
859 | ///
860 | WM_IME_KEYDOWN = 0x0290,
861 |
862 | ///
863 | /// Specified WM_IME_KEYUP enumeration value.
864 | ///
865 | WM_IME_KEYUP = 0x0291,
866 |
867 | ///
868 | /// Specified WM_MOUSEHOVER enumeration value.
869 | ///
870 | WM_MOUSEHOVER = 0x02A1,
871 |
872 | ///
873 | /// Specified WM_MOUSELEAVE enumeration value.
874 | ///
875 | WM_MOUSELEAVE = 0x02A3,
876 |
877 | ///
878 | /// Specified WM_CUT enumeration value.
879 | ///
880 | WM_CUT = 0x0300,
881 |
882 | ///
883 | /// Specified WM_COPY enumeration value.
884 | ///
885 | WM_COPY = 0x0301,
886 |
887 | ///
888 | /// Specified WM_PASTE enumeration value.
889 | ///
890 | WM_PASTE = 0x0302,
891 |
892 | ///
893 | /// Specified WM_CLEAR enumeration value.
894 | ///
895 | WM_CLEAR = 0x0303,
896 |
897 | ///
898 | /// Specified WM_UNDO enumeration value.
899 | ///
900 | WM_UNDO = 0x0304,
901 |
902 | ///
903 | /// Specified WM_RENDERFORMAT enumeration value.
904 | ///
905 | WM_RENDERFORMAT = 0x0305,
906 |
907 | ///
908 | /// Specified WM_RENDERALLFORMATS enumeration value.
909 | ///
910 | WM_RENDERALLFORMATS = 0x0306,
911 |
912 | ///
913 | /// Specified WM_DESTROYCLIPBOARD enumeration value.
914 | ///
915 | WM_DESTROYCLIPBOARD = 0x0307,
916 |
917 | ///
918 | /// Specified WM_DRAWCLIPBOARD enumeration value.
919 | ///
920 | WM_DRAWCLIPBOARD = 0x0308,
921 |
922 | ///
923 | /// Specified WM_PAINTCLIPBOARD enumeration value.
924 | ///
925 | WM_PAINTCLIPBOARD = 0x0309,
926 |
927 | ///
928 | /// Specified WM_VSCROLLCLIPBOARD enumeration value.
929 | ///
930 | WM_VSCROLLCLIPBOARD = 0x030A,
931 |
932 | ///
933 | /// Specified WM_SIZECLIPBOARD enumeration value.
934 | ///
935 | WM_SIZECLIPBOARD = 0x030B,
936 |
937 | ///
938 | /// Specified WM_ASKCBFORMATNAME enumeration value.
939 | ///
940 | WM_ASKCBFORMATNAME = 0x030C,
941 |
942 | ///
943 | /// Specified WM_CHANGECBCHAIN enumeration value.
944 | ///
945 | WM_CHANGECBCHAIN = 0x030D,
946 |
947 | ///
948 | /// Specified WM_HSCROLLCLIPBOARD enumeration value.
949 | ///
950 | WM_HSCROLLCLIPBOARD = 0x030E,
951 |
952 | ///
953 | /// Specified WM_QUERYNEWPALETTE enumeration value.
954 | ///
955 | WM_QUERYNEWPALETTE = 0x030F,
956 |
957 | ///
958 | /// Specified WM_PALETTEISCHANGING enumeration value.
959 | ///
960 | WM_PALETTEISCHANGING = 0x0310,
961 |
962 | ///
963 | /// Specified WM_PALETTECHANGED enumeration value.
964 | ///
965 | WM_PALETTECHANGED = 0x0311,
966 |
967 | ///
968 | /// Specified WM_HOTKEY enumeration value.
969 | ///
970 | WM_HOTKEY = 0x0312,
971 |
972 | ///
973 | /// Specified WM_PRINT enumeration value.
974 | ///
975 | WM_PRINT = 0x0317,
976 |
977 | ///
978 | /// Specified WM_PRINTCLIENT enumeration value.
979 | ///
980 | WM_PRINTCLIENT = 0x0318,
981 |
982 | ///
983 | /// Specified WM_HANDHELDFIRST enumeration value.
984 | ///
985 | WM_HANDHELDFIRST = 0x0358,
986 |
987 | ///
988 | /// Specified WM_HANDHELDLAST enumeration value.
989 | ///
990 | WM_HANDHELDLAST = 0x035F,
991 |
992 | ///
993 | /// Specified WM_AFXFIRST enumeration value.
994 | ///
995 | WM_AFXFIRST = 0x0360,
996 |
997 | ///
998 | /// Specified WM_AFXLAST enumeration value.
999 | ///
1000 | WM_AFXLAST = 0x037F,
1001 |
1002 | ///
1003 | /// Specified WM_PENWINFIRST enumeration value.
1004 | ///
1005 | WM_PENWINFIRST = 0x0380,
1006 |
1007 | ///
1008 | /// Specified WM_PENWINLAST enumeration value.
1009 | ///
1010 | WM_PENWINLAST = 0x038F,
1011 |
1012 | ///
1013 | /// Specified WM_APP enumeration value.
1014 | ///
1015 | WM_APP = 0x8000,
1016 |
1017 | ///
1018 | /// Specified WM_USER enumeration value.
1019 | ///
1020 | WM_USER = 0x0400,
1021 |
1022 | ///
1023 | /// Specified WM_THEMECHANGED enumeration value.
1024 | ///
1025 | WM_THEMECHANGED = 0x031A,
1026 |
1027 | NIN_BALLOONSHOW = 0x402,
1028 | NIN_BALLOONHIDE = 0x403,
1029 | NIN_BALLOONTIMEOUT = 0x404,
1030 | NIN_BALLOONUSERCLICK = 0x405,
1031 |
1032 | WM_REFLECT = WM_USER + 0x1C00,
1033 |
1034 | SC_MOVE = 0xF010,
1035 | SC_SIZE = 0xF000,
1036 |
1037 |
1038 | WM_NCUAHDRAWCAPTION = 0x00AE,
1039 | WM_NCUAHDRAWFRAME = 0x00AF,
1040 | WM_UNKNOWN_GHOST = 0xC1BC,
1041 |
1042 | WM_DPICHANGED = 0x02E0
1043 | }
1044 |
1045 | }
1046 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ModernUI Form
2 |
3 | **ModernUI Form** is a library that makes your .Net Windows Form Application look like ModernUI window in Win8/8.1 and Win10.
4 |
5 | It's frameless, border customizable. You could set border size, border color and dropshadows. It redrews borders of stardard WinForm, and make a dropshadow around the window. You can set your form's border size and color, also you can set color of the dropshadow too.
6 |
7 | 
8 |
9 | ## 2019/12/13 ##
10 |
11 | .NET 4.6以及之后的版本微软为WinForm添加了原生的缩放支持,在app.config文件中加入一下代码即可开启原生的缩放支持。
12 | ```
13 |
14 | ...
15 |
16 |
17 |
18 |
19 |
20 | ```
21 | 针对此特性,修改了处理DPI变化的消息,忽略原生的缩放下次,避免窗口被缩放2次的问题。
22 |
23 | ## 2019/11/11 更新 ##
24 |
25 | 加入了对Win8.1/Win10的PerMonitor/PerMonitorV2的DPI相关API的支持.
26 |
27 | 现在能过通过添加dpiAwareness属性来声明对不同DPI接口的支持。
28 |
29 | ```
30 |
31 |
32 | PerMonitorV2
33 | true
34 |
35 |
36 | ```
37 |
38 | ## 2019/11/2 更新 ##
39 |
40 | 重新写了窗口底层解决了以下问题:
41 |
42 | - 最大化最小化之后内容错乱
43 | - 设计器大小与实际大小不一致
44 | - 初始的 WindowState 设置为 Maximized 时窗口位置错误
45 | - FormBorderStyle设置为None是全屏窗口大小不正确
46 | - Win7+系统下,拖拽窗口到桌面顶部最大化,还原时窗口位置错误
47 |
48 | 修改的API
49 |
50 | - 使用Borders属性替代了BorderWidth属性,现在可以使用Borders属性[Padding类型]来为窗体指定每条边框的大小
51 | - 使用BorderColor属性替代了ActiveBorderColor和InactiveBorderColor属性,现在统一使用BorderColor属性设置边框颜色
52 | - 使用ShadowColor属性替代了ActiveShaodowColor和InactiveShadowColor属性,现在统一使用ShadowColor属性设置窗体投影效果
53 | - 移除了BorderEffect属性,现在只保留DropShadow一种投影模式,取消了Glow投影样式。
54 |
55 |
56 |
57 | ## Features
58 | - Make ModernUI-like Forms for .Net Windows Form Applications.
59 | - Full window animations support (Not just set FormBorderStyle to None).
60 | - Fast draw the dropshadow around the form.
61 | - Support Form Active/Inactive state.
62 |
63 | ## NuGet
64 | ```
65 | PM> Install-Package NetDimension.WinForm.ModernUI
66 | ```
67 |
68 |
69 | ## Example
70 |
71 |
72 | ```C#
73 | public partial class Form1 : ModernUIForm
74 | {
75 | public Form1()
76 | {
77 | InitializeComponent();
78 | }
79 | }
80 | ```
81 |
82 | Change properties in "UI" category to make your form style as your wish.
83 |
84 | ## Donate
85 |
86 | If you like my work, please buy me a cup of coffee to encourage me continue with this library.
87 | 
88 |
89 | [](https://www.paypal.me/mrjson)
90 |
--------------------------------------------------------------------------------
/SystemInfoPrograme/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/SystemInfoPrograme/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace SystemInfoPrograme
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new SystemInfoBrowser.SystemInfoBrowserForm());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/SystemInfoPrograme/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SystemInfoPrograme")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("SystemInfoPrograme")]
13 | [assembly: AssemblyCopyright("Copyright © 2019")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("58fd5123-c625-4db3-be02-8cd6ac5a26d7")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/SystemInfoPrograme/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace SystemInfoPrograme.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
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 Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SystemInfoPrograme.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/SystemInfoPrograme/Properties/Resources.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 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/SystemInfoPrograme/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace SystemInfoPrograme.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/SystemInfoPrograme/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/SystemInfoPrograme/SystemInfoBrowserForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace SystemInfoPrograme
8 | {
9 | using System;
10 | using System.Collections;
11 | using System.ComponentModel;
12 | using System.Drawing;
13 | using System.Reflection;
14 | using System.Windows.Forms;
15 |
16 | namespace SystemInfoBrowser
17 | {
18 | public class SystemInfoBrowserForm : System.Windows.Forms.Form
19 | {
20 | private System.Windows.Forms.ListBox listBox1;
21 | private System.Windows.Forms.TextBox textBox1;
22 |
23 | public SystemInfoBrowserForm()
24 | {
25 | this.SuspendLayout();
26 | InitForm();
27 |
28 | // Add each property of the SystemInformation class to the list box.
29 | Type t = typeof(System.Windows.Forms.SystemInformation);
30 | PropertyInfo[] pi = t.GetProperties();
31 | for (int i = 0; i < pi.Length; i++)
32 | listBox1.Items.Add(pi[i].Name);
33 | textBox1.Text = "The SystemInformation class has " + pi.Length.ToString() + " properties.\r\n";
34 |
35 | // Configure the list item selected handler for the list box to invoke a
36 | // method that displays the value of each property.
37 | listBox1.SelectedIndexChanged += new EventHandler(listBox1_SelectedIndexChanged);
38 | this.ResumeLayout(false);
39 | }
40 |
41 | private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
42 | {
43 | // Return if no list item is selected.
44 | if (listBox1.SelectedIndex == -1) return;
45 | // Get the property name from the list item.
46 | string propname = listBox1.Text;
47 |
48 | if (propname == "PowerStatus")
49 | {
50 | // Cycle and display the values of each property of the PowerStatus property.
51 | textBox1.Text += "\r\nThe value of the PowerStatus property is:";
52 | Type t = typeof(System.Windows.Forms.PowerStatus);
53 | PropertyInfo[] pi = t.GetProperties();
54 | for (int i = 0; i < pi.Length; i++)
55 | {
56 | object propval = pi[i].GetValue(SystemInformation.PowerStatus, null);
57 | textBox1.Text += "\r\n PowerStatus." + pi[i].Name + " is: " + propval.ToString();
58 | }
59 | }
60 | else
61 | {
62 | // Display the value of the selected property of the SystemInformation type.
63 | Type t = typeof(System.Windows.Forms.SystemInformation);
64 | PropertyInfo[] pi = t.GetProperties();
65 | PropertyInfo prop = null;
66 | for (int i = 0; i < pi.Length; i++)
67 | if (pi[i].Name == propname)
68 | {
69 | prop = pi[i];
70 | break;
71 | }
72 | object propval = prop.GetValue(null, null);
73 | textBox1.AppendText("\r\nThe value of the " + propname + " property is: " + propval.ToString());
74 |
75 | }
76 | }
77 |
78 | private void InitForm()
79 | {
80 | // Initialize the form settings
81 | this.listBox1 = new System.Windows.Forms.ListBox();
82 | this.textBox1 = new System.Windows.Forms.TextBox();
83 | this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
84 | | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
85 | this.listBox1.Location = new System.Drawing.Point(8, 16);
86 | this.listBox1.Size = new System.Drawing.Size(172, 496);
87 | this.listBox1.TabIndex = 0;
88 | this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
89 | | System.Windows.Forms.AnchorStyles.Right)));
90 | this.textBox1.Location = new System.Drawing.Point(188, 16);
91 | this.textBox1.Multiline = true;
92 | this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
93 | this.textBox1.Size = new System.Drawing.Size(420, 496);
94 | this.textBox1.TabIndex = 1;
95 | this.ClientSize = new System.Drawing.Size(616, 525);
96 | this.Controls.Add(this.textBox1);
97 | this.Controls.Add(this.listBox1);
98 | this.Text = "Select a SystemInformation property to get the value of";
99 | }
100 |
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/SystemInfoPrograme/SystemInfoPrograme.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {58FD5123-C625-4DB3-BE02-8CD6AC5A26D7}
8 | WinExe
9 | SystemInfoPrograme
10 | SystemInfoPrograme
11 | v4.7
12 | 512
13 | true
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | Form
53 |
54 |
55 | ResXFileCodeGenerator
56 | Resources.Designer.cs
57 | Designer
58 |
59 |
60 | True
61 | Resources.resx
62 |
63 |
64 | SettingsSingleFileGenerator
65 | Settings.Designer.cs
66 |
67 |
68 | True
69 | Settings.settings
70 | True
71 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------