Add a InteractiveDialog demo for the DialogExtension.
This commit is contained in:
1 parent
70d4a39e3b
commit
e9329ef982
11 files changed
+338
-159
No files matched your search
@@ -186,6 +186,7 @@
|
|||||||
<Compile Include="Tools\Converter\BorderClipConverter.cs" />
|
<Compile Include="Tools\Converter\BorderClipConverter.cs" />
|
||||||
<Compile Include="Tools\Converter\BorderCircularConverter.cs" />
|
<Compile Include="Tools\Converter\BorderCircularConverter.cs" />
|
||||||
<Compile Include="Tools\Converter\Int2StrConverter.cs" />
|
<Compile Include="Tools\Converter\Int2StrConverter.cs" />
|
||||||
|
<Compile Include="Tools\Extension\DialogExtension.cs" />
|
||||||
<Compile Include="Tools\Extension\EnumerableExtension.cs" />
|
<Compile Include="Tools\Extension\EnumerableExtension.cs" />
|
||||||
<Compile Include="Tools\Extension\GeometryExtension.cs" />
|
<Compile Include="Tools\Extension\GeometryExtension.cs" />
|
||||||
<Compile Include="Tools\GithubGravatarGenerator.cs" />
|
<Compile Include="Tools\GithubGravatarGenerator.cs" />
|
||||||
|
|||||||
@@ -130,6 +130,9 @@
|
|||||||
<Compile Include="UserControl\Basic\ChatBox.xaml.cs">
|
<Compile Include="UserControl\Basic\ChatBox.xaml.cs">
|
||||||
<DependentUpon>ChatBox.xaml</DependentUpon>
|
<DependentUpon>ChatBox.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="UserControl\Basic\InteractiveDialog.xaml.cs">
|
||||||
|
<DependentUpon>InteractiveDialog.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="UserControl\Basic\TextDialog.xaml.cs">
|
<Compile Include="UserControl\Basic\TextDialog.xaml.cs">
|
||||||
<DependentUpon>TextDialog.xaml</DependentUpon>
|
<DependentUpon>TextDialog.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -359,6 +362,7 @@
|
|||||||
<DependentUpon>TreeViewDemoCtl.xaml</DependentUpon>
|
<DependentUpon>TreeViewDemoCtl.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="ViewModel\Basic\ChatBoxViewModel.cs" />
|
<Compile Include="ViewModel\Basic\ChatBoxViewModel.cs" />
|
||||||
|
<Compile Include="ViewModel\Basic\InteractiveDialogViewModel.cs" />
|
||||||
<Compile Include="ViewModel\Common\ComboBoxDemoViewModel.cs" />
|
<Compile Include="ViewModel\Common\ComboBoxDemoViewModel.cs" />
|
||||||
<Compile Include="ViewModel\Controls\CoverViewModel.cs" />
|
<Compile Include="ViewModel\Controls\CoverViewModel.cs" />
|
||||||
<Compile Include="ViewModel\Controls\DialogDemoViewModel.cs" />
|
<Compile Include="ViewModel\Controls\DialogDemoViewModel.cs" />
|
||||||
@@ -455,6 +459,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="UserControl\Basic\InteractiveDialog.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="UserControl\Basic\TextDialog.xaml">
|
<Page Include="UserControl\Basic\TextDialog.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
+184
-157
File diff suppressed because it is too large.
Load diff
@@ -552,4 +552,13 @@
|
|||||||
<data name="Try2CloseApp" xml:space="preserve">
|
<data name="Try2CloseApp" xml:space="preserve">
|
||||||
<value>Try to close app?</value>
|
<value>Try to close app?</value>
|
||||||
</data>
|
</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>
|
</root>
|
||||||
@@ -552,4 +552,13 @@
|
|||||||
<data name="Try2CloseApp" xml:space="preserve">
|
<data name="Try2CloseApp" xml:space="preserve">
|
||||||
<value>试试关闭程序吧?</value>
|
<value>试试关闭程序吧?</value>
|
||||||
</data>
|
</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>
|
</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:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
||||||
Background="{DynamicResource RegionBrush}"
|
Background="{DynamicResource RegionBrush}"
|
||||||
DataContext="{Binding DialogDemo,Source={StaticResource Locator}}">
|
DataContext="{Binding DialogDemo,Source={StaticResource Locator}}"
|
||||||
<Button Margin="32" Content="{x:Static langs:Lang.TextDialog}" Command="{Binding ShowTextCmd}"/>
|
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>
|
</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;
|
||||||
|
using System.Windows.Input;
|
||||||
using GalaSoft.MvvmLight;
|
using GalaSoft.MvvmLight;
|
||||||
using GalaSoft.MvvmLight.CommandWpf;
|
using GalaSoft.MvvmLight.CommandWpf;
|
||||||
using HandyControl.Controls;
|
using HandyControl.Controls;
|
||||||
|
using HandyControl.Tools.Extension;
|
||||||
|
using HandyControlDemo.Properties.Langs;
|
||||||
using HandyControlDemo.UserControl;
|
using HandyControlDemo.UserControl;
|
||||||
|
using HandyControlDemo.UserControl.Basic;
|
||||||
|
using HandyControlDemo.ViewModel.Basic;
|
||||||
|
|
||||||
namespace HandyControlDemo.ViewModel
|
namespace HandyControlDemo.ViewModel
|
||||||
{
|
{
|
||||||
public class DialogDemoViewModel : ViewModelBase
|
public class DialogDemoViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
private string _dialogResult;
|
||||||
|
|
||||||
public RelayCommand ShowTextCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand ShowTextCmd => new Lazy<RelayCommand>(() =>
|
||||||
new RelayCommand(ShowText)).Value;
|
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()
|
private void ShowText()
|
||||||
{
|
{
|
||||||
Dialog.Show(new TextDialog());
|
Dialog.Show(new TextDialog());
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using CommonServiceLocator;
|
|||||||
using GalaSoft.MvvmLight.Ioc;
|
using GalaSoft.MvvmLight.Ioc;
|
||||||
using HandyControlDemo.Data;
|
using HandyControlDemo.Data;
|
||||||
using HandyControlDemo.Service;
|
using HandyControlDemo.Service;
|
||||||
|
using HandyControlDemo.ViewModel.Basic;
|
||||||
|
|
||||||
namespace HandyControlDemo.ViewModel
|
namespace HandyControlDemo.ViewModel
|
||||||
{
|
{
|
||||||
@@ -30,6 +31,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
SimpleIoc.Default.Register<DialogDemoViewModel>();
|
SimpleIoc.Default.Register<DialogDemoViewModel>();
|
||||||
SimpleIoc.Default.Register<SearchBarDemoViewModel>();
|
SimpleIoc.Default.Register<SearchBarDemoViewModel>();
|
||||||
SimpleIoc.Default.Register<NotifyIconDemoViewModel>();
|
SimpleIoc.Default.Register<NotifyIconDemoViewModel>();
|
||||||
|
SimpleIoc.Default.Register<InteractiveDialogViewModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
|
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
|
||||||
@@ -65,6 +67,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
|
|
||||||
public NotifyIconDemoViewModel NotifyIconDemo => ServiceLocator.Current.GetInstance<NotifyIconDemoViewModel>();
|
public NotifyIconDemoViewModel NotifyIconDemo => ServiceLocator.Current.GetInstance<NotifyIconDemoViewModel>();
|
||||||
|
|
||||||
|
public InteractiveDialogViewModel InteractiveDialog => ServiceLocator.Current.GetInstance<InteractiveDialogViewModel>();
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user