Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Prism
提交
e72c6c4c
P
Prism
项目概览
jobily
/
Prism
9 个月 前同步成功
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Prism
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e72c6c4c
编写于
8月 12, 2023
作者:
D
Dan Siegel
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: update WPF sample for updated Dialog API
上级
ec2c1b2b
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
57 addition
and
26 deletion
+57
-26
e2e/Wpf/HelloWorld.Core/DialogServiceExtensions.cs
e2e/Wpf/HelloWorld.Core/DialogServiceExtensions.cs
+1
-1
e2e/Wpf/HelloWorld/Dialogs/AnotherDialogWindow.xaml.cs
e2e/Wpf/HelloWorld/Dialogs/AnotherDialogWindow.xaml.cs
+1
-1
e2e/Wpf/HelloWorld/Dialogs/CustomDialogWindow.xaml.cs
e2e/Wpf/HelloWorld/Dialogs/CustomDialogWindow.xaml.cs
+1
-1
e2e/Wpf/HelloWorld/Dialogs/DialogViewModelBase.cs
e2e/Wpf/HelloWorld/Dialogs/DialogViewModelBase.cs
+11
-10
e2e/Wpf/HelloWorld/Dialogs/NotificationDialogViewModel.cs
e2e/Wpf/HelloWorld/Dialogs/NotificationDialogViewModel.cs
+1
-1
e2e/Wpf/HelloWorld/ViewModels/MainWindowViewModel.cs
e2e/Wpf/HelloWorld/ViewModels/MainWindowViewModel.cs
+1
-1
e2e/Wpf/Modules/HelloWorld.Modules.ModuleA/ViewModels/ViewAViewModel.cs
...s/HelloWorld.Modules.ModuleA/ViewModels/ViewAViewModel.cs
+1
-1
src/Prism.Core/Dialogs/DialogCloseListener.cs
src/Prism.Core/Dialogs/DialogCloseListener.cs
+7
-0
src/Prism.Core/Dialogs/DialogResult.cs
src/Prism.Core/Dialogs/DialogResult.cs
+17
-0
src/Prism.Core/Dialogs/DialogUtilities.cs
src/Prism.Core/Dialogs/DialogUtilities.cs
+15
-9
src/Wpf/Prism.Wpf/Properties/AssemblyInfo.cs
src/Wpf/Prism.Wpf/Properties/AssemblyInfo.cs
+1
-1
未找到文件。
e2e/Wpf/HelloWorld.Core/DialogServiceExtensions.cs
浏览文件 @
e72c6c4c
using
Prism.
Services.
Dialogs
;
using
Prism.Dialogs
;
using
System
;
using
System
;
namespace
HelloWorld.Core
namespace
HelloWorld.Core
...
...
e2e/Wpf/HelloWorld/Dialogs/AnotherDialogWindow.xaml.cs
浏览文件 @
e72c6c4c
using
Prism.
Services.
Dialogs
;
using
Prism.Dialogs
;
using
System.Windows
;
using
System.Windows
;
namespace
HelloWorld.Dialogs
namespace
HelloWorld.Dialogs
...
...
e2e/Wpf/HelloWorld/Dialogs/CustomDialogWindow.xaml.cs
浏览文件 @
e72c6c4c
using
Prism.
Services.
Dialogs
;
using
Prism.Dialogs
;
using
System.Windows
;
using
System.Windows
;
namespace
HelloWorld.Dialogs
namespace
HelloWorld.Dialogs
...
...
e2e/Wpf/HelloWorld/Dialogs/DialogViewModelBase.cs
浏览文件 @
e72c6c4c
using
Prism.Commands
;
using
Prism.Commands
;
using
Prism.Mvvm
;
using
Prism.Mvvm
;
using
Prism.
Services.
Dialogs
;
using
Prism.Dialogs
;
using
System
;
using
System
;
namespace
HelloWorld.Dialogs
namespace
HelloWorld.Dialogs
...
@@ -18,18 +18,19 @@ namespace HelloWorld.Dialogs
...
@@ -18,18 +18,19 @@ namespace HelloWorld.Dialogs
set
{
SetProperty
(
ref
_title
,
value
);
}
set
{
SetProperty
(
ref
_title
,
value
);
}
}
}
public
event
Action
<
IDialogResult
>
RequestClose
;
public
DialogCloseListener
RequestClose
{
get
;
}
protected
virtual
void
CloseDialog
(
string
parameter
)
protected
virtual
void
CloseDialog
(
string
parameter
)
{
{
ButtonResult
result
=
ButtonResult
.
None
;
var
result
=
parameter
?.
ToLower
()
switch
{
if
(
parameter
?.
ToLower
()
==
"true"
)
"true"
=>
ButtonResult
.
OK
,
result
=
ButtonResult
.
OK
;
"false"
=>
ButtonResult
.
Cancel
,
else
if
(
parameter
?.
ToLower
()
==
"false"
)
_
=>
ButtonResult
.
None
result
=
ButtonResult
.
Cancel
;
};
RequestClose
?.
Invoke
(
new
DialogResult
(
result
));
//RequestClose.Invoke(new DialogResult(result));
RequestClose
.
Invoke
(
result
);
}
}
public
virtual
bool
CanCloseDialog
()
public
virtual
bool
CanCloseDialog
()
...
...
e2e/Wpf/HelloWorld/Dialogs/NotificationDialogViewModel.cs
浏览文件 @
e72c6c4c
using
Prism.
Services.
Dialogs
;
using
Prism.Dialogs
;
namespace
HelloWorld.Dialogs
namespace
HelloWorld.Dialogs
{
{
...
...
e2e/Wpf/HelloWorld/ViewModels/MainWindowViewModel.cs
浏览文件 @
e72c6c4c
...
@@ -3,7 +3,7 @@ using HelloWorld.Core;
...
@@ -3,7 +3,7 @@ using HelloWorld.Core;
using
Prism.Commands
;
using
Prism.Commands
;
using
Prism.Mvvm
;
using
Prism.Mvvm
;
using
Prism.Regions
;
using
Prism.Regions
;
using
Prism.
Services.
Dialogs
;
using
Prism.Dialogs
;
namespace
HelloWorld.ViewModels
namespace
HelloWorld.ViewModels
{
{
...
...
e2e/Wpf/Modules/HelloWorld.Modules.ModuleA/ViewModels/ViewAViewModel.cs
浏览文件 @
e72c6c4c
using
Prism.Commands
;
using
Prism.Commands
;
using
Prism.Mvvm
;
using
Prism.Mvvm
;
using
Prism.
Services.
Dialogs
;
using
Prism.Dialogs
;
using
HelloWorld.Core
;
using
HelloWorld.Core
;
namespace
HelloWorld.Modules.ModuleA.ViewModels
namespace
HelloWorld.Modules.ModuleA.ViewModels
...
...
src/Prism.Core/Dialogs/DialogCloseListener.cs
浏览文件 @
e72c6c4c
...
@@ -35,6 +35,13 @@ public struct DialogCloseListener
...
@@ -35,6 +35,13 @@ public struct DialogCloseListener
public
void
Invoke
()
=>
public
void
Invoke
()
=>
Invoke
(
new
DialogResult
());
Invoke
(
new
DialogResult
());
/// <summary>
/// Invokes the initialized delegate with the specified <see cref="ButtonResult"/>.
/// </summary>
/// <param name="result">The <see cref="ButtonResult"/>.</param>
public
void
Invoke
(
ButtonResult
result
)
=>
Invoke
(
new
DialogResult
(
result
));
/// <summary>
/// <summary>
/// Invokes the initialized delegate with the specified <see cref="IDialogParameters"/>.
/// Invokes the initialized delegate with the specified <see cref="IDialogParameters"/>.
/// </summary>
/// </summary>
...
...
src/Prism.Core/Dialogs/DialogResult.cs
浏览文件 @
e72c6c4c
...
@@ -9,6 +9,23 @@ namespace Prism.Dialogs;
...
@@ -9,6 +9,23 @@ namespace Prism.Dialogs;
/// </summary>
/// </summary>
public
class
DialogResult
:
IDialogResult
public
class
DialogResult
:
IDialogResult
{
{
/// <summary>
/// Creates a new <see cref="DialogResult"/>
/// </summary>
public
DialogResult
()
:
this
(
ButtonResult
.
None
)
{
}
/// <summary>
/// Creates a new <see cref="DialogResult"/> with a specified <see cref="ButtonResult"/>
/// </summary>
/// <param name="result"></param>
public
DialogResult
(
ButtonResult
result
)
{
Result
=
result
;
}
/// <summary>
/// <summary>
/// An <see cref="System.Exception"/> that was thrown by the DialogService
/// An <see cref="System.Exception"/> that was thrown by the DialogService
/// </summary>
/// </summary>
...
...
src/Prism.Core/Dialogs/DialogUtilities.cs
浏览文件 @
e72c6c4c
...
@@ -38,29 +38,35 @@ public static class DialogUtilities
...
@@ -38,29 +38,35 @@ public static class DialogUtilities
private
static
void
SetListener
(
IDialogAware
dialogAware
,
DialogCloseListener
listener
)
private
static
void
SetListener
(
IDialogAware
dialogAware
,
DialogCloseListener
listener
)
{
{
var
type
=
dialogAware
.
GetType
();
var
setter
=
GetListenerSetter
(
dialogAware
,
dialogAware
.
GetType
());
setter
(
listener
);
}
private
static
Action
<
DialogCloseListener
>
GetListenerSetter
(
IDialogAware
dialogAware
,
Type
type
)
{
var
propInfo
=
type
.
GetProperty
(
nameof
(
IDialogAware
.
RequestClose
));
var
propInfo
=
type
.
GetProperty
(
nameof
(
IDialogAware
.
RequestClose
));
if
(
propInfo
is
not
null
&&
propInfo
.
PropertyType
==
typeof
(
DialogCloseListener
)
&&
propInfo
.
SetMethod
is
not
null
)
if
(
propInfo
is
not
null
&&
propInfo
.
PropertyType
==
typeof
(
DialogCloseListener
)
&&
propInfo
.
SetMethod
is
not
null
)
{
{
propInfo
.
SetValue
(
dialogAware
,
listener
);
return
x
=>
propInfo
.
SetValue
(
dialogAware
,
x
);
return
;
}
}
var
fields
=
type
.
GetRuntimeFields
().
Where
(
x
=>
x
.
FieldType
==
typeof
(
DialogCloseListener
));
var
fields
=
type
.
GetRuntimeFields
().
Where
(
x
=>
x
.
FieldType
==
typeof
(
DialogCloseListener
));
var
field
=
fields
.
FirstOrDefault
(
x
=>
x
.
Name
==
$"<
{
nameof
(
IDialogAware
.
RequestClose
)}
>k__BackingField"
);
var
field
=
fields
.
FirstOrDefault
(
x
=>
x
.
Name
==
$"<
{
nameof
(
IDialogAware
.
RequestClose
)}
>k__BackingField"
);
if
(
field
is
not
null
)
if
(
field
is
not
null
)
{
{
field
.
SetValue
(
dialogAware
,
listener
);
return
x
=>
field
.
SetValue
(
dialogAware
,
x
);
}
}
else
if
(
fields
.
Any
())
else
if
(
fields
.
Any
())
{
{
field
=
fields
.
First
();
field
=
fields
.
First
();
field
.
SetValue
(
dialogAware
,
listener
);
return
x
=>
field
.
SetValue
(
dialogAware
,
x
);
}
}
else
{
var
baseType
=
type
.
BaseType
;
if
(
baseType
is
null
||
baseType
==
typeof
(
object
))
throw
new
DialogException
(
DialogException
.
UnableToSetTheDialogCloseListener
);
throw
new
DialogException
(
DialogException
.
UnableToSetTheDialogCloseListener
);
}
return
GetListenerSetter
(
dialogAware
,
baseType
);
}
}
}
}
src/Wpf/Prism.Wpf/Properties/AssemblyInfo.cs
浏览文件 @
e72c6c4c
...
@@ -21,6 +21,6 @@ using System.Windows.Markup;
...
@@ -21,6 +21,6 @@ using System.Windows.Markup;
[
assembly
:
XmlnsDefinition
(
"http://prismlibrary.com/"
,
"Prism.Regions.Behaviors"
)]
[
assembly
:
XmlnsDefinition
(
"http://prismlibrary.com/"
,
"Prism.Regions.Behaviors"
)]
[
assembly
:
XmlnsDefinition
(
"http://prismlibrary.com/"
,
"Prism.Mvvm"
)]
[
assembly
:
XmlnsDefinition
(
"http://prismlibrary.com/"
,
"Prism.Mvvm"
)]
[
assembly
:
XmlnsDefinition
(
"http://prismlibrary.com/"
,
"Prism.Interactivity"
)]
[
assembly
:
XmlnsDefinition
(
"http://prismlibrary.com/"
,
"Prism.Interactivity"
)]
[
assembly
:
XmlnsDefinition
(
"http://prismlibrary.com/"
,
"Prism.
Services.
Dialogs"
)]
[
assembly
:
XmlnsDefinition
(
"http://prismlibrary.com/"
,
"Prism.Dialogs"
)]
[
assembly
:
XmlnsDefinition
(
"http://prismlibrary.com/"
,
"Prism.Ioc"
)]
[
assembly
:
XmlnsDefinition
(
"http://prismlibrary.com/"
,
"Prism.Ioc"
)]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录