Add a InteractiveDialog demo for the DialogExtension.

This commit is contained in:
Dingping Zhang committed 2019-04-03 00:37:10 +08:00
1 parent 70d4a39e3b
commit e9329ef982
11 files changed
+338 -159

No files matched your search

+8
View File
@@ -130,6 +130,9 @@
<Compile Include="UserControl\Basic\ChatBox.xaml.cs">
<DependentUpon>ChatBox.xaml</DependentUpon>
</Compile>
<Compile Include="UserControl\Basic\InteractiveDialog.xaml.cs">
<DependentUpon>InteractiveDialog.xaml</DependentUpon>
</Compile>
<Compile Include="UserControl\Basic\TextDialog.xaml.cs">
<DependentUpon>TextDialog.xaml</DependentUpon>
</Compile>
@@ -359,6 +362,7 @@
<DependentUpon>TreeViewDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModel\Basic\ChatBoxViewModel.cs" />
<Compile Include="ViewModel\Basic\InteractiveDialogViewModel.cs" />
<Compile Include="ViewModel\Common\ComboBoxDemoViewModel.cs" />
<Compile Include="ViewModel\Controls\CoverViewModel.cs" />
<Compile Include="ViewModel\Controls\DialogDemoViewModel.cs" />
@@ -455,6 +459,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControl\Basic\InteractiveDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControl\Basic\TextDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
File diff suppressed because it is too large. Load diff
@@ -552,4 +552,13 @@
<data name="Try2CloseApp" xml:space="preserve">
<value>Try to close app?</value>
</data>
<data name="InteractiveDialog" xml:space="preserve">
<value>Interactive Dialog</value>
</data>
<data name="Ok" xml:space="preserve">
<value>Ok</value>
</data>
<data name="PleaseInput" xml:space="preserve">
<value>Please input...</value>
</data>
</root>
@@ -552,4 +552,13 @@
<data name="Try2CloseApp" xml:space="preserve">
<value>试试关闭程序吧?</value>
</data>
<data name="InteractiveDialog" xml:space="preserve">
<value>可交互对话框</value>
</data>
<data name="Ok" xml:space="preserve">
<value>确定</value>
</data>
<data name="PleaseInput" xml:space="preserve">
<value>请输入...</value>
</data>
</root>
@@ -0,0 +1,33 @@
<Border x:Class="HandyControlDemo.UserControl.Basic.InteractiveDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity;assembly=HandyControl"
CornerRadius="10"
Width="400"
Height="247"
DataContext="{Binding Path=InteractiveDialog, Source={StaticResource Locator}}"
Background="{DynamicResource RegionBrush}">
<controls:SimplePanel>
<TextBlock Style="{StaticResource TextBlockLargeBold}"
Text="{Binding Message}"
Margin="30"
VerticalAlignment="Top" />
<TextBox x:Name="TextBox"
Style="{StaticResource TextBoxBaseStyle}"
Text="{x:Static langs:Lang.PleaseInput}"
Margin="70"
VerticalAlignment="Top" />
<Button Width="120"
Height="32"
Command="{Binding CloseCommand}"
CommandParameter="{Binding Path=Text, ElementName=TextBox}"
Style="{StaticResource ButtonPrimary}"
Content="{x:Static langs:Lang.Ok}"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Margin="0 0 0 30" />
</controls:SimplePanel>
</Border>
@@ -0,0 +1,13 @@
namespace HandyControlDemo.UserControl.Basic
{
/// <summary>
/// Interaction logic for InteractiveDialog.xaml
/// </summary>
public partial class InteractiveDialog
{
public InteractiveDialog()
{
InitializeComponent();
}
}
}
@@ -3,6 +3,19 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
Background="{DynamicResource RegionBrush}"
DataContext="{Binding DialogDemo,Source={StaticResource Locator}}">
<Button Margin="32" Content="{x:Static langs:Lang.TextDialog}" Command="{Binding ShowTextCmd}"/>
DataContext="{Binding DialogDemo,Source={StaticResource Locator}}"
Width="300">
<StackPanel>
<Button Margin="32"
Content="{x:Static langs:Lang.TextDialog}"
Command="{Binding ShowTextCmd}" />
<TextBox x:Name="TextBox"
Style="{StaticResource TextBoxBaseStyle}"
Text="{Binding DialogResult}"
Margin="20 0"/>
<Button Margin="32"
Content="{x:Static langs:Lang.InteractiveDialog}"
Command="{Binding ShowInteractiveDialogCmd}"
CommandParameter="{Binding Path=Text, ElementName=TextBox}"/>
</StackPanel>
</UserControl>
@@ -0,0 +1,36 @@
using System;
using System.Windows.Input;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.CommandWpf;
using HandyControl.Tools.Extension;
namespace HandyControlDemo.ViewModel.Basic
{
public class InteractiveDialogViewModel : ViewModelBase, IDialogResultable
{
private string _message;
public object Result { get; set; }
public Action ClosureToken { get; set; }
public ICommand CloseCommand { get; }
public string Message
{
get => _message;
set => Set(ref _message, value);
}
public InteractiveDialogViewModel()
{
CloseCommand = new RelayCommand<string>(result =>
{
Result = result;
ClosureToken();
});
}
}
}
@@ -1,16 +1,43 @@
using System;
using System.Windows.Input;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.CommandWpf;
using HandyControl.Controls;
using HandyControl.Tools.Extension;
using HandyControlDemo.Properties.Langs;
using HandyControlDemo.UserControl;
using HandyControlDemo.UserControl.Basic;
using HandyControlDemo.ViewModel.Basic;
namespace HandyControlDemo.ViewModel
{
public class DialogDemoViewModel : ViewModelBase
{
private string _dialogResult;
public RelayCommand ShowTextCmd => new Lazy<RelayCommand>(() =>
new RelayCommand(ShowText)).Value;
public string DialogResult
{
get => _dialogResult;
set => Set(ref _dialogResult, value);
}
public ICommand ShowInteractiveDialogCmd { get; }
public DialogDemoViewModel()
{
DialogResult = Lang.PleaseInput;
ShowInteractiveDialogCmd = new RelayCommand<string>(async message =>
{
DialogResult = await Dialog.Show<InteractiveDialog>()
.Initialize<InteractiveDialogViewModel>(vm => vm.Message = message)
.GetResultAsync<string>();
});
}
private void ShowText()
{
Dialog.Show(new TextDialog());
@@ -5,6 +5,7 @@ using CommonServiceLocator;
using GalaSoft.MvvmLight.Ioc;
using HandyControlDemo.Data;
using HandyControlDemo.Service;
using HandyControlDemo.ViewModel.Basic;
namespace HandyControlDemo.ViewModel
{
@@ -30,6 +31,7 @@ namespace HandyControlDemo.ViewModel
SimpleIoc.Default.Register<DialogDemoViewModel>();
SimpleIoc.Default.Register<SearchBarDemoViewModel>();
SimpleIoc.Default.Register<NotifyIconDemoViewModel>();
SimpleIoc.Default.Register<InteractiveDialogViewModel>();
}
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
@@ -65,6 +67,7 @@ namespace HandyControlDemo.ViewModel
public NotifyIconDemoViewModel NotifyIconDemo => ServiceLocator.Current.GetInstance<NotifyIconDemoViewModel>();
public InteractiveDialogViewModel InteractiveDialog => ServiceLocator.Current.GetInstance<InteractiveDialogViewModel>();
#endregion
}
}