improved dialog

This commit is contained in:
NaBian committed 2019-04-24 23:53:36 +08:00
1 parent 76a886c331
commit 745909f485
16 files changed
+219 -11

No files matched your search

@@ -164,5 +164,9 @@
public static readonly string GrowlDemoPanel = nameof(GrowlDemoPanel);
public static readonly string DialogDemoWindow = nameof(DialogDemoWindow);
public static readonly string MainWindow = nameof(MainWindow);
}
}
@@ -93,7 +93,9 @@ var messageList = new List<string>
"ContributorsView",
"ClearLeftSelected",
"SendChatMessage",
"GrowlDemoPanel"
"GrowlDemoPanel",
"DialogDemoWindow",
"MainWindow"
};
#>
namespace HandyControlDemo.Data
@@ -298,6 +298,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Window\CustomNonClientAreaWindow.xaml.cs">
<DependentUpon>CustomNonClientAreaWindow.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Window\DialogDemoWindow.xaml.cs">
<DependentUpon>DialogDemoWindow.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Window\GrowlDemoWindow.xaml.cs">
<DependentUpon>GrowlDemoWindow.xaml</DependentUpon>
</Compile>
@@ -682,6 +685,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Window\DialogDemoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Window\GrowlDemoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -5,6 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:userControl="clr-namespace:HandyControlDemo.UserControl"
xmlns:data="clr-namespace:HandyControlDemo.Data"
mc:Ignorable="d"
BorderThickness="1"
BorderBrush="#262e2f"
@@ -19,6 +20,7 @@
ResizeMode="CanResizeWithGrip"
Name="MyWindow"
DataContext="{Binding Main,Source={StaticResource Locator}}"
controls:Dialog.Token="{x:Static data:MessageToken.MainWindow}"
d:DesignHeight="800"
d:DesignWidth="1400">
<controls:Window.NonClientAreaContent>
@@ -429,6 +429,15 @@ namespace HandyControlDemo.Properties.Langs {
}
}
/// <summary>
/// 查找类似 对话框示例 的本地化字符串。
/// </summary>
public static string DialogDemo {
get {
return ResourceManager.GetString("DialogDemo", resourceCulture);
}
}
/// <summary>
/// 查找类似 在这里拖拽 的本地化字符串。
/// </summary>
@@ -1122,6 +1131,24 @@ namespace HandyControlDemo.Properties.Langs {
}
}
/// <summary>
/// 查找类似 在当前窗口显示 的本地化字符串。
/// </summary>
public static string ShowInCurrentWindow {
get {
return ResourceManager.GetString("ShowInCurrentWindow", resourceCulture);
}
}
/// <summary>
/// 查找类似 在主窗口显示 的本地化字符串。
/// </summary>
public static string ShowInMainWindow {
get {
return ResourceManager.GetString("ShowInMainWindow", resourceCulture);
}
}
/// <summary>
/// 查找类似 显示行号 的本地化字符串。
/// </summary>
@@ -567,4 +567,13 @@
<data name="RepeatButton" xml:space="preserve">
<value>RepeatButton</value>
</data>
<data name="DialogDemo" xml:space="preserve">
<value>Dialog demo</value>
</data>
<data name="ShowInCurrentWindow" xml:space="preserve">
<value>Show in the current window</value>
</data>
<data name="ShowInMainWindow" xml:space="preserve">
<value>Show in the main window</value>
</data>
</root>
@@ -567,4 +567,13 @@
<data name="RepeatButton" xml:space="preserve">
<value>重复按钮</value>
</data>
<data name="DialogDemo" xml:space="preserve">
<value>对话框示例</value>
</data>
<data name="ShowInCurrentWindow" xml:space="preserve">
<value>在当前窗口显示</value>
</data>
<data name="ShowInMainWindow" xml:space="preserve">
<value>在主窗口显示</value>
</data>
</root>
@@ -11,6 +11,7 @@
<Button Content="{x:Static langs:Lang.TextDialog}" Command="{Binding ShowTextCmd}" />
<TextBox Margin="0,32,0,0" Text="{Binding DialogResult,UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TextBoxExtend}" controls: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}"/>
</StackPanel>
</controls:TransitioningContentControl>
</UserControl>
@@ -11,7 +11,7 @@ namespace HandyControlDemo.ViewModel.Basic
{
public class InteractiveDialogViewModel : ViewModelBase, IDialogResultable<string>
{
public Action CloseAction { get; set; }
public Action<string> CloseAction { get; set; }
private string _result;
@@ -37,6 +37,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(""))).Value;
}
}
@@ -1,4 +1,5 @@
using System;
using System.Windows;
using GalaSoft.MvvmLight;
#if netle40
using GalaSoft.MvvmLight.Command;
@@ -11,6 +12,7 @@ using HandyControl.Tools.Extension;
using HandyControlDemo.UserControl;
using HandyControlDemo.UserControl.Basic;
using HandyControlDemo.ViewModel.Basic;
using HandyControlDemo.Window;
namespace HandyControlDemo.ViewModel
{
@@ -57,5 +59,14 @@ namespace HandyControlDemo.ViewModel
.GetResultAsync<string>();
}
#endif
public RelayCommand NewWindowCmd => new Lazy<RelayCommand>(() =>
new RelayCommand(() => new DialogDemoWindow
{
Owner = Application.Current.MainWindow
}.Show())).Value;
public RelayCommand<string> ShowWithTokenCmd => new Lazy<RelayCommand<string>>(() =>
new RelayCommand<string>(token => Dialog.Show(new TextDialog(), token))).Value;
}
}
@@ -1,4 +1,5 @@
using System;
using System.Windows;
#if netle40
using GalaSoft.MvvmLight.Command;
#else
@@ -65,6 +66,9 @@ namespace HandyControlDemo.ViewModel
new RelayCommand(() => Growl.Clear())).Value;
public RelayCommand NewWindowCmd => new Lazy<RelayCommand>(() =>
new RelayCommand(() => new GrowlDemoWindow().Show())).Value;
new RelayCommand(() => new GrowlDemoWindow
{
Owner = Application.Current.MainWindow
}.Show())).Value;
}
}
@@ -0,0 +1,18 @@
<Window x:Class="HandyControlDemo.Window.DialogDemoWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:data="clr-namespace:HandyControlDemo.Data"
controls:Dialog.Token="{x:Static data:MessageToken.DialogDemoWindow}"
DataContext="{Binding DialogDemo,Source={StaticResource Locator}}"
Title="{x:Static langs:Lang.DialogDemo}"
Width="800"
Height="500">
<controls:TransitioningContentControl>
<StackPanel Margin="32" VerticalAlignment="Center">
<Button Content="{x:Static langs:Lang.ShowInCurrentWindow}" Command="{Binding ShowWithTokenCmd}" CommandParameter="{x:Static data:MessageToken.DialogDemoWindow}"/>
<Button Margin="0,10,0,0" Content="{x:Static langs:Lang.ShowInMainWindow}" Command="{Binding ShowWithTokenCmd}" CommandParameter="{x:Static data:MessageToken.MainWindow}"/>
</StackPanel>
</controls:TransitioningContentControl>
</Window>
@@ -0,0 +1,10 @@
namespace HandyControlDemo.Window
{
public partial class DialogDemoWindow
{
public DialogDemoWindow()
{
InitializeComponent();
}
}
}