├── .gitattributes
├── .gitignore
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── WindowsFormsAero.nuspec
├── icon
├── WindowsFormsAero-128.png
├── WindowsFormsAero-64.png
└── WindowsFormsAero.ico
└── src
├── WindowsFormsAero.sln
├── WindowsFormsAero
├── AeroForm.cs
├── Button.cs
├── ComboBox.cs
├── CommandLink.cs
├── Dwm
│ ├── CloakedStatus.cs
│ ├── DwmCompositionException.cs
│ ├── DwmManager.cs
│ ├── Thumbnail.cs
│ └── ThumbnailViewer.cs
├── Flip3dPolicy.cs
├── GeometryExtensions.cs
├── HorizontalPanel.cs
├── LabeledDivider.cs
├── ListView.cs
├── Native
│ ├── BitBlpOp.cs
│ ├── BitmapInfo.cs
│ ├── ButtonSplitInfo.cs
│ ├── ButtonStyle.cs
│ ├── ClassLong.cs
│ ├── DttOpts.cs
│ ├── DttOptsFlags.cs
│ ├── DwmBlurBehind.cs
│ ├── DwmBlurBehindFlags.cs
│ ├── DwmMethods.cs
│ ├── DwmSize.cs
│ ├── DwmThumbnailFlags.cs
│ ├── DwmThumbnailProperties.cs
│ ├── DwmWindowAttribute.cs
│ ├── HitTest.cs
│ ├── IVirtualDesktopManager.cs
│ ├── IntHelpers.cs
│ ├── ListViewExtendedStyle.cs
│ ├── Margins.cs
│ ├── Methods.cs
│ ├── Point.cs
│ ├── ProgressBarState.cs
│ ├── ProgressBarStyle.cs
│ ├── Rect.cs
│ ├── Size.cs
│ ├── StructWrapper.cs
│ ├── SystemErrorCode.cs
│ ├── TextShadowType.cs
│ ├── TreeViewExtendedStyle.cs
│ ├── TreeViewStyle.cs
│ ├── UwpMethods.cs
│ ├── WindowExStyles.cs
│ ├── WindowLong.cs
│ ├── WindowMessage.cs
│ ├── WindowStyles.cs
│ └── WindowTheme.cs
├── OSSupport.cs
├── ProgressBar.cs
├── ProgressBarState.cs
├── Properties
│ └── AssemblyInfo.cs
├── Resources
│ ├── ExceptionMessages.Designer.cs
│ ├── ExceptionMessages.resx
│ ├── Pictures.Designer.cs
│ ├── Pictures.resx
│ ├── active_search.png
│ └── inactive_search.png
├── SplitButton.cs
├── SplitMenuEventArgs.cs
├── StoreAppHelper.cs
├── TaskDialog
│ ├── CommonButton.cs
│ ├── CommonButtonResult.cs
│ ├── CommonIcon.cs
│ ├── CustomButton.cs
│ ├── EventArgs.cs
│ ├── Message.cs
│ ├── NativeMethods.cs
│ ├── Results.cs
│ ├── TaskDialog.cs
│ └── TaskDialog_static.cs
├── TextBox.cs
├── ThemeLabel.cs
├── ThemedText.cs
├── TreeView.cs
├── VerticalPanel.cs
├── VirtualDesktop.cs
├── VirtualDesktopManager.cs
├── WindowsFormsAero.csproj
└── WindowsFormsAero.snk
└── WindowsFormsAeroShowcase
├── App.config
├── HorizontalPanelExample.Designer.cs
├── HorizontalPanelExample.cs
├── HorizontalPanelExample.resx
├── Main.Designer.cs
├── Main.cs
├── Main.resx
├── Program.cs
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── ThumbnailedWindow.Designer.cs
├── ThumbnailedWindow.cs
├── ThumbnailedWindow.resx
├── VerticalPanelExample.Designer.cs
├── VerticalPanelExample.cs
├── VerticalPanelExample.resx
├── WindowsFormsAeroShowcase.csproj
└── WindowsFormsAeroShowcase.exe.manifest
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto eol=CRLF
2 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
78 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Microsoft Reciprocal License (MS-RL)
2 | http://www.opensource.org/licenses/ms-rl.html
3 |
4 | This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
5 |
6 | 1. Definitions
7 | The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
8 | A "contribution" is the original software, or any additions or changes to the software.
9 | A "contributor" is any person that distributes its contribution under this license.
10 | "Licensed patents" are a contributor's patent claims that read directly on its contribution.
11 |
12 | 2. Grant of Rights
13 | (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
14 | (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
15 |
16 | 3. Conditions and Limitations
17 | (A) Reciprocal Grants- For any file you distribute that contains code from the software (in source code or binary format), you must provide recipients the source code to that file along with a copy of this license, which license will govern that file. You may license other files that are entirely your own work and do not contain code from the software under any terms you choose.
18 | (B) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
19 | (C) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
20 | (D) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
21 | (E) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
22 | (F) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | # WindowsFormsAero
4 |
5 | WindowsFormsAero is a *Windows Forms* library that provides native controls with many of the modern features introduced with Windows Vista and more recent Windows versions.
6 | Many controls—such as buttons, command buttons, and textboxes—support the functional and stylistic features introduced with “Aero”.
7 | For instance shield icons, cue banners, and so on.
8 |
9 | WindowsFormsAero was started by [Marco Minerva](https://github.com/marcominerva) in January 2007 and was initially hosted on [Codeplex](http://windowsformsaero.codeplex.com).
10 |
11 | The WindowsFormsAero icon has been kindly provided by [Enner Pérez](https://github.com/ennerperez).
12 |
13 | ## Download
14 |
15 | [](https://www.nuget.org/packages/Windows-Forms-Aero)
16 |
17 | Get the latest version through NuGet:
18 |
19 | ```
20 | Install-Package Windows-Forms-Aero
21 | ```
22 |
23 | ## Version history
24 |
25 | ### 3.1.1
26 |
27 | * Fixed [bug with TaskDialog APIs on x64](https://github.com/LorenzCK/WindowsFormsAero/issues/5) (thanks Piotr Zięzio).
28 | * Added icon (thanks Enner Pérez).
29 | * [Added Source Link](https://github.com/LorenzCK/WindowsFormsAero/issues/6) (thanks MagicAndre1981).
30 |
31 | ### 3.1
32 |
33 | * Add support for additional DWM window attributes (`DWMWA_CLOAKED` and `DWMWA_FREEZE_REPRESENTATION`).
34 | * Add support for public Virtual Desktop APIs (Windows 10).
35 |
36 | ### 3.0.1
37 |
38 | * Add simple `StoreAppHelper.IsRunningAsStoreApp()` helper to check whether a program is running as a packaged Windows Store app.
39 | * Add .NET 4.0 support.
40 | * Add XML documentation to NuGet.
41 |
42 | ### 3.0
43 |
44 | First release after migration to GitHub.
45 | * Breaking changes from v2.*.
46 | * Major code refactoring and clean up.
47 | * Minor memory leaks fixed.
48 | * Progress bars now correctly change state.
49 |
50 | ## Contributors
51 |
52 | * [Marco Minerva](https://github.com/marcominerva)
53 | * [Lorenz Cuno Klopfenstein](https://github.com/lorenzck)
54 | * [Julie Koubová](https://github.com/juliekoubova)
55 | * Blake Pell
56 | * multippt
57 | * Nicholas Kwan
58 | * [Enner Pérez](https://github.com/ennerperez)
59 | * [Piotr Zięzio](https://github.com/pziezio)
60 | * [MagicAndre1981](https://github.com/MagicAndre1981)
61 |
--------------------------------------------------------------------------------
/WindowsFormsAero.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Windows-Forms-Aero
5 | WindowsFormsAero
6 |
7 | 3.1.1
8 |
9 | Fixed bug with TaskDialog APIs on x64 (thanks Piotr Zięzio).
10 | Added icon (thanks Enner Pérez).
11 | Added Source Link (thanks MagicAndre1981).
12 | Updated NuGet information.
13 |
14 |
15 | Marco Minerva, Lorenz Cuno Klopfenstein
16 | LorenzCK
17 |
18 | MS-RL
19 | false
20 |
21 | https://github.com/LorenzCK/WindowsFormsAero
22 |
23 | https://raw.githubusercontent.com/LorenzCK/WindowsFormsAero/master/icon/WindowsFormsAero-64.png
24 |
25 |
26 |
27 | Windows Forms library with modern common controls for Windows Vista and later.
28 |
29 | A Windows Forms library that provides common controls with many of the modern features introduced with Vista and more recent Windows versions.
30 |
31 | Common controls include modern buttons, combo boxes (with cue banner), command links, native-looking list views, progress bars with status, and Windows Explorer-like tree views. The library also includes additional modules that wrap functionalities such as TaskDialogs, “glass sheet” forms, text on glass, live thumbnails using the Windows DWM, virtual desktop APIs, and so on.
32 |
33 |
34 | winforms aero windows controls library windowsforms windowsformsaero taskdialog dwm
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/icon/WindowsFormsAero-128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LorenzCK/WindowsFormsAero/14c921f21939c4f535617e66ffc1ace4b0173e44/icon/WindowsFormsAero-128.png
--------------------------------------------------------------------------------
/icon/WindowsFormsAero-64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LorenzCK/WindowsFormsAero/14c921f21939c4f535617e66ffc1ace4b0173e44/icon/WindowsFormsAero-64.png
--------------------------------------------------------------------------------
/icon/WindowsFormsAero.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LorenzCK/WindowsFormsAero/14c921f21939c4f535617e66ffc1ace4b0173e44/icon/WindowsFormsAero.ico
--------------------------------------------------------------------------------
/src/WindowsFormsAero.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26403.7
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFormsAero", "WindowsFormsAero\WindowsFormsAero.csproj", "{844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFormsAeroShowcase", "WindowsFormsAeroShowcase\WindowsFormsAeroShowcase.csproj", "{FC842DD0-6736-46A5-8D00-28CAFD33312F}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Debug|x64 = Debug|x64
14 | Debug|x86 = Debug|x86
15 | Release-NET40|Any CPU = Release-NET40|Any CPU
16 | Release-NET40|x64 = Release-NET40|x64
17 | Release-NET40|x86 = Release-NET40|x86
18 | Release-NET461|Any CPU = Release-NET461|Any CPU
19 | Release-NET461|x64 = Release-NET461|x64
20 | Release-NET461|x86 = Release-NET461|x86
21 | EndGlobalSection
22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
23 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Debug|x64.ActiveCfg = Debug|Any CPU
26 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Debug|x64.Build.0 = Debug|Any CPU
27 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Debug|x86.ActiveCfg = Debug|Any CPU
28 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Debug|x86.Build.0 = Debug|Any CPU
29 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Release-NET40|Any CPU.ActiveCfg = Release-NET40|Any CPU
30 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Release-NET40|Any CPU.Build.0 = Release-NET40|Any CPU
31 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Release-NET40|x64.ActiveCfg = Release-NET40|Any CPU
32 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Release-NET40|x64.Build.0 = Release-NET40|Any CPU
33 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Release-NET40|x86.ActiveCfg = Release-NET40|Any CPU
34 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Release-NET40|x86.Build.0 = Release-NET40|Any CPU
35 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Release-NET461|Any CPU.ActiveCfg = Release|Any CPU
36 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Release-NET461|Any CPU.Build.0 = Release|Any CPU
37 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Release-NET461|x64.ActiveCfg = Release-NET40|Any CPU
38 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Release-NET461|x64.Build.0 = Release-NET40|Any CPU
39 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Release-NET461|x86.ActiveCfg = Release|Any CPU
40 | {844F1DE5-17EA-4E69-A7C5-B803AD3BD5D9}.Release-NET461|x86.Build.0 = Release|Any CPU
41 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Debug|Any CPU.Build.0 = Debug|Any CPU
43 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Debug|x64.ActiveCfg = Debug|x64
44 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Debug|x64.Build.0 = Debug|x64
45 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Debug|x86.ActiveCfg = Debug|x86
46 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Debug|x86.Build.0 = Debug|x86
47 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Release-NET40|Any CPU.ActiveCfg = Release|Any CPU
48 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Release-NET40|Any CPU.Build.0 = Release|Any CPU
49 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Release-NET40|x64.ActiveCfg = Release|x64
50 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Release-NET40|x64.Build.0 = Release|x64
51 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Release-NET40|x86.ActiveCfg = Release|Any CPU
52 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Release-NET40|x86.Build.0 = Release|Any CPU
53 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Release-NET461|Any CPU.ActiveCfg = Release|Any CPU
54 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Release-NET461|Any CPU.Build.0 = Release|Any CPU
55 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Release-NET461|x64.ActiveCfg = Release|x64
56 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Release-NET461|x64.Build.0 = Release|x64
57 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Release-NET461|x86.ActiveCfg = Release|Any CPU
58 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}.Release-NET461|x86.Build.0 = Release|Any CPU
59 | EndGlobalSection
60 | GlobalSection(SolutionProperties) = preSolution
61 | HideSolutionNode = FALSE
62 | EndGlobalSection
63 | GlobalSection(ExtensibilityGlobals) = postSolution
64 | SolutionGuid = {3BBAE3F7-44C5-4A69-84A3-B82368931640}
65 | EndGlobalSection
66 | EndGlobal
67 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Button.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Marco Minerva
7 | * Lorenz Cuno Klopfenstein
8 | *****************************************************/
9 |
10 | using System;
11 | using System.ComponentModel;
12 | using System.Drawing;
13 | using System.Windows.Forms;
14 | using WindowsFormsAero.Native;
15 |
16 | namespace WindowsFormsAero {
17 |
18 | [ToolboxBitmap(typeof(Button))]
19 | public class Button : System.Windows.Forms.Button {
20 |
21 | private bool _showShield = false;
22 |
23 | [
24 | Description("Gets or sets whether if the control should use an elevated shield icon."),
25 | Category("Appearance"),
26 | DefaultValue(false)
27 | ]
28 | public bool ShowShield {
29 | get {
30 | return _showShield;
31 | }
32 | set {
33 | if(_showShield != value) {
34 | if(value) {
35 | //Shields are visible only with FlatStyle.System
36 | //which hides the button's image however
37 | FlatStyle = FlatStyle.System;
38 | }
39 | else if(Image != null) {
40 | //If no shield but image displayed, switch to FlatStyle.System
41 | //which is the only style showing the image
42 | FlatStyle = FlatStyle.Standard;
43 | }
44 |
45 | if (IsHandleCreated) {
46 | Methods.SendMessage(Handle,
47 | (uint)WindowMessage.BCM_SETSHIELD,
48 | 0,
49 | (value) ? 1 : 0
50 | );
51 | }
52 | }
53 |
54 | _showShield = value;
55 | }
56 | }
57 |
58 | protected override void OnHandleCreated(EventArgs e) {
59 | base.OnHandleCreated(e);
60 |
61 | Methods.SendMessage(Handle,
62 | (uint)WindowMessage.BCM_SETSHIELD,
63 | 0,
64 | (_showShield) ? 1 : 0
65 | );
66 | }
67 |
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/ComboBox.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Marco Minerva
7 | * Lorenz Cuno Klopfenstein
8 | *****************************************************/
9 |
10 | using System;
11 | using System.ComponentModel;
12 | using System.Drawing;
13 | using System.Windows.Forms;
14 | using WindowsFormsAero.Native;
15 |
16 | namespace WindowsFormsAero {
17 |
18 | [ToolboxBitmap(typeof(ComboBox))]
19 | public class ComboBox : System.Windows.Forms.ComboBox {
20 |
21 | public ComboBox() {
22 | FlatStyle = FlatStyle.System;
23 | DropDownStyle = ComboBoxStyle.DropDownList;
24 | }
25 |
26 | private string _cueBannerText = string.Empty;
27 |
28 | [
29 | Description("Gets or sets the cue text that is displayed on a ComboBox control."),
30 | Category("Appearance"),
31 | DefaultValue("")
32 | ]
33 | public string CueBannerText {
34 | get {
35 | return _cueBannerText;
36 | }
37 | set {
38 | if (value == null)
39 | throw new ArgumentNullException();
40 |
41 | if(_cueBannerText != value) {
42 | Methods.SendMessage(Handle, (uint)WindowMessage.CB_SETCUEBANNER, 0, value);
43 | }
44 |
45 | _cueBannerText = value;
46 | }
47 | }
48 |
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/CommandLink.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Marco Minerva
7 | * Lorenz Cuno Klopfenstein
8 | *****************************************************/
9 |
10 | using System;
11 | using System.ComponentModel;
12 | using System.Drawing;
13 | using System.Windows.Forms;
14 | using WindowsFormsAero.Native;
15 |
16 | namespace WindowsFormsAero {
17 |
18 | [ToolboxBitmap(typeof(Button))]
19 | public class CommandLink : Button {
20 |
21 | protected override CreateParams CreateParams {
22 | get {
23 | CreateParams cp = base.CreateParams;
24 |
25 | //Fix for XP provided by jonpreece (http://windowsformsaero.codeplex.com/Thread/View.aspx?ThreadId=81391)
26 | if (OsSupport.IsVistaOrLater)
27 | cp.Style |= (int)(IsDefault ? ButtonStyle.DefaultCommandLink : ButtonStyle.CommandLink);
28 | else
29 | cp.Style |= (int)(IsDefault ? ButtonStyle.PushButton : ButtonStyle.DefaultPushButton);
30 | return cp;
31 | }
32 | }
33 |
34 | private string _note = string.Empty;
35 |
36 | [
37 | Description("Gets or sets the note that is displayed on a button control."),
38 | Category("Appearance"),
39 | DefaultValue("")
40 | ]
41 | public string Note {
42 | get {
43 | return _note;
44 | }
45 | set {
46 | if (IsHandleCreated) {
47 | Methods.SendMessage(Handle, (uint)WindowMessage.BCM_SETNOTE, 0, _note);
48 | }
49 |
50 | _note = value;
51 | }
52 | }
53 |
54 | protected override void OnHandleCreated(EventArgs e) {
55 | base.OnHandleCreated(e);
56 |
57 | Methods.SendMessage(Handle, (uint)WindowMessage.BCM_SETNOTE, 0, _note);
58 | }
59 |
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Dwm/CloakedStatus.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 WindowsFormsAero.Dwm {
8 |
9 | ///
10 | /// Describes whether and why a window is cloaked by the DWM.
11 | ///
12 | [Flags]
13 | public enum CloakedStatus : int {
14 | ///
15 | /// Window is not cloaked.
16 | ///
17 | Uncloaked = 0,
18 | ///
19 | /// The window was cloaked by its owner application.
20 | ///
21 | ApplicationLevel = 0x0000001,
22 | ///
23 | /// The window was cloaked by the Shell.
24 | ///
25 | ShellLevel = 0x0000002,
26 | ///
27 | /// The cloak value was inherited from its owner window.
28 | ///
29 | Inherited = 0x0000004
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Dwm/DwmCompositionException.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 | using System.Runtime.Serialization;
11 |
12 | namespace WindowsFormsAero.Dwm {
13 |
14 | [Serializable]
15 | class DwmCompositionException : Exception {
16 |
17 | public DwmCompositionException(string m)
18 | : base(m) {
19 | }
20 |
21 | public DwmCompositionException(string m, Exception innerException)
22 | : base(m, innerException) {
23 | }
24 |
25 | public DwmCompositionException(SerializationInfo info, StreamingContext context)
26 | : base(info, context) {
27 | }
28 |
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Flip3dPolicy.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero {
10 |
11 | ///
12 | /// Determines a window's Flip 3D policy.
13 | ///
14 | public enum Flip3DPolicy : int {
15 | ///
16 | /// Default Flip 3D behavior.
17 | ///
18 | Default,
19 | ///
20 | /// Excludes the window from Flip 3D and hides it behind the animation.
21 | ///
22 | ExcludeBelow,
23 | ///
24 | /// Excludes the window from Flip 3D and shows it above the animation.
25 | ///
26 | ExcludeAbove
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/GeometryExtensions.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System.Drawing;
10 | using System.Windows.Forms;
11 |
12 | namespace WindowsFormsAero {
13 |
14 | internal static class GeometryExtensions {
15 |
16 | ///
17 | /// Returns true if any side of the padding is a positive, non-zero value.
18 | ///
19 | public static bool IsPositive(this Padding p) {
20 | return (p.All > 0 || p.Top > 0 || p.Bottom > 0 || p.Left > 0 || p.Right > 0);
21 | }
22 |
23 | ///
24 | /// Returns true if all sides are negative.
25 | ///
26 | public static bool AllNegative(this Padding p) {
27 | return (p.Top < 0 && p.Bottom < 0 && p.Left < 0 && p.Right < 0);
28 | }
29 |
30 | ///
31 | /// Returns whether a point in client coordinates is outside the padded region.
32 | ///
33 | /// Point in client coordinates.
34 | /// Full size of the region on which padding is applied.
35 | public static bool IsOutside(this Padding p, Point point, Size size) {
36 | return (point.X < p.Left ||
37 | point.X > (size.Width - p.Right) ||
38 | point.Y < p.Top ||
39 | point.Y > (size.Height - p.Bottom));
40 | }
41 |
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/HorizontalPanel.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Blake Pell http://www.blakepell.com
7 | *****************************************************/
8 |
9 | using System;
10 | using System.Drawing;
11 | using System.Windows.Forms;
12 | using System.ComponentModel;
13 |
14 | namespace WindowsFormsAero {
15 |
16 | ///
17 | /// A horizontal panel which resembles what is used for information and navigation in the Control Panel of Windows 7 and Vista.
18 | ///
19 | ///
20 | /// This control is meant to be used on the left hand side of a form, it creates a graphic border on the right hand side. Also
21 | /// I have VB code for this control if anyone needs it, just send me an e-mail at bpell@indiana.edu or blakepell@hotmail.com.
22 | ///
23 | [ToolboxBitmap(typeof(Panel))]
24 | public class HorizontalPanel : Panel {
25 |
26 | ///
27 | /// Constructor
28 | ///
29 | ///
30 | /// We are by default setting the background color to Color.Transparent. The reason for this is that a lot of controls that will
31 | /// be used with this, namingly the Label and LinkLabel default their back color to the color of the panel and for those controls
32 | /// to display properly on this panel, their BackColor will need to be Color.Transparent (otherwise, they'll display as a black
33 | /// box). This should help to isolate the developer from having to research this.
34 | ///
35 | /// To reduce flicker, especially when glass is enabled, I had to set all three of the below styles.
36 | ///
37 | ///
38 | public HorizontalPanel() {
39 | this.BackColor = Color.Transparent;
40 | this.Font = new Font("Segoe UI", 9, FontStyle.Regular, GraphicsUnit.Point, 0);
41 | SetStyle(ControlStyles.UserPaint, true);
42 | SetStyle(ControlStyles.AllPaintingInWmPaint, true);
43 | SetStyle(ControlStyles.DoubleBuffer, true);
44 | this.UpdateStyles();
45 | }
46 |
47 | ///
48 | /// When a control is added, we will check the type and if it meets certain criteria will change some default behaviors of
49 | /// the control so that it fits our theme by default. The developer can still change this as they desire after it's added.
50 | ///
51 | ///
52 | protected override void OnControlAdded(ControlEventArgs e) {
53 | base.OnControlAdded(e);
54 | if (e.Control is LinkLabel) {
55 | e.Control.Font = new Font("Segoe UI", 9, FontStyle.Regular, GraphicsUnit.Point, 0);
56 | ((LinkLabel)e.Control).LinkBehavior = LinkBehavior.HoverUnderline;
57 | ((LinkLabel)e.Control).LinkColor = Color.FromArgb(64, 64, 64);
58 | ((LinkLabel)e.Control).ActiveLinkColor = Color.Blue;
59 | }
60 | }
61 |
62 | ///
63 | /// The actual painting of the background of our control.
64 | ///
65 | ///
66 | ///
67 | /// The colors in use here were extracted from an image of the Control Panel taken from a Windows 7 RC1 installation.
68 | ///
69 | protected override void OnPaint(PaintEventArgs e) {
70 | base.OnPaint(e);
71 |
72 | Color aeroColor1 = Color.FromArgb(204, 217, 234);
73 | Color aeroColor2 = Color.FromArgb(217, 227, 240);
74 | Color aeroColor3 = Color.FromArgb(232, 238, 247);
75 | Color aeroColor4 = Color.FromArgb(237, 242, 249);
76 | Color aeroColor5 = Color.FromArgb(240, 244, 250);
77 | Color aeroColor6 = Color.FromArgb(241, 245, 251);
78 |
79 | Rectangle rect = new Rectangle(0, 0, this.Width, 1);
80 | SolidBrush sb = new SolidBrush(aeroColor1);
81 | e.Graphics.FillRectangle(sb, rect);
82 |
83 | rect = new Rectangle(0, 1, this.Width, 1);
84 | sb.Color = aeroColor2;
85 | e.Graphics.FillRectangle(sb, rect);
86 |
87 | rect = new Rectangle(0, 2, this.Width, 1);
88 | sb.Color = aeroColor3;
89 | e.Graphics.FillRectangle(sb, rect);
90 |
91 | rect = new Rectangle(0, 3, this.Width, 1);
92 | sb.Color = aeroColor3;
93 | e.Graphics.FillRectangle(sb, rect);
94 |
95 | rect = new Rectangle(0, 4, this.Width, 1);
96 | sb.Color = aeroColor4;
97 | e.Graphics.FillRectangle(sb, rect);
98 |
99 | rect = new Rectangle(0, 5, this.Width, 1);
100 | sb.Color = aeroColor5;
101 | e.Graphics.FillRectangle(sb, rect);
102 |
103 | rect = new Rectangle(0, 6, this.Width, this.Height - 5);
104 | sb.Color = aeroColor6;
105 | e.Graphics.FillRectangle(sb, rect);
106 |
107 | sb.Dispose();
108 | }
109 |
110 | ///
111 | /// This procedure will redraw any control, given it's handl as an image on the form. This is necessary if you want to lay this
112 | /// control on top of the glass surface of an Aero form.
113 | ///
114 | ///
115 | public void RedrawControlAsBitmap(IntPtr hwnd) {
116 | Control c = Control.FromHandle(hwnd);
117 | using (Bitmap bm = new Bitmap(c.Width, c.Height)) {
118 | c.DrawToBitmap(bm, c.ClientRectangle);
119 | using (Graphics g = c.CreateGraphics()) {
120 | Point p = new Point(-1, -1);
121 | g.DrawImage(bm, p);
122 | }
123 | }
124 | c = null;
125 | }
126 |
127 | ///
128 | /// Handles incoming Windows Messages.
129 | ///
130 | ///
131 | ///
132 | /// On the paint event and if the RenderOnGlass is set to true, we will redraw the control as an image directly on
133 | /// the form. This has a little extra overhead but also provides the ability to lay this control directly on the
134 | /// glass and have it rendered correctly.
135 | ///
136 | protected override void WndProc(ref Message m) {
137 | base.WndProc(ref m);
138 | int WM_PAINT = 15;
139 | if ((m.Msg == WM_PAINT) && this.RenderOnGlass) {
140 | this.RedrawControlAsBitmap(this.Handle);
141 | }
142 | }
143 |
144 | private bool _renderOnGlass = false;
145 | ///
146 | /// Whether or not the control needs to be rendered on the Glass surface.
147 | ///
148 | ///
149 | /// This is false by default, it should only be toggled to true if the control needs to lay directly on
150 | /// the glass surface of the form.
151 | ///
152 | [Description("Gets or sets whether the control can render on an Aero glass surface."), Category("Appearance"), DefaultValue(false)]
153 | public bool RenderOnGlass {
154 | get {
155 | return this._renderOnGlass;
156 | }
157 | set {
158 | this._renderOnGlass = value;
159 | }
160 | }
161 | }
162 |
163 | }
164 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/LabeledDivider.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Blake Pell http://www.blakepell.com
7 | *****************************************************/
8 |
9 | using System.ComponentModel;
10 | using System.Drawing;
11 | using System.Windows.Forms;
12 |
13 | namespace WindowsFormsAero {
14 |
15 | ///
16 | /// The labeled divider provides a Aero styled divider with an optional caption,
17 | /// similiar to what is seen in the Control Panel dialogs of Windows 7 and Vista.
18 | ///
19 | public class LabeledDivider : Label {
20 |
21 | ///
22 | /// Constructor
23 | ///
24 | public LabeledDivider() {
25 | Font = new Font(Font.FontFamily, 9); //ensures that divider takes the "ambient" font from its parent
26 | this.ForeColor = Color.FromArgb(0, 51, 170);
27 | AutoSize = false;
28 | }
29 |
30 | ///
31 | /// The actual painting of the background of our control.
32 | ///
33 | ///
34 | ///
35 | /// The colors in use here were extracted from an image of the Control Panel taken from a Windows 7 RC1 installation.
36 | ///
37 | protected override void OnPaint(PaintEventArgs e) {
38 | base.OnPaint(e);
39 |
40 | e.Graphics.Clear(BackColor);
41 |
42 | SolidBrush sbDividerColor = new SolidBrush(this._dividerColor);
43 | SolidBrush sbForeColor = new SolidBrush(this.ForeColor);
44 |
45 | // Draw the caption string, then get the size of it as it appears on the screen so
46 | // we know where to put the caption.
47 | e.Graphics.DrawString(this.Text, this.Font, Brushes.Black, ClientRectangle.X, ClientRectangle.Y);
48 | SizeF sf = e.Graphics.MeasureString(this.Text, this.Font);
49 |
50 | // This didn't quiet get in the cente rso I had to add 1 pixel to the sf.Height / 2
51 | if (this.DividerPosition == DividerPositions.Center) {
52 | Rectangle rect = new Rectangle((int)sf.Width, ((int)sf.Height / 2) + 1, this.Width - (int)sf.Width, 1);
53 | e.Graphics.FillRectangle(sbDividerColor, rect);
54 | }
55 | else if (this.DividerPosition == DividerPositions.Below) {
56 | Rectangle rect = new Rectangle(1, (int)sf.Height, this.Width, 1);
57 | e.Graphics.FillRectangle(sbDividerColor, rect);
58 | }
59 |
60 | sbForeColor.Dispose();
61 | sbDividerColor.Dispose();
62 | }
63 |
64 | ///
65 | /// The positions that the divider line can be drawn in
66 | ///
67 | public enum DividerPositions {
68 | ///
69 | /// The divider will be centered after the text caption and will begin drawing after the string. This is the default behavior.
70 | ///
71 | Center,
72 | ///
73 | /// The divider will be drawn below the text caption.
74 | ///
75 | Below
76 | };
77 |
78 | private DividerPositions _dividerPosition = DividerPositions.Center;
79 |
80 | ///
81 | /// The position of the divider line.
82 | ///
83 | ///
84 | /// The default value is the center position which is consistent on how this type of divider has been used throughout the Windows
85 | /// 7 and Vista UI's.
86 | ///
87 | [Description("The placement of the divider line."), Category("Appearance"), DefaultValue(DividerPositions.Center)]
88 | public DividerPositions DividerPosition {
89 | get {
90 | return this._dividerPosition;
91 | }
92 | set {
93 | this._dividerPosition = value;
94 | this.Invalidate();
95 | }
96 | }
97 |
98 | private Color _dividerColor = Color.FromArgb(176, 191, 222);
99 | ///
100 | /// The color of the divider line.
101 | ///
102 | [Description("The color of the divider line."), Category("Appearance")]
103 | public Color DividerColor {
104 | get {
105 | return this._dividerColor;
106 | }
107 | set {
108 | this._dividerColor = value;
109 | this.Invalidate();
110 | }
111 | }
112 |
113 | private string _text = "";
114 | ///
115 | /// The text that should be used for the caption. If the caption is set to blank and the divider position is set to center then
116 | /// a simple divider line will be drawn.
117 | ///
118 | ///
119 | /// After a change is made to the text property we want to invalidate the control so it triggers a new paint message being sent.
120 | ///
121 | [Description("The text that will display as the caption."), Category("Appearance"), DefaultValue("DividerLabel")]
122 | public override string Text {
123 | get {
124 | return this._text;
125 | }
126 | set {
127 | this._text = value;
128 | this.Invalidate();
129 | }
130 | }
131 |
132 | }
133 |
134 | }
135 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/ListView.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Marco Minerva
7 | * Lorenz Cuno Klopfenstein
8 | *****************************************************/
9 |
10 | using System;
11 | using System.Drawing;
12 | using WindowsFormsAero.Native;
13 |
14 | namespace WindowsFormsAero {
15 |
16 | [ToolboxBitmap(typeof(ListView))]
17 | public class ListView : System.Windows.Forms.ListView {
18 |
19 | protected override void OnHandleCreated(EventArgs e) {
20 | base.OnHandleCreated(e);
21 |
22 | //Set Explorer style
23 | Methods.SetWindowTheme(Handle, "explorer", null);
24 |
25 | //Blue selection, keeps other extended styles
26 | Methods.SendMessage(Handle,
27 | (uint)WindowMessage.LVM_SETEXTENDEDLISTVIEWSTYLE,
28 | (uint)ListViewExtendedStyle.LVS_EX_DOUBLEBUFFER,
29 | (uint)ListViewExtendedStyle.LVS_EX_DOUBLEBUFFER);
30 | }
31 |
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/BitBlpOp.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero.Native {
10 |
11 | internal enum BitBltOp : uint {
12 | SRCCOPY = 0x00CC0020, /* dest = source */
13 | SRCPAINT = 0x00EE0086, /* dest = source OR dest */
14 | SRCAND = 0x008800C6, /* dest = source AND dest */
15 | SRCINVERT = 0x00660046, /* dest = source XOR dest */
16 | SRCERASE = 0x00440328, /* dest = source AND (NOT dest ) */
17 | NOTSRCCOPY = 0x00330008, /* dest = (NOT source) */
18 | NOTSRCERASE = 0x001100A6, /* dest = (NOT src) AND (NOT dest) */
19 | MERGECOPY = 0x00C000CA, /* dest = (source AND pattern) */
20 | MERGEPAINT = 0x00BB0226, /* dest = (NOT source) OR dest */
21 | PATCOPY = 0x00F00021, /* dest = pattern */
22 | PATPAINT = 0x00FB0A09, /* dest = DPSnoo */
23 | PATINVERT = 0x005A0049, /* dest = pattern XOR dest */
24 | DSTINVERT = 0x00550009, /* dest = (NOT dest) */
25 | BLACKNESS = 0x00000042, /* dest = BLACK */
26 | WHITENESS = 0x00FF0062, /* dest = WHITE */
27 |
28 | NOMIRRORBITMAP = 0x80000000, /* Do not Mirror the bitmap in this call */
29 | CAPTUREBLT = 0x40000000 /* Include layered windows */
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/BitmapInfo.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System.Runtime.InteropServices;
10 |
11 | namespace WindowsFormsAero.Native {
12 |
13 | [StructLayout(LayoutKind.Sequential)]
14 | internal struct BitmapInfo {
15 | public int biSize;
16 | public int biWidth;
17 | public int biHeight;
18 | public short biPlanes;
19 | public short biBitCount;
20 | public int biCompression;
21 | public int biSizeImage;
22 | public int biXPelsPerMeter;
23 | public int biYPelsPerMeter;
24 | public int biClrUsed;
25 | public int biClrImportant;
26 | public byte bmiColors_rgbBlue;
27 | public byte bmiColors_rgbGreen;
28 | public byte bmiColors_rgbRed;
29 | public byte bmiColors_rgbReserved;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/ButtonSplitInfo.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 | using System.Runtime.InteropServices;
11 |
12 | namespace WindowsFormsAero.Native {
13 |
14 | ///
15 | /// Contains information that defines a split button.
16 | ///
17 | ///
18 | /// See: https://msdn.microsoft.com/en-us/library/windows/desktop/bb775955(v=vs.85).aspx
19 | ///
20 | [StructLayout(LayoutKind.Sequential)]
21 | internal struct ButtonSplitInfo {
22 |
23 | [Flags]
24 | public enum MaskType : uint {
25 | Glyph = 0x0001,
26 | Image = 0x0002,
27 | Style = 0x0004,
28 | Size = 0x0008
29 | }
30 |
31 | [Flags]
32 | public enum SplitStyle : uint {
33 | None = 0,
34 | NoSplit = 0x0001,
35 | Stretch = 0x0002,
36 | AlignLeft = 0x0004,
37 | Image = 0x0008
38 | }
39 |
40 | public MaskType Mask;
41 | public IntPtr GlyphList;
42 | public SplitStyle Style;
43 | public Size Size;
44 |
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/ButtonStyle.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero.Native {
10 |
11 | internal enum ButtonStyle : uint {
12 | PushButton = 0x00000000,
13 | DefaultPushButton = 0x00000001,
14 | SplitButton = 0x0000000C,
15 | DefaultSplitButton = 0x0000000D,
16 | CommandLink = 0x0000000E,
17 | DefaultCommandLink = 0x0000000F,
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/ClassLong.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero.Native {
10 |
11 | internal enum ClassLong : int {
12 | Icon = -14,
13 | IconSmall = -34
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/DttOpts.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 | using System.Runtime.InteropServices;
11 |
12 | namespace WindowsFormsAero.Native {
13 |
14 | [StructLayout(LayoutKind.Sequential)]
15 | internal struct DttOpts {
16 | public int dwSize;
17 | public DttOptsFlags dwFlags;
18 | public int crText;
19 | public int crBorder;
20 | public int crShadow;
21 | public int iTextShadowType;
22 | public Point ptShadowOffset;
23 | public int iBorderSize;
24 | public int iFontPropId;
25 | public int iColorPropId;
26 | public int iStateId;
27 | public bool fApplyOverlay;
28 | public int iGlowSize;
29 | public int pfnDrawTextCallback;
30 | public IntPtr lParam;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/DttOptsFlags.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 |
11 | namespace WindowsFormsAero.Native {
12 |
13 | [Flags]
14 | internal enum DttOptsFlags : int {
15 | DTT_TEXTCOLOR = 1,
16 | DTT_BORDERCOLOR = 2,
17 | DTT_SHADOWCOLOR = 4,
18 | DTT_SHADOWTYPE = 8,
19 | DTT_SHADOWOFFSET = 16,
20 | DTT_BORDERSIZE = 32,
21 | //DTT_FONTPROP = 64, commented values are currently unused
22 | //DTT_COLORPROP = 128,
23 | //DTT_STATEID = 256,
24 | DTT_CALCRECT = 512,
25 | DTT_APPLYOVERLAY = 1024,
26 | DTT_GLOWSIZE = 2048,
27 | //DTT_CALLBACK = 4096,
28 | DTT_COMPOSITED = 8192
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/DwmBlurBehind.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 | using System.Runtime.InteropServices;
11 |
12 | namespace WindowsFormsAero.Native {
13 |
14 | [StructLayout(LayoutKind.Sequential)]
15 | internal struct DwmBlurBehind {
16 | public DwmBlurBehindFlags dwFlags;
17 | public bool fEnable;
18 | public IntPtr hRgnBlur;
19 | public bool fTransitionOnMaximized;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/DwmBlurBehindFlags.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 |
11 | namespace WindowsFormsAero.Native {
12 |
13 | [Flags]
14 | internal enum DwmBlurBehindFlags : int {
15 | Enable = 0x00000001,
16 | BlurRegion = 0x00000002,
17 | TransitionOnMaximized = 0x00000004
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/DwmMethods.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 | using System.Runtime.InteropServices;
11 |
12 | namespace WindowsFormsAero.Native {
13 |
14 | internal static class DwmMethods {
15 |
16 | #region DWM Thumbnail methods
17 |
18 | [DllImport("dwmapi.dll")]
19 | public static extern int DwmRegisterThumbnail(IntPtr hwndDestination, IntPtr hwndSource, out IntPtr phThumbnailId);
20 |
21 | [DllImport("dwmapi.dll")]
22 | public static extern int DwmUnregisterThumbnail(IntPtr hThumbnailId);
23 |
24 | [DllImport("dwmapi.dll")]
25 | public static extern int DwmUpdateThumbnailProperties(IntPtr hThumbnailId, ref DwmThumbnailProperties ptnProperties);
26 |
27 | [DllImport("dwmapi.dll")]
28 | public static extern int DwmIsCompositionEnabled([MarshalAs(UnmanagedType.Bool)] out bool pfEnabled);
29 |
30 | [DllImport("dwmapi.dll")]
31 | public static extern int DwmQueryThumbnailSourceSize(IntPtr hThumbnail, out DwmSize pSize);
32 |
33 | #endregion
34 |
35 | #region DWM Glass Frame
36 |
37 | [DllImport("dwmapi.dll")]
38 | public static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Margins pMarInset);
39 |
40 | #endregion
41 |
42 | #region DWM Blur Behind
43 |
44 | [DllImport("dwmapi.dll")]
45 | public static extern int DwmEnableBlurBehindWindow(IntPtr hWnd, ref DwmBlurBehind pBlurBehind);
46 |
47 | #endregion
48 |
49 | #region Attributes
50 |
51 | [DllImport("dwmapi.dll")]
52 | public static extern int DwmSetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, ref int pvAttribute, int cbAttribute);
53 |
54 | public static int DwmSetWindowForceIconicRepresentation(IntPtr hwnd, bool forceIconic) {
55 | return DwmSetBoolAttribute(hwnd, DwmWindowAttribute.DWMWA_FORCE_ICONIC_REPRESENTATION, forceIconic);
56 | }
57 |
58 | public static int DwmSetWindowFlip3dPolicy(IntPtr hwnd, Flip3DPolicy policy) {
59 | return DwmSetIntAttribute(hwnd, DwmWindowAttribute.DWMWA_FLIP3D_POLICY, (int)policy);
60 | }
61 |
62 | public static int DwmSetWindowDisallowPeek(IntPtr hwnd, bool disallowPeek) {
63 | return DwmSetBoolAttribute(hwnd, DwmWindowAttribute.DWMWA_DISALLOW_PEEK, disallowPeek);
64 | }
65 |
66 | public static int DwmSetWindowExcludedFromPeek(IntPtr hwnd, bool preventPeek) {
67 | return DwmSetBoolAttribute(hwnd, DwmWindowAttribute.DWMWA_EXCLUDED_FROM_PEEK, preventPeek);
68 | }
69 |
70 | public static int DwmSetWindowCloaked(IntPtr hwnd, bool cloak) {
71 | return DwmSetBoolAttribute(hwnd, DwmWindowAttribute.DWMWA_CLOAK, cloak);
72 | }
73 |
74 | public static int DwmSetWindowFreezeRepresentation(IntPtr hwnd, bool freeze) {
75 | return DwmSetBoolAttribute(hwnd, DwmWindowAttribute.DWMWA_FREEZE_REPRESENTATION, freeze);
76 | }
77 |
78 | private static int DwmSetIntAttribute(IntPtr hwnd, DwmWindowAttribute att, int v) {
79 | return DwmSetWindowAttribute(hwnd, att, ref v, Marshal.SizeOf(typeof(int)));
80 | }
81 |
82 | private static int DwmSetBoolAttribute(IntPtr hwnd, DwmWindowAttribute att, bool v) {
83 | int iV = v ? 1 : 0;
84 | return DwmSetWindowAttribute(hwnd, att, ref iV, Marshal.SizeOf(typeof(int)));
85 | }
86 |
87 | [DllImport("dwmapi.dll")]
88 | public static extern int DwmGetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, out int pvAttribute, int cbAttribute);
89 |
90 | public static Dwm.CloakedStatus DwmGetWindowCloaked(IntPtr hwnd) {
91 | DwmGetWindowAttribute(hwnd, DwmWindowAttribute.DWMWA_CLOAKED, out int retValue, Marshal.SizeOf(typeof(int)));
92 |
93 | if (!Enum.IsDefined(typeof(Dwm.CloakedStatus), retValue)) {
94 | return Dwm.CloakedStatus.Uncloaked;
95 | }
96 |
97 | return (Dwm.CloakedStatus)retValue;
98 | }
99 |
100 | public static bool DwmGetWindowFreezeRepresentation(IntPtr hwnd) {
101 | if(DwmGetWindowAttribute(hwnd, DwmWindowAttribute.DWMWA_CLOAKED, out int retValue, Marshal.SizeOf(typeof(int))) != 0) {
102 | return false;
103 | }
104 |
105 | return (retValue != 0);
106 | }
107 |
108 | #endregion
109 |
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/DwmSize.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System.Runtime.InteropServices;
10 |
11 | namespace WindowsFormsAero.Native {
12 |
13 | [StructLayout(LayoutKind.Sequential)]
14 | internal struct DwmSize {
15 |
16 | public int Width;
17 | public int Height;
18 |
19 | public Size ToNativeSize() {
20 | return new Size(Width, Height);
21 | }
22 |
23 | public System.Drawing.Size ToSize() {
24 | return new System.Drawing.Size(Width, Height);
25 | }
26 |
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/DwmThumbnailFlags.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 |
11 | namespace WindowsFormsAero.Native {
12 |
13 | [Flags]
14 | internal enum DwmThumbnailFlags {
15 | RectDestination = 0x1,
16 | RectSource = 0x2,
17 | Opacity = 0x4,
18 | Visible = 0x8,
19 | SourceClientAreaOnly = 0x10
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/DwmThumbnailProperties.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 | using System.Runtime.InteropServices;
11 |
12 | namespace WindowsFormsAero.Native {
13 |
14 | internal struct DwmThumbnailProperties {
15 | public DwmThumbnailFlags dwFlags;
16 | public Rect rcDestination;
17 | public Rect rcSource;
18 | public byte opacity;
19 | [MarshalAs(UnmanagedType.Bool)]
20 | public bool fVisible;
21 | [MarshalAs(UnmanagedType.Bool)]
22 | public bool fSourceClientAreaOnly;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/DwmWindowAttribute.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 |
11 | namespace WindowsFormsAero.Native {
12 |
13 | internal enum DwmWindowAttribute : int {
14 | DWMWA_NCRENDERING_ENABLED = 1,
15 | DWMWA_NCRENDERING_POLICY = 2,
16 | DWMWA_TRANSITIONS_FORCEDISABLED = 3,
17 | DWMWA_ALLOW_NCPAINT = 4,
18 | DWMWA_CAPTION_BUTTON_BOUNDS = 5,
19 | DWMWA_NONCLIENT_RTL_LAYOUT = 6,
20 | DWMWA_FORCE_ICONIC_REPRESENTATION = 7,
21 | DWMWA_FLIP3D_POLICY = 8,
22 | DWMWA_EXTENDED_FRAME_BOUNDS = 9,
23 | DWMWA_HAS_ICONIC_BITMAP = 10,
24 | DWMWA_DISALLOW_PEEK = 11,
25 | DWMWA_EXCLUDED_FROM_PEEK = 12,
26 | DWMWA_CLOAK = 13,
27 | DWMWA_CLOAKED = 14,
28 | DWMWA_FREEZE_REPRESENTATION = 15,
29 | DWMWA_LAST = 16
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/HitTest.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero.Native {
10 |
11 | internal enum HitTest : int {
12 | HTERROR = (-2),
13 | HTTRANSPARENT = (-1),
14 | HTNOWHERE = 0,
15 | HTCLIENT = 1,
16 | HTCAPTION = 2,
17 | HTSYSMENU = 3,
18 | HTGROWBOX = 4,
19 | HTSIZE = HTGROWBOX,
20 | HTMENU = 5,
21 | HTHSCROLL = 6,
22 | HTVSCROLL = 7,
23 | HTMINBUTTON = 8,
24 | HTMAXBUTTON = 9,
25 | HTLEFT = 10,
26 | HTRIGHT = 11,
27 | HTTOP = 12,
28 | HTTOPLEFT = 13,
29 | HTTOPRIGHT = 14,
30 | HTBOTTOM = 15,
31 | HTBOTTOMLEFT = 16,
32 | HTBOTTOMRIGHT = 17,
33 | HTBORDER = 18,
34 | HTREDUCE = HTMINBUTTON,
35 | HTZOOM = HTMAXBUTTON,
36 | HTSIZEFIRST = HTLEFT,
37 | HTSIZELAST = HTBOTTOMRIGHT,
38 | HTOBJECT = 19,
39 | HTCLOSE = 20,
40 | HTHELP = 21
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/IVirtualDesktopManager.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 | using System.Runtime.InteropServices;
11 |
12 | namespace WindowsFormsAero.Native {
13 |
14 | ///
15 | /// Exposes methods that enable an application to interact with groups of
16 | /// windows that form virtual workspaces.
17 | ///
18 | [ComImport]
19 | [Guid("a5cd92ff-29be-454c-8d04-d82879fb3f1b")]
20 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
21 | internal interface IVirtualDesktopManager {
22 |
23 | bool IsWindowOnCurrentVirtualDesktop(IntPtr topLevelWindow);
24 |
25 | Guid GetWindowDesktopId(IntPtr topLevelWindow);
26 |
27 | void MoveWindowToDesktop(IntPtr topLevelWindow, ref Guid desktopId);
28 |
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/IntHelpers.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero.Native {
10 |
11 | internal static class IntHelpers {
12 |
13 | public static ushort LowWord(uint val) {
14 | return (ushort)val;
15 | }
16 |
17 | public static ushort HighWord(uint val) {
18 | return (ushort)(val >> 16);
19 | }
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/ListViewExtendedStyle.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero.Native {
10 |
11 | internal enum ListViewExtendedStyle : uint {
12 | LVS_EX_GRIDLINES = 0x00000001,
13 | LVS_EX_SUBITEMIMAGES = 0x00000002,
14 | LVS_EX_CHECKBOXES = 0x00000004,
15 | LVS_EX_TRACKSELECT = 0x00000008,
16 | LVS_EX_HEADERDRAGDROP = 0x00000010,
17 | LVS_EX_FULLROWSELECT = 0x00000020,
18 | LVS_EX_ONECLICKACTIVATE = 0x00000040,
19 | LVS_EX_TWOCLICKACTIVATE = 0x00000080,
20 | LVS_EX_FLATSB = 0x00000100,
21 | LVS_EX_REGIONAL = 0x00000200,
22 | LVS_EX_INFOTIP = 0x00000400,
23 | LVS_EX_UNDERLINEHOT = 0x00000800,
24 | LVS_EX_UNDERLINECOLD = 0x00001000,
25 | LVS_EX_MULTIWORKAREAS = 0x00002000,
26 | LVS_EX_LABELTIP = 0x00004000,
27 | LVS_EX_BORDERSELECT = 0x00008000,
28 | LVS_EX_DOUBLEBUFFER = 0x00010000,
29 | LVS_EX_HIDELABELS = 0x00020000,
30 | LVS_EX_SINGLEROW = 0x00040000,
31 | LVS_EX_SNAPTOGRID = 0x00080000,
32 | LVS_EX_SIMPLESELECT = 0x00100000,
33 | LVS_EX_JUSTIFYCOLUMNS = 0x00200000,
34 | LVS_EX_TRANSPARENTBKGND = 0x00400000,
35 | LVS_EX_TRANSPARENTSHADOWTEXT = 0x00800000,
36 | LVS_EX_AUTOAUTOARRANGE = 0x01000000,
37 | LVS_EX_HEADERINALLVIEWS = 0x02000000,
38 | LVS_EX_AUTOCHECKSELECT = 0x08000000,
39 | LVS_EX_AUTOSIZECOLUMNS = 0x10000000,
40 | LVS_EX_COLUMNSNAPPOINTS = 0x40000000,
41 | LVS_EX_COLUMNOVERFLOW = 0x80000000
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/Margins.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System.Runtime.InteropServices;
10 |
11 | namespace WindowsFormsAero.Native {
12 |
13 | [StructLayout(LayoutKind.Sequential)]
14 | internal struct Margins {
15 |
16 | public Margins(int left, int right, int top, int bottom) {
17 | Left = left;
18 | Right = right;
19 | Top = top;
20 | Bottom = bottom;
21 | }
22 |
23 | public Margins(int all) {
24 | Left = all;
25 | Right = all;
26 | Top = all;
27 | Bottom = all;
28 | }
29 |
30 | public int Left;
31 | public int Right;
32 | public int Top;
33 | public int Bottom;
34 |
35 | ///
36 | /// Gets a static readonly 0-pixel margin.
37 | ///
38 | public static readonly Margins Zero = new Margins(0);
39 |
40 | ///
41 | /// Converts margins to a instance.
42 | ///
43 | public System.Windows.Forms.Padding ToPadding() {
44 | return new System.Windows.Forms.Padding(Left, Top, Right, Bottom);
45 | }
46 |
47 | ///
48 | /// Creates margins from a instance.
49 | ///
50 | public static Margins FromPadding(System.Windows.Forms.Padding padding) {
51 | return new Margins(padding.Left, padding.Right, padding.Top, padding.Bottom);
52 | }
53 |
54 | public override string ToString() {
55 | return string.Format("{{{0},{1},{2},{3}}}", Left, Right, Top, Bottom);
56 | }
57 |
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/Methods.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Marco Minerva
7 | * Lorenz Cuno Klopfenstein
8 | *****************************************************/
9 |
10 | using System;
11 | using System.Runtime.InteropServices;
12 |
13 | namespace WindowsFormsAero.Native {
14 |
15 | internal static class Methods {
16 |
17 | #region Window manager
18 |
19 | [DllImport("uxtheme.dll", CharSet = CharSet.Unicode)]
20 | public extern static int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList);
21 |
22 | [DllImport("uxtheme.dll", CharSet = CharSet.Unicode, SetLastError = true)]
23 | public static extern int DrawThemeTextEx(IntPtr hTheme, IntPtr hdc,
24 | int iPartId, int iStateId, string text,
25 | int iCharCount, int dwFlags, ref Rect pRect, ref DttOpts pOptions);
26 |
27 | /// Returns the active windows on the current thread.
28 | [DllImport("user32.dll")]
29 | public static extern IntPtr GetActiveWindow();
30 |
31 | [DllImport("user32.dll")]
32 | public static extern bool GetWindowRect(IntPtr hwnd, out Rect rect);
33 |
34 | [DllImport("user32.dll")]
35 | public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
36 |
37 | [DllImport("user32.dll")]
38 | public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
39 |
40 | [DllImport("user32.dll")]
41 | public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, uint wParam, uint lParam);
42 |
43 | //TODO Remove these methods
44 |
45 | //[DllImport("user32.dll")]
46 | //public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
47 |
48 | //[DllImport("user32.dll")]
49 | //public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
50 |
51 | [DllImport("user32.dll", CharSet = CharSet.Unicode)]
52 | public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, string lParam);
53 |
54 | [DllImport("user32.dll")]
55 | [return: MarshalAs(UnmanagedType.Bool)]
56 | public static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
57 |
58 | public static IntPtr GetWindowLong(this IntPtr hWnd, WindowLong i) {
59 | if (IntPtr.Size == 8) {
60 | return GetWindowLongPtr64(hWnd, (int)i);
61 | }
62 | else {
63 | return new IntPtr(GetWindowLong32(hWnd, (int)i));
64 | }
65 | }
66 |
67 | [DllImport("user32.dll", EntryPoint = "GetWindowLong")]
68 | private static extern int GetWindowLong32(IntPtr hWnd, int nIndex);
69 |
70 | [DllImport("user32.dll", EntryPoint = "GetWindowLongPtr")]
71 | private static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);
72 |
73 | public static IntPtr GetClassLongPtr(this IntPtr hWnd, ClassLong i) {
74 | if (IntPtr.Size == 8) {
75 | return GetClassLong64(hWnd, (int)i);
76 | }
77 | else {
78 | return new IntPtr(GetClassLong32(hWnd, (int)i));
79 | }
80 | }
81 |
82 | [DllImport("user32.dll", EntryPoint = "GetClassLongPtrW")]
83 | private static extern IntPtr GetClassLong64(IntPtr hWnd, int nIndex);
84 |
85 | [DllImport("user32.dll", EntryPoint = "GetClassLongW")]
86 | private static extern int GetClassLong32(IntPtr hWnd, int nIndex);
87 |
88 | #endregion
89 |
90 | #region GDI, DC and Blitting
91 |
92 | [DllImport("gdi32.dll")]
93 | public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
94 |
95 | [DllImport("gdi32.dll", SetLastError = true)]
96 | public static extern bool DeleteDC(IntPtr hdc);
97 |
98 | [DllImport("gdi32.dll")]
99 | public static extern bool BitBlt(IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight,
100 | IntPtr hdcSrc, int nXSrc, int nYSrc, BitBltOp dwRop);
101 |
102 | [DllImport("user32.dll")]
103 | public static extern int FillRect(IntPtr hDC, [In] ref Rect lprc, IntPtr hbr);
104 |
105 | [DllImport("gdi32.dll")]
106 | public static extern IntPtr CreateSolidBrush(int crColor);
107 |
108 | [DllImport("gdi32.dll")]
109 | public static extern IntPtr CreateDIBSection(IntPtr hdc, ref BitmapInfo pbmi,
110 | uint iUsage, int ppvBits, IntPtr hSection, uint dwOffset);
111 |
112 | [DllImport("gdi32.dll", ExactSpelling = true)]
113 | public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject);
114 |
115 | [DllImport("gdi32.dll", ExactSpelling = true)]
116 | public static extern bool DeleteObject(IntPtr hObject);
117 |
118 | #endregion
119 |
120 | }
121 |
122 | }
123 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/Point.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System.Runtime.InteropServices;
10 |
11 | namespace WindowsFormsAero.Native {
12 |
13 | [StructLayout(LayoutKind.Sequential)]
14 | internal struct Point {
15 |
16 | public Point(int x, int y) {
17 | X = x;
18 | Y = y;
19 | }
20 |
21 | public Point(System.Drawing.Point p) {
22 | X = p.X;
23 | Y = p.Y;
24 | }
25 |
26 | public Point(System.Drawing.PointF p) {
27 | X = (int)p.X;
28 | Y = (int)p.Y;
29 | }
30 |
31 | public int X;
32 | public int Y;
33 |
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/ProgressBarState.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero.Native {
10 |
11 | internal enum ProgressBarState : int {
12 | Normal = 0x0001, //PBST_NORMAL
13 | Error = 0x0002, //PBST_ERROR
14 | Paused = 0x0003 //PBST_PAUSED
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/ProgressBarStyle.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero.Native {
10 |
11 | internal enum ProgressBarStyle : int {
12 | Smooth = 0x01,
13 | Vertical = 0x04,
14 | Marquee = 0x08,
15 | SmoothReverse = 0x10
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/Rect.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System.Runtime.InteropServices;
10 |
11 | namespace WindowsFormsAero.Native {
12 |
13 | [StructLayout(LayoutKind.Sequential)]
14 | internal struct Rect {
15 |
16 | public Rect(int left, int top, int right, int bottom) {
17 | Left = left;
18 | Top = top;
19 | Right = right;
20 | Bottom = bottom;
21 | }
22 |
23 | public Rect(System.Drawing.Rectangle rect) {
24 | Left = rect.X;
25 | Top = rect.Y;
26 | Right = rect.Right;
27 | Bottom = rect.Bottom;
28 | }
29 |
30 | public int Left;
31 | public int Top;
32 | public int Right;
33 | public int Bottom;
34 |
35 | public int Width {
36 | get {
37 | return Right - Left;
38 | }
39 | set {
40 | Right = Left + value;
41 | }
42 | }
43 |
44 | public int Height {
45 | get {
46 | return Bottom - Top;
47 | }
48 | set {
49 | Bottom = Top + value;
50 | }
51 | }
52 |
53 | public System.Drawing.Rectangle ToRectangle() {
54 | return new System.Drawing.Rectangle(Left, Top, Right - Left, Bottom - Top);
55 | }
56 |
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/Size.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System.Runtime.InteropServices;
10 |
11 | namespace WindowsFormsAero.Native {
12 |
13 | ///
14 | /// Specifies the width and height of a rectangle.
15 | ///
16 | ///
17 | /// See: https://msdn.microsoft.com/en-us/library/windows/desktop/dd145106(v=vs.85).aspx
18 | ///
19 | [StructLayout(LayoutKind.Sequential)]
20 | internal struct Size {
21 |
22 | public Size(int w, int h) {
23 | Width = w;
24 | Height = h;
25 | }
26 |
27 | public int Width;
28 | public int Height;
29 |
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/StructWrapper.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 | using System.Runtime.InteropServices;
11 |
12 | namespace WindowsFormsAero.Native {
13 |
14 | ///
15 | /// Class wrapping a managed struct that is duplicated onto the unmanaged
16 | /// heap and correctly destroyed when disposed or finalized.
17 | ///
18 | internal class StructWrapper : IDisposable
19 | where T : struct {
20 |
21 | public IntPtr Ptr { get; private set; }
22 |
23 | public StructWrapper(T s) {
24 | Ptr = Marshal.AllocHGlobal(Marshal.SizeOf(s));
25 | Marshal.StructureToPtr(s, Ptr, false);
26 | }
27 |
28 | ~StructWrapper() {
29 | if (Ptr != IntPtr.Zero) {
30 | Marshal.DestroyStructure(Ptr, typeof(T));
31 | Marshal.FreeHGlobal(Ptr);
32 | Ptr = IntPtr.Zero;
33 | }
34 | }
35 |
36 | public void Dispose() {
37 | Marshal.DestroyStructure(Ptr, typeof(T));
38 | Marshal.FreeHGlobal(Ptr);
39 | Ptr = IntPtr.Zero;
40 |
41 | GC.SuppressFinalize(this);
42 | }
43 |
44 | public static implicit operator IntPtr(StructWrapper w) {
45 | return w.Ptr;
46 | }
47 |
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/SystemErrorCode.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 WindowsFormsAero.Native {
8 |
9 | internal enum SystemErrorCode : int {
10 | Success = 0,
11 | ErrorInvalidFunction = 1,
12 | ErrorInsufficientBuffer = 122,
13 | AppModelErrorNoPackage = 15700,
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/TextShadowType.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero.Native {
10 |
11 | internal enum TextShadowType : int {
12 | TST_NONE = 0,
13 | TST_SINGLE = 1,
14 | TST_CONTINUOUS = 2
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/TreeViewExtendedStyle.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero.Native {
10 |
11 | internal enum TreeViewExtendedStyle : uint {
12 | TVS_EX_NOSINGLECOLLAPSE = 0x0001,
13 | TVS_EX_MULTISELECT = 0x0002,
14 | TVS_EX_DOUBLEBUFFER = 0x0004,
15 | TVS_EX_NOINDENTSTATE = 0x0008,
16 | TVS_EX_RICHTOOLTIP = 0x0010,
17 | TVS_EX_AUTOHSCROLL = 0x0020,
18 | TVS_EX_FADEINOUTEXPANDOS = 0x0040,
19 | TVS_EX_PARTIALCHECKBOXES = 0x0080,
20 | TVS_EX_EXCLUSIONCHECKBOXES = 0x0100,
21 | TVS_EX_DIMMEDCHECKBOXES = 0x0200,
22 | TVS_EX_DRAWIMAGEASYNC = 0x0400,
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/TreeViewStyle.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero.Native {
10 |
11 | internal enum TreeViewStyle : uint {
12 | TVS_HASBUTTONS = 0x0001,
13 | TVS_HASLINES = 0x0002,
14 | TVS_LINESATROOT = 0x0004,
15 | TVS_EDITLABELS = 0x0008,
16 | TVS_DISABLEDRAGDROP = 0x0010,
17 | TVS_SHOWSELALWAYS = 0x0020,
18 | TVS_RTLREADING = 0x0040,
19 | TVS_NOTOOLTIPS = 0x0080,
20 | TVS_CHECKBOXES = 0x0100,
21 | TVS_TRACKSELECT = 0x0200,
22 | TVS_SINGLEEXPAND = 0x0400,
23 | TVS_INFOTIP = 0x0800,
24 | TVS_FULLROWSELECT = 0x1000,
25 | TVS_NOSCROLL = 0x2000,
26 | TVS_NONEVENHEIGHT = 0x4000,
27 | TVS_NOHSCROLL = 0x8000,
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/UwpMethods.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System.Runtime.InteropServices;
10 | using System.Text;
11 |
12 | namespace WindowsFormsAero.Native {
13 |
14 | internal static class UwpMethods {
15 |
16 | [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
17 | public static extern int GetCurrentPackageFullName(ref int packageFullNameLength, ref StringBuilder packageFullName);
18 |
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/WindowExStyles.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 |
11 | namespace WindowsFormsAero.Native {
12 |
13 | [Flags]
14 | internal enum WindowExStyles : long {
15 | AppWindow = 0x00040000L,
16 | ClientEdge = 0x00000200L,
17 | ControlParent = 0x00010000L,
18 | Layered = 0x00080000,
19 | NoActivate = 0x08000000L,
20 | ToolWindow = 0x00000080L,
21 | TopMost = 0x00000008L,
22 | Transparent = 0x00000020L
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/WindowLong.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero.Native {
10 |
11 | internal enum WindowLong : int {
12 | WndProc = (-4),
13 | HInstance = (-6),
14 | HwndParent = (-8),
15 | Style = (-16),
16 | ExStyle = (-20),
17 | UserData = (-21),
18 | Id = (-12)
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/WindowStyles.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 |
11 | namespace WindowsFormsAero.Native {
12 |
13 | [Flags]
14 | internal enum WindowStyles : long {
15 | None = 0x00000000L,
16 | Border = 0x00800000L,
17 | Caption = 0x00C00000L,
18 | Child = 0x40000000L,
19 | DialogFrame = 0x00400000L,
20 | Disabled = 0x08000000L,
21 | Maximize = 0x01000000L,
22 | MaximizeBox = 0x00010000L,
23 | Minimize = 0x20000000L,
24 | MinimizeBox = 0x00020000L,
25 | Overlapped = 0x00000000L,
26 | SysMenu = 0x00080000L,
27 | ThickFrame = 0x00040000L,
28 | Visible = 0x10000000L,
29 | OverlappedWindow = Overlapped | Caption | SysMenu | ThickFrame | MinimizeBox | MaximizeBox
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Native/WindowTheme.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 | using System.Runtime.InteropServices;
11 |
12 | namespace WindowsFormsAero.Native {
13 |
14 | [Flags]
15 | internal enum WindowThemeNonClientAttributes : uint {
16 | NullAttribute = 0,
17 | NoDrawCaption = 0x00000001,
18 | NoDrawIcon = 0x00000002
19 | }
20 |
21 | [StructLayout(LayoutKind.Sequential)]
22 | internal struct WTA_OPTIONS {
23 | public WindowThemeNonClientAttributes Flags;
24 | public WindowThemeNonClientAttributes Mask;
25 | }
26 |
27 | internal static class WindowTheme {
28 |
29 | public enum WindowThemeAttributeType : int {
30 | WTA_NONCLIENT = 1
31 | }
32 |
33 | [DllImport("uxtheme.dll")]
34 | public static extern int SetWindowThemeAttribute(IntPtr hWnd,
35 | WindowThemeAttributeType wtype, ref WTA_OPTIONS attributes, uint size);
36 |
37 | public static int SetWindowThemeNonClientAttributes(IntPtr hwnd,
38 | WindowThemeNonClientAttributes mask, WindowThemeNonClientAttributes attributes) {
39 |
40 | var opt = new WTA_OPTIONS {
41 | Flags = attributes,
42 | Mask = mask
43 | };
44 | return SetWindowThemeAttribute(hwnd, WindowThemeAttributeType.WTA_NONCLIENT,
45 | ref opt, (uint)Marshal.SizeOf(typeof(WTA_OPTIONS)));
46 | }
47 |
48 |
49 | /*public const uint WTNCA_NODRAWCAPTION = 0x00000001;
50 | public const uint WTNCA_NODRAWICON = 0x00000002;*/
51 |
52 | /*WTA_OPTIONS wta = new WTA_OPTIONS() { Flags = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON, Mask = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON };
53 |
54 | SetWindowThemeAttribute(this.Handle, WTA_NONCLIENT, ref wta, (uint)Marshal.SizeOf(typeof(WTA_OPTIONS)));*/
55 |
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/OSSupport.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 | using WindowsFormsAero.Native;
11 |
12 | namespace WindowsFormsAero {
13 |
14 | ///
15 | /// Static class providing information about the running OS's version.
16 | ///
17 | public static class OsSupport {
18 |
19 | private const int VistaMajorVersion = 6;
20 | private const int SevenMinorVersion = 1;
21 | private const int EightMinorVersion = 2;
22 | private const int EightDotOneMinorVersion = 3;
23 | private const int TenMajorVersion = 10;
24 | private const int TenAnniversaryBuild = 14393;
25 |
26 | ///
27 | /// Gets whether the running operating system is Windows Vista or a more recent
28 | /// version.
29 | ///
30 | [Obsolete("Use IsVistaOrLater")]
31 | public static bool IsVistaOrBetter {
32 | get {
33 | return (Environment.OSVersion.Platform == PlatformID.Win32NT &&
34 | Environment.OSVersion.Version.Major >= VistaMajorVersion);
35 | }
36 | }
37 |
38 | ///
39 | /// Gets whether the running operating system is Windows Vista or a more recent
40 | /// version.
41 | ///
42 | public static bool IsVistaOrLater {
43 | get {
44 | return (Environment.OSVersion.Platform == PlatformID.Win32NT &&
45 | Environment.OSVersion.Version.Major >= VistaMajorVersion);
46 | }
47 | }
48 |
49 | ///
50 | /// Gets whether the running operating system is Windows Seven or a more recent
51 | /// version.
52 | ///
53 | [Obsolete("Use IsSevenOrLater")]
54 | public static bool IsSevenOrBetter {
55 | get {
56 | return IsSevenOrLater;
57 | }
58 | }
59 |
60 | ///
61 | /// Gets whether the running operating system is Windows Seven or a more recent
62 | /// version.
63 | ///
64 | public static bool IsSevenOrLater {
65 | get {
66 | if (Environment.OSVersion.Platform != PlatformID.Win32NT)
67 | return false;
68 |
69 | var version = Environment.OSVersion.Version;
70 | if (version.Major > VistaMajorVersion)
71 | return true;
72 | else if (version.Major == VistaMajorVersion)
73 | return (version.Minor >= SevenMinorVersion);
74 |
75 | return false;
76 | }
77 | }
78 |
79 | ///
80 | /// Gets whether the running operating system is Windows 8 or a more recent
81 | /// version.
82 | ///
83 | [Obsolete("Use IsEightOrLater")]
84 | public static bool IsEightOrBetter {
85 | get {
86 | return IsEightOrLater;
87 | }
88 | }
89 |
90 | ///
91 | /// Gets whether the running operating system is Windows 8 or a more recent
92 | /// version.
93 | ///
94 | public static bool IsEightOrLater {
95 | get {
96 | if (Environment.OSVersion.Platform != PlatformID.Win32NT)
97 | return false;
98 |
99 | var version = Environment.OSVersion.Version;
100 |
101 | if (version.Major > VistaMajorVersion)
102 | return true;
103 | else if (version.Major == VistaMajorVersion)
104 | return (version.Minor >= EightMinorVersion);
105 |
106 | return false;
107 | }
108 | }
109 |
110 | ///
111 | /// Gets whether the running operating system is Windows 8.1 or a more recent
112 | /// version.
113 | ///
114 | [Obsolete("Use IsEightDotOneOrLater")]
115 | public static bool IsEightDotOneOrBetter {
116 | get {
117 | return IsEightDotOneOrLater;
118 | }
119 | }
120 |
121 | ///
122 | /// Gets whether the running operating system is Windows 8.1 or a more recent
123 | /// version.
124 | ///
125 | public static bool IsEightDotOneOrLater {
126 | get {
127 | if (Environment.OSVersion.Platform != PlatformID.Win32NT)
128 | return false;
129 |
130 | var version = Environment.OSVersion.Version;
131 |
132 | if (version.Major > VistaMajorVersion)
133 | return true;
134 | else if (version.Major == VistaMajorVersion)
135 | return (version.Minor >= EightDotOneMinorVersion);
136 |
137 | return false;
138 | }
139 | }
140 |
141 | ///
142 | /// Gets whether the running operating system is Windows 10 or a more recent
143 | /// version.
144 | ///
145 | [Obsolete("Use IsTenOrLater")]
146 | public static bool IsTenOrBetter {
147 | get {
148 | return IsTenOrLater;
149 | }
150 | }
151 |
152 | ///
153 | /// Gets whether the running operating system is Windows 10 or a more recent
154 | /// version.
155 | ///
156 | public static bool IsTenOrLater {
157 | get {
158 | if (Environment.OSVersion.Platform != PlatformID.Win32NT)
159 | return false;
160 |
161 | var version = Environment.OSVersion.Version;
162 |
163 | if (version.Major >= TenMajorVersion)
164 | return true;
165 |
166 | return false;
167 | }
168 | }
169 |
170 | ///
171 | /// Gets whether the running operating system is Windows 10 "Anniversary Edition"
172 | /// or a more recent version.
173 | ///
174 | [Obsolete("Use IsTenAnniversaryEditionOrLater")]
175 | public static bool IsTenAnniversaryEditionOrBetter {
176 | get {
177 | return IsTenAnniversaryEditionOrLater;
178 | }
179 | }
180 |
181 | ///
182 | /// Gets whether the running operating system is Windows 10 "Anniversary Edition"
183 | /// or a more recent version.
184 | ///
185 | public static bool IsTenAnniversaryEditionOrLater {
186 | get {
187 | if (!IsTenOrLater)
188 | return false;
189 |
190 | return Environment.OSVersion.Version.Build >= TenAnniversaryBuild;
191 | }
192 | }
193 |
194 | ///
195 | /// Is true if the DWM composition engine is currently enabled.
196 | ///
197 | public static bool IsCompositionEnabled {
198 | get {
199 | if (!IsVistaOrLater)
200 | return false;
201 |
202 | try {
203 | DwmMethods.DwmIsCompositionEnabled(out bool enabled);
204 | return enabled;
205 | }
206 | catch (Exception) {
207 | return false;
208 | }
209 | }
210 | }
211 |
212 | }
213 |
214 | }
215 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/ProgressBar.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Marco Minerva
7 | * Lorenz Cuno Klopfenstein
8 | *****************************************************/
9 |
10 | using System;
11 | using System.ComponentModel;
12 | using System.Drawing;
13 | using System.Windows.Forms;
14 | using WindowsFormsAero.Native;
15 |
16 | namespace WindowsFormsAero {
17 |
18 | [ToolboxBitmap(typeof(ProgressBar))]
19 | public class ProgressBar : System.Windows.Forms.ProgressBar {
20 |
21 | protected override CreateParams CreateParams {
22 | get {
23 | CreateParams cParams = base.CreateParams;
24 |
25 | // Enables smooth transition even when progressbar value is decreased
26 | cParams.Style |= (int)Native.ProgressBarStyle.SmoothReverse;
27 |
28 | return cParams;
29 | }
30 | }
31 |
32 | private ProgressBarState _state = ProgressBarState.Normal;
33 |
34 | [
35 | Description("Gets or sets the ProgressBar state."),
36 | Category("Appearance"),
37 | DefaultValue(ProgressBarState.Normal)
38 | ]
39 | public ProgressBarState State {
40 | get {
41 | return _state;
42 | }
43 | set {
44 | if(_state != value) {
45 | SetState(value);
46 | }
47 |
48 | _state = value;
49 | }
50 | }
51 |
52 | private void SetState(ProgressBarState targetState) {
53 | if (!IsHandleCreated)
54 | return;
55 |
56 | Methods.SendMessage(Handle, (uint)WindowMessage.PBM_SETSTATE,
57 | (int)targetState.ToNative(), 0);
58 | }
59 |
60 | protected override void OnHandleCreated(EventArgs e) {
61 | base.OnHandleCreated(e);
62 |
63 | SetState(_state);
64 | }
65 |
66 | protected override void WndProc(ref Message m) {
67 | //Intercept PBM_SETPOS messages that update the progressbar's value
68 | //and switch to normal state if the progress bar is paused or in error
69 | //(which prevents the progressbar from updating its value correctly).
70 | if (m.Msg == (int)WindowMessage.PBM_SETPOS && _state != ProgressBarState.Normal) {
71 | SetState(ProgressBarState.Normal);
72 | }
73 |
74 | base.WndProc(ref m);
75 |
76 | //Switch back to original state if needed
77 | if(m.Msg == (int)WindowMessage.PBM_SETPOS && _state != ProgressBarState.Normal) {
78 | SetState(_state);
79 | }
80 | }
81 |
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/ProgressBarState.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero {
10 |
11 | ///
12 | /// Represents the state of a progress bar.
13 | ///
14 | public enum ProgressBarState {
15 | Normal,
16 | Paused,
17 | Error
18 | }
19 |
20 | internal static class ProgressBarStateExtensions {
21 |
22 | ///
23 | /// Converts a value into a native
24 | /// Win32 value, represented by .
25 | ///
26 | public static Native.ProgressBarState ToNative(this ProgressBarState state) {
27 | switch (state) {
28 | default:
29 | case ProgressBarState.Normal:
30 | return Native.ProgressBarState.Normal;
31 |
32 | case ProgressBarState.Error:
33 | return Native.ProgressBarState.Error;
34 |
35 | case ProgressBarState.Paused:
36 | return Native.ProgressBarState.Paused;
37 | }
38 | }
39 |
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/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("WindowsFormsAero")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("WindowsFormsAero")]
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("844f1de5-17ea-4e69-a7c5-b803ad3bd5d9")]
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("3.1.1.0")]
36 | [assembly: AssemblyFileVersion("3.1.1.0")]
37 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Resources/Pictures.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 WindowsFormsAero.Resources {
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", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | public class Pictures {
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 Pictures() {
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 | public 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("WindowsFormsAero.Resources.Pictures", typeof(Pictures).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 | public 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 | public static System.Drawing.Bitmap ActiveSearch {
67 | get {
68 | object obj = ResourceManager.GetObject("ActiveSearch", resourceCulture);
69 | return ((System.Drawing.Bitmap)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// Looks up a localized resource of type System.Drawing.Bitmap.
75 | ///
76 | public static System.Drawing.Bitmap InactiveSearch {
77 | get {
78 | object obj = ResourceManager.GetObject("InactiveSearch", resourceCulture);
79 | return ((System.Drawing.Bitmap)(obj));
80 | }
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Resources/Pictures.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | active_search.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
125 | inactive_search.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
126 |
127 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Resources/active_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LorenzCK/WindowsFormsAero/14c921f21939c4f535617e66ffc1ace4b0173e44/src/WindowsFormsAero/Resources/active_search.png
--------------------------------------------------------------------------------
/src/WindowsFormsAero/Resources/inactive_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LorenzCK/WindowsFormsAero/14c921f21939c4f535617e66ffc1ace4b0173e44/src/WindowsFormsAero/Resources/inactive_search.png
--------------------------------------------------------------------------------
/src/WindowsFormsAero/SplitButton.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Nicholas Kwan
7 | *****************************************************/
8 |
9 | using System;
10 | using System.ComponentModel;
11 | using System.Drawing;
12 | using System.Windows.Forms;
13 | using WindowsFormsAero.Native;
14 |
15 | namespace WindowsFormsAero {
16 |
17 | ///
18 | /// A complex button provided with a secondary split push button
19 | /// that open up a context menu.
20 | ///
21 | ///
22 | /// See: http://www.codeproject.com/KB/vista/themedvistacontrols.aspx
23 | ///
24 | public class SplitButton : Button {
25 |
26 | protected override CreateParams CreateParams {
27 | get {
28 | CreateParams p = base.CreateParams;
29 |
30 | p.Style |= (int)(
31 | (IsDefault) ? ButtonStyle.DefaultSplitButton : ButtonStyle.SplitButton
32 | );
33 |
34 | return p;
35 | }
36 | }
37 |
38 | #region Split Context Menu
39 |
40 | ///
41 | /// Occurs when the split label is clicked.
42 | ///
43 | [
44 | Description("Occurs when the split button is clicked."),
45 | Category("Action")
46 | ]
47 | public event EventHandler SplitClick;
48 |
49 | ///
50 | /// Occurs when the split label is clicked, but before the associated
51 | /// context menu is displayed by the control.
52 | ///
53 | [
54 | Description("Occurs when the split label is clicked, but before the associated context menu is displayed."),
55 | Category("Action")
56 | ]
57 | public event EventHandler SplitMenuOpening;
58 |
59 | protected virtual void OnSplitClick(SplitMenuEventArgs e) {
60 | SplitClick?.Invoke(this, e);
61 |
62 | if (SplitMenu == null && SplitMenuStrip == null)
63 | return;
64 |
65 | SplitMenuOpening?.Invoke(this, e);
66 |
67 | if (e.PreventOpening)
68 | return;
69 |
70 | var pBottomLeft = new System.Drawing.Point(e.DrawArea.Left, e.DrawArea.Bottom);
71 | if (SplitMenu != null) {
72 | SplitMenu.Show(this, pBottomLeft);
73 | }
74 | else if (SplitMenuStrip != null) {
75 | SplitMenuStrip.Width = e.DrawArea.Width;
76 | SplitMenuStrip.Show(this, pBottomLeft);
77 | }
78 | }
79 |
80 | ///
81 | /// Gets or sets the associated context menu that is displayed when the split
82 | /// glyph of the button is clicked.
83 | ///
84 | [
85 | Description("Sets the context menu that is displayed by clicking on the split button."),
86 | Category("Behavior"),
87 | DefaultValue(null)
88 | ]
89 | public ContextMenuStrip SplitMenuStrip { get; set; }
90 |
91 | ///
92 | /// Gets or sets the associated context menu that is displayed when the split
93 | /// glyph of the button is clicked.
94 | ///
95 | ///
96 | /// Exposed for backward compatibility with legacy context menu classes.
97 | /// If both and are
98 | /// set, the first is preferred.
99 | ///
100 | [
101 | Description("Sets the context menu that is displayed by clicking on the split button."),
102 | Category("Behavior"),
103 | DefaultValue(null)
104 | ]
105 | public ContextMenu SplitMenu { get; set; }
106 |
107 | #endregion Split Context Menu
108 |
109 | bool _alignLeft = false;
110 |
111 | ///
112 | /// Gets or sets whether the split button should be aligned on the left side of the button.
113 | ///
114 | [
115 | Description("Align the split button on the left side of the button."),
116 | Category("Appearance"),
117 | DefaultValue(false)
118 | ]
119 | public bool SplitButtonAlignLeft {
120 | get {
121 | return _alignLeft;
122 | }
123 | set {
124 | _alignLeft = value;
125 | UpdateStyle();
126 | }
127 | }
128 |
129 | bool _noSplit = false;
130 |
131 | ///
132 | /// Gets or sets whether the split button should be shown or not.
133 | ///
134 | [
135 | Description("Hide the split button."),
136 | Category("Appearance"),
137 | DefaultValue(false)
138 | ]
139 | public bool SplitButtonNoSplit {
140 | get {
141 | return _noSplit;
142 | }
143 | set {
144 | _noSplit = value;
145 | UpdateStyle();
146 | }
147 | }
148 |
149 | private void UpdateStyle() {
150 | //TODO: add "no split" style
151 |
152 | var info = new ButtonSplitInfo();
153 | info.Mask = ButtonSplitInfo.MaskType.Style;
154 | info.Style = (
155 | (SplitButtonAlignLeft) ? ButtonSplitInfo.SplitStyle.AlignLeft : ButtonSplitInfo.SplitStyle.None
156 | );
157 |
158 | using(var hSplitInfo = new StructWrapper(info)) {
159 | Methods.SendMessage(Handle,
160 | (int)WindowMessage.BCM_SETSPLITINFO,
161 | IntPtr.Zero,
162 | hSplitInfo);
163 | }
164 | }
165 |
166 | protected override void WndProc(ref Message m) {
167 | if (m.Msg == (int)WindowMessage.BCM_SETDROPDOWNSTATE) {
168 | if (m.WParam.ToInt32() == 1) {
169 | OnSplitClick(new SplitMenuEventArgs(ClientRectangle));
170 | }
171 | }
172 |
173 | base.WndProc(ref m);
174 | }
175 |
176 | }
177 |
178 | }
179 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/SplitMenuEventArgs.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Nicholas Kwan
7 | *****************************************************/
8 |
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Drawing;
12 |
13 | namespace WindowsFormsAero {
14 |
15 | ///
16 | /// Provides data for the clicking of split buttons and the opening
17 | /// of context menus.
18 | ///
19 | ///
20 | /// See: http://www.codeproject.com/KB/vista/themedvistacontrols.aspx
21 | ///
22 | public class SplitMenuEventArgs : EventArgs {
23 |
24 | public SplitMenuEventArgs() {
25 | PreventOpening = false;
26 | }
27 |
28 | public SplitMenuEventArgs(Rectangle drawArea) {
29 | DrawArea = drawArea;
30 | }
31 |
32 | ///
33 | /// Represents the bounding box of the clicked button.
34 | ///
35 | ///
36 | /// A menu should be opened, with top-left coordinates in the left-bottom
37 | /// point of the rectangle and with width equal (or greater) than the width
38 | /// of the rectangle.
39 | ///
40 | public Rectangle DrawArea { get; set; }
41 |
42 | ///
43 | /// Set to true if you want to prevent the menu from opening.
44 | ///
45 | public bool PreventOpening { get; set; }
46 |
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/StoreAppHelper.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System.Text;
10 | using WindowsFormsAero.Native;
11 |
12 | namespace WindowsFormsAero {
13 |
14 | ///
15 | /// Exposes helpers and auxilary methods for Windows Store apps
16 | /// (i.e., desktop applications converted through Centennial).
17 | ///
18 | public static class StoreAppHelper {
19 |
20 | ///
21 | /// Gets whether the current process is running inside an UWP container
22 | /// "Windows Store" application.
23 | ///
24 | ///
25 | /// Taken from https://github.com/qmatteoq/DesktopBridgeHelpers by Matteo Pagani.
26 | ///
27 | public static bool IsRunningAsStoreApp() {
28 | if (!OsSupport.IsEightOrLater) {
29 | return false;
30 | }
31 | else {
32 | var sb = new StringBuilder(0);
33 | int length = 0;
34 | int result = UwpMethods.GetCurrentPackageFullName(ref length, ref sb);
35 |
36 | // If there is a package name, the 0-length buffer will be insufficient
37 | return (result == (int)SystemErrorCode.ErrorInsufficientBuffer);
38 | }
39 | }
40 |
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/TaskDialog/CommonButton.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 |
11 | namespace WindowsFormsAero.TaskDialog {
12 |
13 | ///
14 | /// Common Task Dialog buttons.
15 | ///
16 | [Flags]
17 | public enum CommonButton : int {
18 | OK = 0x0001,
19 | Cancel = 0x0008,
20 | Yes = 0x0002,
21 | No = 0x0004,
22 | Retry = 0x0010,
23 | Close = 0x0020
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/TaskDialog/CommonButtonResult.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero.TaskDialog {
10 |
11 | ///
12 | /// Results returned by Task Dialogs when closed by the user through a common button.
13 | ///
14 | public enum CommonButtonResult : int {
15 | None = 0,
16 | OK = 1,
17 | Cancel = 2,
18 | Abort = 3,
19 | Retry = 4,
20 | Ignore = 5,
21 | Yes = 6,
22 | No = 7,
23 | Close = 8
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/TaskDialog/CommonIcon.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero.TaskDialog {
10 |
11 | ///
12 | /// Common Task Dialog icon values.
13 | ///
14 | ///
15 | /// Common icon values also determine how the task dialog's main instruction is styled.
16 | ///
17 | public enum CommonIcon : long {
18 | Information = ushort.MaxValue - 2,
19 | Warning = ushort.MaxValue,
20 | Stop = ushort.MaxValue - 1,
21 | None = 0,
22 | SecurityWarning = ushort.MaxValue - 5,
23 | SecurityError = ushort.MaxValue - 6,
24 | SecuritySuccess = ushort.MaxValue - 7,
25 | SecurityShield = ushort.MaxValue - 3,
26 | SecurityShieldBlue = ushort.MaxValue - 4,
27 | SecurityShieldGray = ushort.MaxValue - 8
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/TaskDialog/CustomButton.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System.Runtime.InteropServices;
10 |
11 | namespace WindowsFormsAero.TaskDialog {
12 |
13 | ///
14 | /// Custom button shown on a Task Dialog.
15 | ///
16 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
17 | public struct CustomButton {
18 |
19 | private int _id;
20 |
21 | [MarshalAs(UnmanagedType.LPWStr)]
22 | private string _txt;
23 |
24 | ///
25 | /// Instantiates a new custom button with an ID and a text.
26 | ///
27 | /// Unique ID that will be returned by the Task Dialog if the button is clicked.
28 | /// Text label shown on the button.
29 | public CustomButton(int id, string text) {
30 | _id = id;
31 | _txt = text;
32 | }
33 |
34 | ///
35 | /// Instantiates a new custom button with an ID and a text.
36 | ///
37 | /// Common ID that will be returned by the Task Dialog if the button is clicked.
38 | /// Text label shown on the button.
39 | public CustomButton(CommonButtonResult commonResult, string text) {
40 | _id = (int)commonResult;
41 | _txt = text;
42 | }
43 |
44 | ///
45 | /// Unique ID that will be returned by the Task Dialog if the button is clicked.
46 | /// Use values greater than 8 to prevent conflicts with common button IDs.
47 | ///
48 | public int Id {
49 | get {
50 | return _id;
51 | }
52 | set {
53 | _id = value;
54 | }
55 | }
56 |
57 | ///
58 | /// Text label shown on the button.
59 | ///
60 | ///
61 | /// If you enable Command Links, a newline here separates the upper from the
62 | /// lower string on the button.
63 | ///
64 | public string Text {
65 | get {
66 | return _txt;
67 | }
68 | set {
69 | _txt = value;
70 | }
71 | }
72 |
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/TaskDialog/EventArgs.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 |
11 | namespace WindowsFormsAero.TaskDialog {
12 |
13 | public class ClickEventArgs : EventArgs {
14 |
15 | public ClickEventArgs(int buttonID) {
16 | ButtonID = buttonID;
17 | PreventClosing = false;
18 | }
19 |
20 | public int ButtonID { get; set; }
21 |
22 | public bool PreventClosing { get; set; }
23 |
24 | }
25 |
26 | public class CheckEventArgs : EventArgs {
27 |
28 | public CheckEventArgs(bool state) {
29 | IsChecked = state;
30 | }
31 |
32 | public bool IsChecked { get; set; }
33 |
34 | }
35 |
36 | public class ExpandEventArgs : EventArgs {
37 |
38 | public ExpandEventArgs(bool state) {
39 | IsExpanded = state;
40 | }
41 |
42 | public bool IsExpanded { get; set; }
43 |
44 | }
45 |
46 | public class TimerEventArgs : EventArgs {
47 |
48 | public TimerEventArgs(long ticks) {
49 | Ticks = ticks;
50 | ResetCount = false;
51 | }
52 |
53 | public long Ticks { get; set; }
54 |
55 | public bool ResetCount { get; set; }
56 |
57 | }
58 |
59 | public class HyperlinkEventArgs : EventArgs {
60 |
61 | public HyperlinkEventArgs(string url) {
62 | Url = url;
63 | }
64 |
65 | public string Url { get; set; }
66 |
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/TaskDialog/Message.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 | using System.Runtime.InteropServices;
11 |
12 | namespace WindowsFormsAero.TaskDialog {
13 |
14 | ///
15 | /// Stores a Task Dialog message that will be sent to a dialog in order to update its state.
16 | ///
17 | internal struct Message {
18 |
19 | /// Text values that can be updated.
20 | public enum DialogElements : int {
21 | TDE_CONTENT,
22 | TDE_EXPANDED_INFORMATION,
23 | TDE_FOOTER,
24 | TDE_MAIN_INSTRUCTION
25 | }
26 |
27 | /// Simple int, int message.
28 | public Message(NativeMethods.TaskDialogMessages msg, int w, int l) {
29 | UnsafeHandle = IntPtr.Zero;
30 | MessageType = msg;
31 | WParam = new IntPtr(w);
32 | LParam = new IntPtr(l);
33 | ContainsTaskDialogConfig = false;
34 | }
35 |
36 | /// Simple int, bool message.
37 | public Message(NativeMethods.TaskDialogMessages msg, int w, bool l) {
38 | UnsafeHandle = IntPtr.Zero;
39 | MessageType = msg;
40 | WParam = new IntPtr(w);
41 | LParam = new IntPtr(l ? 1 : 0);
42 | ContainsTaskDialogConfig = false;
43 | }
44 |
45 | /// Simple bool, bool message.
46 | public Message(NativeMethods.TaskDialogMessages msg, bool w, bool l) {
47 | UnsafeHandle = IntPtr.Zero;
48 | MessageType = msg;
49 | WParam = new IntPtr(w ? 1 : 0);
50 | LParam = new IntPtr(l ? 1 : 0);
51 | ContainsTaskDialogConfig = false;
52 | }
53 |
54 | /// Simple bool, int message.
55 | public Message(NativeMethods.TaskDialogMessages msg, bool w, int l) {
56 | UnsafeHandle = IntPtr.Zero;
57 | MessageType = msg;
58 | WParam = new IntPtr(w ? 1 : 0);
59 | LParam = new IntPtr(l);
60 | ContainsTaskDialogConfig = false;
61 | }
62 |
63 | /// Simple int, long (hi word and lo word) message.
64 | public Message(NativeMethods.TaskDialogMessages msg, int w, int l_hi, int l_lo) {
65 | UnsafeHandle = IntPtr.Zero;
66 | MessageType = msg;
67 | WParam = new IntPtr(w);
68 | LParam = new IntPtr((l_lo << 16) + l_hi);
69 | ContainsTaskDialogConfig = false;
70 | }
71 |
72 | /// Text updating message.
73 | /// The string will be marshaled: the Message must be correctly disposed after use.
74 | public Message(NativeMethods.TaskDialogMessages msg, DialogElements element, string s) {
75 | UnsafeHandle = Marshal.StringToHGlobalUni(s);
76 | MessageType = msg;
77 | WParam = new IntPtr((int)element);
78 | LParam = UnsafeHandle;
79 | ContainsTaskDialogConfig = false;
80 | }
81 |
82 | /// Navigation message.
83 | /// The config structure will be marshaled: must be correctly disposed after use.
84 | public Message(NativeMethods.TaskDialogMessages msg, int w, NativeMethods.TaskDialogConfig config) {
85 | UnsafeHandle = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NativeMethods.TaskDialogConfig)));
86 | Marshal.StructureToPtr(config, UnsafeHandle, false);
87 | MessageType = msg;
88 | WParam = new IntPtr(w);
89 | LParam = UnsafeHandle;
90 | ContainsTaskDialogConfig = true;
91 | }
92 |
93 | private IntPtr UnsafeHandle;
94 |
95 | public NativeMethods.TaskDialogMessages MessageType;
96 |
97 | public IntPtr WParam;
98 |
99 | public IntPtr LParam;
100 |
101 | private bool ContainsTaskDialogConfig;
102 |
103 | ///
104 | /// Cleans up unmanages memory allocated by the message.
105 | ///
106 | ///
107 | /// This pattern is used instead of to avoid
108 | /// unnecessary memory allocations and boxing.
109 | ///
110 | public static void Cleanup(Message m) {
111 | if (m.UnsafeHandle != IntPtr.Zero) {
112 | if (m.ContainsTaskDialogConfig) {
113 | Marshal.DestroyStructure(m.UnsafeHandle, typeof(NativeMethods.TaskDialogConfig));
114 | }
115 | Marshal.FreeHGlobal(m.UnsafeHandle);
116 |
117 | m.UnsafeHandle = IntPtr.Zero;
118 | }
119 | }
120 |
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/TaskDialog/NativeMethods.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 | using System.Runtime.InteropServices;
11 |
12 | namespace WindowsFormsAero.TaskDialog {
13 |
14 | internal class NativeMethods {
15 |
16 | /// Direct Task Dialog call.
17 | [DllImport("comctl32.dll", CharSet = CharSet.Unicode, EntryPoint = "TaskDialog")]
18 | public static extern int TaskDialog(IntPtr hWndParent, IntPtr hInstance,
19 | string pszWindowTitle, string pszMainInstruction, string pszContent,
20 | int dwCommonButtons, IntPtr pszIcon, out int pnButton);
21 |
22 | /// Indirect Task Dialog call. Allows complex dialogs with interaction logic (via callback).
23 | [DllImport("comctl32.dll", CharSet = CharSet.Unicode)]
24 | public static extern IntPtr TaskDialogIndirect(ref TaskDialogConfig pTaskConfig,
25 | out int pnButton, out int pnRadioButton, out bool pfVerificationFlagChecked);
26 |
27 | internal delegate IntPtr TaskDialogCallback(IntPtr hwnd, uint msg, UIntPtr wParam, IntPtr lParam, IntPtr refData);
28 |
29 | /// The Task Dialog config structure.
30 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
31 | internal struct TaskDialogConfig {
32 | public uint cbSize;
33 | public IntPtr hwndParent;
34 | public IntPtr hInstance;
35 | public TaskDialogFlags dwFlags;
36 | public CommonButton dwCommonButtons;
37 | [MarshalAs(UnmanagedType.LPWStr)]
38 | public string pszWindowTitle;
39 | public IntPtr hMainIcon;
40 | [MarshalAs(UnmanagedType.LPWStr)]
41 | public string pszMainInstruction;
42 | [MarshalAs(UnmanagedType.LPWStr)]
43 | public string pszContent;
44 | public uint cButtons;
45 | public IntPtr pButtons;
46 | public int nDefaultButton;
47 | public uint cRadioButtons;
48 | public IntPtr pRadioButtons;
49 | public int nDefaultRadioButton;
50 | [MarshalAs(UnmanagedType.LPWStr)]
51 | public string pszVerificationText;
52 | [MarshalAs(UnmanagedType.LPWStr)]
53 | public string pszExpandedInformation;
54 | [MarshalAs(UnmanagedType.LPWStr)]
55 | public string pszExpandedControlText;
56 | [MarshalAs(UnmanagedType.LPWStr)]
57 | public string pszCollapsedControlText;
58 | public IntPtr hFooterIcon;
59 | [MarshalAs(UnmanagedType.LPWStr)]
60 | public string pszFooter;
61 | public TaskDialogCallback pfCallback;
62 | public IntPtr lpCallbackData;
63 | public uint cxWidth;
64 | }
65 |
66 | /// Flags used in TaskDialogConfig struct.
67 | /// From CommCtrl.h.
68 | [Flags]
69 | internal enum TaskDialogFlags {
70 | TDF_ENABLE_HYPERLINKS = 0x0001,
71 | TDF_USE_HICON_MAIN = 0x0002,
72 | TDF_USE_HICON_FOOTER = 0x0004,
73 | TDF_ALLOW_DIALOG_CANCELLATION = 0x0008,
74 | TDF_USE_COMMAND_LINKS = 0x0010,
75 | TDF_USE_COMMAND_LINKS_NO_ICON = 0x0020,
76 | TDF_EXPAND_FOOTER_AREA = 0x0040,
77 | TDF_EXPANDED_BY_DEFAULT = 0x0080,
78 | TDF_VERIFICATION_FLAG_CHECKED = 0x0100,
79 | TDF_SHOW_PROGRESS_BAR = 0x0200,
80 | TDF_SHOW_MARQUEE_PROGRESS_BAR = 0x0400,
81 | TDF_CALLBACK_TIMER = 0x0800,
82 | TDF_POSITION_RELATIVE_TO_WINDOW = 0x1000,
83 | TDF_RTL_LAYOUT = 0x2000,
84 | TDF_NO_DEFAULT_RADIO_BUTTON = 0x4000,
85 | TDF_CAN_BE_MINIMIZED = 0x8000
86 | }
87 |
88 | /// Notifications returned by Task Dialogs to the callback.
89 | /// From CommCtrl.h.
90 | public enum TaskDialogNotification : uint {
91 | TDN_CREATED = 0,
92 | TDN_NAVIGATED = 1,
93 | TDN_BUTTON_CLICKED = 2, // wParam = Button ID
94 | TDN_HYPERLINK_CLICKED = 3, // lParam = (LPCWSTR)pszHREF
95 | TDN_TIMER = 4, // wParam = Milliseconds since dialog created or timer reset
96 | TDN_DESTROYED = 5,
97 | TDN_RADIO_BUTTON_CLICKED = 6, // wParam = Radio Button ID
98 | TDN_DIALOG_CONSTRUCTED = 7,
99 | TDN_VERIFICATION_CLICKED = 8, // wParam = 1 if checkbox checked, 0 if not, lParam is unused and always 0
100 | TDN_HELP = 9,
101 | TDN_EXPANDO_BUTTON_CLICKED = 10 // wParam = 0 (dialog is now collapsed), wParam != 0 (dialog is now expanded)
102 | }
103 |
104 | /// Messages that can be sent to Task Dialogs.
105 | /// From CommCtrl.h.
106 | public enum TaskDialogMessages : uint {
107 | TDM_NAVIGATE_PAGE = 0x0400 + 101,
108 | TDM_CLICK_BUTTON = 0x0400 + 102, // wParam = Button ID
109 | TDM_SET_MARQUEE_PROGRESS_BAR = 0x0400 + 103, // wParam = 0 (nonMarque) wParam != 0 (Marquee)
110 | TDM_SET_PROGRESS_BAR_STATE = 0x0400 + 104, // wParam = new progress state
111 | TDM_SET_PROGRESS_BAR_RANGE = 0x0400 + 105, // lParam = MAKELPARAM(nMinRange, nMaxRange)
112 | TDM_SET_PROGRESS_BAR_POS = 0x0400 + 106, // wParam = new position
113 | TDM_SET_PROGRESS_BAR_MARQUEE = 0x0400 + 107, // wParam = 0 (stop marquee), wParam != 0 (start marquee), lparam = speed (milliseconds between repaints)
114 | TDM_SET_ELEMENT_TEXT = 0x0400 + 108, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
115 | TDM_CLICK_RADIO_BUTTON = 0x0400 + 110, // wParam = Radio Button ID
116 | TDM_ENABLE_BUTTON = 0x0400 + 111, // lParam = 0 (disable), lParam != 0 (enable), wParam = Button ID
117 | TDM_ENABLE_RADIO_BUTTON = 0x0400 + 112, // lParam = 0 (disable), lParam != 0 (enable), wParam = Radio Button ID
118 | TDM_CLICK_VERIFICATION = 0x0400 + 113, // wParam = 0 (unchecked), 1 (checked), lParam = 1 (set key focus)
119 | TDM_UPDATE_ELEMENT_TEXT = 0x0400 + 114, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
120 | TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = 0x0400 + 115, // wParam = Button ID, lParam = 0 (elevation not required), lParam != 0 (elevation required)
121 | TDM_UPDATE_ICON = 0x0400 + 116 // wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise)
122 | }
123 | }
124 |
125 | }
126 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/TaskDialog/Results.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | namespace WindowsFormsAero.TaskDialog {
10 |
11 | ///
12 | /// Class that aggregates the results of a Task Dialog when closed.
13 | ///
14 | public class TaskDialogResult {
15 |
16 | internal TaskDialogResult(int buttonId, int radioId, bool selVerification) {
17 | ButtonID = buttonId;
18 | RadioID = radioId;
19 | IsVerificationChecked = selVerification;
20 | }
21 |
22 | ///
23 | /// Gets the ID of the clicked button.
24 | ///
25 | public int ButtonID { get; set; }
26 |
27 | ///
28 | /// Gets the ID of the checked radio control.
29 | ///
30 | public int RadioID { get; set; }
31 |
32 | ///
33 | /// Gets whether verification was checked.
34 | ///
35 | public bool IsVerificationChecked { get; set; }
36 |
37 | ///
38 | /// Gets the clicked common button, if any.
39 | ///
40 | ///
41 | /// Will return if no common button was
42 | /// clicked or if a custom button with an out of range ID was clicked.
43 | ///
44 | public CommonButtonResult CommonButton {
45 | get {
46 | if (ButtonID > 0 && ButtonID <= 8)
47 | return (CommonButtonResult)ButtonID;
48 | else
49 | return CommonButtonResult.None;
50 | }
51 | }
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/TaskDialog/TaskDialog_static.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 |
11 | namespace WindowsFormsAero.TaskDialog {
12 |
13 | // Static convenience methods
14 | public partial class TaskDialog {
15 |
16 | #region Static display methods
17 |
18 | /// Displays a task dialog that has a message.
19 | /// The text to display.
20 | public static CommonButtonResult Show(string instruction) {
21 | return InternalShow(IntPtr.Zero, string.Empty, instruction, null, CommonButton.OK, CommonIcon.None);
22 | }
23 |
24 | /// Displays a task dialog that has a message and a title.
25 | /// The text to display.
26 | /// The title bar caption of the dialog.
27 | public static CommonButtonResult Show(string instruction, string title) {
28 | return InternalShow(IntPtr.Zero, title, instruction, null, CommonButton.OK, CommonIcon.None);
29 | }
30 |
31 | /// Displays a task dialog that has a message, a title, and an instruction.
32 | /// The text to display.
33 | /// The title bar caption of the dialog.
34 | /// The instruction shown below the main text.
35 | public static CommonButtonResult Show(string instruction, string title, string content) {
36 | return InternalShow(IntPtr.Zero, title, instruction, content, CommonButton.OK, CommonIcon.None);
37 | }
38 |
39 | /// Displays a task dialog that has a message, a title, an instruction, and one or more buttons.
40 | /// The text to display.
41 | /// The title bar caption of the dialog.
42 | /// The instruction shown below the main text.
43 | /// Value that specifies which button or buttons to display.
44 | public static CommonButtonResult Show(string instruction, string title, string content, CommonButton buttons) {
45 | return InternalShow(IntPtr.Zero, title, instruction, content, buttons, CommonIcon.None);
46 | }
47 |
48 | /// Displays a task dialog that has a message, a title, an instruction, one or more buttons, and an icon.
49 | /// The text to display.
50 | /// The title bar caption of the dialog.
51 | /// The instruction shown below the main text.
52 | /// Value that specifies which button or buttons to display.
53 | /// The icon to display.
54 | public static CommonButtonResult Show(string instruction, string title, string content, CommonButton buttons, CommonIcon icon) {
55 | return InternalShow(IntPtr.Zero, title, instruction, content, buttons, icon);
56 | }
57 |
58 | private static CommonButtonResult InternalShow(IntPtr parent, string title, string instruction, string content, CommonButton commonButtons, CommonIcon icon) {
59 | int dlgValue;
60 |
61 | try {
62 | //Get handle for parent window if none specified (behave like MessageBox)
63 | if (parent == IntPtr.Zero)
64 | parent = Native.Methods.GetActiveWindow();
65 |
66 | if (NativeMethods.TaskDialog(parent, IntPtr.Zero, title, instruction, content, (int)commonButtons, new IntPtr((long)icon), out dlgValue) != 0)
67 | throw new Exception(string.Format(Resources.ExceptionMessages.NativeCallFailure, "TaskDialog"));
68 | }
69 | catch (EntryPointNotFoundException ex) {
70 | throw new Exception(Resources.ExceptionMessages.CommonControlEntryPointNotFound, ex);
71 | }
72 | catch (Exception ex) {
73 | throw new Exception(Resources.ExceptionMessages.TaskDialogFailure, ex);
74 | }
75 |
76 | //Convert int value to common dialog result
77 | if (dlgValue > 0 && dlgValue <= 8)
78 | return (CommonButtonResult)dlgValue;
79 | else
80 | return CommonButtonResult.None;
81 | }
82 |
83 | #endregion
84 |
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/TextBox.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Marco Minerva
7 | *****************************************************/
8 |
9 | using System;
10 | using System.ComponentModel;
11 | using System.Drawing;
12 | using WindowsFormsAero.Native;
13 |
14 | namespace WindowsFormsAero {
15 |
16 | [ToolboxBitmap(typeof(TextBox))]
17 | public class TextBox : System.Windows.Forms.TextBox {
18 |
19 | private string _cueBannerText = string.Empty;
20 |
21 | ///
22 | /// Gets or sets the cue text that is displayed on the TextBox control.
23 | ///
24 | [
25 | Description("Text that is displayed as Cue banner."),
26 | Category("Appearance"),
27 | DefaultValue("")
28 | ]
29 | public string CueBannerText {
30 | get {
31 | return _cueBannerText;
32 | }
33 | set {
34 | _cueBannerText = value;
35 | UpdateControl();
36 | }
37 | }
38 |
39 | /*
40 | [Browsable(false)]
41 | public new bool Multiline {
42 | get { return base.Multiline; }
43 | set { base.Multiline = false; }
44 | }
45 | */
46 | //TODO: check this
47 |
48 | private bool _showCueFocused = false;
49 |
50 | ///
51 | /// Gets or sets whether the Cue text should be displyed even
52 | /// when the control has keybord focus.
53 | ///
54 | ///
55 | /// If true, the Cue text will disappear as soon as the user starts typing.
56 | ///
57 | [
58 | Description("If true, the Cue text will be displayed even when the control has keyboard focus."),
59 | Category("Appearance"),
60 | DefaultValue(false)
61 | ]
62 | public bool ShowCueFocused {
63 | get {
64 | return _showCueFocused;
65 | }
66 | set {
67 | _showCueFocused = value;
68 | UpdateControl();
69 | }
70 | }
71 |
72 | private void UpdateControl() {
73 | if (IsHandleCreated) {
74 | Methods.SendMessage(Handle,
75 | (uint)WindowMessage.EM_SETCUEBANNER,
76 | (_showCueFocused) ? 1 : 0,
77 | _cueBannerText);
78 | }
79 | }
80 |
81 | protected override void OnHandleCreated(EventArgs e) {
82 | base.OnHandleCreated(e);
83 |
84 | UpdateControl();
85 | }
86 |
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/ThemedText.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 | using System.Drawing;
11 | using System.Runtime.InteropServices;
12 | using System.Windows.Forms;
13 | using System.Windows.Forms.VisualStyles;
14 | using WindowsFormsAero.Native;
15 |
16 | namespace WindowsFormsAero {
17 |
18 | ///
19 | /// Renders themed text.
20 | ///
21 | ///
22 | /// Needs major reworking to be exposed as a public class.
23 | ///
24 | internal class ThemedText : IDisposable {
25 |
26 | private static int _win32Black = ColorTranslator.ToWin32(Color.Black);
27 |
28 | private static VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Window.Caption.Active);
29 |
30 | public ThemedText() {
31 |
32 | }
33 |
34 | private bool _invalidated = true;
35 |
36 | private string _text = string.Empty;
37 |
38 | public string Text {
39 | get { return _text; }
40 | set {
41 | if (_text != value)
42 | _invalidated = true;
43 | _text = value;
44 | }
45 | }
46 |
47 | private Font _font = SystemFonts.CaptionFont;
48 |
49 | public Font Font {
50 | get { return _font; }
51 | set {
52 | if (_font != value)
53 | _invalidated = true;
54 | _font = value;
55 | }
56 | }
57 |
58 | private Padding _padding = Padding.Empty;
59 |
60 | public Padding Padding {
61 | get { return _padding; }
62 | set {
63 | if (_padding != value)
64 | _invalidated = true;
65 | _padding = value;
66 | }
67 | }
68 |
69 | private int _win32Color = ColorTranslator.ToWin32(Color.Black);
70 |
71 | public Color Color {
72 | get { return ColorTranslator.FromWin32(_win32Black); }
73 | set {
74 | _invalidated = true;
75 | _win32Color = ColorTranslator.ToWin32(value);
76 | }
77 | }
78 |
79 | private TextFormatFlags _formatFlags = TextFormatFlags.Default;
80 |
81 | public TextFormatFlags FormatFlags {
82 | get { return _formatFlags; }
83 | set {
84 | if (_formatFlags != value)
85 | _invalidated = true;
86 | _formatFlags = value;
87 | }
88 | }
89 |
90 | ///
91 | /// Default glow size.
92 | ///
93 | public const int DefaultGlowSize = 10;
94 |
95 | ///
96 | /// Glow size used commonly by Office 2007 in titles.
97 | ///
98 | public const int Word2007GlowSize = 15;
99 |
100 | private int _glowSize = DefaultGlowSize;
101 |
102 | public int GlowSize {
103 | get {
104 | return _glowSize;
105 | }
106 | set {
107 | if (_glowSize != value)
108 | _invalidated = true;
109 | _glowSize = value;
110 | }
111 | }
112 |
113 | private bool _glowEnabled = true;
114 |
115 | public bool GlowEnabled {
116 | get {
117 | return _glowEnabled;
118 | }
119 | set {
120 | if (_glowEnabled != value)
121 | _invalidated = true;
122 | _glowEnabled = value;
123 | }
124 | }
125 |
126 | #region IDisposable Members
127 |
128 | ~ThemedText() {
129 | Dispose();
130 | }
131 |
132 | public void Dispose() {
133 | if (_textHdc != IntPtr.Zero) {
134 | Methods.DeleteDC(_textHdc);
135 | _textHdc = IntPtr.Zero;
136 | }
137 |
138 | GC.SuppressFinalize(this);
139 | }
140 |
141 | #endregion
142 |
143 | public void Draw(Graphics g, System.Drawing.Point location, System.Drawing.Size size) {
144 | Draw(g, location.X, location.Y, size.Width, size.Height);
145 | }
146 |
147 | public void Draw(Graphics g, Rectangle rect) {
148 | Draw(g, rect.X, rect.Y, rect.Width, rect.Height);
149 | }
150 |
151 | public void Draw(Graphics g, int x, int y, int width, int height) {
152 | var outputHdc = g.GetHdc();
153 |
154 | var sourceHdc = PrepareHdc(outputHdc, width, height);
155 |
156 | Methods.BitBlt(outputHdc,
157 | x, y, width, height,
158 | sourceHdc, 0, 0,
159 | BitBltOp.SRCCOPY);
160 |
161 | g.ReleaseHdc(outputHdc);
162 |
163 | System.Diagnostics.Debug.WriteLine("ThemedText.Draw");
164 | }
165 |
166 | private IntPtr _textHdc = IntPtr.Zero;
167 | private IntPtr _dibSectionRef;
168 | private int _lastHdcWidth = -1;
169 | private int _lastHdcHeight = -1;
170 |
171 | ///
172 | /// Ensures that a valid source HDC exists and has been rendered to.
173 | ///
174 | private IntPtr PrepareHdc(IntPtr outputHdc, int width, int height) {
175 | if (width == _lastHdcWidth && height == _lastHdcHeight && !_invalidated)
176 | return _textHdc;
177 |
178 | _lastHdcWidth = width;
179 | _lastHdcHeight = height;
180 |
181 | if(_textHdc != IntPtr.Zero) {
182 | Methods.DeleteObject(_dibSectionRef);
183 | Methods.DeleteDC(_textHdc);
184 | }
185 | _textHdc = Methods.CreateCompatibleDC(outputHdc);
186 |
187 | // Create a DIB-Bitmap on which to draw
188 | var info = new BitmapInfo() {
189 | biSize = Marshal.SizeOf(typeof(BitmapInfo)),
190 | biWidth = width,
191 | biHeight = -height, // DIB use top-down ref system, thus we set negative height
192 | biPlanes = 1,
193 | biBitCount = 32,
194 | biCompression = 0
195 | };
196 | _dibSectionRef = Methods.CreateDIBSection(outputHdc, ref info, 0, 0, IntPtr.Zero, 0);
197 | Methods.SelectObject(_textHdc, _dibSectionRef);
198 |
199 | // Create the Font to use
200 | IntPtr hFont = Font.ToHfont();
201 | Methods.SelectObject(_textHdc, hFont);
202 |
203 | // Prepare options
204 | var dttOpts = new DttOpts {
205 | dwSize = Marshal.SizeOf(typeof(DttOpts)),
206 | dwFlags = DttOptsFlags.DTT_COMPOSITED | DttOptsFlags.DTT_TEXTCOLOR,
207 | crText = _win32Color
208 | };
209 | if(_glowEnabled) {
210 | dttOpts.dwFlags |= DttOptsFlags.DTT_GLOWSIZE;
211 | dttOpts.iGlowSize = _glowSize;
212 | }
213 |
214 | // Set full bounds with padding
215 | Rect paddedBounds = new Rect(
216 | _padding.Left, _padding.Top,
217 | width - _padding.Right, height - _padding.Bottom
218 | );
219 |
220 | // Draw
221 | int ret = Methods.DrawThemeTextEx(renderer.Handle, _textHdc, 0, 0,
222 | _text, -1,
223 | (int)_formatFlags, ref paddedBounds, ref dttOpts);
224 | if (ret != 0)
225 | Marshal.ThrowExceptionForHR(ret);
226 |
227 | // Clean up
228 | Methods.DeleteObject(hFont);
229 |
230 | return _textHdc;
231 | }
232 |
233 | }
234 |
235 | }
236 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/TreeView.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Marco Minerva
7 | *****************************************************/
8 |
9 | using System;
10 | using System.ComponentModel;
11 | using System.Drawing;
12 | using System.Windows.Forms;
13 | using WindowsFormsAero.Native;
14 |
15 | namespace WindowsFormsAero {
16 |
17 | [ToolboxBitmap(typeof(TreeView))]
18 | public class TreeView : System.Windows.Forms.TreeView {
19 |
20 | public TreeView() {
21 | base.HotTracking = true;
22 | base.ShowLines = false;
23 | }
24 |
25 | protected override CreateParams CreateParams {
26 | get {
27 | CreateParams cp = base.CreateParams;
28 | cp.Style |= (int)TreeViewStyle.TVS_NOHSCROLL;
29 | return cp;
30 | }
31 | }
32 |
33 | [Browsable(false)]
34 | private new bool HotTracking {
35 | get { return base.HotTracking; }
36 | set { }
37 | }
38 |
39 | [Browsable(false)]
40 | private new bool ShowLines {
41 | get { return base.ShowLines; }
42 | set { }
43 | }
44 |
45 | protected override void OnHandleCreated(EventArgs e) {
46 | base.OnHandleCreated(e);
47 |
48 | Methods.SetWindowTheme(Handle, "explorer", null);
49 |
50 | uint style = (uint)(Methods.SendMessage(Handle,
51 | (uint)WindowMessage.TVM_GETEXTENDEDSTYLE, 0, 0).ToInt64());
52 | style |= (uint)TreeViewExtendedStyle.TVS_EX_AUTOHSCROLL;
53 | style |= (uint)TreeViewExtendedStyle.TVS_EX_FADEINOUTEXPANDOS;
54 | style |= (uint)TreeViewExtendedStyle.TVS_EX_DOUBLEBUFFER;
55 | Methods.SendMessage(Handle, (uint)WindowMessage.TVM_SETEXTENDEDSTYLE, 0, style);
56 | }
57 |
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/VerticalPanel.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Blake Pell http://www.blakepell.com
7 | *****************************************************/
8 |
9 | using System;
10 | using System.ComponentModel;
11 | using System.Drawing;
12 | using System.Windows.Forms;
13 |
14 | namespace WindowsFormsAero {
15 |
16 | ///
17 | /// A vertical panel which resembles what is used for information and navigation
18 | /// in the Control Panel of Windows 7 and Vista.
19 | ///
20 | ///
21 | /// This control is meant to be used on the left hand side of a form, it creates
22 | /// a graphic border on the right hand side. Also I have VB code for this control
23 | /// if anyone needs it, just send me an e-mail at bpell@indiana.edu or
24 | /// blakepell@hotmail.com.
25 | ///
26 | [ToolboxBitmap(typeof(Panel))]
27 | public class VerticalPanel : Panel {
28 |
29 | ///
30 | /// Constructor.
31 | ///
32 | ///
33 | /// We are by default setting the background color to Color.Transparent.
34 | /// The reason for this is that a lot of controls that willbe used with this,
35 | /// namingly the Label and LinkLabel default their back color to the color of
36 | /// the panel and for those controls to display properly on this panel, thei
37 | /// BackColor will need to be Color.Transparent (otherwise, they'll display as
38 | /// a black box). This should help to isolate the developer from having to
39 | /// research this.
40 | /// To reduce flicker, especially when glass is enabled, I had to set all three
41 | /// of the below styles.
42 | ///
43 | public VerticalPanel() {
44 | this.BackColor = Color.Transparent;
45 | this.Font = new Font("Segoe UI", 9, FontStyle.Regular, GraphicsUnit.Point, 0);
46 | SetStyle(ControlStyles.UserPaint, true);
47 | SetStyle(ControlStyles.AllPaintingInWmPaint, true);
48 | SetStyle(ControlStyles.DoubleBuffer, true);
49 | this.UpdateStyles();
50 | }
51 |
52 | ///
53 | /// When a control is added, we will check the type and if it meets certain
54 | /// criteria will change some default behaviors of the control so that it fits
55 | /// our theme by default.
56 | /// The developer can still change this as they desire after it's added.
57 | ///
58 | protected override void OnControlAdded(ControlEventArgs e) {
59 | base.OnControlAdded(e);
60 |
61 | if (e.Control is LinkLabel) {
62 | e.Control.Font = new Font("Segoe UI", 9, FontStyle.Regular, GraphicsUnit.Point, 0);
63 | ((LinkLabel)e.Control).LinkBehavior = LinkBehavior.HoverUnderline;
64 | ((LinkLabel)e.Control).LinkColor = Color.FromArgb(64, 64, 64);
65 | ((LinkLabel)e.Control).ActiveLinkColor = Color.Blue;
66 | }
67 | }
68 |
69 | private static readonly Color aeroColor1 = Color.FromArgb(204, 217, 234);
70 | private static readonly Color aeroColor2 = Color.FromArgb(217, 227, 240);
71 | private static readonly Color aeroColor3 = Color.FromArgb(232, 238, 247);
72 | private static readonly Color aeroColor4 = Color.FromArgb(237, 242, 249);
73 | private static readonly Color aeroColor5 = Color.FromArgb(240, 244, 250);
74 | private static readonly Color aeroColor6 = Color.FromArgb(241, 245, 251);
75 |
76 | ///
77 | /// The actual painting of the background of our control.
78 | ///
79 | ///
80 | /// The colors in use here were extracted from an image of the Control Panel
81 | /// taken from a Windows 7 RC1 installation.
82 | ///
83 | protected override void OnPaint(PaintEventArgs e) {
84 | base.OnPaint(e);
85 |
86 | Rectangle rect = new Rectangle(this.Width - 1, 0, 1, this.Height);
87 | SolidBrush sb = new SolidBrush(aeroColor1);
88 | e.Graphics.FillRectangle(sb, rect);
89 | rect = new Rectangle(this.Width + 1, 0, 1, this.Height);
90 | sb.Color = aeroColor1;
91 | e.Graphics.FillRectangle(sb, rect);
92 | rect = new Rectangle(this.Width - 2, 0, 1, this.Height);
93 | sb.Color = aeroColor2;
94 | e.Graphics.FillRectangle(sb, rect);
95 | rect = new Rectangle(this.Width - 3, 0, 1, this.Height);
96 | sb.Color = aeroColor3;
97 | e.Graphics.FillRectangle(sb, rect);
98 | rect = new Rectangle(this.Width - 4, 0, 1, this.Height);
99 | sb.Color = aeroColor4;
100 | e.Graphics.FillRectangle(sb, rect);
101 | rect = new Rectangle(this.Width - 5, 0, 1, this.Height);
102 | sb.Color = aeroColor5;
103 | e.Graphics.FillRectangle(sb, rect);
104 | rect = new Rectangle(0, 0, this.Width - 5, this.Height);
105 | sb.Color = aeroColor6;
106 | e.Graphics.FillRectangle(sb, rect);
107 | sb.Dispose();
108 | }
109 |
110 | ///
111 | /// This procedure will redraw any control, given its handle, as an image
112 | /// on the form.
113 | /// This is necessary if you want to lay this control on top of the glass
114 | /// surface of an Aero form.
115 | ///
116 | public void RedrawControlAsBitmap(IntPtr hwnd) {
117 | Control c = Control.FromHandle(hwnd);
118 | using (Bitmap bm = new Bitmap(c.Width, c.Height)) {
119 | c.DrawToBitmap(bm, c.ClientRectangle);
120 | using (Graphics g = c.CreateGraphics()) {
121 | Point p = new Point(-1, -1);
122 | g.DrawImage(bm, p);
123 | }
124 | }
125 | c = null;
126 | }
127 |
128 | ///
129 | /// Handles incoming Windows Messages.
130 | ///
131 | ///
132 | /// On the paint event and if the RenderOnGlass is set to true, we will redraw
133 | /// the control as an image directly on the form.
134 | /// This has a little extra overhead but also provides the ability to lay this
135 | /// control directly on the glass and have it rendered correctly.
136 | ///
137 | protected override void WndProc(ref Message m) {
138 | base.WndProc(ref m);
139 | int WM_PAINT = 15;
140 | if ((m.Msg == WM_PAINT) && this.RenderOnGlass) {
141 | this.RedrawControlAsBitmap(this.Handle);
142 | }
143 | }
144 |
145 | private bool _renderOnGlass = false;
146 |
147 | ///
148 | /// Whether or not the control needs to be rendered on the Glass surface.
149 | ///
150 | ///
151 | /// This is false by default, it should only be toggled to true if the control
152 | /// needs to lay directly on the glass surface of the form.
153 | ///
154 | [Description("Gets or sets whether the control can render on an Aero glass surface."), Category("Appearance"), DefaultValue(false)]
155 | public bool RenderOnGlass {
156 | get {
157 | return this._renderOnGlass;
158 | }
159 | set {
160 | this._renderOnGlass = value;
161 | }
162 | }
163 |
164 | }
165 |
166 | }
167 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/VirtualDesktop.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using System.Threading.Tasks;
14 |
15 | namespace WindowsFormsAero {
16 |
17 | ///
18 | /// Represents a virtual desktop instance.
19 | ///
20 | public struct VirtualDesktop : IEquatable {
21 |
22 | internal VirtualDesktop(Guid id) {
23 | Id = id;
24 | }
25 |
26 | ///
27 | /// Gets the virtual desktop's ID.
28 | ///
29 | public Guid Id { get; }
30 |
31 | public override bool Equals(object obj) {
32 | if (obj is VirtualDesktop)
33 | return Equals(obj);
34 |
35 | return false;
36 | }
37 |
38 | public bool Equals(VirtualDesktop other) {
39 | return Id == other.Id;
40 | }
41 |
42 | public override int GetHashCode() {
43 | return Id.GetHashCode();
44 | }
45 |
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/VirtualDesktopManager.cs:
--------------------------------------------------------------------------------
1 | /*****************************************************
2 | * WindowsFormsAero
3 | * https://github.com/LorenzCK/WindowsFormsAero
4 | * http://windowsformsaero.codeplex.com
5 | *
6 | * Author: Lorenz Cuno Klopfenstein
7 | *****************************************************/
8 |
9 | using System;
10 | using System.Windows.Forms;
11 | using WindowsFormsAero.Native;
12 |
13 | namespace WindowsFormsAero {
14 |
15 | ///
16 | /// Exposes methods that enable an application to interact with groups of
17 | /// windows that form virtual workspaces.
18 | ///
19 | public static class VirtualDesktopManager {
20 |
21 | private static readonly Guid VirtualDesktopManagerTypeGuid = new Guid("aa509086-5ca9-4c25-8f95-589d3c07b48a");
22 |
23 | private static IVirtualDesktopManager _com;
24 |
25 | private static IVirtualDesktopManager Internal {
26 | get {
27 | if(_com == null) {
28 | var t = Type.GetTypeFromCLSID(VirtualDesktopManagerTypeGuid);
29 | _com = (IVirtualDesktopManager)Activator.CreateInstance(t);
30 | }
31 | return _com;
32 | }
33 | }
34 |
35 | ///
36 | /// Indicates whether the provided window is on the currently active virtual desktop.
37 | ///
38 | /// Top-level window handle.
39 | /// True if the provided window is on the currently active virtual desktop or if there is only one desktop.
40 | /// Always returns true on OSs that do not support virtual desktops.
41 | public static bool IsWindowOnCurrentVirtualDesktop(IntPtr topLevelHwnd) {
42 | if(!OsSupport.IsTenOrLater) {
43 | // Only one virtual desktop exists
44 | return true;
45 | }
46 |
47 | return Internal.IsWindowOnCurrentVirtualDesktop(topLevelHwnd);
48 | }
49 |
50 | ///
51 | /// Indicates whether the provided form is on the currently active virtual desktop.
52 | ///
53 | /// Top-level form.
54 | /// True if the provided window is on the currently active virtual desktop or if there is only one desktop.
55 | /// Always returns true on OSs that do not support virtual desktops.
56 | public static bool IsWindowOnCurrentVirtualDesktop(Form form) {
57 | return IsWindowOnCurrentVirtualDesktop(form.Handle);
58 | }
59 |
60 | ///
61 | /// Gets the handle for the virtual desktop hosting the provided top-level window.
62 | ///
63 | /// Top-level window handle.
64 | /// Virtual desktop handle hosting the provided top-level window.
65 | /// Returns default virtual desktop handle on OSs that do not support virtual desktops.
66 | public static VirtualDesktop GetWindowDesktopId(IntPtr topLevelHwnd) {
67 | if (!OsSupport.IsTenOrLater) {
68 | // Default to virtual desktop with empty ID
69 | return new VirtualDesktop(Guid.Empty);
70 | }
71 |
72 | return new VirtualDesktop(Internal.GetWindowDesktopId(topLevelHwnd));
73 | }
74 |
75 | ///
76 | /// Gets the handle for the virtual desktop hosting the provided top-level form.
77 | ///
78 | /// Top-level form.
79 | /// Virtual desktop handle hosting the provided top-level window.
80 | /// Returns default virtual desktop handle on OSs that do not support virtual desktops.
81 | public static VirtualDesktop GetWindowDesktopId(Form form) {
82 | return GetWindowDesktopId(form.Handle);
83 | }
84 |
85 | ///
86 | /// Moves a window to the specified virtual desktop.
87 | ///
88 | /// Top-level window handle.
89 | /// Target virtual desktop handle.
90 | /// Is ignored on OSs that do not support virtual desktops.
91 | public static void MoveWindowToDesktop(IntPtr topLevelHwnd, VirtualDesktop target) {
92 | if(!OsSupport.IsTenOrLater) {
93 | return;
94 | }
95 |
96 | var id = target.Id;
97 | Internal.MoveWindowToDesktop(topLevelHwnd, ref id);
98 | }
99 |
100 | ///
101 | /// Moves a form to the specified virtual desktop.
102 | ///
103 | /// Top-level form.
104 | /// Target virtual desktop handle.
105 | /// Is ignored on OSs that do not support virtual desktops.
106 | public static void MoveWindowToDesktop(Form form, VirtualDesktop target) {
107 | MoveWindowToDesktop(form.Handle, target);
108 | }
109 |
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/src/WindowsFormsAero/WindowsFormsAero.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LorenzCK/WindowsFormsAero/14c921f21939c4f535617e66ffc1ace4b0173e44/src/WindowsFormsAero/WindowsFormsAero.snk
--------------------------------------------------------------------------------
/src/WindowsFormsAeroShowcase/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/WindowsFormsAeroShowcase/HorizontalPanelExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WindowsFormsAeroShowcase {
4 |
5 | public partial class HorizontalPanelExample : WindowsFormsAero.AeroForm {
6 |
7 | public HorizontalPanelExample() {
8 | InitializeComponent();
9 | }
10 |
11 | private void HorizontalPanelExample_Load(object sender, EventArgs e) {
12 | label4.Text = Environment.MachineName.ToString();
13 | label5.Text = "3.00 GB";
14 | label6.Text = "Intel(R) Pentium(R) 4 CPU 3.40 Ghz (Quad Core)";
15 | }
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/WindowsFormsAeroShowcase/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace WindowsFormsAeroShowcase {
5 |
6 | internal static class Program {
7 |
8 | ///
9 | /// The main entry point for the application.
10 | ///
11 | [STAThread]
12 | private static void Main() {
13 | Application.EnableVisualStyles();
14 | Application.SetCompatibleTextRenderingDefault(false);
15 |
16 | //Compatibility check
17 | if (!WindowsFormsAero.OsSupport.IsVistaOrLater)
18 | if (MessageBox.Show("It appears you are not running on Windows Vista (or later). The controls and dialogs implemented in this application might not work or crash.\n\nDo you want to continue?", "Windows Vista or later required", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.No)
19 | return;
20 |
21 | Application.Run(new Main());
22 | }
23 |
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/WindowsFormsAeroShowcase/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("WindowsFormsAeroShowcase")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("WindowsFormsAeroShowcase")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
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("fc842dd0-6736-46a5-8d00-28cafd33312f")]
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 |
--------------------------------------------------------------------------------
/src/WindowsFormsAeroShowcase/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 WindowsFormsAeroShowcase.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", "4.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("WindowsFormsAeroShowcase.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 |
--------------------------------------------------------------------------------
/src/WindowsFormsAeroShowcase/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 |
--------------------------------------------------------------------------------
/src/WindowsFormsAeroShowcase/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 WindowsFormsAeroShowcase.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.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 |
--------------------------------------------------------------------------------
/src/WindowsFormsAeroShowcase/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/WindowsFormsAeroShowcase/ThumbnailedWindow.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsFormsAeroShowcase {
2 | partial class ThumbnailedWindow {
3 | ///
4 | /// Required designer variable.
5 | ///
6 | private System.ComponentModel.IContainer components = null;
7 |
8 | ///
9 | /// Clean up any resources being used.
10 | ///
11 | /// true if managed resources should be disposed; otherwise, false.
12 | protected override void Dispose(bool disposing) {
13 | if (disposing && (components != null)) {
14 | components.Dispose();
15 | }
16 | base.Dispose(disposing);
17 | }
18 |
19 | #region Windows Form Designer generated code
20 |
21 | ///
22 | /// Required method for Designer support - do not modify
23 | /// the contents of this method with the code editor.
24 | ///
25 | private void InitializeComponent() {
26 | this.SuspendLayout();
27 | //
28 | // ThumbnailedWindow
29 | //
30 | this.AutoScaleDimensions = new System.Drawing.SizeF(144F, 144F);
31 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
32 | this.ClientSize = new System.Drawing.Size(373, 238);
33 | this.ControlBox = false;
34 | this.DoubleBuffered = true;
35 | this.Name = "ThumbnailedWindow";
36 | this.ShowInTaskbar = false;
37 | this.Text = "Thumbnailed Window (resize me!)";
38 | this.ResumeLayout(false);
39 |
40 | }
41 |
42 | #endregion
43 |
44 | }
45 | }
--------------------------------------------------------------------------------
/src/WindowsFormsAeroShowcase/ThumbnailedWindow.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Drawing;
4 | using System.Windows.Forms;
5 |
6 | namespace WindowsFormsAeroShowcase {
7 |
8 | public partial class ThumbnailedWindow : Form {
9 |
10 | private Timer timer = new Timer();
11 |
12 | public ThumbnailedWindow() {
13 | InitializeComponent();
14 |
15 | timer.Interval = 500;
16 | timer.Tick += new EventHandler(timer_Tick);
17 | timer.Start();
18 |
19 | Font = new Font(Font.FontFamily, 20.0f, FontStyle.Bold);
20 | }
21 |
22 | private bool resizing = false;
23 |
24 | protected override void OnResizeBegin(EventArgs e) {
25 | timer.Stop();
26 | resizing = true;
27 | base.OnResizeBegin(e);
28 | }
29 |
30 | protected override void OnResizeEnd(EventArgs e) {
31 | timer.Start();
32 | resizing = false;
33 | this.Invalidate();
34 | base.OnResizeEnd(e);
35 | }
36 |
37 | private void timer_Tick(object sender, EventArgs e) {
38 | this.Invalidate();
39 | }
40 |
41 | private Color[] colors = new Color[] {
42 | Color.Red,
43 | Color.Blue,
44 | Color.Green,
45 | Color.DarkRed,
46 | Color.DarkBlue,
47 | Color.DarkGreen,
48 | Color.Snow,
49 | Color.CornflowerBlue,
50 | Color.Sienna,
51 | Color.Salmon
52 | };
53 |
54 | private Random rnd = new Random(DateTime.Now.GetHashCode());
55 |
56 | private Color GetColor() {
57 | return colors[rnd.Next() % colors.Length];
58 | }
59 |
60 | private Color lastBackground;
61 | protected override void OnPaint(PaintEventArgs e) {
62 | if (resizing) {
63 | e.Graphics.Clear(lastBackground);
64 | return;
65 | }
66 |
67 | lastBackground = GetColor();
68 | e.Graphics.Clear(lastBackground);
69 |
70 | for (int i = 0; i < 7; ++i) {
71 | DrawEllipse(e.Graphics);
72 | }
73 |
74 | e.Graphics.DrawString("WindowsFormsAero", Font, new SolidBrush(GetColor()), GetPos(), GetPos());
75 |
76 | base.OnPaint(e);
77 | }
78 |
79 | private void DrawEllipse(Graphics graphics) {
80 | float x = GetPos();
81 | float y = GetPos();
82 | float size = (float)(rnd.NextDouble() * ClientSize.Width / 2);
83 |
84 | graphics.FillEllipse(new SolidBrush(GetColor()), x, y, size, size);
85 | }
86 |
87 | private float GetPos() {
88 | return (float)((rnd.NextDouble() - 0.20) * Math.Max(ClientSize.Width, ClientSize.Height));
89 | }
90 |
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/src/WindowsFormsAeroShowcase/ThumbnailedWindow.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 |
--------------------------------------------------------------------------------
/src/WindowsFormsAeroShowcase/VerticalPanelExample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace WindowsFormsAeroShowcase {
5 |
6 | public partial class ControlPanel : WindowsFormsAero.AeroForm {
7 |
8 | public ControlPanel() {
9 | InitializeComponent();
10 | }
11 |
12 | private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
13 | this.Close();
14 | }
15 |
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/WindowsFormsAeroShowcase/VerticalPanelExample.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 |
--------------------------------------------------------------------------------
/src/WindowsFormsAeroShowcase/WindowsFormsAeroShowcase.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {FC842DD0-6736-46A5-8D00-28CAFD33312F}
8 | WinExe
9 | Properties
10 | WindowsFormsAeroShowcase
11 | WindowsFormsAeroShowcase
12 | v4.6.1
13 | 512
14 | true
15 |
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 | false
27 |
28 |
29 | AnyCPU
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 | true
39 | bin\x86\Debug\
40 | DEBUG;TRACE
41 | full
42 | x86
43 | prompt
44 | MinimumRecommendedRules.ruleset
45 | true
46 |
47 |
48 | bin\x86\Release\
49 | TRACE
50 | true
51 | pdbonly
52 | x86
53 | prompt
54 | MinimumRecommendedRules.ruleset
55 | true
56 |
57 |
58 | WindowsFormsAeroShowcase.exe.manifest
59 |
60 |
61 | true
62 | bin\x64\Debug\
63 | DEBUG;TRACE
64 | full
65 | x64
66 | false
67 | prompt
68 | MinimumRecommendedRules.ruleset
69 | true
70 |
71 |
72 | bin\x64\Release\
73 | TRACE
74 | true
75 | pdbonly
76 | x64
77 | prompt
78 | MinimumRecommendedRules.ruleset
79 | true
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | Form
97 |
98 |
99 | VerticalPanelExample.cs
100 |
101 |
102 | Form
103 |
104 |
105 | HorizontalPanelExample.cs
106 |
107 |
108 | Form
109 |
110 |
111 | Main.cs
112 |
113 |
114 |
115 |
116 | VerticalPanelExample.cs
117 |
118 |
119 | HorizontalPanelExample.cs
120 |
121 |
122 | Main.cs
123 | Designer
124 |
125 |
126 | ResXFileCodeGenerator
127 | Resources.Designer.cs
128 | Designer
129 |
130 |
131 | ThumbnailedWindow.cs
132 | Designer
133 |
134 |
135 | True
136 | Resources.resx
137 | True
138 |
139 |
140 | SettingsSingleFileGenerator
141 | Settings.Designer.cs
142 |
143 |
144 |
145 | True
146 | Settings.settings
147 | True
148 |
149 |
150 | Form
151 |
152 |
153 | ThumbnailedWindow.cs
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 | {844f1de5-17ea-4e69-a7c5-b803ad3bd5d9}
162 | WindowsFormsAero
163 |
164 |
165 |
166 |
173 |
--------------------------------------------------------------------------------
/src/WindowsFormsAeroShowcase/WindowsFormsAeroShowcase.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | true
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------