mirror of
https://gitee.com/handyorg/HandyControl.git
synced 2024-12-03 20:37:51 +08:00
updated DialogDemo
This commit is contained in:
parent
e4ae2d21d1
commit
cb4f5b4907
@ -45,6 +45,9 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Basic\TextDialog.xaml.cs">
|
||||
<DependentUpon>TextDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Basic\TextDialogWithTimer.xaml.cs">
|
||||
<DependentUpon>TextDialogWithTimer.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\AnimationPathDemoCtl.xaml.cs">
|
||||
<DependentUpon>AnimationPathDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -405,6 +408,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="$(MSBuildThisFileDirectory)UserControl\Basic\TextDialogWithTimer.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="$(MSBuildThisFileDirectory)UserControl\Controls\AnimationPathDemoCtl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
@ -1410,6 +1410,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 文本对话框,带计时器 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TextDialogWithTimer {
|
||||
get {
|
||||
return ResourceManager.GetString("TextDialogWithTimer", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 时间条 的本地化字符串。
|
||||
/// </summary>
|
||||
|
@ -624,4 +624,7 @@
|
||||
<data name="Card" xml:space="preserve">
|
||||
<value>Card</value>
|
||||
</data>
|
||||
<data name="TextDialogWithTimer" xml:space="preserve">
|
||||
<value>TextDialog with timer</value>
|
||||
</data>
|
||||
</root>
|
@ -624,4 +624,7 @@
|
||||
<data name="Card" xml:space="preserve">
|
||||
<value>卡片</value>
|
||||
</data>
|
||||
<data name="TextDialogWithTimer" xml:space="preserve">
|
||||
<value>文本对话框,带计时器</value>
|
||||
</data>
|
||||
</root>
|
@ -37,7 +37,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<ToggleButton Name="ToggleButtonAudio" hc:BorderElement.CornerRadius="15" Width="30" Height="30" Padding="7" Margin="6" hc:IconSwitchElement.Geometry="{StaticResource AudioGeometry}" hc:IconSwitchElement.GeometrySelected="{StaticResource KeyboardGeometry}" Style="{StaticResource ToggleButtonIcon}"/>
|
||||
<Button Command="{Binding OpenImageCmd}" Grid.Column="2" Margin="6,0,6,0" hc:BorderElement.CornerRadius="15" Width="30" Height="30" Padding="7" hc:IconElement.Geometry="{StaticResource ImageGeometry}"/>
|
||||
<TextBox Grid.Column="1" Text="{Binding ChatString,UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding IsChecked,ElementName=ToggleButtonAudio,Converter={StaticResource Boolean2VisibilityReConverter}}">
|
||||
<TextBox VerticalAlignment="Center" Grid.Column="1" Text="{Binding ChatString,UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding IsChecked,ElementName=ToggleButtonAudio,Converter={StaticResource Boolean2VisibilityReConverter}}">
|
||||
<hc:Interaction.Triggers>
|
||||
<hc:EventTrigger EventName="KeyDown">
|
||||
<hc:EventToCommand Command="{Binding SendStringCmd}" PassEventArgsToCommand="True" />
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Border x:Class="HandyControlDemo.UserControl.Basic.InteractiveDialog"
|
||||
<Border x:Class="HandyControlDemo.UserControl.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"
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace HandyControlDemo.UserControl.Basic
|
||||
namespace HandyControlDemo.UserControl
|
||||
{
|
||||
public partial class InteractiveDialog
|
||||
{
|
||||
|
@ -0,0 +1,18 @@
|
||||
<Border x:Class="HandyControlDemo.UserControl.TextDialogWithTimer"
|
||||
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:hc="https://handyorg.github.io/handycontrol"
|
||||
CornerRadius="10"
|
||||
Width="400"
|
||||
Height="247"
|
||||
DataContext="{Binding InteractiveDialog, Source={StaticResource Locator}}"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<hc:SimplePanel>
|
||||
<Viewbox Width="80" Height="80">
|
||||
<TextBlock TextWrapping="Wrap" Style="{StaticResource TextBlockLargeBold}" Text="{x:Static langs:Lang.PleaseWait}"/>
|
||||
</Viewbox>
|
||||
<Button Name="ButtonClose" Width="22" Height="22" Command="{Binding CloseCmd}" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource PrimaryBrush}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,4,0"/>
|
||||
<hc:CircleProgressBar Name="ProgressBarTimer" ShowText="False" Width="120" Height="120"/>
|
||||
</hc:SimplePanel>
|
||||
</Border>
|
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using HandyControl.Tools;
|
||||
|
||||
namespace HandyControlDemo.UserControl
|
||||
{
|
||||
public partial class TextDialogWithTimer
|
||||
{
|
||||
public TextDialogWithTimer()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
var animation = AnimationHelper.CreateAnimation(100, 5000);
|
||||
animation.EasingFunction = null;
|
||||
animation.Completed += Animation_Completed;
|
||||
ProgressBarTimer.BeginAnimation(RangeBase.ValueProperty, animation);
|
||||
}
|
||||
|
||||
private void Animation_Completed(object sender, EventArgs e)
|
||||
{
|
||||
ButtonClose.Command.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@
|
||||
<hc:TransitioningContentControl>
|
||||
<StackPanel Margin="32" VerticalAlignment="Center">
|
||||
<Button Content="{x:Static langs:Lang.TextDialog}" Command="{Binding ShowTextCmd}" />
|
||||
<Button Margin="0,32,0,0" Content="{x:Static langs:Lang.TextDialogWithTimer}" Command="{Binding ShowInteractiveDialogCmd}" CommandParameter="True"/>
|
||||
<TextBox Margin="0,32,0,0" Text="{Binding DialogResult,UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TextBoxExtend}" hc:InfoElement.Placeholder="{x:Static langs:Lang.PleaseInput}"/>
|
||||
<Button Margin="0,10,0,0" Content="{x:Static langs:Lang.InteractiveDialog}" Command="{Binding ShowInteractiveDialogCmd}"/>
|
||||
<Button Margin="0,32,0,0" Content="{x:Static langs:Lang.NewWindow}" Command="{Binding NewWindowCmd}"/>
|
||||
|
@ -6,6 +6,7 @@ using GalaSoft.MvvmLight.Command;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
#endif
|
||||
using HandyControl.Tools.Extension;
|
||||
using HandyControlDemo.Data;
|
||||
|
||||
namespace HandyControlDemo.ViewModel.Basic
|
||||
{
|
||||
@ -37,6 +38,6 @@ namespace HandyControlDemo.ViewModel.Basic
|
||||
#endif
|
||||
}
|
||||
|
||||
public RelayCommand CloseCmd => new Lazy<RelayCommand>(() => new RelayCommand(() => CloseAction?.Invoke(""))).Value;
|
||||
public RelayCommand CloseCmd => new Lazy<RelayCommand>(() => new RelayCommand(() => CloseAction?.Invoke(MessageToken.MainWindow))).Value;
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ using GalaSoft.MvvmLight.CommandWpf;
|
||||
using HandyControl.Controls;
|
||||
using HandyControl.Tools.Extension;
|
||||
using HandyControlDemo.UserControl;
|
||||
using HandyControlDemo.UserControl.Basic;
|
||||
using HandyControlDemo.ViewModel.Basic;
|
||||
using HandyControlDemo.Window;
|
||||
|
||||
@ -39,24 +38,38 @@ namespace HandyControlDemo.ViewModel
|
||||
}
|
||||
|
||||
#if netle40
|
||||
public RelayCommand ShowInteractiveDialogCmd => new Lazy<RelayCommand>(() =>
|
||||
new RelayCommand(ShowInteractiveDialog)).Value;
|
||||
public RelayCommand<bool> ShowInteractiveDialogCmd => new Lazy<RelayCommand<bool>>(() =>
|
||||
new RelayCommand<bool>(ShowInteractiveDialog)).Value;
|
||||
|
||||
private void ShowInteractiveDialog()
|
||||
private void ShowInteractiveDialog(bool withTimer)
|
||||
{
|
||||
Dialog.Show<InteractiveDialog>()
|
||||
.Initialize<InteractiveDialogViewModel>(vm => vm.Message = DialogResult)
|
||||
.GetResultAsync<string>().ContinueWith(str => DialogResult = str.Result);
|
||||
if (!withTimer)
|
||||
{
|
||||
Dialog.Show<InteractiveDialog>()
|
||||
.Initialize<InteractiveDialogViewModel>(vm => vm.Message = DialogResult)
|
||||
.GetResultAsync<string>().ContinueWith(str => DialogResult = str.Result);
|
||||
}
|
||||
else
|
||||
{
|
||||
Dialog.Show<TextDialogWithTimer>().GetResultAsync<string>();
|
||||
}
|
||||
}
|
||||
#else
|
||||
public RelayCommand ShowInteractiveDialogCmd => new Lazy<RelayCommand>(() =>
|
||||
new RelayCommand(async () => await ShowInteractiveDialog())).Value;
|
||||
public RelayCommand<bool> ShowInteractiveDialogCmd => new Lazy<RelayCommand<bool>>(() =>
|
||||
new RelayCommand<bool>(async withTimer => await ShowInteractiveDialog(withTimer))).Value;
|
||||
|
||||
private async Task ShowInteractiveDialog()
|
||||
private async Task ShowInteractiveDialog(bool withTimer)
|
||||
{
|
||||
DialogResult = await Dialog.Show<InteractiveDialog>()
|
||||
.Initialize<InteractiveDialogViewModel>(vm => vm.Message = DialogResult)
|
||||
.GetResultAsync<string>();
|
||||
if (!withTimer)
|
||||
{
|
||||
DialogResult = await Dialog.Show<InteractiveDialog>()
|
||||
.Initialize<InteractiveDialogViewModel>(vm => vm.Message = DialogResult)
|
||||
.GetResultAsync<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
await Dialog.Show<TextDialogWithTimer>().GetResultAsync<string>();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user