├── .gitattributes
├── .gitignore
├── AutoCloseNotTaskDialog
├── AutoCloseNotTaskDialog.csproj
├── Classes
│ └── SpecialNumericUpDown.cs
├── Extensions
│ └── GenericExtensions.cs
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── Program.cs
└── readme.md
├── DesktopHelperLibrary
├── Classes
│ └── Dialogs.cs
├── DesktopHelperLibrary.csproj
├── Properties
│ ├── Resources.Designer.cs
│ └── Resources.resx
└── Resources
│ ├── Explaination.ico
│ ├── QuestionBlue.ico
│ └── question32.ico
├── Libraries
├── AutoClosingMessageBox.deps.json
└── AutoClosingMessageBox.dll
├── TaskDialogAutoCloseApp
├── Classes
│ └── WinDialogs.cs
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── Program.cs
├── Properties
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Resources
│ └── Timer_16x.ico
├── TaskDialogAutoCloseApp.csproj
├── assets
│ └── screenshot.png
└── readme.md
├── TaskDialogSolution_csharp.sln
├── WinFormsExamples
├── Classes
│ ├── ImageHelper.cs
│ ├── ResourceImages.cs
│ ├── ResourceItem.cs
│ ├── SpecialNumericUpDown.cs
│ └── WindowsDialogs.cs
├── Extensions
│ └── Extensions.cs
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── Program.cs
├── Properties
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── Resources
│ ├── ASX_Link_blue_16x.png
│ ├── About.ico
│ ├── Chat.ico
│ ├── ConfigurationFile_16x.ico
│ ├── Csharp.ico
│ ├── DatabaseMethod.ico
│ ├── Excel.ico
│ ├── NuGet.ico
│ ├── QuestionBlue.ico
│ ├── SQL_16x.ico
│ ├── ShowDetails_16x.png
│ ├── SplashScreen_16x.png
│ ├── Timer_16x.ico
│ ├── WindowsForm_16x.ico
│ ├── agent1.ico
│ ├── csharp_sql.ico
│ ├── error.ico
│ ├── error.png
│ ├── error1.ico
│ ├── git1.ico
│ ├── ps.ico
│ ├── tree.ico
│ └── tree.png
├── WinFormsExamples.csproj
├── appsettings.json
├── csharp1.ico
└── readme.md
├── WinFormsExamples1
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── Program.cs
└── WinFormsExamples1.csproj
├── WindowsFormsLibrary
├── Classes
│ ├── ApplicationSettings.cs
│ ├── CenterWinDialog.cs
│ ├── Dialogs.cs
│ ├── MachineComputerInformation.cs
│ ├── NoShowResult.cs
│ ├── PowerShellOperations.cs
│ ├── SettingOperations.cs
│ ├── ShowAgainOptions.cs
│ ├── StopWatcher.cs
│ └── Win32Window.cs
├── LanguageExtensions
│ ├── Extensions.cs
│ └── VisualStudioVersion.cs
├── Properties
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── Resources
│ ├── Explaination.ico
│ ├── QuestionBlue.ico
│ ├── error.ico
│ ├── error1.ico
│ ├── question32.ico
│ ├── visualstudio32.ico
│ └── visualstudio32.png
├── WindowsFormsLibrary.csproj
├── assets
│ ├── Versions.png
│ └── core_csharp_shield.png
└── readme.md
├── WpfExamples
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── Classes
│ ├── FocusBehavior.cs
│ └── ImageHelpers.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Properties
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── Resources
│ ├── Database_16x.ico
│ ├── agent1.ico
│ └── sql_server.ico
├── WpfExamples.csproj
├── app.manifest
├── appsettings.json
├── assets
│ ├── auttClose.png
│ ├── information.png
│ ├── mainWindow.png
│ ├── question1.png
│ └── questionComplex.png
├── csharp.png
└── readme.md
├── assets
├── DialogsMethods.png
├── Event_16x.png
├── Example1.png
├── Example10.png
├── Example11.png
├── Example12.png
├── Example13.png
├── Example14.png
├── Example15.png
├── Example16.png
├── Example2.png
├── Example3.png
├── Example4.png
├── Example5.png
├── Example6.png
├── Example7.png
├── Example8.png
├── Example9.png
├── Reference.png
├── ShowAgain.png
├── coffee.png
├── dataOperations.png
├── q1.png
├── radio.png
├── title.png
└── title.snag
├── readme.md
└── stash.txt
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Oo]ut/
33 | [Ll]og/
34 | [Ll]ogs/
35 |
36 | # Visual Studio 2015/2017 cache/options directory
37 | .vs/
38 | # Uncomment if you have tasks that create the project's static files in wwwroot
39 | #wwwroot/
40 |
41 | # Visual Studio 2017 auto generated files
42 | Generated\ Files/
43 |
44 | # MSTest test Results
45 | [Tt]est[Rr]esult*/
46 | [Bb]uild[Ll]og.*
47 |
48 | # NUnit
49 | *.VisualState.xml
50 | TestResult.xml
51 | nunit-*.xml
52 |
53 | # Build Results of an ATL Project
54 | [Dd]ebugPS/
55 | [Rr]eleasePS/
56 | dlldata.c
57 |
58 | # Benchmark Results
59 | BenchmarkDotNet.Artifacts/
60 |
61 | # .NET Core
62 | project.lock.json
63 | project.fragment.lock.json
64 | artifacts/
65 |
66 | # ASP.NET Scaffolding
67 | ScaffoldingReadMe.txt
68 |
69 | # StyleCop
70 | StyleCopReport.xml
71 |
72 | # Files built by Visual Studio
73 | *_i.c
74 | *_p.c
75 | *_h.h
76 | *.ilk
77 | *.meta
78 | *.obj
79 | *.iobj
80 | *.pch
81 | *.pdb
82 | *.ipdb
83 | *.pgc
84 | *.pgd
85 | *.rsp
86 | *.sbr
87 | *.tlb
88 | *.tli
89 | *.tlh
90 | *.tmp
91 | *.tmp_proj
92 | *_wpftmp.csproj
93 | *.log
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Microsoft Azure Build Output
210 | csx/
211 | *.build.csdef
212 |
213 | # Microsoft Azure Emulator
214 | ecf/
215 | rcf/
216 |
217 | # Windows Store app package directories and files
218 | AppPackages/
219 | BundleArtifacts/
220 | Package.StoreAssociation.xml
221 | _pkginfo.txt
222 | *.appx
223 | *.appxbundle
224 | *.appxupload
225 |
226 | # Visual Studio cache files
227 | # files ending in .cache can be ignored
228 | *.[Cc]ache
229 | # but keep track of directories ending in .cache
230 | !?*.[Cc]ache/
231 |
232 | # Others
233 | ClientBin/
234 | ~$*
235 | *~
236 | *.dbmdl
237 | *.dbproj.schemaview
238 | *.jfm
239 | *.pfx
240 | *.publishsettings
241 | orleans.codegen.cs
242 |
243 | # Including strong name files can present a security risk
244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
245 | #*.snk
246 |
247 | # Since there are multiple workflows, uncomment next line to ignore bower_components
248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
249 | #bower_components/
250 |
251 | # RIA/Silverlight projects
252 | Generated_Code/
253 |
254 | # Backup & report files from converting an old project file
255 | # to a newer Visual Studio version. Backup files are not needed,
256 | # because we have git ;-)
257 | _UpgradeReport_Files/
258 | Backup*/
259 | UpgradeLog*.XML
260 | UpgradeLog*.htm
261 | ServiceFabricBackup/
262 | *.rptproj.bak
263 |
264 | # SQL Server files
265 | *.mdf
266 | *.ldf
267 | *.ndf
268 |
269 | # Business Intelligence projects
270 | *.rdl.data
271 | *.bim.layout
272 | *.bim_*.settings
273 | *.rptproj.rsuser
274 | *- [Bb]ackup.rdl
275 | *- [Bb]ackup ([0-9]).rdl
276 | *- [Bb]ackup ([0-9][0-9]).rdl
277 |
278 | # Microsoft Fakes
279 | FakesAssemblies/
280 |
281 | # GhostDoc plugin setting file
282 | *.GhostDoc.xml
283 |
284 | # Node.js Tools for Visual Studio
285 | .ntvs_analysis.dat
286 | node_modules/
287 |
288 | # Visual Studio 6 build log
289 | *.plg
290 |
291 | # Visual Studio 6 workspace options file
292 | *.opt
293 |
294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
295 | *.vbw
296 |
297 | # Visual Studio LightSwitch build output
298 | **/*.HTMLClient/GeneratedArtifacts
299 | **/*.DesktopClient/GeneratedArtifacts
300 | **/*.DesktopClient/ModelManifest.xml
301 | **/*.Server/GeneratedArtifacts
302 | **/*.Server/ModelManifest.xml
303 | _Pvt_Extensions
304 |
305 | # Paket dependency manager
306 | .paket/paket.exe
307 | paket-files/
308 |
309 | # FAKE - F# Make
310 | .fake/
311 |
312 | # CodeRush personal settings
313 | .cr/personal
314 |
315 | # Python Tools for Visual Studio (PTVS)
316 | __pycache__/
317 | *.pyc
318 |
319 | # Cake - Uncomment if you are using it
320 | # tools/**
321 | # !tools/packages.config
322 |
323 | # Tabs Studio
324 | *.tss
325 |
326 | # Telerik's JustMock configuration file
327 | *.jmconfig
328 |
329 | # BizTalk build output
330 | *.btp.cs
331 | *.btm.cs
332 | *.odx.cs
333 | *.xsd.cs
334 |
335 | # OpenCover UI analysis results
336 | OpenCover/
337 |
338 | # Azure Stream Analytics local run output
339 | ASALocalRun/
340 |
341 | # MSBuild Binary and Structured Log
342 | *.binlog
343 |
344 | # NVidia Nsight GPU debugger configuration file
345 | *.nvuser
346 |
347 | # MFractors (Xamarin productivity tool) working folder
348 | .mfractor/
349 |
350 | # Local History for Visual Studio
351 | .localhistory/
352 |
353 | # BeatPulse healthcheck temp database
354 | healthchecksdb
355 |
356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
357 | MigrationBackup/
358 |
359 | # Ionide (cross platform F# VS Code tools) working folder
360 | .ionide/
361 |
362 | # Fody - auto-generated XML schema
363 | FodyWeavers.xsd
--------------------------------------------------------------------------------
/AutoCloseNotTaskDialog/AutoCloseNotTaskDialog.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 | WinExe
11 | net8.0-windows
12 | enable
13 | true
14 | enable
15 |
16 |
17 |
18 | ..\Libraries\AutoClosingMessageBox.dll
19 |
20 |
21 |
22 |
23 |
24 | Component
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/AutoCloseNotTaskDialog/Classes/SpecialNumericUpDown.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Windows.Forms;
4 |
5 | namespace AutoCloseNotTaskDialog.Classes
6 | {
7 | ///
8 | /// Custom without spinner and a property to obtain value as an int
9 | ///
10 | public class SpecialNumericUpDown : NumericUpDown
11 | {
12 |
13 | public SpecialNumericUpDown()
14 | {
15 | Controls[0].Hide();
16 | TextAlign = HorizontalAlignment.Right;
17 | }
18 | protected override void OnTextBoxResize(object source, EventArgs e)
19 | {
20 | Controls[1].Width = Width - 4;
21 | }
22 |
23 | ///
24 | /// Return Value as an int
25 | ///
26 | [Browsable(false)] public int AsInteger => (int)Value;
27 | [Browsable(false)] public int Seconds => AsInteger * 1000;
28 |
29 | public delegate void TriggerDelegate();
30 |
31 | public event TriggerDelegate TriggerEvent;
32 | protected override void OnKeyDown(KeyEventArgs e)
33 | {
34 | if (e.KeyCode == (Keys.Return))
35 | {
36 | e.Handled = true;
37 | e.SuppressKeyPress = true;
38 |
39 | TriggerEvent?.Invoke();
40 |
41 | return;
42 | }
43 |
44 | base.OnKeyDown(e);
45 | }
46 |
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/AutoCloseNotTaskDialog/Extensions/GenericExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace AutoCloseNotTaskDialog.Extensions
6 | {
7 | public static class GenericExtensions
8 | {
9 | public static bool IsNull(this object sender)
10 | {
11 | return sender == null || sender == DBNull.Value || Convert.IsDBNull(sender) == true;
12 | }
13 |
14 | ///
15 | /// Is the instance of a class null
16 | ///
17 | /// Concrete class type
18 | /// Instance of concrete class
19 | /// True if null, false if not null
20 | public static bool IsNull(this T senderInstance) where T : new() => senderInstance is null;
21 |
22 | ///
23 | /// Is the instance of a class not null
24 | ///
25 | /// Concrete class type
26 | /// Instance of concrete class
27 | /// True if not null, false if null
28 | public static bool IsNotNull(this T senderInstance) where T : new() => !senderInstance.IsNull();
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/AutoCloseNotTaskDialog/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace AutoCloseNotTaskDialog
3 | {
4 | partial class Form1
5 | {
6 | ///
7 | /// Required designer variable.
8 | ///
9 | private System.ComponentModel.IContainer components = null;
10 |
11 | ///
12 | /// Clean up any resources being used.
13 | ///
14 | /// true if managed resources should be disposed; otherwise, false.
15 | protected override void Dispose(bool disposing)
16 | {
17 | if (disposing && (components != null))
18 | {
19 | components.Dispose();
20 | }
21 | base.Dispose(disposing);
22 | }
23 |
24 | #region Windows Form Designer generated code
25 |
26 | ///
27 | /// Required method for Designer support - do not modify
28 | /// the contents of this method with the code editor.
29 | ///
30 | private void InitializeComponent()
31 | {
32 | this.SecondsUpDown = new AutoCloseNotTaskDialog.Classes.SpecialNumericUpDown();
33 | this.AutoCloseButton = new System.Windows.Forms.Button();
34 | this.label1 = new System.Windows.Forms.Label();
35 | ((System.ComponentModel.ISupportInitialize)(this.SecondsUpDown)).BeginInit();
36 | this.SuspendLayout();
37 | //
38 | // SecondsUpDown
39 | //
40 | this.SecondsUpDown.Location = new System.Drawing.Point(163, 14);
41 | this.SecondsUpDown.Name = "SecondsUpDown";
42 | this.SecondsUpDown.Size = new System.Drawing.Size(67, 23);
43 | this.SecondsUpDown.TabIndex = 0;
44 | this.SecondsUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
45 | this.SecondsUpDown.Value = new decimal(new int[] {
46 | 5,
47 | 0,
48 | 0,
49 | 0});
50 | //
51 | // AutoCloseButton
52 | //
53 | this.AutoCloseButton.Location = new System.Drawing.Point(12, 14);
54 | this.AutoCloseButton.Name = "AutoCloseButton";
55 | this.AutoCloseButton.Size = new System.Drawing.Size(145, 23);
56 | this.AutoCloseButton.TabIndex = 1;
57 | this.AutoCloseButton.Text = "Auto-close";
58 | this.AutoCloseButton.UseVisualStyleBackColor = true;
59 | this.AutoCloseButton.Click += new System.EventHandler(this.AutoCloseButton_Click);
60 | //
61 | // label1
62 | //
63 | this.label1.AutoSize = true;
64 | this.label1.Location = new System.Drawing.Point(236, 18);
65 | this.label1.Name = "label1";
66 | this.label1.Size = new System.Drawing.Size(82, 15);
67 | this.label1.TabIndex = 2;
68 | this.label1.Text = "Seconds delay";
69 | //
70 | // Form1
71 | //
72 | this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
73 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
74 | this.ClientSize = new System.Drawing.Size(428, 146);
75 | this.Controls.Add(this.label1);
76 | this.Controls.Add(this.AutoCloseButton);
77 | this.Controls.Add(this.SecondsUpDown);
78 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
79 | this.Name = "Form1";
80 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
81 | this.Text = "Auto-Close code sample";
82 | ((System.ComponentModel.ISupportInitialize)(this.SecondsUpDown)).EndInit();
83 | this.ResumeLayout(false);
84 | this.PerformLayout();
85 |
86 | }
87 |
88 | #endregion
89 |
90 | private Classes.SpecialNumericUpDown SecondsUpDown;
91 | private System.Windows.Forms.Button AutoCloseButton;
92 | private System.Windows.Forms.Label label1;
93 | }
94 | }
95 |
96 |
--------------------------------------------------------------------------------
/AutoCloseNotTaskDialog/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Diagnostics;
6 | using System.Drawing;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows.Forms;
11 |
12 | namespace AutoCloseNotTaskDialog
13 | {
14 | public partial class Form1 : Form
15 | {
16 | public Form1()
17 | {
18 | InitializeComponent();
19 | }
20 |
21 | private void AutoCloseButton_Click(object sender, EventArgs e)
22 | {
23 | AutoClosingMessageBox.Show(text: "Chunking completed", caption: "Information", timeout: SecondsUpDown.Seconds);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/AutoCloseNotTaskDialog/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
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 |
48 |
49 | text/microsoft-resx
50 |
51 |
52 | 2.0
53 |
54 |
55 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
56 |
57 |
58 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
59 |
60 |
--------------------------------------------------------------------------------
/AutoCloseNotTaskDialog/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace AutoCloseNotTaskDialog
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.SetHighDpiMode(HighDpiMode.SystemAware);
18 | Application.EnableVisualStyles();
19 | Application.SetCompatibleTextRenderingDefault(false);
20 | Application.Run(new Form1());
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/AutoCloseNotTaskDialog/readme.md:
--------------------------------------------------------------------------------
1 | # About
2 |
3 | This project shows how to use a MessageBox wrapped in a class from the following [repository](https://github.com/DmitryGaravsky/AutoClosingMessageBox) available in the following [NuGet package](https://www.nuget.org/packages/AutoClosingMessageBox/).
4 |
5 | The package will not work for .NET Core, only Framework 4.8 and lower.
6 |
7 | The author provides various solutions e.g. Net3.5, Net5 for Windows and Net 5 for WPF.
8 |
9 | The version used here was compiled with Net5, placed in Libraries folder off the root of this solution.
10 |
--------------------------------------------------------------------------------
/DesktopHelperLibrary/Classes/Dialogs.cs:
--------------------------------------------------------------------------------
1 |
2 | using System.Windows.Forms;
3 |
4 | namespace DesktopHelperLibrary.Classes
5 | {
6 | public class Dialogs
7 | {
8 | ///
9 | /// Dialog to ask a question
10 | ///
11 | /// text for dialog caption
12 | /// text for dialog heading
13 | /// text for yes button
14 | /// text for no button
15 | /// specifies the default button for this dialog
16 | /// true for yes button, false for no button
17 | public static bool Question(string caption, string heading, string yesText, string noText, DialogResult defaultButton)
18 | {
19 |
20 | TaskDialogButton yesButton = new(yesText) { Tag = DialogResult.Yes };
21 | TaskDialogButton noButton = new(noText) { Tag = DialogResult.No };
22 |
23 | TaskDialogButtonCollection buttons = new();
24 |
25 | if (defaultButton == DialogResult.Yes)
26 | {
27 | buttons.Add(yesButton);
28 | buttons.Add(noButton);
29 | }
30 | else
31 | {
32 | buttons.Add(noButton);
33 | buttons.Add(yesButton);
34 | }
35 |
36 | TaskDialogPage page = new()
37 | {
38 | Caption = caption,
39 | SizeToContent = true,
40 | Heading = heading,
41 | Icon = TaskDialogIcon.Information,
42 | Buttons = buttons
43 | };
44 |
45 |
46 | TaskDialogButton result = TaskDialog.ShowDialog(page);
47 |
48 | return (DialogResult)result.Tag! == DialogResult.Yes;
49 |
50 | }
51 |
52 | ///
53 | /// Dialog to ask a question
54 | ///
55 | /// control or form
56 | /// text for dialog caption
57 | /// text for dialog heading
58 | /// text for yes button
59 | /// text for no button
60 | /// specifies the default button for this dialog
61 | /// true for yes button, false for no button
62 | ///
63 | /// With a user defined icon from project resources
64 | ///
65 | public static bool Question(Control owner, string caption, string heading, string yesText, string noText, DialogResult defaultButton)
66 | {
67 |
68 | TaskDialogButton yesButton = new(yesText) { Tag = DialogResult.Yes };
69 | TaskDialogButton noButton = new(noText) { Tag = DialogResult.No };
70 |
71 | var buttons = new TaskDialogButtonCollection();
72 |
73 | if (defaultButton == DialogResult.Yes)
74 | {
75 | buttons.Add(yesButton);
76 | buttons.Add(noButton);
77 | }
78 | else
79 | {
80 | buttons.Add(noButton);
81 | buttons.Add(yesButton);
82 | }
83 |
84 |
85 | TaskDialogPage page = new()
86 | {
87 | Caption = caption,
88 | SizeToContent = true,
89 | Heading = heading,
90 | Icon = new TaskDialogIcon(Properties.Resources.QuestionBlue),
91 | Buttons = buttons
92 | };
93 |
94 | var result = TaskDialog.ShowDialog(owner, page);
95 |
96 | return (DialogResult)result.Tag! == DialogResult.Yes;
97 |
98 | }
99 | public static void QuestionWithActions(Control owner, string heading, Action yesAction, Action noAction)
100 | {
101 |
102 | TaskDialogButton yesButton = new("Go for it") { Tag = DialogResult.Yes };
103 | TaskDialogButton noButton = new("No way") { Tag = DialogResult.No };
104 |
105 | var buttons = new TaskDialogButtonCollection
106 | {
107 | yesButton,
108 | noButton
109 | };
110 |
111 |
112 | TaskDialogPage page = new()
113 | {
114 | Caption = "Question",
115 | SizeToContent = true,
116 | Heading = heading,
117 | Icon = new TaskDialogIcon(Properties.Resources.QuestionBlue),
118 | Buttons = buttons
119 | };
120 |
121 | var result = TaskDialog.ShowDialog(owner, page);
122 |
123 | if ((DialogResult)result.Tag! == DialogResult.Yes)
124 | {
125 | yesAction?.Invoke();
126 | }
127 | else
128 | {
129 | noAction?.Invoke();
130 | }
131 |
132 | }
133 |
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/DesktopHelperLibrary/DesktopHelperLibrary.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 | net8.0-windows
11 | enable
12 | true
13 | enable
14 |
15 |
16 |
17 |
18 | True
19 | True
20 | Resources.resx
21 |
22 |
23 |
24 |
25 |
26 | ResXFileCodeGenerator
27 | Resources.Designer.cs
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/DesktopHelperLibrary/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 DesktopHelperLibrary.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DesktopHelperLibrary.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
65 | ///
66 | internal static System.Drawing.Icon Explaination {
67 | get {
68 | object obj = ResourceManager.GetObject("Explaination", resourceCulture);
69 | return ((System.Drawing.Icon)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
75 | ///
76 | internal static System.Drawing.Icon question32 {
77 | get {
78 | object obj = ResourceManager.GetObject("question32", resourceCulture);
79 | return ((System.Drawing.Icon)(obj));
80 | }
81 | }
82 |
83 | ///
84 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
85 | ///
86 | internal static System.Drawing.Icon QuestionBlue {
87 | get {
88 | object obj = ResourceManager.GetObject("QuestionBlue", resourceCulture);
89 | return ((System.Drawing.Icon)(obj));
90 | }
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/DesktopHelperLibrary/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\Explaination.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
125 | ..\Resources\question32.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
126 |
127 |
128 | ..\Resources\QuestionBlue.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
129 |
130 |
--------------------------------------------------------------------------------
/DesktopHelperLibrary/Resources/Explaination.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/DesktopHelperLibrary/Resources/Explaination.ico
--------------------------------------------------------------------------------
/DesktopHelperLibrary/Resources/QuestionBlue.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/DesktopHelperLibrary/Resources/QuestionBlue.ico
--------------------------------------------------------------------------------
/DesktopHelperLibrary/Resources/question32.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/DesktopHelperLibrary/Resources/question32.ico
--------------------------------------------------------------------------------
/Libraries/AutoClosingMessageBox.deps.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtimeTarget": {
3 | "name": ".NETCoreApp,Version=v5.0",
4 | "signature": ""
5 | },
6 | "compilationOptions": {},
7 | "targets": {
8 | ".NETCoreApp,Version=v5.0": {
9 | "AutoClosingMessageBox/1.0.0": {
10 | "runtime": {
11 | "AutoClosingMessageBox.dll": {}
12 | }
13 | }
14 | }
15 | },
16 | "libraries": {
17 | "AutoClosingMessageBox/1.0.0": {
18 | "type": "project",
19 | "serviceable": false,
20 | "sha512": ""
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/Libraries/AutoClosingMessageBox.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/Libraries/AutoClosingMessageBox.dll
--------------------------------------------------------------------------------
/TaskDialogAutoCloseApp/Classes/WinDialogs.cs:
--------------------------------------------------------------------------------
1 |
2 | using Timer = System.Windows.Forms.Timer;
3 |
4 | namespace TaskDialogAutoCloseApp.Classes;
5 |
6 | public class WinDialogs
7 | {
8 | public static void AutoCloseDialog1(Control owner, Icon icon, string header, int seconds, string caption = "Notification")
9 | {
10 |
11 | var remaining = seconds * 10;
12 |
13 | TaskDialogButton continueButton = new("Ok");
14 |
15 | TaskDialogPage page = new()
16 | {
17 | Heading = header,
18 | Icon = new TaskDialogIcon(icon),
19 | Buttons = new TaskDialogButtonCollection() { continueButton },
20 | Caption = caption
21 | };
22 |
23 | using Timer timer = new()
24 | {
25 | Enabled = true,
26 | Interval = 100
27 | };
28 |
29 | timer.Tick += (_, _) =>
30 | {
31 | remaining -= 1;
32 |
33 | if (remaining != 0) return;
34 | timer.Enabled = false;
35 | if (continueButton.BoundPage is not null)
36 | {
37 | continueButton.PerformClick();
38 | }
39 | };
40 |
41 | TaskDialog.ShowDialog(owner, page);
42 | }
43 |
44 | public static void AutoCloseDialog2(Control owner, string header, int seconds, string additionalText = "")
45 | {
46 |
47 | var remaining = seconds * 10;
48 |
49 | TaskDialogButton continueButton = new("Continue");
50 | TaskDialogButton cancelButton = new("Stop");
51 |
52 | TaskDialogPage page = new()
53 | {
54 | Heading = header,
55 | Text = additionalText,
56 | Buttons = new TaskDialogButtonCollection() { continueButton, cancelButton },
57 | Caption = "Auto-close" // this could be a param
58 | };
59 |
60 | using Timer timer = new()
61 | {
62 | Enabled = true,
63 | Interval = 100
64 | };
65 |
66 | timer.Tick += (_, _) =>
67 | {
68 | remaining -= 1;
69 |
70 | if (remaining != 0) return;
71 | timer.Enabled = false;
72 | if (continueButton.BoundPage is not null)
73 | {
74 | continueButton.PerformClick();
75 | }
76 | };
77 |
78 | TaskDialogButton result = TaskDialog.ShowDialog(owner, page);
79 |
80 | ContinueOperation?.Invoke(result == continueButton);
81 | }
82 |
83 | public delegate void OnContinue(bool sender);
84 | public static event OnContinue? ContinueOperation;
85 |
86 | }
--------------------------------------------------------------------------------
/TaskDialogAutoCloseApp/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace TaskDialogAutoCloseApp;
2 |
3 | partial class Form1
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | AutoCloseButton1 = new Button();
32 | button1 = new Button();
33 | SuspendLayout();
34 | //
35 | // AutoCloseButton1
36 | //
37 | AutoCloseButton1.Location = new Point(142, 81);
38 | AutoCloseButton1.Name = "AutoCloseButton1";
39 | AutoCloseButton1.Size = new Size(118, 29);
40 | AutoCloseButton1.TabIndex = 0;
41 | AutoCloseButton1.Text = "Auto close 1";
42 | AutoCloseButton1.UseVisualStyleBackColor = true;
43 | AutoCloseButton1.Click += AutoCloseButton1_Click;
44 | //
45 | // button1
46 | //
47 | button1.Location = new Point(142, 116);
48 | button1.Name = "button1";
49 | button1.Size = new Size(118, 29);
50 | button1.TabIndex = 1;
51 | button1.Text = "Auto close 2";
52 | button1.UseVisualStyleBackColor = true;
53 | button1.Click += AutoCloseButton2_Click;
54 | //
55 | // Form1
56 | //
57 | AutoScaleDimensions = new SizeF(8F, 20F);
58 | AutoScaleMode = AutoScaleMode.Font;
59 | ClientSize = new Size(436, 273);
60 | Controls.Add(button1);
61 | Controls.Add(AutoCloseButton1);
62 | FormBorderStyle = FormBorderStyle.FixedToolWindow;
63 | Name = "Form1";
64 | StartPosition = FormStartPosition.CenterScreen;
65 | Text = "Code sample";
66 | ResumeLayout(false);
67 | }
68 |
69 | #endregion
70 |
71 | private Button AutoCloseButton1;
72 | private Button button1;
73 | }
74 |
--------------------------------------------------------------------------------
/TaskDialogAutoCloseApp/Form1.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using static TaskDialogAutoCloseApp.Classes.WinDialogs;
3 |
4 | namespace TaskDialogAutoCloseApp;
5 |
6 | public partial class Form1 : Form
7 | {
8 | public Form1()
9 | {
10 | InitializeComponent();
11 | ContinueOperation += WinDialogsOnContinueOperation;
12 | }
13 |
14 | private void WinDialogsOnContinueOperation(bool sender)
15 | {
16 | Debug.WriteLine(sender);
17 | }
18 |
19 | private void AutoCloseButton1_Click(object sender, EventArgs e)
20 | {
21 | AutoCloseDialog1(AutoCloseButton1, Properties.Resources.Timer_16x,"Header", 2);
22 | }
23 |
24 | private void AutoCloseButton2_Click(object sender, EventArgs e)
25 | {
26 | AutoCloseDialog2(this, "Header", 2, "More text to display");
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/TaskDialogAutoCloseApp/Form1.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 |
--------------------------------------------------------------------------------
/TaskDialogAutoCloseApp/Program.cs:
--------------------------------------------------------------------------------
1 | namespace TaskDialogAutoCloseApp;
2 |
3 | internal static class Program
4 | {
5 | ///
6 | /// The main entry point for the application.
7 | ///
8 | [STAThread]
9 | static void Main()
10 | {
11 | // To customize application configuration such as set high DPI settings or default font,
12 | // see https://aka.ms/applicationconfiguration.
13 | ApplicationConfiguration.Initialize();
14 | Application.Run(new Form1());
15 | }
16 | }
--------------------------------------------------------------------------------
/TaskDialogAutoCloseApp/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 TaskDialogAutoCloseApp.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", "17.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("TaskDialogAutoCloseApp.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
65 | ///
66 | internal static System.Drawing.Icon Timer_16x {
67 | get {
68 | object obj = ResourceManager.GetObject("Timer_16x", resourceCulture);
69 | return ((System.Drawing.Icon)(obj));
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/TaskDialogAutoCloseApp/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\Timer_16x.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
--------------------------------------------------------------------------------
/TaskDialogAutoCloseApp/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 TaskDialogAutoCloseApp.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/TaskDialogAutoCloseApp/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/TaskDialogAutoCloseApp/Resources/Timer_16x.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/TaskDialogAutoCloseApp/Resources/Timer_16x.ico
--------------------------------------------------------------------------------
/TaskDialogAutoCloseApp/TaskDialogAutoCloseApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net8.0-windows
6 | enable
7 | true
8 | enable
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | True
22 | True
23 | Resources.resx
24 |
25 |
26 | True
27 | True
28 | Settings.settings
29 |
30 |
31 |
32 |
33 |
34 | ResXFileCodeGenerator
35 | Resources.Designer.cs
36 |
37 |
38 |
39 |
40 |
41 | SettingsSingleFileGenerator
42 | Settings.Designer.cs
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/TaskDialogAutoCloseApp/assets/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/TaskDialogAutoCloseApp/assets/screenshot.png
--------------------------------------------------------------------------------
/TaskDialogAutoCloseApp/readme.md:
--------------------------------------------------------------------------------
1 | # Auto-close dialog
2 |
3 | Example for an auto-close dialog.
4 |
5 | - [More examples](https://github.com/karenpayneoregon/task-dialog-csharp)
6 | - [Library](https://github.com/karenpayneoregon/task-dialog-library)
7 |
8 |
9 | 
--------------------------------------------------------------------------------
/TaskDialogSolution_csharp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.4.33205.214
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Class projects", "Class projects", "{B9DB63E8-F947-4DFE-A05A-28D2A6F22042}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Frontend projects", "Frontend projects", "{0E0D8F5E-56EE-4AC5-87F0-36AD63DB6A84}"
9 | EndProject
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D3296CAA-55D5-4391-A14D-5A125ABB8CBF}"
11 | ProjectSection(SolutionItems) = preProject
12 | readme.md = readme.md
13 | stash.txt = stash.txt
14 | EndProjectSection
15 | EndProject
16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindowsFormsLibrary", "WindowsFormsLibrary\WindowsFormsLibrary.csproj", "{08E7D8BB-4969-4050-8A4F-59A2AE3CADAC}"
17 | EndProject
18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsExamples", "WinFormsExamples\WinFormsExamples.csproj", "{D7664244-65BB-410F-823B-434B7180A9A1}"
19 | EndProject
20 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfExamples", "WpfExamples\WpfExamples.csproj", "{35FF9794-BF09-4B72-BB96-2A5EF1703441}"
21 | EndProject
22 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoCloseNotTaskDialog", "AutoCloseNotTaskDialog\AutoCloseNotTaskDialog.csproj", "{318573A2-6E28-4E9B-B224-7E76846DA5B1}"
23 | EndProject
24 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DesktopHelperLibrary", "DesktopHelperLibrary\DesktopHelperLibrary.csproj", "{214D0D0B-BE0D-4A63-897A-CFB9A740EE7C}"
25 | EndProject
26 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TaskDialogAutoCloseApp", "TaskDialogAutoCloseApp\TaskDialogAutoCloseApp.csproj", "{59191458-6FB6-4A3A-A347-AD6D56657956}"
27 | EndProject
28 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsExamples1", "WinFormsExamples1\WinFormsExamples1.csproj", "{75B5F830-2C20-48A6-94AB-BED19C9E0CB0}"
29 | EndProject
30 | Global
31 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
32 | Debug|Any CPU = Debug|Any CPU
33 | Release|Any CPU = Release|Any CPU
34 | EndGlobalSection
35 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
36 | {08E7D8BB-4969-4050-8A4F-59A2AE3CADAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37 | {08E7D8BB-4969-4050-8A4F-59A2AE3CADAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
38 | {08E7D8BB-4969-4050-8A4F-59A2AE3CADAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
39 | {08E7D8BB-4969-4050-8A4F-59A2AE3CADAC}.Release|Any CPU.Build.0 = Release|Any CPU
40 | {D7664244-65BB-410F-823B-434B7180A9A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41 | {D7664244-65BB-410F-823B-434B7180A9A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
42 | {D7664244-65BB-410F-823B-434B7180A9A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
43 | {D7664244-65BB-410F-823B-434B7180A9A1}.Release|Any CPU.Build.0 = Release|Any CPU
44 | {35FF9794-BF09-4B72-BB96-2A5EF1703441}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45 | {35FF9794-BF09-4B72-BB96-2A5EF1703441}.Debug|Any CPU.Build.0 = Debug|Any CPU
46 | {35FF9794-BF09-4B72-BB96-2A5EF1703441}.Release|Any CPU.ActiveCfg = Release|Any CPU
47 | {35FF9794-BF09-4B72-BB96-2A5EF1703441}.Release|Any CPU.Build.0 = Release|Any CPU
48 | {318573A2-6E28-4E9B-B224-7E76846DA5B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
49 | {318573A2-6E28-4E9B-B224-7E76846DA5B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
50 | {318573A2-6E28-4E9B-B224-7E76846DA5B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
51 | {318573A2-6E28-4E9B-B224-7E76846DA5B1}.Release|Any CPU.Build.0 = Release|Any CPU
52 | {214D0D0B-BE0D-4A63-897A-CFB9A740EE7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53 | {214D0D0B-BE0D-4A63-897A-CFB9A740EE7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
54 | {214D0D0B-BE0D-4A63-897A-CFB9A740EE7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
55 | {214D0D0B-BE0D-4A63-897A-CFB9A740EE7C}.Release|Any CPU.Build.0 = Release|Any CPU
56 | {59191458-6FB6-4A3A-A347-AD6D56657956}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57 | {59191458-6FB6-4A3A-A347-AD6D56657956}.Debug|Any CPU.Build.0 = Debug|Any CPU
58 | {59191458-6FB6-4A3A-A347-AD6D56657956}.Release|Any CPU.ActiveCfg = Release|Any CPU
59 | {59191458-6FB6-4A3A-A347-AD6D56657956}.Release|Any CPU.Build.0 = Release|Any CPU
60 | {75B5F830-2C20-48A6-94AB-BED19C9E0CB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
61 | {75B5F830-2C20-48A6-94AB-BED19C9E0CB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
62 | {75B5F830-2C20-48A6-94AB-BED19C9E0CB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
63 | {75B5F830-2C20-48A6-94AB-BED19C9E0CB0}.Release|Any CPU.Build.0 = Release|Any CPU
64 | EndGlobalSection
65 | GlobalSection(SolutionProperties) = preSolution
66 | HideSolutionNode = FALSE
67 | EndGlobalSection
68 | GlobalSection(NestedProjects) = preSolution
69 | {08E7D8BB-4969-4050-8A4F-59A2AE3CADAC} = {B9DB63E8-F947-4DFE-A05A-28D2A6F22042}
70 | {D7664244-65BB-410F-823B-434B7180A9A1} = {0E0D8F5E-56EE-4AC5-87F0-36AD63DB6A84}
71 | {35FF9794-BF09-4B72-BB96-2A5EF1703441} = {0E0D8F5E-56EE-4AC5-87F0-36AD63DB6A84}
72 | {318573A2-6E28-4E9B-B224-7E76846DA5B1} = {0E0D8F5E-56EE-4AC5-87F0-36AD63DB6A84}
73 | {214D0D0B-BE0D-4A63-897A-CFB9A740EE7C} = {B9DB63E8-F947-4DFE-A05A-28D2A6F22042}
74 | {59191458-6FB6-4A3A-A347-AD6D56657956} = {0E0D8F5E-56EE-4AC5-87F0-36AD63DB6A84}
75 | {75B5F830-2C20-48A6-94AB-BED19C9E0CB0} = {0E0D8F5E-56EE-4AC5-87F0-36AD63DB6A84}
76 | EndGlobalSection
77 | GlobalSection(ExtensibilityGlobals) = postSolution
78 | SolutionGuid = {72CE84AA-1FD5-4622-8AC0-7D89F500CF74}
79 | EndGlobalSection
80 | EndGlobal
81 |
--------------------------------------------------------------------------------
/WinFormsExamples/Classes/ImageHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Globalization;
3 | using WinFormsExamples.Properties;
4 | #pragma warning disable CS8600
5 | #pragma warning disable CS8601
6 |
7 | namespace WinFormsExamples.Classes;
8 |
9 | ///
10 | /// Read images from current project resources
11 | ///
12 | public class ImageHelper
13 | {
14 |
15 | ///
16 | /// Get all bitmap and icon resources
17 | ///
18 | ///
19 | public static List ResourceItemList()
20 | {
21 | var items = new List();
22 |
23 | foreach (var name in ResourceImageNames())
24 | {
25 | /*
26 | * For this code sample ignore the default image
27 | */
28 | if (name == "ready")
29 | {
30 | continue;
31 | }
32 |
33 | var item = new ResourceItem() { Name = name, IsIcon = false };
34 |
35 | if (Resources.ResourceManager.GetObject(name) is Icon icon)
36 | {
37 | item.Image = ((Icon)Resources.ResourceManager.GetObject(name))?.ToBitmap();
38 | item.Icon = icon;
39 | item.IsIcon = true;
40 | }
41 | else
42 | {
43 | item.Image = (Bitmap)Resources.ResourceManager.GetObject(name);
44 | }
45 |
46 | items.Add(item);
47 |
48 | }
49 |
50 | return items;
51 |
52 | }
53 | ///
54 | /// Get all resource names for icon and bitmaps
55 | ///
56 | ///
57 | public static List ResourceImageNames()
58 | {
59 |
60 | try
61 | {
62 |
63 | var names = new List();
64 |
65 | var resourceSet = Resources
66 | .ResourceManager
67 | .GetResourceSet(CultureInfo.CurrentUICulture, true, true);
68 |
69 | names.AddRange(
70 | from DictionaryEntry dictionaryEntry in resourceSet
71 | where dictionaryEntry.Value is Image || dictionaryEntry.Value is Icon
72 | select dictionaryEntry.Key.ToString());
73 |
74 | return names;
75 |
76 | }
77 | catch (Exception)
78 | {
79 | return null!;
80 | }
81 | }
82 | }
--------------------------------------------------------------------------------
/WinFormsExamples/Classes/ResourceImages.cs:
--------------------------------------------------------------------------------
1 | #pragma warning disable CS8618
2 | namespace WinFormsExamples.Classes;
3 |
4 | ///
5 | /// Provides access to resource images by loading them once
6 | ///
7 | public sealed class ResourceImages
8 | {
9 | private static readonly Lazy Lazy = new(() => new ResourceImages());
10 |
11 | public static ResourceImages Instance => Lazy.Value;
12 |
13 | private List _images;
14 | ///
15 | /// Get all icon and bitmap images from project resources
16 | ///
17 | /// list of images
18 | public List Images()
19 | => _images ??= ImageHelper.ResourceItemList();
20 |
21 | ///
22 | /// Icons only
23 | ///
24 | public List Icons => Images().Where(resourceItem
25 | => resourceItem.IsIcon).OrderBy(resourceItem => resourceItem.Name).ToList();
26 | }
--------------------------------------------------------------------------------
/WinFormsExamples/Classes/ResourceItem.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | #pragma warning disable CS8618
4 | namespace WinFormsExamples.Classes;
5 |
6 | public class ResourceItem
7 | {
8 | ///
9 | /// Resource name
10 | ///
11 | public string Name { get; set; }
12 | ///
13 | /// Image which is either an icon or bitmap
14 | ///
15 | public Bitmap Image { get; set; }
16 |
17 | public Icon Icon { get; set; }
18 | ///
19 | /// Indicates if dealing with an icon so when displaying the
20 | /// control used to display can adjust it's size or Size mode
21 | ///
22 | public bool IsIcon { get; set; }
23 |
24 | public override string ToString() => Name;
25 | }
--------------------------------------------------------------------------------
/WinFormsExamples/Classes/SpecialNumericUpDown.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | #pragma warning disable CS8618
3 |
4 | namespace WinFormsExamples.Classes;
5 |
6 | ///
7 | /// Custom without spinner and a property to obtain value as an int
8 | ///
9 | public class SpecialNumericUpDown : NumericUpDown
10 | {
11 | ///
12 | public SpecialNumericUpDown()
13 | {
14 | Controls[0].Hide();
15 | TextAlign = HorizontalAlignment.Right;
16 | }
17 | protected override void OnTextBoxResize(object? source, EventArgs e)
18 | {
19 | Controls[1].Width = Width - 4;
20 | }
21 |
22 | ///
23 | /// Return Value as an int
24 | ///
25 | [Browsable(false)] public int AsInteger => (int)Value;
26 |
27 | public delegate void TriggerDelegate();
28 |
29 | public event TriggerDelegate TriggerEvent;
30 | protected override void OnKeyDown(KeyEventArgs e)
31 | {
32 | if (e.KeyCode == (Keys.Return))
33 | {
34 | e.Handled = true;
35 | e.SuppressKeyPress = true;
36 |
37 | TriggerEvent?.Invoke();
38 |
39 | return;
40 | }
41 |
42 | base.OnKeyDown(e);
43 | }
44 |
45 | }
--------------------------------------------------------------------------------
/WinFormsExamples/Classes/WindowsDialogs.cs:
--------------------------------------------------------------------------------
1 | namespace WinFormsExamples.Classes;
2 |
3 | public static class WindowsDialogs
4 | {
5 | public static bool Question(string text) =>
6 | (MessageBox.Show(
7 | text,
8 | Application.ProductName,
9 | MessageBoxButtons.YesNo,
10 | MessageBoxIcon.Question,
11 | MessageBoxDefaultButton.Button2) == DialogResult.Yes);
12 | }
--------------------------------------------------------------------------------
/WinFormsExamples/Extensions/Extensions.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 |
3 | namespace WinFormsExamples.Extensions;
4 |
5 | ///
6 | /// Common string extensions
7 | ///
8 | public static class Extensions
9 | {
10 | [DebuggerStepThrough]
11 | public static string ToYesNoString(this bool value) => (value ? "Yes" : "No");
12 | }
--------------------------------------------------------------------------------
/WinFormsExamples/Form1.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.Text.RegularExpressions;
3 | using WindowsFormsLibrary.Classes;
4 | using WindowsFormsLibrary.LanguageExtensions;
5 | using WinFormsExamples.Classes;
6 | #pragma warning disable CS0168
7 | #pragma warning disable CS8622
8 |
9 | namespace WinFormsExamples;
10 |
11 | public partial class Form1 : Form
12 | {
13 | public Form1()
14 | {
15 | InitializeComponent();
16 |
17 | Dialogs.ContinueOperation += OnContinueOperation;
18 | //Dialogs.ComputerInformationEvent += OnComputerInformation;
19 | Dialogs.VisualStudioChecked += DialogsOnVisualStudioChecked;
20 |
21 | ShowAgainCheckBox.CheckedChanged += ShowAgainCheckBoxOnCheckedChanged;
22 | toolTip1.Draw += ToolTip1OnDraw;
23 |
24 | IconListBox.DataSource = ResourceImages.Instance.Icons;
25 | IconListBox.SelectedIndexChanged += IconListBoxOnSelectedIndexChanged;
26 |
27 | IconListBox.SelectedIndex = IconListBox.FindString("Csharp");
28 |
29 | }
30 |
31 | private void DialogsOnVisualStudioChecked(TaskDialogRadioButton radiobutton)
32 | {
33 | VersionLabel.Text = radiobutton.Version().ToString();
34 | }
35 |
36 | ///
37 | /// As coded DialogQuestion will center on this form, to center
38 | /// on the screen remove the first parameter for owner.
39 | ///
40 | private void AskQuestionButton_Click(object sender, EventArgs e)
41 | {
42 | // center on this form
43 | if (Dialogs.Question(this, "Do you like coffee?"))
44 | {
45 | MessageBox.Show("Yes");
46 | }
47 | else
48 | {
49 | MessageBox.Show("No");
50 | }
51 | }
52 |
53 | private void AutoCloseButton_Click(object sender, EventArgs e)
54 | {
55 | Dialogs.AutoCloseDialog(this, Properties.Resources.Timer_16x, 2);
56 | }
57 |
58 | private void AutoCloseProgressButton_Click(object sender, EventArgs e) =>
59 | Dialogs.AutoClosingTaskDialog(Properties.Resources.Timer_16x);
60 |
61 | private void ShowAgainCheckBoxOnCheckedChanged(object sender, EventArgs e)
62 | {
63 | var settings = SettingOperations.GetSetting;
64 | settings.ShowAgain = ShowAgainCheckBox.Checked;
65 | SettingOperations.SaveChanges(settings);
66 |
67 | ResultsListBox.Items.Add(ShowAgainCheckBox.Checked ? "Show again" : "Do not show again");
68 | }
69 |
70 | ///
71 | /// Use PowerShell to get computer information to a json file,
72 | /// ask user to open.
73 | ///
74 | /// result will be either 'Open' or 'Cancel'
75 | ///
76 | /// A callback is used to return the json data in a container.
77 | ///
78 | ///
79 | private void OpenTextFileButton_Click(object sender, EventArgs e)
80 | {
81 | TaskDialogButton result = Dialogs.OpenFileAlert(this);
82 | }
83 |
84 | private void DoNotShowAgainButton_Click(object sender, EventArgs e)
85 | {
86 | var settings = SettingOperations.GetSetting;
87 |
88 | if (!settings.ShowAgain)
89 | {
90 | return;
91 | }
92 |
93 | Icon icon = (((ResourceItem)IconListBox.SelectedItem!)!).Icon;
94 |
95 | ShowAgainOptions options = new ShowAgainOptions
96 | {
97 | Heading = settings.Heading,
98 | Text = settings.Text,
99 | Caption = settings.Caption,
100 | Icon = icon,
101 | VerificationText = settings.VerificationText,
102 | Owner = this
103 | };
104 |
105 | (NoShowResult DialogResult, bool ShowAgain) result = Dialogs.DoNotShowAgain(options);
106 |
107 | ShowAgainCheckBox.Checked = result.ShowAgain;
108 |
109 | ResultsListBox.Items.Add(result.ToString());
110 | }
111 |
112 |
113 |
114 | private void ShowCurrentIcon()
115 | {
116 | if (IconListBox.SelectedIndex <= -1) return;
117 | var item = (ResourceItem)IconListBox.SelectedItem!;
118 | pictureBox1.SizeMode = item.IsIcon ? PictureBoxSizeMode.Normal : PictureBoxSizeMode.Zoom;
119 | pictureBox1.Image = item.Image;
120 | Icon = item.Icon;
121 | }
122 |
123 | private void IconListBoxOnSelectedIndexChanged(object sender, EventArgs e)
124 | {
125 | ShowCurrentIcon();
126 | }
127 |
128 | private void LinkExampleButton_Click(object sender, EventArgs e)
129 | {
130 | Dialogs.OpenLink(this);
131 | }
132 |
133 | private void EventsButton_Click(object sender, EventArgs e)
134 | {
135 | Dialogs.ShowEventsTaskDialog();
136 | }
137 |
138 | private void ToolTip1OnDraw(object sender, DrawToolTipEventArgs e)
139 | {
140 | e.DrawBackground();
141 | e.DrawBorder();
142 | e.DrawText();
143 | }
144 |
145 | private void OnContinueOperation(bool sender)
146 | {
147 | Dialogs.Information(this, $"Continue: {sender.ToYesNoString()} ");
148 | }
149 |
150 | ///
151 | /// For
152 | ///
153 | ///
154 | private void OnComputerInformation(MachineComputerInformation information)
155 | {
156 | var free = $"Free memory on this computer is {(information.OsFreePhysicalMemory / 1048576)} mb";
157 | Dialogs.Information(this, free);
158 | }
159 |
160 | ///
161 | /// Example for TaskDialog with radio buttons
162 | ///
163 | private void RadioGroupButton_Click(object sender, EventArgs e)
164 | {
165 | var (response, version) = Dialogs.VisualStudioVersionDialog();
166 | if (response)
167 | {
168 | var selected = Regex.Replace(version.ToString(), "[^0-9]", "");
169 | selected = string.IsNullOrWhiteSpace(selected) ? "No version" : $"Visual Studio {version}";
170 | VersionLabel.Text = selected;
171 | }
172 | else
173 | {
174 | VersionLabel.Text = @"Canceled";
175 | }
176 | }
177 |
178 | private void ConventionalQuestionButton_Click(object sender, EventArgs e)
179 | {
180 | var dir = new DirectoryInfo("C:\\Alstom\\NMS-IPv2\\NCM\\DevicesConfiguration");
181 | if (WindowsDialogs.Question("Remove files?"))
182 | {
183 |
184 | try
185 | {
186 | foreach (var file in dir.EnumerateFiles("test*.*\""))
187 | {
188 | file.Delete();
189 | }
190 | }
191 | catch (Exception exception)
192 | {
193 | // log exception
194 | }
195 | }
196 | }
197 |
198 | private void ErrorExampleButton_Click(object sender, EventArgs e)
199 | {
200 | Dialogs.OpenHelp(this);
201 | }
202 |
203 | private void ActionsButton_Click(object sender, EventArgs e)
204 | {
205 | Dialogs.QuestionWithActions(this, "Heading", YesMethod, NoMethod);
206 | }
207 |
208 | public void YesMethod()
209 | {
210 | Debug.WriteLine(nameof(YesMethod));
211 | }
212 | public void NoMethod()
213 | {
214 | Debug.WriteLine(nameof(NoMethod));
215 | }
216 | }
--------------------------------------------------------------------------------
/WinFormsExamples/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace WinFormsExamples
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.SetHighDpiMode(HighDpiMode.SystemAware);
18 | Application.EnableVisualStyles();
19 | Application.SetCompatibleTextRenderingDefault(false);
20 | Application.Run(new Form1());
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/WinFormsExamples/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 WinFormsExamples.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinFormsExamples.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
65 | ///
66 | internal static System.Drawing.Icon About {
67 | get {
68 | object obj = ResourceManager.GetObject("About", resourceCulture);
69 | return ((System.Drawing.Icon)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
75 | ///
76 | internal static System.Drawing.Icon agent1 {
77 | get {
78 | object obj = ResourceManager.GetObject("agent1", resourceCulture);
79 | return ((System.Drawing.Icon)(obj));
80 | }
81 | }
82 |
83 | ///
84 | /// Looks up a localized resource of type System.Drawing.Bitmap.
85 | ///
86 | internal static System.Drawing.Bitmap ASX_Link_blue_16x {
87 | get {
88 | object obj = ResourceManager.GetObject("ASX_Link_blue_16x", resourceCulture);
89 | return ((System.Drawing.Bitmap)(obj));
90 | }
91 | }
92 |
93 | ///
94 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
95 | ///
96 | internal static System.Drawing.Icon Chat {
97 | get {
98 | object obj = ResourceManager.GetObject("Chat", resourceCulture);
99 | return ((System.Drawing.Icon)(obj));
100 | }
101 | }
102 |
103 | ///
104 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
105 | ///
106 | internal static System.Drawing.Icon ConfigurationFile_16x {
107 | get {
108 | object obj = ResourceManager.GetObject("ConfigurationFile_16x", resourceCulture);
109 | return ((System.Drawing.Icon)(obj));
110 | }
111 | }
112 |
113 | ///
114 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
115 | ///
116 | internal static System.Drawing.Icon Csharp {
117 | get {
118 | object obj = ResourceManager.GetObject("Csharp", resourceCulture);
119 | return ((System.Drawing.Icon)(obj));
120 | }
121 | }
122 |
123 | ///
124 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
125 | ///
126 | internal static System.Drawing.Icon csharp_sql {
127 | get {
128 | object obj = ResourceManager.GetObject("csharp_sql", resourceCulture);
129 | return ((System.Drawing.Icon)(obj));
130 | }
131 | }
132 |
133 | ///
134 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
135 | ///
136 | internal static System.Drawing.Icon DatabaseMethod {
137 | get {
138 | object obj = ResourceManager.GetObject("DatabaseMethod", resourceCulture);
139 | return ((System.Drawing.Icon)(obj));
140 | }
141 | }
142 |
143 | ///
144 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
145 | ///
146 | internal static System.Drawing.Icon Excel {
147 | get {
148 | object obj = ResourceManager.GetObject("Excel", resourceCulture);
149 | return ((System.Drawing.Icon)(obj));
150 | }
151 | }
152 |
153 | ///
154 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
155 | ///
156 | internal static System.Drawing.Icon git1 {
157 | get {
158 | object obj = ResourceManager.GetObject("git1", resourceCulture);
159 | return ((System.Drawing.Icon)(obj));
160 | }
161 | }
162 |
163 | ///
164 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
165 | ///
166 | internal static System.Drawing.Icon NuGet {
167 | get {
168 | object obj = ResourceManager.GetObject("NuGet", resourceCulture);
169 | return ((System.Drawing.Icon)(obj));
170 | }
171 | }
172 |
173 | ///
174 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
175 | ///
176 | internal static System.Drawing.Icon ps {
177 | get {
178 | object obj = ResourceManager.GetObject("ps", resourceCulture);
179 | return ((System.Drawing.Icon)(obj));
180 | }
181 | }
182 |
183 | ///
184 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
185 | ///
186 | internal static System.Drawing.Icon QuestionBlue {
187 | get {
188 | object obj = ResourceManager.GetObject("QuestionBlue", resourceCulture);
189 | return ((System.Drawing.Icon)(obj));
190 | }
191 | }
192 |
193 | ///
194 | /// Looks up a localized resource of type System.Drawing.Bitmap.
195 | ///
196 | internal static System.Drawing.Bitmap ShowDetails_16x {
197 | get {
198 | object obj = ResourceManager.GetObject("ShowDetails_16x", resourceCulture);
199 | return ((System.Drawing.Bitmap)(obj));
200 | }
201 | }
202 |
203 | ///
204 | /// Looks up a localized resource of type System.Drawing.Bitmap.
205 | ///
206 | internal static System.Drawing.Bitmap SplashScreen_16x {
207 | get {
208 | object obj = ResourceManager.GetObject("SplashScreen_16x", resourceCulture);
209 | return ((System.Drawing.Bitmap)(obj));
210 | }
211 | }
212 |
213 | ///
214 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
215 | ///
216 | internal static System.Drawing.Icon SQL_16x {
217 | get {
218 | object obj = ResourceManager.GetObject("SQL_16x", resourceCulture);
219 | return ((System.Drawing.Icon)(obj));
220 | }
221 | }
222 |
223 | ///
224 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
225 | ///
226 | internal static System.Drawing.Icon Timer_16x {
227 | get {
228 | object obj = ResourceManager.GetObject("Timer_16x", resourceCulture);
229 | return ((System.Drawing.Icon)(obj));
230 | }
231 | }
232 |
233 | ///
234 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
235 | ///
236 | internal static System.Drawing.Icon tree {
237 | get {
238 | object obj = ResourceManager.GetObject("tree", resourceCulture);
239 | return ((System.Drawing.Icon)(obj));
240 | }
241 | }
242 |
243 | ///
244 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
245 | ///
246 | internal static System.Drawing.Icon WindowsForm_16x {
247 | get {
248 | object obj = ResourceManager.GetObject("WindowsForm_16x", resourceCulture);
249 | return ((System.Drawing.Icon)(obj));
250 | }
251 | }
252 | }
253 | }
254 |
--------------------------------------------------------------------------------
/WinFormsExamples/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=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\WindowsForm_16x.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
125 | ..\Resources\SplashScreen_16x.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
126 |
127 |
128 | ..\Resources\Timer_16x.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
129 |
130 |
131 | ..\Resources\ShowDetails_16x.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
132 |
133 |
134 | ..\Resources\tree.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
135 |
136 |
137 | ..\Resources\About.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
138 |
139 |
140 | ..\Resources\agent1.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
141 |
142 |
143 | ..\Resources\Chat.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
144 |
145 |
146 | ..\Resources\ConfigurationFile_16x.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
147 |
148 |
149 | ..\Resources\Csharp.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
150 |
151 |
152 | ..\Resources\csharp_sql.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
153 |
154 |
155 | ..\Resources\DatabaseMethod.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
156 |
157 |
158 | ..\Resources\Excel.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
159 |
160 |
161 | ..\Resources\git1.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
162 |
163 |
164 | ..\Resources\NuGet.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
165 |
166 |
167 | ..\Resources\ps.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
168 |
169 |
170 | ..\Resources\SQL_16x.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
171 |
172 |
173 | ..\Resources\QuestionBlue.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
174 |
175 |
176 | ..\Resources\ASX_Link_blue_16x.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
177 |
178 |
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/ASX_Link_blue_16x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/ASX_Link_blue_16x.png
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/About.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/About.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/Chat.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/Chat.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/ConfigurationFile_16x.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/ConfigurationFile_16x.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/Csharp.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/Csharp.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/DatabaseMethod.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/DatabaseMethod.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/Excel.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/Excel.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/NuGet.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/NuGet.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/QuestionBlue.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/QuestionBlue.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/SQL_16x.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/SQL_16x.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/ShowDetails_16x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/ShowDetails_16x.png
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/SplashScreen_16x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/SplashScreen_16x.png
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/Timer_16x.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/Timer_16x.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/WindowsForm_16x.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/WindowsForm_16x.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/agent1.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/agent1.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/csharp_sql.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/csharp_sql.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/error.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/error.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/error.png
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/error1.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/error1.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/git1.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/git1.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/ps.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/ps.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/tree.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/tree.ico
--------------------------------------------------------------------------------
/WinFormsExamples/Resources/tree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/Resources/tree.png
--------------------------------------------------------------------------------
/WinFormsExamples/WinFormsExamples.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
12 | WinExe
13 | net8.0-windows
14 | enable
15 | true
16 | enable
17 | csharp1.ico
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | True
27 | True
28 | Resources.resx
29 |
30 |
31 |
32 |
33 |
34 | ResXFileCodeGenerator
35 | Resources.Designer.cs
36 |
37 |
38 |
39 |
40 |
41 | PreserveNewest
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/WinFormsExamples/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ShowAgain": true,
3 | "Heading": "Are you sure you want to stop?",
4 | "Text": "Stopping the operation might leave your database in a corrupted state.",
5 | "Caption": "Confirmation",
6 | "VerificationText": "Do not show again"
7 | }
--------------------------------------------------------------------------------
/WinFormsExamples/csharp1.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WinFormsExamples/csharp1.ico
--------------------------------------------------------------------------------
/WinFormsExamples/readme.md:
--------------------------------------------------------------------------------
1 | # About
2 |
3 | This project shows how to use TaskDialog in a Windows Forms Core application where the main difference between this project and the WPF project is that for Windows Forms TaskDialog accepts a control or form while for WPF we need to pass in a IntPtr.
4 |
--------------------------------------------------------------------------------
/WinFormsExamples1/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WinFormsExamples1;
2 |
3 | partial class Form1
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | CenterOnThisButton = new Button();
32 | CenterOnFormButton = new Button();
33 | DialogWithActionsButton = new Button();
34 | SuspendLayout();
35 | //
36 | // CenterOnThisButton
37 | //
38 | CenterOnThisButton.Location = new Point(423, 313);
39 | CenterOnThisButton.Name = "CenterOnThisButton";
40 | CenterOnThisButton.Size = new Size(274, 29);
41 | CenterOnThisButton.TabIndex = 0;
42 | CenterOnThisButton.Text = "Center dialog on this button";
43 | CenterOnThisButton.UseVisualStyleBackColor = true;
44 | CenterOnThisButton.Click += CenterOnThisButton_Click;
45 | //
46 | // CenterOnFormButton
47 | //
48 | CenterOnFormButton.Location = new Point(23, 23);
49 | CenterOnFormButton.Name = "CenterOnFormButton";
50 | CenterOnFormButton.Size = new Size(274, 29);
51 | CenterOnFormButton.TabIndex = 1;
52 | CenterOnFormButton.Text = "Center dialog on this form";
53 | CenterOnFormButton.UseVisualStyleBackColor = true;
54 | CenterOnFormButton.Click += CenterOnFormButton_Click;
55 | //
56 | // DialogWithActionsButton
57 | //
58 | DialogWithActionsButton.Location = new Point(23, 71);
59 | DialogWithActionsButton.Name = "DialogWithActionsButton";
60 | DialogWithActionsButton.Size = new Size(274, 29);
61 | DialogWithActionsButton.TabIndex = 2;
62 | DialogWithActionsButton.Text = "Dialog with actions";
63 | DialogWithActionsButton.UseVisualStyleBackColor = true;
64 | DialogWithActionsButton.Click += DialogWithActionsButton_Click;
65 | //
66 | // Form1
67 | //
68 | AutoScaleDimensions = new SizeF(8F, 20F);
69 | AutoScaleMode = AutoScaleMode.Font;
70 | ClientSize = new Size(800, 450);
71 | Controls.Add(DialogWithActionsButton);
72 | Controls.Add(CenterOnFormButton);
73 | Controls.Add(CenterOnThisButton);
74 | FormBorderStyle = FormBorderStyle.FixedToolWindow;
75 | Name = "Form1";
76 | StartPosition = FormStartPosition.CenterScreen;
77 | Text = "Dialogs";
78 | ResumeLayout(false);
79 | }
80 |
81 | #endregion
82 |
83 | private Button CenterOnThisButton;
84 | private Button CenterOnFormButton;
85 | private Button DialogWithActionsButton;
86 | }
87 |
--------------------------------------------------------------------------------
/WinFormsExamples1/Form1.cs:
--------------------------------------------------------------------------------
1 | using DesktopHelperLibrary.Classes;
2 | using System.Diagnostics;
3 |
4 | namespace WinFormsExamples1;
5 |
6 | public partial class Form1 : Form
7 | {
8 | public Form1()
9 | {
10 | InitializeComponent();
11 | }
12 |
13 | private void CenterOnThisButton_Click(object sender, EventArgs e)
14 | {
15 | Dialogs.Question(CenterOnThisButton, "Center on button", "Do you like C#", "Is great", "Nope", DialogResult.Cancel);
16 | }
17 |
18 | private void CenterOnFormButton_Click(object sender, EventArgs e)
19 | {
20 | Dialogs.Question(this, "Center on form", "Do you like C#", "Is great", "Nope", DialogResult.Cancel);
21 | }
22 |
23 | public void YesMethod()
24 | {
25 | Debug.WriteLine(nameof(YesMethod));
26 | }
27 | public void NoMethod()
28 | {
29 | Debug.WriteLine(nameof(NoMethod));
30 | }
31 |
32 | private void DialogWithActionsButton_Click(object sender, EventArgs e)
33 | {
34 | Dialogs.QuestionWithActions(this, "Heading", YesMethod, NoMethod);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/WinFormsExamples1/Form1.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 |
--------------------------------------------------------------------------------
/WinFormsExamples1/Program.cs:
--------------------------------------------------------------------------------
1 | namespace WinFormsExamples1;
2 |
3 | internal static class Program
4 | {
5 | ///
6 | /// The main entry point for the application.
7 | ///
8 | [STAThread]
9 | static void Main()
10 | {
11 | // To customize application configuration such as set high DPI settings or default font,
12 | // see https://aka.ms/applicationconfiguration.
13 | ApplicationConfiguration.Initialize();
14 | Application.Run(new Form1());
15 | }
16 | }
--------------------------------------------------------------------------------
/WinFormsExamples1/WinFormsExamples1.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net8.0-windows
6 | enable
7 | true
8 | enable
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Classes/ApplicationSettings.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsFormsLibrary.Classes
2 | {
3 | public class ApplicationSettings
4 | {
5 | public bool ShowAgain { get; set; }
6 | public string Heading { get; set; }
7 | public string Text { get; set; }
8 | public string Caption { get; set; }
9 | public string VerificationText { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Classes/CenterWinDialog.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 | using System.Text;
3 |
4 | namespace WindowsFormsLibrary.Classes
5 | {
6 | ///
7 | /// Win forms-How can I make MessageBox appear centered on MainForm?
8 | /// https://stackoverflow.com/questions/2576156/winforms-how-can-i-make-messagebox-appear-centered-on-mainform
9 | ///
10 | public class CenterWinDialog : IDisposable
11 | {
12 | private int _tries = 0;
13 | private readonly Form _formOwner;
14 |
15 | public CenterWinDialog(Form owner)
16 | {
17 | _formOwner = owner;
18 | owner.BeginInvoke(new MethodInvoker(findDialog));
19 | }
20 |
21 | private void findDialog()
22 | {
23 | // Enumerate windows to find the message box
24 | if (_tries < 0) return;
25 | EnumThreadWndProc callback = new(checkWindow);
26 | if (EnumThreadWindows(GetCurrentThreadId(), callback, IntPtr.Zero))
27 | {
28 | if (++_tries < 10) _formOwner.BeginInvoke(new MethodInvoker(findDialog));
29 | }
30 | }
31 | private bool checkWindow(IntPtr hWnd, IntPtr lp)
32 | {
33 | // Checks if is a dialog
34 | StringBuilder sb = new (260);
35 | GetClassName(hWnd, sb, sb.Capacity);
36 | if (sb.ToString() != "#32770") return true;
37 |
38 | // Got it
39 | Rectangle frmRect = new Rectangle(_formOwner.Location, _formOwner.Size);
40 | RECT dlgRect;
41 | GetWindowRect(hWnd, out dlgRect);
42 |
43 | MoveWindow(hWnd,
44 | frmRect.Left + (frmRect.Width - dlgRect.Right + dlgRect.Left) / 2,
45 | frmRect.Top + (frmRect.Height - dlgRect.Bottom + dlgRect.Top) / 2,
46 | dlgRect.Right - dlgRect.Left,
47 | dlgRect.Bottom - dlgRect.Top, true);
48 | return false;
49 | }
50 | public void Dispose()
51 | {
52 | _tries = -1;
53 | }
54 |
55 | #region P/Invoke declarations
56 | private delegate bool EnumThreadWndProc(IntPtr hWnd, IntPtr lp);
57 | [DllImport("user32.dll")]
58 | private static extern bool EnumThreadWindows(int tid, EnumThreadWndProc callback, IntPtr lp);
59 | [DllImport("kernel32.dll")]
60 | private static extern int GetCurrentThreadId();
61 | [DllImport("user32.dll")]
62 | private static extern int GetClassName(IntPtr hWnd, StringBuilder buffer, int buflen);
63 | [DllImport("user32.dll")]
64 | private static extern bool GetWindowRect(IntPtr hWnd, out RECT rc);
65 | [DllImport("user32.dll")]
66 | private static extern bool MoveWindow(IntPtr hWnd, int x, int y, int w, int h, bool repaint);
67 | private struct RECT { public int Left; public int Top; public int Right; public int Bottom; }
68 | #endregion
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Classes/MachineComputerInformation.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 WindowsFormsLibrary.Classes
8 | {
9 | ///
10 | /// Get-ComputerInfo | ConvertTo-Json
11 | ///
12 | public class MachineComputerInformation
13 | {
14 | public string WindowsBuildLabEx { get; set; }
15 | public string WindowsCurrentVersion { get; set; }
16 | public string WindowsEditionId { get; set; }
17 | public string WindowsInstallationType { get; set; }
18 | public DateTime WindowsInstallDateFromRegistry { get; set; }
19 | public string WindowsProductId { get; set; }
20 | public string WindowsProductName { get; set; }
21 | public string WindowsRegisteredOrganization { get; set; }
22 | public string WindowsRegisteredOwner { get; set; }
23 | public string WindowsSystemRoot { get; set; }
24 | public string WindowsVersion { get; set; }
25 | public int[] BiosCharacteristics { get; set; }
26 | public string[] BiosBIOSVersion { get; set; }
27 | public object BiosBuildNumber { get; set; }
28 | public string BiosCaption { get; set; }
29 | public object BiosCodeSet { get; set; }
30 | public string BiosCurrentLanguage { get; set; }
31 | public string BiosDescription { get; set; }
32 | public int BiosEmbeddedControllerMajorVersion { get; set; }
33 | public int BiosEmbeddedControllerMinorVersion { get; set; }
34 | public int BiosFirmwareType { get; set; }
35 | public object BiosIdentificationCode { get; set; }
36 | public int BiosInstallableLanguages { get; set; }
37 | public object BiosInstallDate { get; set; }
38 | public object BiosLanguageEdition { get; set; }
39 | public string[] BiosListOfLanguages { get; set; }
40 | public string BiosManufacturer { get; set; }
41 | public string BiosName { get; set; }
42 | public object BiosOtherTargetOS { get; set; }
43 | public bool BiosPrimaryBIOS { get; set; }
44 | public DateTime BiosReleaseDate { get; set; }
45 | public string BiosSeralNumber { get; set; }
46 | public string BiosSMBIOSBIOSVersion { get; set; }
47 | public int BiosSMBIOSMajorVersion { get; set; }
48 | public int BiosSMBIOSMinorVersion { get; set; }
49 | public bool BiosSMBIOSPresent { get; set; }
50 | public int BiosSoftwareElementState { get; set; }
51 | public string BiosStatus { get; set; }
52 | public int BiosSystemBiosMajorVersion { get; set; }
53 | public int BiosSystemBiosMinorVersion { get; set; }
54 | public int BiosTargetOperatingSystem { get; set; }
55 | public string BiosVersion { get; set; }
56 | public int CsAdminPasswordStatus { get; set; }
57 | public bool CsAutomaticManagedPagefile { get; set; }
58 | public bool CsAutomaticResetBootOption { get; set; }
59 | public bool CsAutomaticResetCapability { get; set; }
60 | public object CsBootOptionOnLimit { get; set; }
61 | public object CsBootOptionOnWatchDog { get; set; }
62 | public bool CsBootROMSupported { get; set; }
63 | public int[] CsBootStatus { get; set; }
64 | public string CsBootupState { get; set; }
65 | public string CsCaption { get; set; }
66 | public int CsChassisBootupState { get; set; }
67 | public string CsChassisSKUNumber { get; set; }
68 | public int CsCurrentTimeZone { get; set; }
69 | public bool CsDaylightInEffect { get; set; }
70 | public string CsDescription { get; set; }
71 | public string CsDNSHostName { get; set; }
72 | public string CsDomain { get; set; }
73 | public int CsDomainRole { get; set; }
74 | public bool CsEnableDaylightSavingsTime { get; set; }
75 | public int CsFrontPanelResetStatus { get; set; }
76 | public bool CsHypervisorPresent { get; set; }
77 | public bool CsInfraredSupported { get; set; }
78 | public object CsInitialLoadInfo { get; set; }
79 | public object CsInstallDate { get; set; }
80 | public int CsKeyboardPasswordStatus { get; set; }
81 | public object CsLastLoadInfo { get; set; }
82 | public string CsManufacturer { get; set; }
83 | public string CsModel { get; set; }
84 | public string CsName { get; set; }
85 | public Csnetworkadapter[] CsNetworkAdapters { get; set; }
86 | public bool CsNetworkServerModeEnabled { get; set; }
87 | public int CsNumberOfLogicalProcessors { get; set; }
88 | public int CsNumberOfProcessors { get; set; }
89 | public Csprocessor[] CsProcessors { get; set; }
90 | public string[] CsOEMStringArray { get; set; }
91 | public bool CsPartOfDomain { get; set; }
92 | public int CsPauseAfterReset { get; set; }
93 | public int CsPCSystemType { get; set; }
94 | public int CsPCSystemTypeEx { get; set; }
95 | public object CsPowerManagementCapabilities { get; set; }
96 | public object CsPowerManagementSupported { get; set; }
97 | public int CsPowerOnPasswordStatus { get; set; }
98 | public int CsPowerState { get; set; }
99 | public int CsPowerSupplyState { get; set; }
100 | public object CsPrimaryOwnerContact { get; set; }
101 | public string CsPrimaryOwnerName { get; set; }
102 | public int CsResetCapability { get; set; }
103 | public int CsResetCount { get; set; }
104 | public int CsResetLimit { get; set; }
105 | public string[] CsRoles { get; set; }
106 | public string CsStatus { get; set; }
107 | public object CsSupportContactDescription { get; set; }
108 | public string CsSystemFamily { get; set; }
109 | public string CsSystemSKUNumber { get; set; }
110 | public string CsSystemType { get; set; }
111 | public int CsThermalState { get; set; }
112 | public long CsTotalPhysicalMemory { get; set; }
113 | public int CsPhyicallyInstalledMemory { get; set; }
114 | public string CsUserName { get; set; }
115 | public int CsWakeUpType { get; set; }
116 | public object CsWorkgroup { get; set; }
117 | public string OsName { get; set; }
118 | public int OsType { get; set; }
119 | public int OsOperatingSystemSKU { get; set; }
120 | public string OsVersion { get; set; }
121 | public object OsCSDVersion { get; set; }
122 | public string OsBuildNumber { get; set; }
123 | public Oshotfix[] OsHotFixes { get; set; }
124 | public string OsBootDevice { get; set; }
125 | public string OsSystemDevice { get; set; }
126 | public string OsSystemDirectory { get; set; }
127 | public string OsSystemDrive { get; set; }
128 | public string OsWindowsDirectory { get; set; }
129 | public string OsCountryCode { get; set; }
130 | public int OsCurrentTimeZone { get; set; }
131 | public string OsLocaleID { get; set; }
132 | public string OsLocale { get; set; }
133 | public DateTime OsLocalDateTime { get; set; }
134 | public DateTime OsLastBootUpTime { get; set; }
135 | public Osuptime OsUptime { get; set; }
136 | public string OsBuildType { get; set; }
137 | public string OsCodeSet { get; set; }
138 | public bool OsDataExecutionPreventionAvailable { get; set; }
139 | public bool OsDataExecutionPrevention32BitApplications { get; set; }
140 | public bool OsDataExecutionPreventionDrivers { get; set; }
141 | public int OsDataExecutionPreventionSupportPolicy { get; set; }
142 | public bool OsDebug { get; set; }
143 | public bool OsDistributed { get; set; }
144 | public int OsEncryptionLevel { get; set; }
145 | public int OsForegroundApplicationBoost { get; set; }
146 | public int OsTotalVisibleMemorySize { get; set; }
147 | public int OsFreePhysicalMemory { get; set; }
148 | public int OsTotalVirtualMemorySize { get; set; }
149 | public int OsFreeVirtualMemory { get; set; }
150 | public int OsInUseVirtualMemory { get; set; }
151 | public object OsTotalSwapSpaceSize { get; set; }
152 | public int OsSizeStoredInPagingFiles { get; set; }
153 | public int OsFreeSpaceInPagingFiles { get; set; }
154 | public string[] OsPagingFiles { get; set; }
155 | public string OsHardwareAbstractionLayer { get; set; }
156 | public DateTime OsInstallDate { get; set; }
157 | public string OsManufacturer { get; set; }
158 | public long OsMaxNumberOfProcesses { get; set; }
159 | public long OsMaxProcessMemorySize { get; set; }
160 | public string[] OsMuiLanguages { get; set; }
161 | public object OsNumberOfLicensedUsers { get; set; }
162 | public int OsNumberOfProcesses { get; set; }
163 | public int OsNumberOfUsers { get; set; }
164 | public string OsOrganization { get; set; }
165 | public string OsArchitecture { get; set; }
166 | public string OsLanguage { get; set; }
167 | public int[] OsProductSuites { get; set; }
168 | public object OsOtherTypeDescription { get; set; }
169 | public object OsPAEEnabled { get; set; }
170 | public bool OsPortableOperatingSystem { get; set; }
171 | public bool OsPrimary { get; set; }
172 | public int OsProductType { get; set; }
173 | public string OsRegisteredUser { get; set; }
174 | public string OsSerialNumber { get; set; }
175 | public int OsServicePackMajorVersion { get; set; }
176 | public int OsServicePackMinorVersion { get; set; }
177 | public string OsStatus { get; set; }
178 | public int[] OsSuites { get; set; }
179 | public object OsServerLevel { get; set; }
180 | public string KeyboardLayout { get; set; }
181 | public string TimeZone { get; set; }
182 | public string LogonServer { get; set; }
183 | public int PowerPlatformRole { get; set; }
184 | public bool HyperVisorPresent { get; set; }
185 | public object HyperVRequirementDataExecutionPreventionAvailable { get; set; }
186 | public object HyperVRequirementSecondLevelAddressTranslation { get; set; }
187 | public object HyperVRequirementVirtualizationFirmwareEnabled { get; set; }
188 | public object HyperVRequirementVMMonitorModeExtensions { get; set; }
189 | public int DeviceGuardSmartStatus { get; set; }
190 | public int[] DeviceGuardRequiredSecurityProperties { get; set; }
191 | public int[] DeviceGuardAvailableSecurityProperties { get; set; }
192 | public int[] DeviceGuardSecurityServicesConfigured { get; set; }
193 | public int[] DeviceGuardSecurityServicesRunning { get; set; }
194 | public object DeviceGuardCodeIntegrityPolicyEnforcementStatus { get; set; }
195 | public object DeviceGuardUserModeCodeIntegrityPolicyEnforcementStatus { get; set; }
196 |
197 | public override string ToString()
198 | {
199 | return $"{WindowsRegisteredOwner}";
200 | }
201 | }
202 |
203 | public class Osuptime
204 | {
205 | public long Ticks { get; set; }
206 | public int Days { get; set; }
207 | public int Hours { get; set; }
208 | public int Milliseconds { get; set; }
209 | public int Minutes { get; set; }
210 | public int Seconds { get; set; }
211 | public float TotalDays { get; set; }
212 | public float TotalHours { get; set; }
213 | public float TotalMilliseconds { get; set; }
214 | public float TotalMinutes { get; set; }
215 | public float TotalSeconds { get; set; }
216 | public override string ToString() => $"{Hours} hours {Minutes} minutes {Days} days";
217 |
218 | }
219 |
220 | public class Csnetworkadapter
221 | {
222 | public string Description { get; set; }
223 | public string ConnectionID { get; set; }
224 | public bool? DHCPEnabled { get; set; }
225 | public string DHCPServer { get; set; }
226 | public int ConnectionStatus { get; set; }
227 | public string IPAddresses { get; set; }
228 | }
229 |
230 | public class Csprocessor
231 | {
232 | public string Name { get; set; }
233 | public string Manufacturer { get; set; }
234 | public string Description { get; set; }
235 | public int Architecture { get; set; }
236 | public int AddressWidth { get; set; }
237 | public int DataWidth { get; set; }
238 | public int MaxClockSpeed { get; set; }
239 | public int CurrentClockSpeed { get; set; }
240 | public int NumberOfCores { get; set; }
241 | public int NumberOfLogicalProcessors { get; set; }
242 | public string ProcessorID { get; set; }
243 | public string SocketDesignation { get; set; }
244 | public int ProcessorType { get; set; }
245 | public string Role { get; set; }
246 | public string Status { get; set; }
247 | public int CpuStatus { get; set; }
248 | public int Availability { get; set; }
249 | }
250 |
251 | public class Oshotfix
252 | {
253 | public string HotFixID { get; set; }
254 | public string Description { get; set; }
255 | public string InstalledOn { get; set; }
256 | public string FixComments { get; set; }
257 | }
258 |
259 | }
260 |
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Classes/NoShowResult.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace WindowsFormsLibrary.Classes
3 | {
4 | public enum NoShowResult
5 | {
6 | DoNotShowAgain,
7 | StopOperation,
8 | No
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Classes/PowerShellOperations.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.IO;
3 | using System.Threading.Tasks;
4 | using Newtonsoft.Json;
5 |
6 | namespace WindowsFormsLibrary.Classes
7 | {
8 | public class PowerShellOperations
9 | {
10 | public static string ComputerInfoFileName => "computerInformation.json";
11 | public static async Task GetComputerInformationTask()
12 | {
13 |
14 | if (File.Exists(ComputerInfoFileName))
15 | {
16 | File.Delete(ComputerInfoFileName);
17 | }
18 |
19 | var start = new ProcessStartInfo
20 | {
21 | FileName = "powershell.exe",
22 | RedirectStandardOutput = true,
23 | Arguments = "Get-ComputerInfo | ConvertTo-Json",
24 | CreateNoWindow = true
25 | };
26 |
27 | using var process = Process.Start(start);
28 | using var reader = process.StandardOutput;
29 |
30 | process.EnableRaisingEvents = true;
31 |
32 | var fileContents = await reader.ReadToEndAsync();
33 |
34 | await File.WriteAllTextAsync(ComputerInfoFileName, fileContents);
35 | await process.WaitForExitAsync();
36 |
37 | var json = await File.ReadAllTextAsync(ComputerInfoFileName);
38 | return JsonConvert.DeserializeObject(json);
39 |
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Classes/SettingOperations.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using Newtonsoft.Json;
3 |
4 | namespace WindowsFormsLibrary.Classes
5 | {
6 | public class SettingOperations
7 | {
8 | public static string FileName { get; set; } = "appsettings.json";
9 | public static void Create()
10 | {
11 | var settings = new ApplicationSettings
12 | {
13 | ShowAgain = true,
14 | Heading = "Are you sure you want to stop?",
15 | Text = "Stopping the operation might leave your database in a corrupted state.",
16 | Caption = "Confirmation",
17 | VerificationText = "Do not show again"
18 | };
19 | var json = JsonConvert.SerializeObject(settings, Formatting.Indented);
20 | File.WriteAllText(FileName, json);
21 | }
22 | ///
23 | /// Does exists for settings
24 | ///
25 | ///
26 | public static bool FileExists => File.Exists(FileName);
27 |
28 | ///
29 | /// Read settings from file
30 | ///
31 | ///
32 | public static ApplicationSettings GetSetting =>
33 | JsonConvert.DeserializeObject(File.ReadAllText(FileName));
34 |
35 | ///
36 | /// Indicates whether to show or not show the dialog
37 | ///
38 | ///
39 | public static bool ShowAgain => GetSetting.ShowAgain;
40 |
41 | ///
42 | /// Save settings to file
43 | ///
44 | ///
45 | public static void SaveChanges(ApplicationSettings settings)
46 | {
47 | var json = JsonConvert.SerializeObject(settings, Formatting.Indented);
48 | File.WriteAllText(FileName, json);
49 | }
50 | ///
51 | /// Save ShowAgain property only
52 | ///
53 | ///
54 | public static void SetShowAgain(bool value)
55 | {
56 | var current = GetSetting;
57 | current.ShowAgain = value;
58 | SaveChanges(current);
59 | }
60 |
61 | }
62 | }
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Classes/ShowAgainOptions.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsFormsLibrary.Classes
2 | {
3 | public class ShowAgainOptions
4 | {
5 | public string Heading { get; set; }
6 | public string Text { get; set; }
7 | public string Caption { get; set; }
8 | public string VerificationText { get; set; }
9 | public Control Owner { get; set; }
10 | public IntPtr IntPtr { get; set; }
11 | public Icon Icon { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Classes/StopWatcher.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 |
4 | namespace WindowsFormsLibrary.Classes
5 | {
6 | ///
7 | /// Single instance class for a StopWatch useful for validating elapsed time
8 | /// from a single instance.
9 | ///
10 | public sealed class StopWatcher
11 | {
12 | ///
13 | /// Creates a thread safe instance of this class
14 | ///
15 | private static readonly Lazy Lazy = new(() => new StopWatcher());
16 |
17 | ///
18 | /// StopWatch for measuring time.
19 | ///
20 | private readonly Stopwatch _stopwatch;
21 |
22 | ///
23 | /// Inaccessible constructor
24 | ///
25 | private StopWatcher()
26 | {
27 | _stopwatch = new Stopwatch();
28 | }
29 |
30 | ///
31 | /// Start timer
32 | ///
33 | ///
34 | /// First reset the stop watch to get fresh calculations
35 | ///
36 | public void Start()
37 | {
38 | _stopwatch.Reset();
39 | _stopwatch.Start();
40 | }
41 |
42 | ///
43 | /// Stop for measuring stop watch Elapsed time
44 | ///
45 | public void Stop() => _stopwatch.Stop();
46 |
47 | ///
48 | /// Get elapsed time as a TimeSpan
49 | ///
50 | public TimeSpan Elapsed
51 | {
52 | get
53 | {
54 | Stop();
55 | return _stopwatch.Elapsed;
56 | }
57 | }
58 |
59 | ///
60 | /// Format elapsed time to minutes, seconds, milliseconds
61 | ///
62 | public string ElapsedFormatted
63 | {
64 | get
65 | {
66 | Stop();
67 | return Elapsed.ToString("mm\\:ss\\.fff");
68 | }
69 | }
70 |
71 | ///
72 | /// Access point to methods and properties
73 | ///
74 | public static StopWatcher Instance => Lazy.Value;
75 |
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Classes/Win32Window.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsFormsLibrary.Classes;
2 |
3 | public class Win32Window : IWin32Window
4 | {
5 | readonly IntPtr handle;
6 | public Win32Window(IWin32Window window)
7 | {
8 | handle = window.Handle;
9 | }
10 | IntPtr IWin32Window.Handle => handle;
11 | }
--------------------------------------------------------------------------------
/WindowsFormsLibrary/LanguageExtensions/Extensions.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 |
3 | namespace WindowsFormsLibrary.LanguageExtensions
4 | {
5 | ///
6 | /// Common string extensions
7 | ///
8 | public static class Extensions
9 | {
10 | [DebuggerStepThrough]
11 | public static string ToYesNoString(this bool value) => (value ? "Yes" : "No");
12 |
13 | ///
14 | /// Get Visual Studio version
15 | ///
16 | ///
17 | /// Version
18 | [DebuggerStepThrough]
19 | public static VisualStudioVersion Version(this TaskDialogRadioButton sender) => sender is null ? VisualStudioVersion.None : (VisualStudioVersion)sender.Tag;
20 |
21 | public static (bool hasUrl, string address) GetAddress(this TaskDialogCommandLinkButton button)
22 | {
23 | if (button.Tag is not null)
24 | {
25 | return (true, Convert.ToString(button.Tag));
26 | }
27 | else
28 | {
29 | return (false,null);
30 | }
31 | }
32 | ///
33 | /// Set web address for use in opening a web page
34 | ///
35 | ///
36 | ///
37 | public static void SetAddress(this TaskDialogCommandLinkButton button, string address)
38 | {
39 | button.Tag = address;
40 | }
41 |
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/WindowsFormsLibrary/LanguageExtensions/VisualStudioVersion.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsFormsLibrary.LanguageExtensions
2 | {
3 | ///
4 | /// Visual Studio versions for RadioButton
5 | ///
6 | public enum VisualStudioVersion
7 | {
8 | V2017,
9 | V2019,
10 | V2022,
11 | None
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/WindowsFormsLibrary/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 WindowsFormsLibrary.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", "17.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("WindowsFormsLibrary.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
65 | ///
66 | internal static System.Drawing.Icon error {
67 | get {
68 | object obj = ResourceManager.GetObject("error", resourceCulture);
69 | return ((System.Drawing.Icon)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
75 | ///
76 | internal static System.Drawing.Icon error1 {
77 | get {
78 | object obj = ResourceManager.GetObject("error1", resourceCulture);
79 | return ((System.Drawing.Icon)(obj));
80 | }
81 | }
82 |
83 | ///
84 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
85 | ///
86 | internal static System.Drawing.Icon Explaination {
87 | get {
88 | object obj = ResourceManager.GetObject("Explaination", resourceCulture);
89 | return ((System.Drawing.Icon)(obj));
90 | }
91 | }
92 |
93 | ///
94 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
95 | ///
96 | internal static System.Drawing.Icon question32 {
97 | get {
98 | object obj = ResourceManager.GetObject("question32", resourceCulture);
99 | return ((System.Drawing.Icon)(obj));
100 | }
101 | }
102 |
103 | ///
104 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
105 | ///
106 | internal static System.Drawing.Icon QuestionBlue {
107 | get {
108 | object obj = ResourceManager.GetObject("QuestionBlue", resourceCulture);
109 | return ((System.Drawing.Icon)(obj));
110 | }
111 | }
112 |
113 | ///
114 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
115 | ///
116 | internal static System.Drawing.Icon visualstudio32 {
117 | get {
118 | object obj = ResourceManager.GetObject("visualstudio32", resourceCulture);
119 | return ((System.Drawing.Icon)(obj));
120 | }
121 | }
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\error.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
125 | ..\Resources\error1.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
126 |
127 |
128 | ..\Resources\Explaination.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
129 |
130 |
131 | ..\Resources\question32.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
132 |
133 |
134 | ..\Resources\QuestionBlue.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
135 |
136 |
137 | ..\Resources\visualstudio32.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
138 |
139 |
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Resources/Explaination.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WindowsFormsLibrary/Resources/Explaination.ico
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Resources/QuestionBlue.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WindowsFormsLibrary/Resources/QuestionBlue.ico
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Resources/error.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WindowsFormsLibrary/Resources/error.ico
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Resources/error1.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WindowsFormsLibrary/Resources/error1.ico
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Resources/question32.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WindowsFormsLibrary/Resources/question32.ico
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Resources/visualstudio32.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WindowsFormsLibrary/Resources/visualstudio32.ico
--------------------------------------------------------------------------------
/WindowsFormsLibrary/Resources/visualstudio32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WindowsFormsLibrary/Resources/visualstudio32.png
--------------------------------------------------------------------------------
/WindowsFormsLibrary/WindowsFormsLibrary.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 | net8.0-windows
11 | disable
12 | true
13 | enable
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | Form
24 |
25 |
26 | True
27 | True
28 | Resources.resx
29 |
30 |
31 |
32 |
33 |
34 | ResXFileCodeGenerator
35 | Resources.Designer.cs
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/WindowsFormsLibrary/assets/Versions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WindowsFormsLibrary/assets/Versions.png
--------------------------------------------------------------------------------
/WindowsFormsLibrary/assets/core_csharp_shield.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WindowsFormsLibrary/assets/core_csharp_shield.png
--------------------------------------------------------------------------------
/WindowsFormsLibrary/readme.md:
--------------------------------------------------------------------------------
1 | # About
2 |
3 | This project contains code for displaying various forms of TaskDialog for both Windows Forms and WPF projects.
4 |
5 | **Note** that there are differences between the Owner for both types of projects, Windows Forms accepts a control or form while in the WPF project a IntPtr.
--------------------------------------------------------------------------------
/WpfExamples/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/WpfExamples/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace WpfExamples
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/WpfExamples/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/WpfExamples/Classes/FocusBehavior.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 | using System.Windows.Input;
4 |
5 | namespace WpfExamples.Classes;
6 |
7 | ///
8 | /// attached behavior for selecting first control in a window
9 | ///
10 | public static class FocusBehavior
11 | {
12 | public static readonly DependencyProperty GiveInitialFocusProperty =
13 | DependencyProperty.RegisterAttached("GiveInitialFocus", typeof(bool), typeof(FocusBehavior),
14 | new PropertyMetadata(false, OnFocusFirstPropertyChanged));
15 |
16 | public static bool GetGiveInitialFocus(Control control) => (bool)control.GetValue(GiveInitialFocusProperty);
17 | public static void SetGiveInitialFocus(Control control, bool value) => control.SetValue(GiveInitialFocusProperty, value);
18 |
19 | private static void OnFocusFirstPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
20 | {
21 | if (sender is not Control control || args.NewValue is not bool value)
22 | {
23 | return;
24 | }
25 |
26 | if (value)
27 | {
28 | control.Loaded += OnControlLoaded;
29 | }
30 | else
31 | {
32 | control.Loaded -= OnControlLoaded;
33 | }
34 | }
35 |
36 | private static void OnControlLoaded(object sender, RoutedEventArgs e) =>
37 | ((Control)sender).MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
38 | }
--------------------------------------------------------------------------------
/WpfExamples/Classes/ImageHelpers.cs:
--------------------------------------------------------------------------------
1 | using System.Drawing;
2 | using System.IO;
3 | using System.Windows.Media.Imaging;
4 |
5 | namespace WpfExamples.Classes;
6 |
7 | public class ImageHelpers
8 | {
9 | ///
10 | /// Convert to
11 | ///
12 | /// Location of image file
13 | /// An Icon
14 | public static Icon BitmapImageToIcon(string path)
15 | {
16 | BitmapImage bitmapImage = new (new Uri(path, UriKind.Relative));
17 | using MemoryStream outStream = new ();
18 | BitmapEncoder encoder = new BmpBitmapEncoder();
19 | encoder.Frames.Add(BitmapFrame.Create(bitmapImage));
20 | encoder.Save(outStream);
21 | Bitmap bitmap = new (outStream);
22 |
23 | return Icon.FromHandle(new Bitmap(bitmap).GetHicon());
24 | }
25 | }
--------------------------------------------------------------------------------
/WpfExamples/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
33 |
40 |
53 |
60 |
70 |
77 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/WpfExamples/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Drawing;
2 | using System.Text.RegularExpressions;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using System.Windows.Input;
6 | using System.Windows.Interop;
7 | using WindowsFormsLibrary.Classes;
8 | using WpfExamples.Classes;
9 |
10 | namespace WpfExamples;
11 |
12 | ///
13 | /// Interaction logic for MainWindow.xaml
14 | ///
15 | public partial class MainWindow : Window
16 | {
17 | private IntPtr _intPtr;
18 |
19 | private bool _shown;
20 |
21 | private Icon _agentIcon;
22 | private Icon _sqlServerIcon;
23 | private Icon _DatabaseIcon;
24 | protected override void OnContentRendered(EventArgs e)
25 | {
26 | base.OnContentRendered(e);
27 |
28 | if (_shown)
29 | {
30 | return;
31 | }
32 |
33 | _shown = true;
34 |
35 | Window window = GetWindow(this);
36 |
37 | var windowInterop = new WindowInteropHelper(window ?? throw new InvalidOperationException());
38 | _intPtr = windowInterop.Handle;
39 |
40 | _agentIcon = ImageHelpers.BitmapImageToIcon("Resources\\agent1.ico");
41 | _sqlServerIcon = ImageHelpers.BitmapImageToIcon("Resources\\sql_server.ico");
42 | _DatabaseIcon = ImageHelpers.BitmapImageToIcon("Resources\\Database_16x.ico");
43 |
44 | var settings = SettingOperations.GetSetting;
45 | ShowAgainCheckBox.IsChecked = settings.ShowAgain;
46 | ShowAgainCheckBox.Checked += ShowAgainCheckBox_Checked;
47 | ShowAgainCheckBox.Unchecked += ShowAgainCheckBox_Checked;
48 |
49 | }
50 |
51 | public MainWindow()
52 | {
53 | InitializeComponent();
54 | }
55 |
56 | private void QuestionButtonComplex_Click(object sender, RoutedEventArgs e)
57 | {
58 | ComplexLabel.Content = Dialogs.Question(_intPtr, "Question", "Do you like coffee?", "Sure do", "Tea for me") ?
59 | "Coffee it is" :
60 | "Tea it is";
61 | }
62 |
63 | private void QuestionButton_Click(object sender, RoutedEventArgs e)
64 | {
65 |
66 | if (Dialogs.Question(_intPtr, "Do you like coffee?", _agentIcon))
67 | {
68 | Dialogs.Information(_intPtr, "Continue","Woo-hoo");
69 | }
70 | else
71 | {
72 | Dialogs.Information(_intPtr, "Exit stage right", "Sad face");
73 | }
74 | }
75 |
76 | ///
77 | /// Numbers only for text box
78 | ///
79 | ///
80 | ///
81 | private new void PreviewTextInput(object sender, TextCompositionEventArgs e)
82 | {
83 | Regex regex = new("[^0-9]+");
84 | e.Handled = regex.IsMatch(e.Text);
85 | }
86 |
87 | private void AutoCloseButton_Click(object sender, RoutedEventArgs e)
88 | {
89 | int seconds = Convert.ToInt32(SecondsTextBox.Text);
90 | Dialogs.AutoCloseDialog(_intPtr, _sqlServerIcon, seconds, $"Backing up in {seconds} seconds!!!");
91 | }
92 |
93 | private void DoNotShowAgainReset_OnClick(object sender, RoutedEventArgs e)
94 | {
95 | var checkBox = (CheckBox)sender;
96 | }
97 |
98 | ///
99 | /// Display a dialog with option to not display again where their choice
100 | /// is stored in appsettings.json
101 | ///
102 | ///
103 | ///
104 | private void DoNotShowAgainButton_Click(object sender, RoutedEventArgs e)
105 | {
106 | var settings = SettingOperations.GetSetting;
107 |
108 | if (!settings.ShowAgain) return;
109 | ShowAgainOptions options = new()
110 | {
111 | Heading = settings.Heading,
112 | Text = settings.Text,
113 | Caption = settings.Caption,
114 | Icon = _DatabaseIcon,
115 | VerificationText = settings.VerificationText,
116 | IntPtr = _intPtr
117 | };
118 |
119 | (NoShowResult DialogResult, bool ShowAgain) result = Dialogs.DoNotShowAgain(options);
120 | ShowAgainCheckBox.IsChecked = result.ShowAgain;
121 |
122 | }
123 |
124 | ///
125 | /// When the check box is checked/un-checked save back to appsettings.json
126 | ///
127 | private void ShowAgainCheckBox_Checked(object sender, RoutedEventArgs e)
128 | {
129 | var settings = SettingOperations.GetSetting;
130 | settings.ShowAgain = ShowAgainCheckBox.IsChecked.Value;
131 | SettingOperations.SaveChanges(settings);
132 |
133 | }
134 | }
--------------------------------------------------------------------------------
/WpfExamples/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 WpfExamples.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | public 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 | 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("WpfExamples.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 | 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.Icon similar to (Icon).
65 | ///
66 | public static System.Drawing.Icon agent1 {
67 | get {
68 | object obj = ResourceManager.GetObject("agent1", resourceCulture);
69 | return ((System.Drawing.Icon)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
75 | ///
76 | public static System.Drawing.Icon Database_16x {
77 | get {
78 | object obj = ResourceManager.GetObject("Database_16x", resourceCulture);
79 | return ((System.Drawing.Icon)(obj));
80 | }
81 | }
82 |
83 | ///
84 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
85 | ///
86 | public static System.Drawing.Icon sql_server {
87 | get {
88 | object obj = ResourceManager.GetObject("sql_server", resourceCulture);
89 | return ((System.Drawing.Icon)(obj));
90 | }
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/WpfExamples/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=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\agent1.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
125 | ..\Resources\Database_16x.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
126 |
127 |
128 | ..\Resources\sql_server.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
129 |
130 |
--------------------------------------------------------------------------------
/WpfExamples/Resources/Database_16x.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WpfExamples/Resources/Database_16x.ico
--------------------------------------------------------------------------------
/WpfExamples/Resources/agent1.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WpfExamples/Resources/agent1.ico
--------------------------------------------------------------------------------
/WpfExamples/Resources/sql_server.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WpfExamples/Resources/sql_server.ico
--------------------------------------------------------------------------------
/WpfExamples/WpfExamples.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net8.0-windows
6 | true
7 | disable
8 | enable
9 | app.manifest
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | True
27 | True
28 | Resources.resx
29 |
30 |
31 |
32 |
33 |
34 | PublicResXFileCodeGenerator
35 | Resources.Designer.cs
36 |
37 |
38 |
39 |
40 |
41 | PreserveNewest
42 |
43 |
44 | PreserveNewest
45 |
46 |
47 | PreserveNewest
48 |
49 |
50 | PreserveNewest
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/WpfExamples/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
54 |
62 |
63 |
64 |
65 |
66 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/WpfExamples/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ShowAgain": true,
3 | "Heading": "Are you sure you want to stop?",
4 | "Text": "Stopping the operation might leave your database in a corrupted state.",
5 | "Caption": "Confirmation",
6 | "VerificationText": "Do not show again"
7 | }
--------------------------------------------------------------------------------
/WpfExamples/assets/auttClose.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WpfExamples/assets/auttClose.png
--------------------------------------------------------------------------------
/WpfExamples/assets/information.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WpfExamples/assets/information.png
--------------------------------------------------------------------------------
/WpfExamples/assets/mainWindow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WpfExamples/assets/mainWindow.png
--------------------------------------------------------------------------------
/WpfExamples/assets/question1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WpfExamples/assets/question1.png
--------------------------------------------------------------------------------
/WpfExamples/assets/questionComplex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WpfExamples/assets/questionComplex.png
--------------------------------------------------------------------------------
/WpfExamples/csharp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/WpfExamples/csharp.png
--------------------------------------------------------------------------------
/WpfExamples/readme.md:
--------------------------------------------------------------------------------
1 | # About
2 |
3 | This project shows how to use TaskDialog in a WPF Core application where the main difference between this project and the Windows Form project is that for Windows Forms TaskDialog accepts a control or form while for WPF we need to pass in a IntPtr.
4 |
5 | There are less examples here than in the Windows form code sample but easy enough to add them here, in this project.
6 |
7 | 
8 |
9 | ### Question 1
10 |
11 | 
12 |
13 | ### Question 2
14 |
15 | 
16 |
17 | ### Information
18 |
19 | 
20 |
21 | ### Auto close
22 |
23 | Has a parameter for second to wait.
24 |
25 | 
--------------------------------------------------------------------------------
/assets/DialogsMethods.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/DialogsMethods.png
--------------------------------------------------------------------------------
/assets/Event_16x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Event_16x.png
--------------------------------------------------------------------------------
/assets/Example1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Example1.png
--------------------------------------------------------------------------------
/assets/Example10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Example10.png
--------------------------------------------------------------------------------
/assets/Example11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Example11.png
--------------------------------------------------------------------------------
/assets/Example12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Example12.png
--------------------------------------------------------------------------------
/assets/Example13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Example13.png
--------------------------------------------------------------------------------
/assets/Example14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Example14.png
--------------------------------------------------------------------------------
/assets/Example15.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Example15.png
--------------------------------------------------------------------------------
/assets/Example16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Example16.png
--------------------------------------------------------------------------------
/assets/Example2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Example2.png
--------------------------------------------------------------------------------
/assets/Example3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Example3.png
--------------------------------------------------------------------------------
/assets/Example4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Example4.png
--------------------------------------------------------------------------------
/assets/Example5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Example5.png
--------------------------------------------------------------------------------
/assets/Example6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Example6.png
--------------------------------------------------------------------------------
/assets/Example7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Example7.png
--------------------------------------------------------------------------------
/assets/Example8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Example8.png
--------------------------------------------------------------------------------
/assets/Example9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Example9.png
--------------------------------------------------------------------------------
/assets/Reference.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/Reference.png
--------------------------------------------------------------------------------
/assets/ShowAgain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/ShowAgain.png
--------------------------------------------------------------------------------
/assets/coffee.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/coffee.png
--------------------------------------------------------------------------------
/assets/dataOperations.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/dataOperations.png
--------------------------------------------------------------------------------
/assets/q1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/q1.png
--------------------------------------------------------------------------------
/assets/radio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/radio.png
--------------------------------------------------------------------------------
/assets/title.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/title.png
--------------------------------------------------------------------------------
/assets/title.snag:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/assets/title.snag
--------------------------------------------------------------------------------
/stash.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karenpayneoregon/task-dialog-csharp/82c5c71f318bab4c52af323746b61c27dc20bda8/stash.txt
--------------------------------------------------------------------------------