-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[WIP] Metro/MessageDialogs V2 #785
Conversation
<ApplicationRevision>0</ApplicationRevision> | ||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion> | ||
<UseApplicationTrust>false</UseApplicationTrust> | ||
<BootstrapperEnabled>true</BootstrapperEnabled> |
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.
Mental note to self: Remove this.
…or the general public later.
… is slightly bigger.
…ion of SetMessage.
…argin between the buttons in the MessageDialog.
Will there be any way of showing message dialog with calling static method, just like MessageBox.Show? I can't figure a elegant way how to use this applying mvvm since I don't want to access instance of my view in viewmodel class... |
@mcsdodo Interesting question actually. In my own MVVM framework, I have something called services. I have one service called From what my implementation, I did:
I don't know how that translates to other MVVM frameworks though. I did borrow the Services idea from another framework. A MessageBox.Show would be interesting to do, however. Probably won't do that until later revisions though. |
@Amrykid . I work with MEF and do quite the same like you for displaying the message box. But I have a problem with modal dialogs. I tried to search for the current active window in order to display the message box on that window Application.Current.Windows.OfType<Window>().SingleOrDefault(i => i.IsActive) as MetroWindow; It is working unless i do not minimize the program. If I have a long running operation and want to notify the user after completion and the user minimizes the program then the code above will return null. Do you have any suggestion how to find the active window? |
@xxMUROxx That's an interesting idea. I'll add that for when a window is minimized, it will flash in the taskbar. EDIT: |
@topvis The overlay makes it more or less to a modal dialog, you can't click anything else in the application until you close the dialog |
@flagbug, a modal dialog not only prevents user from clicking anything else in the application but also holds the program until the modal dialog is closed. What I'm missing is the latter. My code to handle window closing event is as below. The window will just close without waiting for user to click yes or no. I assume it's because the message dialog is opened "Async" so it doesn't hold other things as what modal dialog does.
|
@topvis Can you use 'await'? |
@topvis or use .Wait() |
@flagbug I tried Dialogs.MetroWindowDialogExtensions.ShowMessageAsync(....).Wait() Furthermore, it would be good to have more options for the button style than just "yes and no". e.g., to remind user to save changes would need "yes, no and cancel". |
Hm, I'm not yet familiar with the message boxes... summoning @Amrykid , maybe you can help here? |
Using Wait() in this scenario wouldn't help very much since Dialogs in this implementation are controls inside of the Window. Any blocking function will cause the window to lock, making it useless. I'm sure I'll come up with a way to do this, however. Off-topic: By the way, ShowMessageAsync is an extension method. All you have to do is
and call it like this:
|
@topvis Found a solution for your issue. It's in C# but it is VERY VERY straight-forward to convert to VB.NET. It uses 'async/await' (built-into .NET 4.5 or you can use it in .NET 4.0 if you have the AsyncCTP installed). It can also be converted to normal Tasks by using '.ContinueWith' instead of 'await'.
|
@Amrykid I tried your method. It works. As you said, I have to install the AsyncCTP through NuGet because I'm on .NET 4.0. Thanks! Do you think it's a good idea to include more button styles like yes/no/cancel; ok/cancel etc. that are defined in MessageBoxButton enum? Here is another idea, to make the dialog system more abstract, how about allow user to put a UserControl wherever on the "overlay" layer after calling "ShowOverlayAsync"? |
@topvis Your first idea is already there. You can change what the Affirmative and Negative button say. Your second idea is already there as well. Define a 'SimpleDialog' and place your content in it. |
@Amrykid If I use the "SimpleDialog", is there any way to show the Affirmative and Negative button? If I define my own buttons (Yes/No/Cancel), how can I get which button the user clicks on? |
Nope, you'll have to handle all that logic yourself. What I would do is add all of the buttons to your dialog and handle all of their clicked events. When a button is clicked, unhook every button handler and whatever button was clicked is your result. To show your dialog, call ShowDialogAsync and to hide it... well, HideDialogAsync. |
@topvis Did ^ answer your question? |
hello, thx for this dialog windows. do you think it's possible to add Dialog Button: in the ShowMessageSync ? |
@dairentech At this time, you can only have two buttons. You can change the OK button to yes by using |
Ok as you wish Thx for the answer and well done for this, i like this De : Amrykid [mailto:notifications@github.com] @dairentechhttps://github.com/dairentech At this time, you can only have two buttons. You can change the OK button to yes by using window.MetroDialogOptions.AffirmativeButtonText. The same for the Cancel button but with NegativeButtonText. — Aucun virus trouvé dans ce message. |
@dairentech Thank you for the compliment. A third button will be implemented in the next revision. |
@Amrykid You did answer my question. But it's a little complicated for me as I'm still new to WPF and async stuff. I implemented the dialog in a different way which can also meet my requirement. I just created a Window to mimic your dialog style and show it as a modal dialog by calling |
sorry to bother you but I wanted to know one thing: MessageDialog has been used for a window. how I could use the Dialog controls that you create? De : Amrykid [mailto:notifications@github.com] @dairentechhttps://github.com/dairentech At this time, you can only have two buttons. You can change the OK button to yes by using window.MetroDialogOptions.AffirmativeButtonText. The same for the Cancel button but with NegativeButtonText. — Aucun virus trouvé dans ce message. |
@dairentech Since the Dialog is just a control, you could make your own window and put the dialog inside of it. That can be your dialog. |
I tried this but if i write msg.show() with the dialog sync, i see the dialog but the programm continue to run and run the login windows And if I write msg.showdialog(), I see the windows but no dialog metro… I’m not a super c#/WPF guy ☺ ☺ De : Amrykid [mailto:notifications@github.com] @dairentechhttps://github.com/dairentech Since the Dialog is just a control, you could make your own window and put the dialog inside of it. That can be your dialog. — Aucun virus trouvé dans ce message. |
You're going to have to jump through hoops in order to get your MainWindow to show after the Dialog closes. You're better off showing your main window and using the dialog inside of it before you load any content. |
Ok... so I really need some guidance as a starting point for this version of MetroDialogs. :| I managed to create a custom MetroDialog with login credentials based on the #550 PR and it worked somehow great [not exactly the way I really intended] so I decided to give this version o shot; but I'm stuck. I can't find a way to start creating a custom design for the content of a MetroDialog. This is screenshot of my custom MetroDialog (as you have guessed, the login button is on the second step): If I have to create another project, what type should I chose? Class Library or Custom Control? :( Somebody, please do enlighten me. :( |
@robertstefan Relax my friend. It is easy as pie. Depending if you want to make your own dialog or stick your controls into a 'SimpleDialog'. If you want to make your own dialog...
Below is how I created the ProgressDialog using the exact same process...
Once you have your dialog defined, you can show it in a window by using |
Sweet! I like it where it goes. I simply love this library. And all you guys for the good work. :) 👍 I have one more question: there should be no problem if I show a BaseMetroDialog and after the user clicks the "next" button to close it and show a dialog with the progress bar, right? Edit: The button seems to lose the close behavior on the custom window. Am I missing something [the code is exactly as you specified]? |
@robertstefan Check out the metro demo. The MessageDialog demo code and the ProgressDialog demo code show them one after enough. By default, any button in a Metro Dialog grabs the 'SquareButton' style. That could be your issue. |
I am trying to make the dialog system very abstract so that a user can plug in their own dialogs. A major revision of #764.
TODO List:
Screenshots
Message Dialog
Progress Dialog
Note the Indeterminate
MetroProgressBar
on the bottom of the dialog. TheProgressDialog
is inspired by a similar construct in Github for Windows.Simple Dialog
Dark
Breaking Changes
MetroWindow
to extension methods. This was to remove clutter and ugly code from MetroWindow.cs.