|
| 1 | +/* |
| 2 | +* MIT License |
| 3 | +* |
| 4 | +* Copyright (c) 2020 plexdata.de |
| 5 | +* |
| 6 | +* Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | +* of this software and associated documentation files (the "Software"), to deal |
| 8 | +* in the Software without restriction, including without limitation the rights |
| 9 | +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | +* copies of the Software, and to permit persons to whom the Software is |
| 11 | +* furnished to do so, subject to the following conditions: |
| 12 | +* |
| 13 | +* The above copyright notice and this permission notice shall be included in all |
| 14 | +* copies or substantial portions of the Software. |
| 15 | +* |
| 16 | +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | +* SOFTWARE. |
| 23 | +*/ |
| 24 | + |
| 25 | +using System; |
| 26 | +using System.Windows; |
| 27 | +using System.Windows.Input; |
| 28 | + |
| 29 | +namespace Plexdata.Dialogs |
| 30 | +{ |
| 31 | + public static class DialogBox |
| 32 | + { |
| 33 | + public static DialogResult Show(String message) |
| 34 | + { |
| 35 | + return DialogBox.Show((Window)null, message); |
| 36 | + } |
| 37 | + |
| 38 | + public static DialogResult Show(Window owner, String message) |
| 39 | + { |
| 40 | + return DialogBox.Show(owner, message, null); |
| 41 | + } |
| 42 | + |
| 43 | + public static DialogResult Show(String message, DialogSymbol symbol) |
| 44 | + { |
| 45 | + return DialogBox.Show((Window)null, message, symbol); |
| 46 | + } |
| 47 | + |
| 48 | + public static DialogResult Show(Window owner, String message, DialogSymbol symbol) |
| 49 | + { |
| 50 | + return DialogBox.Show(owner, message, owner?.Title, symbol, DialogButton.Close); |
| 51 | + } |
| 52 | + |
| 53 | + public static DialogResult Show(String message, String caption) |
| 54 | + { |
| 55 | + return DialogBox.Show(null, message, caption); |
| 56 | + } |
| 57 | + |
| 58 | + public static DialogResult Show(Window owner, String message, String caption) |
| 59 | + { |
| 60 | + return DialogBox.Show(owner, message, caption, DialogSymbol.None); |
| 61 | + } |
| 62 | + |
| 63 | + public static DialogResult Show(String message, String caption, DialogSymbol symbol) |
| 64 | + { |
| 65 | + return DialogBox.Show(null, message, caption, symbol); |
| 66 | + } |
| 67 | + |
| 68 | + public static DialogResult Show(Window owner, String message, String caption, DialogSymbol symbol) |
| 69 | + { |
| 70 | + return DialogBox.Show(owner, message, caption, symbol, DialogButton.Close); |
| 71 | + } |
| 72 | + |
| 73 | + public static DialogResult Show(String message, String caption, DialogButton buttons) |
| 74 | + { |
| 75 | + return DialogBox.Show(null, message, caption, DialogSymbol.None, buttons, null); |
| 76 | + } |
| 77 | + |
| 78 | + public static DialogResult Show(String message, String caption, DialogButton buttons, params DialogOption[] options) |
| 79 | + { |
| 80 | + return DialogBox.Show(null, message, caption, DialogSymbol.None, buttons, options); |
| 81 | + } |
| 82 | + |
| 83 | + public static DialogResult Show(Window owner, String message, String caption, DialogButton buttons) |
| 84 | + { |
| 85 | + return DialogBox.Show(owner, message, caption, DialogSymbol.None, buttons, null); |
| 86 | + } |
| 87 | + |
| 88 | + public static DialogResult Show(Window owner, String message, String caption, DialogButton buttons, params DialogOption[] options) |
| 89 | + { |
| 90 | + return DialogBox.Show(owner, message, caption, DialogSymbol.None, buttons, options); |
| 91 | + } |
| 92 | + |
| 93 | + public static DialogResult Show(String message, String caption, DialogSymbol symbol, DialogButton buttons) |
| 94 | + { |
| 95 | + return DialogBox.Show(null, message, caption, symbol, buttons, null); |
| 96 | + } |
| 97 | + |
| 98 | + public static DialogResult Show(String message, String caption, DialogSymbol symbol, DialogButton buttons, params DialogOption[] options) |
| 99 | + { |
| 100 | + return DialogBox.Show(null, message, caption, symbol, buttons, options); |
| 101 | + } |
| 102 | + |
| 103 | + public static DialogResult Show(Window owner, String message, String caption, DialogSymbol symbol, DialogButton buttons) |
| 104 | + { |
| 105 | + return DialogBox.Show(owner, message, caption, symbol, buttons, null); |
| 106 | + } |
| 107 | + |
| 108 | + public static DialogResult Show(Window owner, String message, String caption, DialogSymbol symbol, DialogButton buttons, params DialogOption[] options) |
| 109 | + { |
| 110 | + Mouse.OverrideCursor = null; |
| 111 | + |
| 112 | + Internal.DialogBox dialog = new Internal.DialogBox(owner, message, caption, buttons, symbol, options); |
| 113 | + |
| 114 | + dialog.ShowDialog(); |
| 115 | + |
| 116 | + return dialog.Result; |
| 117 | + } |
| 118 | + } |
| 119 | +} |
0 commit comments