mirror of
https://gitee.com/handyorg/HandyControl.git
synced 2024-11-30 02:48:03 +08:00
commit
ceef81ba94
@ -1,9 +1,69 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using HandyControl.Interactivity;
|
||||
using HandyControl.Tools;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class Dialog : ContentControl
|
||||
{
|
||||
|
||||
private Adorner _container;
|
||||
|
||||
public Dialog()
|
||||
{
|
||||
CommandBindings.Add(new CommandBinding(ControlCommands.Close, (s, e) => Close()));
|
||||
}
|
||||
|
||||
public static Dialog Show(object content)
|
||||
{
|
||||
var dialog = new Dialog
|
||||
{
|
||||
Content = content
|
||||
};
|
||||
|
||||
var window = VisualHelper.GetActiveWindow();
|
||||
if (window != null)
|
||||
{
|
||||
var decorator = VisualHelper.GetChild<AdornerDecorator>(window);
|
||||
if (decorator != null)
|
||||
{
|
||||
if (decorator.Child != null)
|
||||
{
|
||||
decorator.Child.IsEnabled = false;
|
||||
}
|
||||
var layer = decorator.AdornerLayer;
|
||||
if (layer != null)
|
||||
{
|
||||
var container = new AdornerContainer(layer)
|
||||
{
|
||||
Child = dialog
|
||||
};
|
||||
dialog._container = container;
|
||||
layer.Add(container);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
var window = VisualHelper.GetActiveWindow();
|
||||
if (window != null)
|
||||
{
|
||||
var decorator = VisualHelper.GetChild<AdornerDecorator>(window);
|
||||
if (decorator != null)
|
||||
{
|
||||
if (decorator.Child != null)
|
||||
{
|
||||
decorator.Child.IsEnabled = true;
|
||||
}
|
||||
var layer = decorator.AdornerLayer;
|
||||
layer?.Remove(_container);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
_scrollViewer.ScrollChanged -= ScrollViewer_ScrollChanged;
|
||||
}
|
||||
_scrollViewer = VisualHelper.GetGetChild<System.Windows.Controls.ScrollViewer>(obj);
|
||||
_scrollViewer = VisualHelper.GetChild<System.Windows.Controls.ScrollViewer>(obj);
|
||||
if (_scrollViewer != null)
|
||||
{
|
||||
_scrollViewer.ScrollChanged += ScrollViewer_ScrollChanged;
|
||||
|
@ -398,6 +398,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Base\DialogBaseStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Base\GotoTopBaseStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@ -450,6 +454,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Dialog.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\FlipClock.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
@ -14,8 +14,7 @@ namespace HandyControl.Interactivity
|
||||
|
||||
public UIElement Child
|
||||
{
|
||||
get =>
|
||||
_child;
|
||||
get => _child;
|
||||
set
|
||||
{
|
||||
AddVisualChild(value);
|
||||
|
19
HandyControl/Themes/Styles/Base/DialogBaseStyle.xaml
Normal file
19
HandyControl/Themes/Styles/Base/DialogBaseStyle.xaml
Normal file
@ -0,0 +1,19 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls">
|
||||
|
||||
<Style x:Key="DialogBaseStyle" TargetType="controls:Dialog">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:Dialog">
|
||||
<Border Background="{DynamicResource DarkOpacityBrush}">
|
||||
<ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
10
HandyControl/Themes/Styles/Dialog.xaml
Normal file
10
HandyControl/Themes/Styles/Dialog.xaml
Normal file
@ -0,0 +1,10 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Base/DialogBaseStyle.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style BasedOn="{StaticResource DialogBaseStyle}" TargetType="controls:Dialog"/>
|
||||
|
||||
</ResourceDictionary>
|
@ -60,6 +60,7 @@
|
||||
<ResourceDictionary Source="GotoTop.xaml"/>
|
||||
<ResourceDictionary Source="Gravatar.xaml"/>
|
||||
<ResourceDictionary Source="Badge.xaml"/>
|
||||
<ResourceDictionary Source="Dialog.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
</ResourceDictionary>
|
@ -27,18 +27,18 @@ namespace HandyControl.Tools
|
||||
: null;
|
||||
}
|
||||
|
||||
internal static T GetGetChild<T>(DependencyObject d) where T : DependencyObject
|
||||
internal static T GetChild<T>(DependencyObject d) where T : DependencyObject
|
||||
{
|
||||
if (d is T scrollViewer)
|
||||
if (d is T t)
|
||||
{
|
||||
return scrollViewer;
|
||||
return t;
|
||||
}
|
||||
|
||||
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(d); i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(d, i);
|
||||
|
||||
var result = GetGetChild<T>(child);
|
||||
var result = GetChild<T>(child);
|
||||
if (result != null) return result;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
<ObjectDataProvider x:Key="DemoTypes" MethodName="GetValues" ObjectType="sys:Enum">
|
||||
<ObjectDataProvider.MethodParameters>
|
||||
<x:Type Type="data:DemoType"></x:Type>
|
||||
<x:Type Type="data:DemoType"/>
|
||||
</ObjectDataProvider.MethodParameters>
|
||||
</ObjectDataProvider>
|
||||
|
||||
|
@ -88,6 +88,8 @@
|
||||
|
||||
public static readonly string GravatarDemoCtl = nameof(GravatarDemoCtl);
|
||||
|
||||
public static readonly string DialogDemoCtl = nameof(DialogDemoCtl);
|
||||
|
||||
public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl);
|
||||
|
||||
public static readonly string ToggleButtonDemoCtl = nameof(ToggleButtonDemoCtl);
|
||||
|
@ -46,7 +46,8 @@ var controlList = new List<string>
|
||||
"ChatBubbleDemoCtl",
|
||||
"GotoTopDemoCtl",
|
||||
"BadgeDemoCtl",
|
||||
"GravatarDemoCtl"
|
||||
"GravatarDemoCtl",
|
||||
"DialogDemoCtl"
|
||||
};
|
||||
var styleList = new List<string>
|
||||
{
|
||||
|
@ -130,6 +130,9 @@
|
||||
<Compile Include="UserControl\Basic\ChatBox.xaml.cs">
|
||||
<DependentUpon>ChatBox.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UserControl\Basic\TextDialog.xaml.cs">
|
||||
<DependentUpon>TextDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UserControl\Controls\AnimationPathDemoCtl.xaml.cs">
|
||||
<DependentUpon>AnimationPathDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -148,6 +151,9 @@
|
||||
<Compile Include="UserControl\Controls\CirclePanelDemoCtl.xaml.cs">
|
||||
<DependentUpon>CirclePanelDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UserControl\Controls\DialogDemoCtl.xaml.cs">
|
||||
<DependentUpon>DialogDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UserControl\Controls\ProgressBarDemoCtl.xaml.cs">
|
||||
<DependentUpon>ProgressBarDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -352,6 +358,7 @@
|
||||
<Compile Include="ViewModel\Basic\ChatBoxViewModel.cs" />
|
||||
<Compile Include="ViewModel\Common\ComboBoxDemoViewModel.cs" />
|
||||
<Compile Include="ViewModel\Controls\CoverViewModel.cs" />
|
||||
<Compile Include="ViewModel\Controls\DialogDemoViewModel.cs" />
|
||||
<Compile Include="ViewModel\DemoViewModelBase!1.cs" />
|
||||
<Compile Include="ViewModel\Main\ContributorsViewModel.cs" />
|
||||
<Compile Include="ViewModel\Controls\GrowlDemoViewModel.cs" />
|
||||
@ -440,6 +447,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UserControl\Basic\TextDialog.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UserControl\Controls\AnimationPathDemoCtl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@ -464,6 +475,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UserControl\Controls\DialogDemoCtl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UserControl\Controls\ProgressBarDemoCtl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@ -774,6 +789,7 @@
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>MessageToken.cs</LastGenOutput>
|
||||
</Content>
|
||||
<Resource Include="Resources\Img\LeftMainContent\Dialog_16x.png" />
|
||||
<Resource Include="Resources\Img\under_construction.gif" />
|
||||
<Resource Include="Resources\Img\LeftMainContent\User_16x.png" />
|
||||
<Resource Include="Resources\Img\LeftMainContent\DotLarge_16x.png" />
|
||||
|
27
HandyControlDemo/Properties/Langs/Lang.Designer.cs
generated
27
HandyControlDemo/Properties/Langs/Lang.Designer.cs
generated
@ -393,6 +393,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 对话框 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string Dialog {
|
||||
get {
|
||||
return ResourceManager.GetString("Dialog", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 在这里拖拽 的本地化字符串。
|
||||
/// </summary>
|
||||
@ -789,6 +798,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 请稍后... 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string PleaseWait {
|
||||
get {
|
||||
return ResourceManager.GetString("PleaseWait", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 请输入内容 的本地化字符串。
|
||||
/// </summary>
|
||||
@ -1104,6 +1122,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 文本对话框 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TextDialog {
|
||||
get {
|
||||
return ResourceManager.GetString("TextDialog", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 时间条 的本地化字符串。
|
||||
/// </summary>
|
||||
|
@ -513,4 +513,13 @@
|
||||
<data name="Reply" xml:space="preserve">
|
||||
<value>Reply</value>
|
||||
</data>
|
||||
<data name="Dialog" xml:space="preserve">
|
||||
<value>Dialog</value>
|
||||
</data>
|
||||
<data name="TextDialog" xml:space="preserve">
|
||||
<value>TextDialog</value>
|
||||
</data>
|
||||
<data name="PleaseWait" xml:space="preserve">
|
||||
<value>Please wait...</value>
|
||||
</data>
|
||||
</root>
|
@ -513,4 +513,13 @@
|
||||
<data name="Reply" xml:space="preserve">
|
||||
<value>回复</value>
|
||||
</data>
|
||||
<data name="Dialog" xml:space="preserve">
|
||||
<value>对话框</value>
|
||||
</data>
|
||||
<data name="TextDialog" xml:space="preserve">
|
||||
<value>文本对话框</value>
|
||||
</data>
|
||||
<data name="PleaseWait" xml:space="preserve">
|
||||
<value>请稍后...</value>
|
||||
</data>
|
||||
</root>
|
BIN
HandyControlDemo/Resources/Img/LeftMainContent/Dialog_16x.png
Normal file
BIN
HandyControlDemo/Resources/Img/LeftMainContent/Dialog_16x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 183 B |
15
HandyControlDemo/UserControl/Basic/TextDialog.xaml
Normal file
15
HandyControlDemo/UserControl/Basic/TextDialog.xaml
Normal file
@ -0,0 +1,15 @@
|
||||
<Border x:Class="HandyControlDemo.UserControl.TextDialog"
|
||||
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"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<Grid>
|
||||
<TextBlock Style="{StaticResource TextBlockLargeBold}" Text="{x:Static langs:Lang.PleaseWait}"/>
|
||||
<Button Width="22" Height="22" Command="interactivity:ControlCommands.Close" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource PrimaryBrush}" controls:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,4,0"/>
|
||||
</Grid>
|
||||
</Border>
|
10
HandyControlDemo/UserControl/Basic/TextDialog.xaml.cs
Normal file
10
HandyControlDemo/UserControl/Basic/TextDialog.xaml.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace HandyControlDemo.UserControl
|
||||
{
|
||||
public partial class TextDialog
|
||||
{
|
||||
public TextDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
8
HandyControlDemo/UserControl/Controls/DialogDemoCtl.xaml
Normal file
8
HandyControlDemo/UserControl/Controls/DialogDemoCtl.xaml
Normal file
@ -0,0 +1,8 @@
|
||||
<UserControl x:Class="HandyControlDemo.UserControl.DialogDemoCtl"
|
||||
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"
|
||||
Background="{DynamicResource RegionBrush}"
|
||||
DataContext="{Binding DialogDemo,Source={StaticResource Locator}}">
|
||||
<Button Margin="32" Content="{x:Static langs:Lang.TextDialog}" Command="{Binding ShowTextCmd}"/>
|
||||
</UserControl>
|
10
HandyControlDemo/UserControl/Controls/DialogDemoCtl.xaml.cs
Normal file
10
HandyControlDemo/UserControl/Controls/DialogDemoCtl.xaml.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace HandyControlDemo.UserControl
|
||||
{
|
||||
public partial class DialogDemoCtl
|
||||
{
|
||||
public DialogDemoCtl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -208,7 +208,7 @@
|
||||
<Image Source="../../Resources/Img/LeftMainContent/ProgressButton_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.ChatBubbleDemoCtl}" Content="{x:Static langs:Lang.ChatBubble}">
|
||||
<ListBoxItem Tag="{x:Static data:MessageToken.ChatBubbleDemoCtl}" Content="{x:Static langs:Lang.ChatBubble}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/Bubble_16xLG.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
@ -388,6 +388,11 @@
|
||||
<Image Source="../../Resources/Img/LeftMainContent/ScrollBox_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.DialogDemoCtl}" Content="{x:Static langs:Lang.Dialog}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/Dialog_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Tag="{x:Static data:MessageToken.WindowDemoCtl}" Content="{x:Static langs:Lang.Window}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/WindowsForm_16x.png"/>
|
||||
|
19
HandyControlDemo/ViewModel/Controls/DialogDemoViewModel.cs
Normal file
19
HandyControlDemo/ViewModel/Controls/DialogDemoViewModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using HandyControl.Controls;
|
||||
using HandyControlDemo.UserControl;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
public class DialogDemoViewModel : ViewModelBase
|
||||
{
|
||||
public RelayCommand ShowTextCmd => new Lazy<RelayCommand>(() =>
|
||||
new RelayCommand(ShowText)).Value;
|
||||
|
||||
private void ShowText()
|
||||
{
|
||||
Dialog.Show(new TextDialog());
|
||||
}
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@ namespace HandyControlDemo.ViewModel
|
||||
SimpleIoc.Default.Register<PaginationDemoViewModel>();
|
||||
SimpleIoc.Default.Register<ChatBoxViewModel>();
|
||||
SimpleIoc.Default.Register<CoverViewModel>();
|
||||
SimpleIoc.Default.Register<DialogDemoViewModel>();
|
||||
}
|
||||
|
||||
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
|
||||
@ -51,6 +52,8 @@ namespace HandyControlDemo.ViewModel
|
||||
|
||||
public CoverViewModel CoverView => ServiceLocator.Current.GetInstance<CoverViewModel>();
|
||||
|
||||
public DialogDemoViewModel DialogDemo => ServiceLocator.Current.GetInstance<DialogDemoViewModel>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -39,6 +39,10 @@ Step 3:enjoy coding
|
||||
|
||||
## Latest examples
|
||||
|
||||
### Dialog
|
||||
|
||||
![Dialog](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/Dialog.png)
|
||||
|
||||
### WaveProgressBar
|
||||
|
||||
![WaveProgressBar](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/WaveProgressBar.gif)
|
||||
@ -55,12 +59,12 @@ Step 3:enjoy coding
|
||||
|
||||
![ChatBubble](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/ChatBubble.png)
|
||||
|
||||
## History publication
|
||||
|
||||
### Transfer
|
||||
|
||||
![Transfer](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/Transfer.png)
|
||||
|
||||
## History publication
|
||||
|
||||
### ProgressButton
|
||||
|
||||
![ProgressButton](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/ProgressButton.png)
|
||||
|
BIN
Resources/Dialog.png
Normal file
BIN
Resources/Dialog.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
Loading…
Reference in New Issue
Block a user