• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コミットメタ情報

リビジョンc8903065d46bb49f61db628db71d9542ec950e82 (tree)
日時2022-07-24 18:57:35
作者yoshy <yoshy.org.bitbucket@gz.j...>
コミッターyoshy

ログメッセージ

[MOD] Dialog関連機能の名前空間を変更
[ADD] 汎用ダイアログ機能を追加

変更サマリ

差分

--- a/Adaptor/Boundary/Gateway/UI/IShowDialogProxy.cs
+++ b/Adaptor/Boundary/Gateway/UI/Dialog/IShowDialogProxy.cs
@@ -1,6 +1,6 @@
11 using Prism.Services.Dialogs;
22
3-namespace CleanAuLait.Adaptor.Boundary.Gateway.UI
3+namespace CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog
44 {
55 public interface IShowDialogProxy
66 {
--- /dev/null
+++ b/Adaptor/Boundary/Gateway/UI/Dialog/IUniversalDialogProxy.cs
@@ -0,0 +1,24 @@
1+using CleanAuLait.Adaptor.Gateway.ViewModel.Dialog;
2+using Prism.Services.Dialogs;
3+using System.Windows;
4+
5+namespace CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog
6+{
7+ public interface IUniversalDialogProxy
8+ {
9+ IDialogResult ShowDialog(
10+ string caption, string text, MessageBoxImage icon,
11+ UniversalDialogButtons buttons);
12+
13+ IDialogResult ShowOkDialog(
14+ string caption, string text, MessageBoxImage image);
15+ IDialogResult ShowOkCancelDialog(
16+ string caption, string text, MessageBoxImage image);
17+ IDialogResult ShowYesNoDialog(
18+ string caption, string text, MessageBoxImage image);
19+ IDialogResult ShowYesNoCancelDialog(
20+ string caption, string text, MessageBoxImage image);
21+ IDialogResult ShowAbortRetryIgnoreDialog(
22+ string caption, string text, MessageBoxImage image);
23+ }
24+}
--- a/Adaptor/Boundary/Gateway/UI/IUserDialogProxy.cs
+++ b/Adaptor/Boundary/Gateway/UI/Dialog/IUserDialogProxy.cs
@@ -1,6 +1,6 @@
1-using CleanAuLait.Adaptor.Gateway.UI;
1+using CleanAuLait.Adaptor.Gateway.UI.Dialog;
22
3-namespace CleanAuLait.Adaptor.Boundary.Gateway.UI
3+namespace CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog
44 {
55 public interface IUserDialogProxy
66 {
--- /dev/null
+++ b/Adaptor/Boundary/Gateway/UI/Dialog/Shell/ICommonFolderDialogProxy.cs
@@ -0,0 +1,9 @@
1+using CleanAuLait.Adaptor.Gateway.UI.Dialog.Shell.Parameters;
2+
3+namespace CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog.Shell
4+{
5+ public interface ICommonFolderDialogProxy
6+ {
7+ bool ShowDialog(CommonFolderDialogParameters settings);
8+ }
9+}
\ No newline at end of file
--- a/Adaptor/Boundary/Gateway/UI/Shell/ICommonOpenLoadFileDialogProxy.cs
+++ b/Adaptor/Boundary/Gateway/UI/Dialog/Shell/ICommonOpenLoadFileDialogProxy.cs
@@ -1,6 +1,6 @@
1-using CleanAuLait.Adaptor.Gateway.UI.Shell.Parameters;
1+using CleanAuLait.Adaptor.Gateway.UI.Dialog.Shell.Parameters;
22
3-namespace CleanAuLait.Adaptor.Boundary.Gateway.UI.Shell
3+namespace CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog.Shell
44 {
55 public interface ICommonOpenLoadFileDialogProxy
66 {
--- a/Adaptor/Boundary/Gateway/UI/Shell/ICommonFolderDialogProxy.cs
+++ /dev/null
@@ -1,9 +0,0 @@
1-using CleanAuLait.Adaptor.Gateway.UI.Shell.Parameters;
2-
3-namespace CleanAuLait.Adaptor.Boundary.Gateway.UI.Shell
4-{
5- public interface ICommonFolderDialogProxy
6- {
7- bool ShowDialog(CommonFolderDialogParameters settings);
8- }
9-}
\ No newline at end of file
--- /dev/null
+++ b/Adaptor/Boundary/Gateway/ViewModel/Dialog/IUniversalDialogViewModel.cs
@@ -0,0 +1,43 @@
1+using Prism.Services.Dialogs;
2+using Reactive.Bindings;
3+using System.Windows;
4+using System.Windows.Media;
5+
6+namespace CleanAuLait.Adaptor.Boundary.Gateway.ViewModel.Dialog
7+{
8+ public interface IUniversalDialogViewModel : IDialogAware
9+ {
10+ ReactivePropertySlim<ImageSource> Icon { get; }
11+ ReactivePropertySlim<string> Text { get; }
12+
13+ ReactivePropertySlim<string> CaptionButton1 { get; }
14+ ReactivePropertySlim<string> CaptionButton2 { get; }
15+ ReactivePropertySlim<string> CaptionButton3 { get; }
16+ ReactivePropertySlim<string> CaptionButton4 { get; }
17+ ReactivePropertySlim<string> CaptionButton5 { get; }
18+
19+ ReactivePropertySlim<bool> IsDefaultButton1 { get; }
20+ ReactivePropertySlim<bool> IsDefaultButton2 { get; }
21+ ReactivePropertySlim<bool> IsDefaultButton3 { get; }
22+ ReactivePropertySlim<bool> IsDefaultButton4 { get; }
23+ ReactivePropertySlim<bool> IsDefaultButton5 { get; }
24+
25+ ReactivePropertySlim<bool> IsCancelButton1 { get; }
26+ ReactivePropertySlim<bool> IsCancelButton2 { get; }
27+ ReactivePropertySlim<bool> IsCancelButton3 { get; }
28+ ReactivePropertySlim<bool> IsCancelButton4 { get; }
29+ ReactivePropertySlim<bool> IsCancelButton5 { get; }
30+
31+ ReactivePropertySlim<Visibility> VisibilityButton1 { get; }
32+ ReactivePropertySlim<Visibility> VisibilityButton2 { get; }
33+ ReactivePropertySlim<Visibility> VisibilityButton3 { get; }
34+ ReactivePropertySlim<Visibility> VisibilityButton4 { get; }
35+ ReactivePropertySlim<Visibility> VisibilityButton5 { get; }
36+
37+ ReactiveCommand CommandButton1 { get; }
38+ ReactiveCommand CommandButton2 { get; }
39+ ReactiveCommand CommandButton3 { get; }
40+ ReactiveCommand CommandButton4 { get; }
41+ ReactiveCommand CommandButton5 { get; }
42+ }
43+}
--- a/Adaptor/Controller/Handler/AbstractErrorHandler.cs
+++ b/Adaptor/Controller/Handler/AbstractErrorHandler.cs
@@ -1,4 +1,4 @@
1-using CleanAuLait.Adaptor.Boundary.Gateway.UI;
1+using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog;
22 using CleanAuLait.UseCase.Request;
33 using CleanAuLait.UseCase.Response;
44
--- a/Adaptor/Controller/Handler/AsyncSimpleUserDialogErrorHandler.cs
+++ b/Adaptor/Controller/Handler/AsyncSimpleUserDialogErrorHandler.cs
@@ -1,6 +1,6 @@
11 using CleanAuLait.Adaptor.Boundary.Controller;
22 using CleanAuLait.Adaptor.Boundary.Controller.Handler;
3-using CleanAuLait.Adaptor.Boundary.Gateway.UI;
3+using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog;
44 using CleanAuLait.UseCase.Request;
55 using CleanAuLait.UseCase.Response;
66 using NLog;
--- a/Adaptor/Controller/Handler/SimpleErrorHandler.cs
+++ b/Adaptor/Controller/Handler/SimpleErrorHandler.cs
@@ -1,6 +1,6 @@
11 using CleanAuLait.Adaptor.Boundary.Controller;
22 using CleanAuLait.Adaptor.Boundary.Controller.Handler;
3-using CleanAuLait.Adaptor.Boundary.Gateway.UI;
3+using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog;
44 using CleanAuLait.UseCase.Request;
55 using CleanAuLait.UseCase.Response;
66 using NLog;
--- a/Adaptor/Gateway/UI/AbstractShowDialogProxy.cs
+++ b/Adaptor/Gateway/UI/Dialog/AbstractShowDialogProxy.cs
@@ -1,6 +1,6 @@
11 using Prism.Services.Dialogs;
22
3-namespace CleanAuLait.Adaptor.Gateway.UI
3+namespace CleanAuLait.Adaptor.Gateway.UI.Dialog
44 {
55 public abstract class AbstractShowDialogProxy
66 {
@@ -15,7 +15,7 @@ namespace CleanAuLait.Adaptor.Gateway.UI
1515 {
1616 IDialogResult res = new DialogResult(ButtonResult.Cancel);
1717
18- this.service.ShowDialog(name, dlgParams, r => res = r);
18+ service.ShowDialog(name, dlgParams, r => res = r);
1919
2020 return res;
2121 }
--- a/Adaptor/Gateway/UI/DlgInfo.cs
+++ b/Adaptor/Gateway/UI/Dialog/DlgInfo.cs
@@ -1,4 +1,4 @@
1-namespace CleanAuLait.Adaptor.Gateway.UI
1+namespace CleanAuLait.Adaptor.Gateway.UI.Dialog
22 {
33 public class DlgInfo
44 {
--- a/Adaptor/Gateway/UI/Shell/CommonFolderDialogProxy.cs
+++ b/Adaptor/Gateway/UI/Dialog/Shell/CommonFolderDialogProxy.cs
@@ -1,8 +1,8 @@
1-using CleanAuLait.Adaptor.Boundary.Gateway.UI.Shell;
2-using CleanAuLait.Adaptor.Gateway.UI.Shell.Parameters;
1+using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog.Shell;
2+using CleanAuLait.Adaptor.Gateway.UI.Dialog.Shell.Parameters;
33 using Microsoft.WindowsAPICodePack.Dialogs;
44
5-namespace CleanAuLait.Adaptor.Gateway.UI.Shell
5+namespace CleanAuLait.Adaptor.Gateway.UI.Dialog.Shell
66 {
77 public class CommonFolderDialogProxy : ICommonFolderDialogProxy
88 {
--- a/Adaptor/Gateway/UI/Shell/CommonOpenLoadFileDialogDialogProxy.cs
+++ b/Adaptor/Gateway/UI/Dialog/Shell/CommonOpenLoadFileDialogDialogProxy.cs
@@ -1,8 +1,8 @@
1-using CleanAuLait.Adaptor.Boundary.Gateway.UI.Shell;
2-using CleanAuLait.Adaptor.Gateway.UI.Shell.Parameters;
1+using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog.Shell;
2+using CleanAuLait.Adaptor.Gateway.UI.Dialog.Shell.Parameters;
33 using Microsoft.WindowsAPICodePack.Dialogs;
44
5-namespace CleanAuLait.Adaptor.Gateway.UI.Shell
5+namespace CleanAuLait.Adaptor.Gateway.UI.Dialog.Shell
66 {
77 public class CommonOpenLoadFileDialogProxy : ICommonOpenLoadFileDialogProxy
88 {
--- a/Adaptor/Gateway/UI/Shell/Parameters/AbstractCommonDialogParameters.cs
+++ b/Adaptor/Gateway/UI/Dialog/Shell/Parameters/AbstractCommonDialogParameters.cs
@@ -1,4 +1,4 @@
1-namespace CleanAuLait.Adaptor.Gateway.UI.Shell.Parameters
1+namespace CleanAuLait.Adaptor.Gateway.UI.Dialog.Shell.Parameters
22 {
33 public abstract class AbstractCommonDialogParameters
44 {
--- a/Adaptor/Gateway/UI/Shell/Parameters/AbstractCommonFileDialogParameters.cs
+++ b/Adaptor/Gateway/UI/Dialog/Shell/Parameters/AbstractCommonFileDialogParameters.cs
@@ -1,4 +1,4 @@
1-namespace CleanAuLait.Adaptor.Gateway.UI.Shell.Parameters
1+namespace CleanAuLait.Adaptor.Gateway.UI.Dialog.Shell.Parameters
22 {
33 public abstract class AbstractCommonFileDialogParameters : AbstractCommonDialogParameters
44 {
--- a/Adaptor/Gateway/UI/Shell/Parameters/AbstractOpenFilteredFileDialogParameters.cs
+++ b/Adaptor/Gateway/UI/Dialog/Shell/Parameters/AbstractOpenFilteredFileDialogParameters.cs
@@ -1,6 +1,6 @@
11 using Microsoft.WindowsAPICodePack.Dialogs;
22
3-namespace CleanAuLait.Adaptor.Gateway.UI.Shell.Parameters
3+namespace CleanAuLait.Adaptor.Gateway.UI.Dialog.Shell.Parameters
44 {
55 public class AbstractOpenFilteredFileDialogParameters : AbstractCommonFileDialogParameters
66 {
--- a/Adaptor/Gateway/UI/Shell/Parameters/CommonFolderDialogParameters.cs
+++ b/Adaptor/Gateway/UI/Dialog/Shell/Parameters/CommonFolderDialogParameters.cs
@@ -1,4 +1,4 @@
1-namespace CleanAuLait.Adaptor.Gateway.UI.Shell.Parameters
1+namespace CleanAuLait.Adaptor.Gateway.UI.Dialog.Shell.Parameters
22 {
33 public class CommonFolderDialogParameters : AbstractOpenFilteredFileDialogParameters
44 {
--- a/Adaptor/Gateway/UI/Shell/Parameters/CommonOpenLoadFileDialogParameters.cs
+++ b/Adaptor/Gateway/UI/Dialog/Shell/Parameters/CommonOpenLoadFileDialogParameters.cs
@@ -1,4 +1,4 @@
1-namespace CleanAuLait.Adaptor.Gateway.UI.Shell.Parameters
1+namespace CleanAuLait.Adaptor.Gateway.UI.Dialog.Shell.Parameters
22 {
33 public class CommonOpenLoadFileDialogParameters : AbstractOpenFilteredFileDialogParameters
44 {
--- a/Adaptor/Gateway/UI/Shell/Parameters/CommonOpenSaveFileDialogParameters.cs
+++ b/Adaptor/Gateway/UI/Dialog/Shell/Parameters/CommonOpenSaveFileDialogParameters.cs
@@ -1,4 +1,4 @@
1-namespace CleanAuLait.Adaptor.Gateway.UI.Shell.Parameters
1+namespace CleanAuLait.Adaptor.Gateway.UI.Dialog.Shell.Parameters
22 {
33 public class CommonOpenSaveFileDialogParameters : AbstractOpenFilteredFileDialogParameters
44 {
--- /dev/null
+++ b/Adaptor/Gateway/UI/Dialog/UniversalDialogProxy.cs
@@ -0,0 +1,157 @@
1+using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog;
2+using CleanAuLait.Adaptor.Gateway.UI.Dialog;
3+using CleanAuLait.Adaptor.Gateway.ViewModel.Dialog;
4+using Prism.Services.Dialogs;
5+using System.Drawing;
6+using System.Media;
7+using System.Windows;
8+using System.Windows.Interop;
9+using System.Windows.Media;
10+using System.Windows.Media.Imaging;
11+
12+namespace FolderCategorizer2.Adaptor.Gateway.Dialog
13+{
14+ internal class UniversalDialogProxy : AbstractShowDialogProxy, IUniversalDialogProxy
15+ {
16+ public static readonly string PARAM_KEY_DIALOG_OPTIONS = "dialogOptions";
17+
18+ private const string DIALOG_NAME = "UniversalDialog";
19+
20+ public UniversalDialogProxy(
21+ IDialogService service
22+ ) : base(service)
23+ {
24+ }
25+
26+ public IDialogResult ShowOkDialog(
27+ string caption, string text, MessageBoxImage image)
28+ {
29+ UniversalDialogButtons buttons = new(
30+ new UniversalDialogButtonInfo[]
31+ {
32+ new UniversalDialogButtonInfo("OK (_O)", ButtonResult.OK).SetDefault().SetCancel(),
33+ }
34+ );
35+
36+ return ShowDialog(caption, text, image, buttons);
37+ }
38+
39+ public IDialogResult ShowOkCancelDialog(
40+ string caption, string text, MessageBoxImage image)
41+ {
42+ UniversalDialogButtons buttons = new(
43+ new UniversalDialogButtonInfo[]
44+ {
45+ new UniversalDialogButtonInfo("OK (_O)", ButtonResult.OK).SetDefault(),
46+ new UniversalDialogButtonInfo("Cancel (_C)", ButtonResult.Cancel).SetCancel(),
47+ }
48+ );
49+
50+ return ShowDialog(caption, text, image, buttons);
51+ }
52+
53+ public IDialogResult ShowYesNoDialog(
54+ string caption, string text, MessageBoxImage image)
55+ {
56+ UniversalDialogButtons buttons = new(
57+ new UniversalDialogButtonInfo[]
58+ {
59+ new UniversalDialogButtonInfo("Yes (_Y)", ButtonResult.Yes),
60+ new UniversalDialogButtonInfo("No (_N)", ButtonResult.No).SetCancel(),
61+ }
62+ );
63+
64+ return ShowDialog(caption, text, image, buttons);
65+ }
66+
67+ public IDialogResult ShowYesNoCancelDialog(
68+ string caption, string text, MessageBoxImage image)
69+ {
70+ UniversalDialogButtons buttons = new(
71+ new UniversalDialogButtonInfo[]
72+ {
73+ new UniversalDialogButtonInfo("Yes (_Y)", ButtonResult.Yes),
74+ new UniversalDialogButtonInfo("No (_N)", ButtonResult.No),
75+ new UniversalDialogButtonInfo("Cancel (_C)", ButtonResult.Cancel).SetCancel(),
76+ }
77+ );
78+
79+ return ShowDialog(caption, text, image, buttons);
80+ }
81+
82+ public IDialogResult ShowAbortRetryIgnoreDialog(
83+ string caption, string text, MessageBoxImage image)
84+ {
85+ UniversalDialogButtons buttons = new(
86+ new UniversalDialogButtonInfo[]
87+ {
88+ new UniversalDialogButtonInfo("Abort (_A)", ButtonResult.Abort).SetCancel(),
89+ new UniversalDialogButtonInfo("Retry (_R)", ButtonResult.Retry),
90+ new UniversalDialogButtonInfo("Ignore (_I)", ButtonResult.Ignore),
91+ }
92+ );
93+
94+ return ShowDialog(caption, text, image, buttons);
95+ }
96+
97+ public IDialogResult ShowDialog(
98+ string caption, string text, MessageBoxImage image, UniversalDialogButtons buttons)
99+ {
100+ (ImageSource icon, SystemSound sound) = ConvertIconAndSound(image);
101+
102+ UniversalDialogOptions options = new(
103+ caption,
104+ icon,
105+ sound,
106+ text,
107+ buttons
108+ );
109+
110+ IDialogParameters dialogParams = new DialogParameters
111+ {
112+ { PARAM_KEY_DIALOG_OPTIONS, options }
113+ };
114+
115+ IDialogResult result = ShowDialog(DIALOG_NAME, dialogParams);
116+
117+ if (result.Result == ButtonResult.None)
118+ {
119+ foreach (UniversalDialogButtonInfo info in buttons.Infos)
120+ {
121+ if (info.IsCancel)
122+ {
123+ result = new DialogResult(info.Result);
124+ }
125+ }
126+ }
127+
128+ return result;
129+ }
130+
131+ private static (ImageSource, SystemSound) ConvertIconAndSound(MessageBoxImage icon)
132+ {
133+ (IntPtr hIcon, SystemSound sound) = icon switch
134+ {
135+ MessageBoxImage.Information or MessageBoxImage.Asterisk
136+ => (SystemIcons.Information.Handle, SystemSounds.Asterisk),
137+ MessageBoxImage.Question
138+ => (SystemIcons.Question.Handle, SystemSounds.Asterisk),
139+ MessageBoxImage.Exclamation or MessageBoxImage.Warning
140+ => (SystemIcons.Exclamation.Handle, SystemSounds.Exclamation),
141+ MessageBoxImage.Error or MessageBoxImage.Stop
142+ => (SystemIcons.Error.Handle, SystemSounds.Hand),
143+ _ => (IntPtr.Zero, null),
144+ };
145+
146+ if (hIcon == IntPtr.Zero)
147+ {
148+ return (null, null);
149+ }
150+
151+ return (Imaging.CreateBitmapSourceFromHIcon(
152+ hIcon, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()),
153+ sound);
154+ }
155+
156+ }
157+}
--- a/Adaptor/Gateway/UI/UserDialogProxy.cs
+++ b/Adaptor/Gateway/UI/Dialog/UserDialogProxy.cs
@@ -1,8 +1,8 @@
1-using CleanAuLait.Adaptor.Boundary.Gateway.UI;
1+using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog;
22 using CleanAuLait.Core.Resource;
33 using System.Windows;
44
5-namespace CleanAuLait.Adaptor.Gateway.UI
5+namespace CleanAuLait.Adaptor.Gateway.UI.Dialog
66 {
77 public class UserDialogProxy : IUserDialogProxy
88 {
--- /dev/null
+++ b/Adaptor/Gateway/ViewModel/Dialog/UniversalDialogButtons.cs
@@ -0,0 +1,35 @@
1+using Prism.Services.Dialogs;
2+
3+namespace CleanAuLait.Adaptor.Gateway.ViewModel.Dialog
4+{
5+ public record class UniversalDialogButtonInfo(
6+ string Caption,
7+ ButtonResult Result,
8+ bool IsDefault,
9+ bool IsCancel
10+ )
11+ {
12+ public UniversalDialogButtonInfo(
13+ string caption,
14+ ButtonResult result
15+ ) : this(caption, result, false, false)
16+ {
17+ }
18+
19+ public UniversalDialogButtonInfo SetDefault()
20+ {
21+ return this with { IsDefault = true };
22+ }
23+
24+ public UniversalDialogButtonInfo SetCancel()
25+ {
26+ return this with { IsCancel = true };
27+ }
28+ }
29+
30+ public record class UniversalDialogButtons(
31+ UniversalDialogButtonInfo[] Infos
32+ )
33+ {
34+ }
35+}
--- /dev/null
+++ b/Adaptor/Gateway/ViewModel/Dialog/UniversalDialogOptions.cs
@@ -0,0 +1,19 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Media;
5+using System.Text;
6+using System.Threading.Tasks;
7+using System.Windows.Media;
8+
9+namespace CleanAuLait.Adaptor.Gateway.ViewModel.Dialog
10+{
11+ internal record class UniversalDialogOptions(
12+ string Caption,
13+ ImageSource Icon,
14+ SystemSound Sound,
15+ string Text,
16+ UniversalDialogButtons Buttons
17+ ) {
18+ }
19+}
--- /dev/null
+++ b/Adaptor/Gateway/ViewModel/Dialog/UniversalDialogViewModel.cs
@@ -0,0 +1,236 @@
1+using CleanAuLait.Adaptor.Boundary.Gateway.ViewModel.Dialog;
2+using CleanAuLait.Adaptor.Gateway.UI.Dialog;
3+using CleanAuLait.Adaptor.Gateway.ViewModel.Dialog;
4+using FolderCategorizer2.Adaptor.Gateway.Dialog;
5+using Prism.Navigation;
6+using Prism.Services.Dialogs;
7+using Reactive.Bindings;
8+using Reactive.Bindings.Extensions;
9+using System.ComponentModel;
10+using System.Diagnostics;
11+using System.Drawing;
12+using System.Media;
13+using System.Reactive.Disposables;
14+using System.Windows;
15+using System.Windows.Interop;
16+using System.Windows.Media;
17+using System.Windows.Media.Imaging;
18+
19+namespace CleanAuLait.Adaptor.Gateway.ViewModel
20+{
21+ public class UniversalDialogViewModel : IUniversalDialogViewModel, IDestructible
22+ {
23+#pragma warning disable CS0067
24+ public event PropertyChangedEventHandler PropertyChanged;
25+ public event Action<IDialogResult> RequestClose;
26+#pragma warning restore CS0067
27+
28+ public string Title { get; protected set; }
29+
30+ public ReactivePropertySlim<ImageSource> Icon { get; }
31+ public ReactivePropertySlim<string> Text { get; }
32+
33+ public ReactivePropertySlim<string> CaptionButton1 { get; }
34+ public ReactivePropertySlim<string> CaptionButton2 { get; }
35+ public ReactivePropertySlim<string> CaptionButton3 { get; }
36+ public ReactivePropertySlim<string> CaptionButton4 { get; }
37+ public ReactivePropertySlim<string> CaptionButton5 { get; }
38+
39+ public ReactivePropertySlim<bool> IsDefaultButton1 { get; }
40+ public ReactivePropertySlim<bool> IsDefaultButton2 { get; }
41+ public ReactivePropertySlim<bool> IsDefaultButton3 { get; }
42+ public ReactivePropertySlim<bool> IsDefaultButton4 { get; }
43+ public ReactivePropertySlim<bool> IsDefaultButton5 { get; }
44+
45+ public ReactivePropertySlim<bool> IsCancelButton1 { get; }
46+ public ReactivePropertySlim<bool> IsCancelButton2 { get; }
47+ public ReactivePropertySlim<bool> IsCancelButton3 { get; }
48+ public ReactivePropertySlim<bool> IsCancelButton4 { get; }
49+ public ReactivePropertySlim<bool> IsCancelButton5 { get; }
50+
51+ public ReactivePropertySlim<Visibility> VisibilityButton1 { get; }
52+ public ReactivePropertySlim<Visibility> VisibilityButton2 { get; }
53+ public ReactivePropertySlim<Visibility> VisibilityButton3 { get; }
54+ public ReactivePropertySlim<Visibility> VisibilityButton4 { get; }
55+ public ReactivePropertySlim<Visibility> VisibilityButton5 { get; }
56+
57+ public ReactiveCommand CommandButton1 { get; }
58+ public ReactiveCommand CommandButton2 { get; }
59+ public ReactiveCommand CommandButton3 { get; }
60+ public ReactiveCommand CommandButton4 { get; }
61+ public ReactiveCommand CommandButton5 { get; }
62+
63+
64+ private UniversalDialogButtons buttons;
65+
66+ private readonly CompositeDisposable disposables = new();
67+
68+ public UniversalDialogViewModel()
69+ {
70+ this.Icon = new ReactivePropertySlim<ImageSource>().AddTo(disposables);
71+ this.Text = new ReactivePropertySlim<string>(string.Empty).AddTo(disposables);
72+
73+ this.CaptionButton1 = new ReactivePropertySlim<string>().AddTo(disposables);
74+ this.CaptionButton2 = new ReactivePropertySlim<string>().AddTo(disposables);
75+ this.CaptionButton3 = new ReactivePropertySlim<string>().AddTo(disposables);
76+ this.CaptionButton4 = new ReactivePropertySlim<string>().AddTo(disposables);
77+ this.CaptionButton5 = new ReactivePropertySlim<string>().AddTo(disposables);
78+
79+ this.IsDefaultButton1 = new ReactivePropertySlim<bool>().AddTo(disposables);
80+ this.IsDefaultButton2 = new ReactivePropertySlim<bool>().AddTo(disposables);
81+ this.IsDefaultButton3 = new ReactivePropertySlim<bool>().AddTo(disposables);
82+ this.IsDefaultButton4 = new ReactivePropertySlim<bool>().AddTo(disposables);
83+ this.IsDefaultButton5 = new ReactivePropertySlim<bool>().AddTo(disposables);
84+
85+ this.IsCancelButton1 = new ReactivePropertySlim<bool>().AddTo(disposables);
86+ this.IsCancelButton2 = new ReactivePropertySlim<bool>().AddTo(disposables);
87+ this.IsCancelButton3 = new ReactivePropertySlim<bool>().AddTo(disposables);
88+ this.IsCancelButton4 = new ReactivePropertySlim<bool>().AddTo(disposables);
89+ this.IsCancelButton5 = new ReactivePropertySlim<bool>().AddTo(disposables);
90+
91+ this.VisibilityButton1 = new ReactivePropertySlim<Visibility>().AddTo(disposables);
92+ this.VisibilityButton2 = new ReactivePropertySlim<Visibility>().AddTo(disposables);
93+ this.VisibilityButton3 = new ReactivePropertySlim<Visibility>().AddTo(disposables);
94+ this.VisibilityButton4 = new ReactivePropertySlim<Visibility>().AddTo(disposables);
95+ this.VisibilityButton5 = new ReactivePropertySlim<Visibility>().AddTo(disposables);
96+
97+ this.CommandButton1 = new ReactiveCommand().WithSubscribe(this.OnButton1).AddTo(disposables);
98+ this.CommandButton2 = new ReactiveCommand().WithSubscribe(this.OnButton2).AddTo(disposables);
99+ this.CommandButton3 = new ReactiveCommand().WithSubscribe(this.OnButton3).AddTo(disposables);
100+ this.CommandButton4 = new ReactiveCommand().WithSubscribe(this.OnButton4).AddTo(disposables);
101+ this.CommandButton5 = new ReactiveCommand().WithSubscribe(this.OnButton5).AddTo(disposables);
102+ }
103+
104+ public void Destroy()
105+ {
106+ disposables.Dispose();
107+ }
108+
109+ public void OnDialogOpened(IDialogParameters parameters)
110+ {
111+ UniversalDialogOptions options =
112+ parameters.GetValue<UniversalDialogOptions>(
113+ UniversalDialogProxy.PARAM_KEY_DIALOG_OPTIONS);
114+
115+ this.Title = options.Caption;
116+ this.Icon.Value = options.Icon;
117+ this.Text.Value = options.Text;
118+
119+ this.buttons = options.Buttons;
120+
121+ int count = this.buttons.Infos.Length;
122+
123+ Debug.Assert(count > 0, "[Bug Check] Dialog with No Buttons Not Allowed.");
124+
125+ for (int idx = 0; idx < count; idx++)
126+ {
127+ switch (idx)
128+ {
129+ case 0:
130+ this.CaptionButton1.Value = this.buttons.Infos[0].Caption;
131+ this.IsDefaultButton1.Value = this.buttons.Infos[0].IsDefault;
132+ this.IsCancelButton1.Value = this.buttons.Infos[0].IsCancel;
133+ this.VisibilityButton1.Value = Visibility.Visible;
134+ break;
135+ case 1:
136+ this.CaptionButton2.Value = this.buttons.Infos[1].Caption;
137+ this.IsDefaultButton2.Value = this.buttons.Infos[1].IsDefault;
138+ this.IsCancelButton2.Value = this.buttons.Infos[1].IsCancel;
139+ this.VisibilityButton2.Value = Visibility.Visible;
140+ break;
141+ case 2:
142+ this.CaptionButton3.Value = this.buttons.Infos[2].Caption;
143+ this.IsDefaultButton3.Value = this.buttons.Infos[2].IsDefault;
144+ this.IsCancelButton3.Value = this.buttons.Infos[2].IsCancel;
145+ this.VisibilityButton3.Value = Visibility.Visible;
146+ break;
147+ case 3:
148+ this.CaptionButton4.Value = this.buttons.Infos[3].Caption;
149+ this.IsDefaultButton4.Value = this.buttons.Infos[3].IsDefault;
150+ this.IsCancelButton4.Value = this.buttons.Infos[3].IsCancel;
151+ this.VisibilityButton4.Value = Visibility.Visible;
152+ break;
153+ case 4:
154+ this.CaptionButton5.Value = this.buttons.Infos[4].Caption;
155+ this.IsDefaultButton5.Value = this.buttons.Infos[4].IsDefault;
156+ this.IsCancelButton5.Value = this.buttons.Infos[4].IsCancel;
157+ this.VisibilityButton5.Value = Visibility.Visible;
158+ break;
159+ default:
160+ break;
161+ }
162+ }
163+
164+ for (int idx = count; idx < 5; idx++)
165+ {
166+ switch (idx)
167+ {
168+ case 0:
169+ this.CaptionButton1.Value = String.Empty;
170+ this.VisibilityButton1.Value = Visibility.Collapsed;
171+ break;
172+ case 1:
173+ this.CaptionButton2.Value = String.Empty;
174+ this.VisibilityButton2.Value = Visibility.Collapsed;
175+ break;
176+ case 2:
177+ this.CaptionButton3.Value = String.Empty;
178+ this.VisibilityButton3.Value = Visibility.Collapsed;
179+ break;
180+ case 3:
181+ this.CaptionButton4.Value = String.Empty;
182+ this.VisibilityButton4.Value = Visibility.Collapsed;
183+ break;
184+ case 4:
185+ this.CaptionButton5.Value = String.Empty;
186+ this.VisibilityButton5.Value = Visibility.Collapsed;
187+ break;
188+ default:
189+ break;
190+ }
191+ }
192+
193+ options.Sound?.Play();
194+ }
195+
196+ public bool CanCloseDialog()
197+ {
198+ return true;
199+ }
200+
201+ public void OnDialogClosed()
202+ {
203+ // NOP
204+ }
205+
206+ private void OnButton1()
207+ {
208+ CloseDialog(1);
209+ }
210+
211+ private void OnButton2()
212+ {
213+ CloseDialog(2);
214+ }
215+
216+ private void OnButton3()
217+ {
218+ CloseDialog(3);
219+ }
220+
221+ private void OnButton4()
222+ {
223+ CloseDialog(4);
224+ }
225+
226+ private void OnButton5()
227+ {
228+ CloseDialog(5);
229+ }
230+
231+ private void CloseDialog(int buttonNo)
232+ {
233+ this.RequestClose.Invoke(new DialogResult(buttons.Infos[buttonNo - 1].Result));
234+ }
235+ }
236+}
--- a/CleanAuLait.csproj
+++ b/CleanAuLait.csproj
@@ -18,10 +18,23 @@
1818 <PackageReference Include="AutoMapper" Version="11.0.1" />
1919 <PackageReference Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.5" />
2020 <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
21- <PackageReference Include="NLog" Version="5.0.0" />
21+ <PackageReference Include="NLog" Version="5.0.1" />
2222 <PackageReference Include="Prism.Unity" Version="8.1.97" />
2323 <PackageReference Include="Prism.Wpf" Version="8.1.97" />
24- <PackageReference Include="ReactiveProperty.WPF" Version="8.1.1" />
24+ <PackageReference Include="ReactiveProperty.WPF" Version="8.1.2" />
25+ </ItemGroup>
26+
27+ <ItemGroup>
28+ <Compile Update="OuterEdge\UI\Dialog\UniversalDialog.xaml.cs">
29+ <SubType>Code</SubType>
30+ </Compile>
31+ </ItemGroup>
32+
33+ <ItemGroup>
34+ <Page Update="OuterEdge\UI\Dialog\UniversalDialog.xaml">
35+ <XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
36+ <SubType>Designer</SubType>
37+ </Page>
2538 </ItemGroup>
2639
2740 </Project>
--- a/CleanAuLaitModule.cs
+++ b/CleanAuLaitModule.cs
@@ -1,12 +1,19 @@
11 using CleanAuLait.Adaptor.Boundary.Gateway.UI;
2-using CleanAuLait.Adaptor.Boundary.Gateway.UI.Shell;
2+using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog;
3+using CleanAuLait.Adaptor.Boundary.Gateway.UI.Dialog.Shell;
4+using CleanAuLait.Adaptor.Boundary.Gateway.ViewModel.Dialog;
35 using CleanAuLait.Adaptor.Gateway.UI;
4-using CleanAuLait.Adaptor.Gateway.UI.Shell;
6+using CleanAuLait.Adaptor.Gateway.UI.Dialog;
7+using CleanAuLait.Adaptor.Gateway.UI.Dialog.Shell;
8+using CleanAuLait.Adaptor.Gateway.ViewModel;
59 using CleanAuLait.Core.DI;
610 using CleanAuLait.Core.Resource;
11+using CleanAuLait.OuterEdge.UI.Dialog;
12+using FolderCategorizer2.Adaptor.Gateway.Dialog;
713 using NLog;
814 using Prism.Ioc;
915 using Prism.Modularity;
16+using Prism.Mvvm;
1017
1118 namespace CleanAuLait
1219 {
@@ -29,10 +36,24 @@ namespace CleanAuLait
2936 containerRegistry.RegisterSingleton<ICaptionFormatter, CaptionFormatter>();
3037
3138 //
32- // UI Proxy
39+ // Dialog Proxy
3340 //
3441
3542 containerRegistry.RegisterSingleton<IUserDialogProxy, UserDialogProxy>();
43+ containerRegistry.RegisterSingleton<IUniversalDialogProxy, UniversalDialogProxy>();
44+
45+ //
46+ // Dialog View Model
47+ //
48+
49+ containerRegistry.RegisterSingleton<IUniversalDialogViewModel, UniversalDialogViewModel>();
50+
51+ containerRegistry.RegisterDialog<UniversalDialog, IUniversalDialogViewModel>();
52+
53+ //
54+ // UI Proxy
55+ //
56+
3657 containerRegistry.RegisterSingleton<IStatusBarProxy, StatusBarProxy>();
3758
3859 //
@@ -47,7 +68,11 @@ namespace CleanAuLait
4768
4869 public void OnInitialized(IContainerProvider containerProvider)
4970 {
50- // NOP
71+ //
72+ // Views and ViewModels
73+ //
74+
75+ ViewModelLocationProvider.Register<UniversalDialog>(() => containerProvider.Resolve<IUniversalDialogViewModel>());
5176 }
5277
5378 }
--- a/Core/Resource/CaptionFormatter.cs
+++ b/Core/Resource/CaptionFormatter.cs
@@ -1,4 +1,4 @@
1-using CleanAuLait.Adaptor.Gateway.UI;
1+using CleanAuLait.Adaptor.Gateway.UI.Dialog;
22
33 namespace CleanAuLait.Core.Resource
44 {
--- a/Core/Resource/ICaptionFormatter.cs
+++ b/Core/Resource/ICaptionFormatter.cs
@@ -1,4 +1,4 @@
1-using CleanAuLait.Adaptor.Gateway.UI;
1+using CleanAuLait.Adaptor.Gateway.UI.Dialog;
22
33 namespace CleanAuLait.Core.Resource
44 {
--- /dev/null
+++ b/OuterEdge/UI/Dialog/UniversalDialog.xaml
@@ -0,0 +1,106 @@
1+<UserControl x:Class="CleanAuLait.OuterEdge.UI.Dialog.UniversalDialog"
2+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+ xmlns:prism="http://prismlibrary.com/"
7+ xmlns:vm="clr-namespace:CleanAuLait.Adaptor.Boundary.Gateway.ViewModel.Dialog"
8+ mc:Ignorable="d"
9+ d:DataContext="{d:DesignInstance Type=vm:IUniversalDialogViewModel}"
10+ d:DesignHeight="132" d:DesignWidth="500" d:Background="White">
11+
12+ <prism:Dialog.WindowStyle>
13+ <Style TargetType="Window">
14+ <Setter Property="prism:Dialog.WindowStartupLocation" Value="CenterOwner" />
15+ <Setter Property="WindowStyle" Value="ToolWindow"/>
16+ <Setter Property="ResizeMode" Value="CanResizeWithGrip"/>
17+ <Setter Property="ShowInTaskbar" Value="False"/>
18+ <Setter Property="SizeToContent" Value="WidthAndHeight"/>
19+ <Setter Property="MinWidth" Value="320"/>
20+ <Setter Property="MinHeight" Value="172"/>
21+ <Setter Property="MaxWidth" Value="1024"/>
22+ <Setter Property="MaxHeight" Value="1024"/>
23+ </Style>
24+ </prism:Dialog.WindowStyle>
25+
26+ <Grid>
27+ <Grid.RowDefinitions>
28+ <RowDefinition Height="*"/>
29+ <RowDefinition Height="32"/>
30+ </Grid.RowDefinitions>
31+ <StackPanel MinHeight="100">
32+ <Grid>
33+ <Grid.ColumnDefinitions>
34+ <ColumnDefinition Width="64" />
35+ <ColumnDefinition/>
36+ </Grid.ColumnDefinitions>
37+ <Image Source="{Binding Icon.Value, TargetNullValue={x:Null}}"
38+ Width="32" Height="32" Margin="16,32,0,0"
39+ HorizontalAlignment="Left" VerticalAlignment="Top" />
40+ <d:Border Width="32" Height="32" Margin="16,32,0,0"
41+ HorizontalAlignment="Left" VerticalAlignment="Top"
42+ BorderThickness="1,1,1,1"
43+ BorderBrush="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
44+ <!--
45+ <RichTextBox Grid.Column="1"
46+ Height="{Binding ActualHeight, RelativeSource={RelativeSource FindAncestor, AncestorType=StackPanel}}"
47+ VerticalContentAlignment="Center"
48+ VerticalScrollBarVisibility="Auto"
49+ Padding="8,8,8,8"
50+ BorderThickness="0,0,0,0"
51+ AllowDrop="False"
52+ Focusable="False"
53+ IsTabStop="False"
54+ IsHitTestVisible="False">
55+ <FlowDocument>
56+ <Paragraph>
57+ <Run Text="{Binding Text.Value}" />
58+ </Paragraph>
59+ </FlowDocument>
60+ </RichTextBox>
61+ -->
62+ <TextBox Grid.Column="1" Text="{Binding Text.Value}" d:Text="Contents"
63+ Padding="8,8,8,8"
64+ MinHeight="100"
65+ Height="{Binding ActualHeight, RelativeSource={RelativeSource FindAncestor, AncestorType=StackPanel}}"
66+ BorderThickness="0,0,0,0"
67+ AllowDrop="False" Focusable="False" IsHitTestVisible="False" IsTabStop="False"/>
68+ </Grid>
69+ </StackPanel>
70+ <StackPanel Grid.Row="1" Orientation="Horizontal"
71+ Margin="0,0,8,0" Height="32"
72+ HorizontalAlignment="Right" VerticalAlignment="Center">
73+ <Button Content="{Binding CaptionButton1.Value}" d:Content="Button1"
74+ Width="80" Height="24" Margin="0,0,8,0"
75+ Command="{Binding CommandButton1}"
76+ IsDefault="{Binding IsDefaultButton1.Value}"
77+ IsCancel="{Binding IsCancelButton1.Value}"
78+ Visibility="{Binding VisibilityButton1.Value}"/>
79+ <Button Content="{Binding CaptionButton2.Value}" d:Content="Button2"
80+ Width="80" Height="24" Margin="0,0,8,0"
81+ Command="{Binding CommandButton2}"
82+ IsDefault="{Binding IsDefaultButton2.Value}"
83+ IsCancel="{Binding IsCancelButton2.Value}"
84+ Visibility="{Binding VisibilityButton2.Value}"/>
85+ <Button Content="{Binding CaptionButton3.Value}" d:Content="Button3"
86+ Width="80" Height="24" Margin="0,0,8,0"
87+ Command="{Binding CommandButton3}"
88+ IsDefault="{Binding IsDefaultButton3.Value}"
89+ IsCancel="{Binding IsCancelButton3.Value}"
90+ Visibility="{Binding VisibilityButton3.Value}"/>
91+ <Button Content="{Binding CaptionButton4.Value}" d:Content="Button4"
92+ Width="80" Height="24" Margin="0,0,8,0"
93+ Command="{Binding CommandButton4}"
94+ IsDefault="{Binding IsDefaultButton4.Value}"
95+ IsCancel="{Binding IsCancelButton4.Value}"
96+ Visibility="{Binding VisibilityButton4.Value}"/>
97+ <Button Content="{Binding CaptionButton5.Value}" d:Content="Button5"
98+ Width="80" Height="24" Margin="0,0,8,0"
99+ Command="{Binding CommandButton5}"
100+ IsDefault="{Binding IsDefaultButton5.Value}"
101+ IsCancel="{Binding IsCancelButton5.Value}"
102+ Visibility="{Binding VisibilityButton5.Value}"/>
103+ </StackPanel>
104+
105+ </Grid>
106+</UserControl>
--- /dev/null
+++ b/OuterEdge/UI/Dialog/UniversalDialog.xaml.cs
@@ -0,0 +1,27 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Text;
5+using System.Threading.Tasks;
6+using System.Windows;
7+using System.Windows.Controls;
8+using System.Windows.Data;
9+using System.Windows.Documents;
10+using System.Windows.Input;
11+using System.Windows.Media;
12+using System.Windows.Media.Imaging;
13+using System.Windows.Shapes;
14+
15+namespace CleanAuLait.OuterEdge.UI.Dialog
16+{
17+ /// <summary>
18+ /// UniversalDialog.xaml の相互作用ロジック
19+ /// </summary>
20+ public partial class UniversalDialog : UserControl
21+ {
22+ public UniversalDialog()
23+ {
24+ InitializeComponent();
25+ }
26+ }
27+}
--- a/UseCase/Request/UIUseCaseRequest.cs
+++ b/UseCase/Request/UIUseCaseRequest.cs
@@ -1,4 +1,4 @@
1-using CleanAuLait.Adaptor.Gateway.UI;
1+using CleanAuLait.Adaptor.Gateway.UI.Dialog;
22
33 namespace CleanAuLait.UseCase.Request
44 {