Skip to content

Commit 958b7f3

Browse files
authored
Merge pull request #1 from akesseler/add-initial-code
The initial implementation.
2 parents 29ad393 + fd008ab commit 958b7f3

32 files changed

+2553
-4
lines changed

LICENSE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
MIT License
1+
# MIT License
22

3-
Copyright (c) 2020 Axel Kesseler
3+
Copyright (c) 2020 plexdata.de
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,44 @@
1-
# Plexdata.Dialogs
2-
A collection of dialog window especially for WFP projects.
1+
<p align="center">
2+
<a href="https://github.com/akesseler/Plexdata.Dialogs/blob/master/LICENSE.md" alt="license">
3+
<img src="https://img.shields.io/github/license/akesseler/Plexdata.Dialogs.svg" />
4+
</a>
5+
<a href="https://github.com/akesseler/Plexdata.Dialogs/releases/latest" alt="latest">
6+
<img src="https://img.shields.io/github/release/akesseler/Plexdata.Dialogs.svg" />
7+
</a>
8+
<a href="https://github.com/akesseler/Plexdata.Dialogs/archive/master.zip" alt="master">
9+
<img src="https://img.shields.io/github/languages/code-size/akesseler/Plexdata.Dialogs.svg" />
10+
</a>
11+
</p>
12+
13+
14+
# Plexdata Dialogs
15+
16+
This library represents a collection of dialog windows especially designed to be used in other
17+
WFP projects.
18+
19+
For the moment, this library supports two dialog windows. The first one is a replacement of the
20+
standard Windows message box. The second one is a open folder dialog window allowing to easily
21+
choose a directory.
22+
23+
## Dialog Box
24+
25+
The _Dialog Box_ represents a simple replacement of the standard Windows message box. This dialog
26+
has been implemented because of the fact that in WPF the standard Windows message box looks pretty
27+
ugly.
28+
29+
## Open Folder Dialog
30+
31+
The _Open Folder Dialog_ instead represents a dialog window allowing users to choose a particular
32+
directory. This dialog has been implemented because of the fact that such a dialog box does not
33+
exist in WPF.
34+
35+
# Library Usage
36+
37+
**First Way**
38+
39+
Download the compiled library from latest release and include and reference it in your project.
40+
41+
**Second Way**
42+
43+
Download all sources and compile them your own way. Thereafter, include the resulting library in
44+
your projects and reference it.

code/src/HISTORY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
3+
**1.0.0**
4+
5+
- Initial draft on _GitHub_.
6+
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
27+
namespace Plexdata.Dialogs
28+
{
29+
[Flags]
30+
public enum DialogButton
31+
{
32+
/// <summary>
33+
/// The dialog box shows an `Ok` button.
34+
/// </summary>
35+
Ok = 1,
36+
37+
/// <summary>
38+
/// The dialog box shows a `Yes` button.
39+
/// </summary>
40+
Yes = 2,
41+
42+
/// <summary>
43+
/// The dialog box shows a `No` button.
44+
/// </summary>
45+
No = 4,
46+
47+
/// <summary>
48+
/// The dialog box shows a `Close` button.
49+
/// </summary>
50+
Close = 8,
51+
52+
/// <summary>
53+
/// The dialog box shows a `Cancel` button.
54+
/// </summary>
55+
Cancel = 16,
56+
57+
/// <summary>
58+
/// The dialog box shows `Ok` and `Close` buttons.
59+
/// </summary>
60+
OkClose = DialogButton.Ok | DialogButton.Close,
61+
62+
/// <summary>
63+
/// The dialog box shows `Ok` and `Cancel` buttons.
64+
/// </summary>
65+
OkCancel = DialogButton.Ok | DialogButton.Cancel,
66+
67+
/// <summary>
68+
/// The dialog box shows `Yes` and `No` buttons.
69+
/// </summary>
70+
YesNo = DialogButton.Yes | DialogButton.No,
71+
72+
/// <summary>
73+
/// The dialog box shows `Yes`, `No` and `Cancel` buttons.
74+
/// </summary>
75+
YesNoCancel = DialogButton.Yes | DialogButton.No | DialogButton.Cancel,
76+
}
77+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
27+
namespace Plexdata.Dialogs
28+
{
29+
public class DialogOption
30+
{
31+
private DialogButton button;
32+
private String label;
33+
34+
public DialogOption()
35+
: this(DialogButton.Ok)
36+
{ }
37+
38+
public DialogOption(DialogButton button)
39+
: this(button, button.ToString())
40+
{ }
41+
42+
public DialogOption(DialogButton button, String label)
43+
{
44+
this.Button = button;
45+
this.Label = label;
46+
}
47+
48+
public DialogButton Button
49+
{
50+
get
51+
{
52+
return this.button;
53+
}
54+
set
55+
{
56+
if ((value & (value - 1)) != 0)
57+
{
58+
throw new ArgumentOutOfRangeException(nameof(this.Button), "Apply only one single button flag.");
59+
}
60+
61+
this.button = value;
62+
}
63+
}
64+
65+
public String Label
66+
{
67+
get
68+
{
69+
return this.label;
70+
}
71+
set
72+
{
73+
if (String.IsNullOrWhiteSpace(value))
74+
{
75+
throw new ArgumentOutOfRangeException(nameof(this.Button), "The label may not be null, empty or consists only of white spaces.");
76+
}
77+
78+
this.label = value.Trim();
79+
}
80+
}
81+
}
82+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
namespace Plexdata.Dialogs
26+
{
27+
public enum DialogResult
28+
{
29+
//
30+
// Summary:
31+
// The message box returns no result.
32+
None = 0,
33+
//
34+
// Summary:
35+
// The result value of the message box is OK.
36+
OK = 1,
37+
38+
Close = 2,
39+
//
40+
// Summary:
41+
// The result value of the message box is Cancel.
42+
Cancel = 3,
43+
//
44+
// Summary:
45+
// The result value of the message box is Yes.
46+
Yes = 4,
47+
//
48+
// Summary:
49+
// The result value of the message box is No.
50+
No = 5
51+
}
52+
}

0 commit comments

Comments
 (0)