-
Notifications
You must be signed in to change notification settings - Fork 992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement the Windows Task Dialog #1133
Conversation
Thank you, we'll start looking at it. Just a heads up, before a merge the PR will need to be tidied up:
|
Hi @RussKie, I rebased the PR with a single commit on top of master, as that was the easiest way. |
Champion! |
…etrieve the last error (and presumably the function also doesn't set it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first sweep of reviews, I have probably missed things and may call them later (apologies in advance).
Overall it is quite impressive 👍
-
A number of comments of stylistic nature, I am not a big fan of line wrapping. I don't think we need to constrain ourselves to 80 char wide lines.
Here's how it looks on my screen:
Granted not everyone is blessed with a 4K screen, but ultra-wide monitors are far from being rare these days. -
All exceptions must be moved to resources and all public API must have valid xml-docs. @merriemcgaw / @OliaG - I suppose we need to help here, please advise.
-
There are number of personal gists referenced in the code. We'll need to either remove them or migrate into docs (?). @merriemcgaw / @OliaG - please advise.
The big question, of course, is how do we test this. We'll need unit- and integration-level tests.
Have you given any thought to this?
Thank you
src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.cs
Outdated
Show resolved
Hide resolved
/// Note: The dialog will not show until this handler returns (even if the | ||
/// handler would run the message loop). | ||
/// </remarks> | ||
public event EventHandler Opened; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Would it be more appropriate to call this Opening
since it is yet to actually open? ...Or Created
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc: @OliaG
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the current event model is illustrated in section "Event Cycle" in the initial post of #146.
(Also note that because this is part of the public API, it would also need to be changed in the API Proposal.)
Currently, on the TaskDialog
there are events Opened
+Shown
(before and after show), and Closing
+Closed
(before and after close).
The Opened
event could be renamed to Opening
, but it is called at the same time with TaskDialogPage.Created
, which means we might also need to rename that one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For public surface area, @RussKie I am inclined to elevate any concerns to @OliaG and @terrajobst for API Review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have had a chat with @OliaG about API, and we have a certain freedom and discretion to exercise.
A review has been scheduled but it is some time away.
src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogPage.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogProgressBar.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogRadioButton.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogRadioButton.cs
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/WindowSubclassHandler.cs
Outdated
Show resolved
Hide resolved
…bclass of WindowSubclassHandler, use a separate virtual method for that. Otherwise, when another subclass overrides WndProc(), its exceptions would not be caught.
-Use longer lines -Use the default 4 instead of 8 spaces indentation after a line wrap -Add braces for single-statement blocks - Use "//" instead of "////" comments -Remove explicit base() calls
Co-Authored-By: Igor Velikorossov <RussKie@users.noreply.github.com>
Hi @RussKie, I have applied some of the changes and will do the remaining ones later. Regarding testing, I must admit that I do not have much experience with unit/integration tests of GUI frameworks. I will probably need to look at how existing tests are done, and check what could be applied to the task dialog. Thank you! |
There are few things we'll need to have before we can merge it:
If we ask nicely @hughbe, he may be able to help with writing tests. |
-Rename TaskDialog.DialogIsShown to .IsShown. -Rename TaskDialog.HandleAvailable to .IsHandleCreated.
…nsistency with Bind() and Unbind().
This ensures the task dialog con be used when you call Application.EnableVisualStyles() without having to add a manifest that enables common controls v6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one fine piece of software craftmanship! 🎉
Few nits. My eyes are aching after reviewing 10K lines of code...
src/System.Windows.Forms/src/System/Windows/Forms/WindowSubclassHandler.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogPage.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.cs
Outdated
Show resolved
Hide resolved
The dialog will close immediately before navigation is finished.
Probably, but I don't see a reason to disallow closing the dialog in that case; it might complicate implementation of navigation for the user when they have to deal with the issue that they cannot call |
Maybe worth add a remark to the Close docs stating this (if it's stating this).
|
…t that has been removed.
…ssHandler. This is to not rely on the implementation detail that Marshal.GetFunctionPointerForDelegate() returns the same pointer for the same delegate instance when called multiple times.
The docs of Thank you! |
I'm not @shanselman, and I'm not on a stage in front of hundreds of developers, but I'm merging this! |
Thanks a lot! 🎉 |
This is so exciting for WinForms developers around the world. @OliaG - time to brag about it for the next preview of .NET 5? |
As an update, with VB support for WinForms announced for .NET 5, I have added a VB.NET project to the I had to make a some modifications to the VB code, because VB doesn't seem to support a number of recent C# language features (for example, pattern matching, local functions, async streams, collection initializer for existing collections within an object initializer), but it should have the same behavior. |
@kpreisser thanks for the VB demo and doing this, besides cloning this Repos and running VS 2019 Version 16.6.0 Preview 6.0 what else do I need to do to run the demo? |
You need to have .NET 5.0 Preview 4 installed, that's where we merged it. Otherwise you need to build the source, and replace assemblies. |
@RussKie I think I do
If you mean the runtime, only 3 is available. |
Then you should all be set to run the demo |
@paul1956 If the It could be that your version ( |
@kpreisser thanks that fixed it. |
This PR implements the Windows Task Dialog as described in #146.
Fixes #146
(Background info: This PR is based on my earlier implementation in the TaskDialog repo.)
Demo App
I have created a demo app (C# and VB) that consists of a Form with buttons, showing various Task Dialog scenarios. You can find it here: https://github.com/kpreisser/TaskDialogDemo
This app referencesSystem.Windows.Forms.dll
andSystem.Windows.Forms.Primitives.dll
built from this PR; you can simply place the app's repo folder near thewinforms
repo folder.Known TODOs
Implementation Notes
TaskDialog.ShowDialog()
will only work if you have previously calledApplication.EnableVisualStyles()
(or your app uses a manifest that enables common controls v6).Otherwise, it will fail with an
InvalidOperationException
caused by anEntryPointNotFoundException
.TaskDialog.ShowDialog()
and specifying an owner window, other windows of the current UI thread will not be disabled.This is different to the
MessageBox.Show()
behavior which also disables the other, non-owner windows (but they don't behave the same as the owner window, because when you click on them, the message box is not brought to the foreground; but clicking on the owner window brings the message box into foreground).TaskDialog.Handle
property, in theory a user could send task dialog messages directly to the dialog and bypass the .NET implementation.The implementation is not protected against that case, but this should be OK since the user cannot expect the implementation to handle that.
Documentation/src/System/Windows/Forms/TaskDialog
folder of this PR, including C++ samle code to reproduce them.