11 files changed
+86
-45
No files matched your search
@@ -46,5 +46,7 @@
|
|||||||
|
|
||||||
public static readonly string NavigationWindow = nameof(NavigationWindow);
|
public static readonly string NavigationWindow = nameof(NavigationWindow);
|
||||||
|
|
||||||
|
public static readonly string DialogContainer = nameof(DialogContainer);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,8 @@ var messageList = new List<string>
|
|||||||
"QQGroupView",
|
"QQGroupView",
|
||||||
"GlowWindow",
|
"GlowWindow",
|
||||||
"NativeCommonWindow",
|
"NativeCommonWindow",
|
||||||
"NavigationWindow"
|
"NavigationWindow",
|
||||||
|
"DialogContainer"
|
||||||
};
|
};
|
||||||
#>
|
#>
|
||||||
namespace HandyControlDemo.Data
|
namespace HandyControlDemo.Data
|
||||||
|
|||||||
@@ -1725,6 +1725,15 @@ namespace HandyControlDemo.Properties.Langs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 文本对话框(控件中) 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string TextDialogInControl {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("TextDialogInControl", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 文本对话框,带计时器 的本地化字符串。
|
/// 查找类似 文本对话框,带计时器 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -744,4 +744,7 @@
|
|||||||
<data name="Screenshot" xml:space="preserve">
|
<data name="Screenshot" xml:space="preserve">
|
||||||
<value>Screenshot</value>
|
<value>Screenshot</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="TextDialogInControl" xml:space="preserve">
|
||||||
|
<value>TextDialog(In control)</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -744,4 +744,7 @@
|
|||||||
<data name="Screenshot" xml:space="preserve">
|
<data name="Screenshot" xml:space="preserve">
|
||||||
<value>Screenshot</value>
|
<value>Screenshot</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="TextDialogInControl" xml:space="preserve">
|
||||||
|
<value>TextDialog(In control)</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -744,4 +744,7 @@
|
|||||||
<data name="Screenshot" xml:space="preserve">
|
<data name="Screenshot" xml:space="preserve">
|
||||||
<value>Screenshot</value>
|
<value>Screenshot</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="TextDialogInControl" xml:space="preserve">
|
||||||
|
<value>TextDialog(In control)</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -744,4 +744,7 @@
|
|||||||
<data name="Screenshot" xml:space="preserve">
|
<data name="Screenshot" xml:space="preserve">
|
||||||
<value>Screenshot</value>
|
<value>Screenshot</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="TextDialogInControl" xml:space="preserve">
|
||||||
|
<value>TextDialog(In control)</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -744,4 +744,7 @@
|
|||||||
<data name="Screenshot" xml:space="preserve">
|
<data name="Screenshot" xml:space="preserve">
|
||||||
<value>截图</value>
|
<value>截图</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="TextDialogInControl" xml:space="preserve">
|
||||||
|
<value>文本对话框(控件中)</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -3,16 +3,23 @@
|
|||||||
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"
|
||||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||||
|
xmlns:data="clr-namespace:HandyControlDemo.Data"
|
||||||
|
hc:Dialog.Token="{x:Static data:MessageToken.DialogContainer}"
|
||||||
Background="{DynamicResource RegionBrush}"
|
Background="{DynamicResource RegionBrush}"
|
||||||
MinWidth="300"
|
MinWidth="500"
|
||||||
DataContext="{Binding DialogDemo,Source={StaticResource Locator}}">
|
DataContext="{Binding DialogDemo,Source={StaticResource Locator}}">
|
||||||
<hc:TransitioningContentControl>
|
<AdornerDecorator>
|
||||||
<StackPanel Margin="32" VerticalAlignment="Center">
|
<hc:TransitioningContentControl>
|
||||||
<Button Content="{x:Static langs:Lang.TextDialog}" Command="{Binding ShowTextCmd}" />
|
<hc:SimplePanel>
|
||||||
<Button Margin="0,32,0,0" Content="{x:Static langs:Lang.TextDialogWithTimer}" Command="{Binding ShowInteractiveDialogCmd}" CommandParameter="True"/>
|
<StackPanel Margin="32" VerticalAlignment="Center">
|
||||||
<TextBox Margin="0,32,0,0" Text="{Binding DialogResult,UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TextBoxExtend}" hc:InfoElement.Placeholder="{x:Static langs:Lang.PleaseInput}"/>
|
<Button Content="{x:Static langs:Lang.TextDialog}" Command="{Binding ShowTextCmd}" />
|
||||||
<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.TextDialogInControl}" Command="{Binding ShowTextCmd}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType=UserControl}}"/>
|
||||||
<Button Margin="0,32,0,0" Content="{x:Static langs:Lang.NewWindow}" Command="{Binding NewWindowCmd}"/>
|
<Button Margin="0,32,0,0" Content="{x:Static langs:Lang.TextDialogWithTimer}" Command="{Binding ShowInteractiveDialogCmd}" CommandParameter="True"/>
|
||||||
</StackPanel>
|
<TextBox Margin="0,32,0,0" Text="{Binding DialogResult,UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TextBoxExtend}" hc:InfoElement.Placeholder="{x:Static langs:Lang.PleaseInput}"/>
|
||||||
</hc:TransitioningContentControl>
|
<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>
|
||||||
|
</hc:SimplePanel>
|
||||||
|
</hc:TransitioningContentControl>
|
||||||
|
</AdornerDecorator>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -29,12 +29,19 @@ namespace HandyControlDemo.ViewModel
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand ShowTextCmd => new Lazy<RelayCommand>(() =>
|
public RelayCommand<FrameworkElement> ShowTextCmd => new Lazy<RelayCommand<FrameworkElement>>(() =>
|
||||||
new RelayCommand(ShowText)).Value;
|
new RelayCommand<FrameworkElement>(ShowText)).Value;
|
||||||
|
|
||||||
private void ShowText()
|
private void ShowText(FrameworkElement element)
|
||||||
{
|
{
|
||||||
Dialog.Show(new TextDialog());
|
if (element == null)
|
||||||
|
{
|
||||||
|
Dialog.Show(new TextDialog());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Dialog.Show(new TextDialog(), MessageToken.DialogContainer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if netle40
|
#if netle40
|
||||||
|
|||||||
@@ -16,14 +16,14 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
private Adorner _container;
|
private Adorner _container;
|
||||||
|
|
||||||
private static readonly Dictionary<string, System.Windows.Window> WindowDic = new Dictionary<string, System.Windows.Window>();
|
private static readonly Dictionary<string, FrameworkElement> ContainerDic = new Dictionary<string, FrameworkElement>();
|
||||||
|
|
||||||
public static readonly DependencyProperty IsClosedProperty = DependencyProperty.Register(
|
public static readonly DependencyProperty IsClosedProperty = DependencyProperty.Register(
|
||||||
"IsClosed", typeof(bool), typeof(Dialog), new PropertyMetadata(ValueBoxes.FalseBox));
|
"IsClosed", typeof(bool), typeof(Dialog), new PropertyMetadata(ValueBoxes.FalseBox));
|
||||||
|
|
||||||
public bool IsClosed
|
public bool IsClosed
|
||||||
{
|
{
|
||||||
get => (bool) GetValue(IsClosedProperty);
|
get => (bool)GetValue(IsClosedProperty);
|
||||||
internal set => SetValue(IsClosedProperty, value);
|
internal set => SetValue(IsClosedProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,15 +32,15 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
private static void OnTokenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
private static void OnTokenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (d is System.Windows.Window window)
|
if (d is FrameworkElement element)
|
||||||
{
|
{
|
||||||
if (e.NewValue == null)
|
if (e.NewValue == null)
|
||||||
{
|
{
|
||||||
Unregister(window);
|
Unregister(element);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Register(e.NewValue.ToString(), window);
|
Register(e.NewValue.ToString(), element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,39 +49,39 @@ namespace HandyControl.Controls
|
|||||||
=> element.SetValue(TokenProperty, value);
|
=> element.SetValue(TokenProperty, value);
|
||||||
|
|
||||||
public static string GetToken(DependencyObject element)
|
public static string GetToken(DependencyObject element)
|
||||||
=> (string) element.GetValue(TokenProperty);
|
=> (string)element.GetValue(TokenProperty);
|
||||||
|
|
||||||
public Dialog()
|
public Dialog()
|
||||||
{
|
{
|
||||||
CommandBindings.Add(new CommandBinding(ControlCommands.Close, (s, e) => Close()));
|
CommandBindings.Add(new CommandBinding(ControlCommands.Close, (s, e) => Close()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Register(string token, System.Windows.Window window)
|
public static void Register(string token, FrameworkElement element)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(token) || window == null) return;
|
if (string.IsNullOrEmpty(token) || element == null) return;
|
||||||
WindowDic[token] = window;
|
ContainerDic[token] = element;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Unregister(string token, System.Windows.Window window)
|
public static void Unregister(string token, FrameworkElement element)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(token) || window == null) return;
|
if (string.IsNullOrEmpty(token) || element == null) return;
|
||||||
|
|
||||||
if (WindowDic.ContainsKey(token))
|
if (ContainerDic.ContainsKey(token))
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(WindowDic[token], window))
|
if (ReferenceEquals(ContainerDic[token], element))
|
||||||
{
|
{
|
||||||
WindowDic.Remove(token);
|
ContainerDic.Remove(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Unregister(System.Windows.Window window)
|
public static void Unregister(FrameworkElement element)
|
||||||
{
|
{
|
||||||
if (window == null) return;
|
if (element == null) return;
|
||||||
var first = WindowDic.FirstOrDefault(item => ReferenceEquals(window, item.Value));
|
var first = ContainerDic.FirstOrDefault(item => ReferenceEquals(element, item.Value));
|
||||||
if (!string.IsNullOrEmpty(first.Key))
|
if (!string.IsNullOrEmpty(first.Key))
|
||||||
{
|
{
|
||||||
WindowDic.Remove(first.Key);
|
ContainerDic.Remove(first.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,9 +89,9 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(token)) return;
|
if (string.IsNullOrEmpty(token)) return;
|
||||||
|
|
||||||
if (WindowDic.ContainsKey(token))
|
if (ContainerDic.ContainsKey(token))
|
||||||
{
|
{
|
||||||
WindowDic.Remove(token);
|
ContainerDic.Remove(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,20 +105,20 @@ namespace HandyControl.Controls
|
|||||||
Content = content
|
Content = content
|
||||||
};
|
};
|
||||||
|
|
||||||
System.Windows.Window window;
|
FrameworkElement element;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(token))
|
if (string.IsNullOrEmpty(token))
|
||||||
{
|
{
|
||||||
window = WindowHelper.GetActiveWindow();
|
element = WindowHelper.GetActiveWindow();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WindowDic.TryGetValue(token, out window);
|
ContainerDic.TryGetValue(token, out element);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
var decorator = VisualHelper.GetChild<AdornerDecorator>(window);
|
var decorator = VisualHelper.GetChild<AdornerDecorator>(element);
|
||||||
if (decorator != null)
|
if (decorator != null)
|
||||||
{
|
{
|
||||||
if (decorator.Child != null)
|
if (decorator.Child != null)
|
||||||
@@ -148,17 +148,17 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
Close(WindowHelper.GetActiveWindow());
|
Close(WindowHelper.GetActiveWindow());
|
||||||
}
|
}
|
||||||
else if (WindowDic.TryGetValue(_token, out var window))
|
else if (ContainerDic.TryGetValue(_token, out var element))
|
||||||
{
|
{
|
||||||
Close(window);
|
Close(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Close(System.Windows.Window window)
|
private void Close(DependencyObject element)
|
||||||
{
|
{
|
||||||
if (window != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
var decorator = VisualHelper.GetChild<AdornerDecorator>(window);
|
var decorator = VisualHelper.GetChild<AdornerDecorator>(element);
|
||||||
if (decorator != null)
|
if (decorator != null)
|
||||||
{
|
{
|
||||||
if (decorator.Child != null)
|
if (decorator.Child != null)
|
||||||
|
|||||||
Reference in new issue
Block a user