fixed #484
This commit is contained in:
1 parent
46d8e8bc65
commit
4ef70ba91d
5 files changed
+237
-38
No files matched your search
@@ -1,16 +1,26 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="clr-namespace:HandyControl.Controls"
|
||||
xmlns:langs="clr-namespace:HandyControl.Properties.Langs"
|
||||
xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
|
||||
xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
|
||||
xmlns:ex="clr-namespace:HandyControl.Tools.Extension"
|
||||
xmlns:themes="clr-namespace:HandyControl.Themes">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/Window.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="MessageBoxButtonStyle" BasedOn="{StaticResource {x:Type Button}}" TargetType="Button">
|
||||
<Setter Property="MinWidth" Value="88"/>
|
||||
<Setter Property="Visibility" Value="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}"/>
|
||||
<Setter Property="Margin" Value="5,0"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="MessageBoxPrimaryButtonStyle" BasedOn="{StaticResource ButtonPrimary}" TargetType="Button">
|
||||
<Setter Property="MinWidth" Value="88"/>
|
||||
<Setter Property="Visibility" Value="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}"/>
|
||||
<Setter Property="Margin" Value="5,0"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="hc:MessageBox" BasedOn="{StaticResource WindowWin10}">
|
||||
<Setter Property="MinHeight" Value="172"/>
|
||||
<Setter Property="ShowInTaskbar" Value="False"/>
|
||||
@@ -34,7 +44,7 @@
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel shell:WindowChrome.IsHitTestVisibleInChrome="True" UseLayoutRounding="True" VerticalAlignment="Top" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<Button Background="{TemplateBinding CloseButtonBackground}" Foreground="{TemplateBinding CloseButtonForeground}" Command="shell:SystemCommands.CloseWindowCommand" IsTabStop="False" Name="ButtonClose" Height="29" Style="{StaticResource ButtonIcon}" Width="46" hc:IconElement.Geometry="{StaticResource CloseGeometry}" BorderThickness="1,0,0,0" hc:IconElement.Width="10" hc:IconElement.Height="10"/>
|
||||
<Button Background="{TemplateBinding CloseButtonBackground}" Foreground="{TemplateBinding CloseButtonForeground}" IsTabStop="False" Name="PART_ButtonClose" Height="29" Style="{StaticResource ButtonIcon}" Width="46" hc:IconElement.Geometry="{StaticResource CloseGeometry}" BorderThickness="1,0,0,0" hc:IconElement.Width="10" hc:IconElement.Height="10"/>
|
||||
</StackPanel>
|
||||
<Grid Grid.Column="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -76,12 +86,7 @@
|
||||
<ScrollViewer Grid.Column="1" Grid.Row="0">
|
||||
<TextBlock Margin="10,39,10,10" Text="{TemplateBinding Message}" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
||||
</ScrollViewer>
|
||||
<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Margin="0,10,0,16" Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsCancel="True" MinWidth="88" Command="interactivity:ControlCommands.Cancel" Content="{ex:Lang Key={x:Static langs:LangKeys.Cancel}}" Margin="5,0"/>
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsDefault="True" MinWidth="88" Command="interactivity:ControlCommands.Confirm" Content="{ex:Lang Key={x:Static langs:LangKeys.Confirm}}" Margin="5,0" Style="{StaticResource ButtonPrimary}"/>
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsCancel="True" MinWidth="88" Command="interactivity:ControlCommands.No" Content="{ex:Lang Key={x:Static langs:LangKeys.No}}" Margin="5,0"/>
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsDefault="True" MinWidth="88" Command="interactivity:ControlCommands.Yes" Content="{ex:Lang Key={x:Static langs:LangKeys.Yes}}" Margin="5,0" Style="{StaticResource ButtonPrimary}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Name="PART_Panel" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Margin="0,10,0,16" Orientation="Horizontal" HorizontalAlignment="Center"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
@@ -89,9 +94,9 @@
|
||||
<Trigger Property="IsActive" Value="False">
|
||||
<Setter Property="Opacity" Value=".8" TargetName="ContentPresenterMain"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonClose">
|
||||
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
<Trigger Property="IsMouseOver" Value="True" SourceName="PART_ButtonClose">
|
||||
<Setter Property="Background" TargetName="PART_ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
<Setter Property="Foreground" TargetName="PART_ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
@@ -4,11 +4,14 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Media;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Interactivity;
|
||||
using HandyControl.Properties.Langs;
|
||||
using HandyControl.Tools;
|
||||
using HandyControl.Tools.Interop;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
@@ -16,10 +19,29 @@ namespace HandyControl.Controls
|
||||
/// 消息框
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "RedundantDelegateCreation")]
|
||||
[TemplatePart(Name = ElementPanel, Type = typeof(Panel))]
|
||||
[TemplatePart(Name = ElementButtonClose, Type = typeof(Button))]
|
||||
|
||||
public sealed class MessageBox : Window
|
||||
{
|
||||
private const string ElementPanel = "PART_Panel";
|
||||
|
||||
private const string ElementButtonClose = "PART_ButtonClose";
|
||||
|
||||
private Button _buttonClose;
|
||||
|
||||
private Panel _panel;
|
||||
|
||||
private MessageBoxResult _messageBoxResult = MessageBoxResult.Cancel;
|
||||
|
||||
private Button _buttonOk;
|
||||
|
||||
private Button _buttonCancel;
|
||||
|
||||
private Button _buttonYes;
|
||||
|
||||
private Button _buttonNo;
|
||||
|
||||
private bool _showOk;
|
||||
|
||||
private bool _showCancel;
|
||||
@@ -88,9 +110,69 @@ namespace HandyControl.Controls
|
||||
}, (s, e) => e.CanExecute = _showNo));
|
||||
}
|
||||
|
||||
protected override void OnSourceInitialized(EventArgs e)
|
||||
{
|
||||
if (_showYes && !_showCancel)
|
||||
{
|
||||
var hMenu = InteropMethods.GetSystemMenu(this.GetHandle(), false);
|
||||
if (hMenu != IntPtr.Zero)
|
||||
{
|
||||
InteropMethods.EnableMenuItem(hMenu, InteropValues.SC_CLOSE, InteropValues.MF_BYCOMMAND | InteropValues.MF_GRAYED);
|
||||
}
|
||||
|
||||
if (_buttonClose != null)
|
||||
{
|
||||
_buttonClose.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
base.OnSourceInitialized(e);
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
_panel = GetTemplateChild(ElementPanel) as Panel;
|
||||
if (_panel != null)
|
||||
{
|
||||
if (_buttonOk != null)
|
||||
{
|
||||
_panel.Children.Add(_buttonOk);
|
||||
}
|
||||
|
||||
if (_buttonYes != null)
|
||||
{
|
||||
_panel.Children.Add(_buttonYes);
|
||||
}
|
||||
|
||||
if (_buttonNo != null)
|
||||
{
|
||||
_panel.Children.Add(_buttonNo);
|
||||
}
|
||||
|
||||
if (_buttonCancel != null)
|
||||
{
|
||||
_panel.Children.Add(_buttonCancel);
|
||||
}
|
||||
}
|
||||
|
||||
_buttonClose = GetTemplateChild(ElementButtonClose) as Button;
|
||||
if (_buttonClose != null)
|
||||
{
|
||||
_buttonClose.Click += ButtonClose_Click;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonClose_Click(object sender, RoutedEventArgs e) => Close();
|
||||
|
||||
protected override void OnPreviewKeyDown(KeyEventArgs e)
|
||||
{
|
||||
base.OnPreviewKeyDown(e);
|
||||
if (e.Key == Key.System && e.SystemKey == Key.F4)
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.C)
|
||||
{
|
||||
@@ -108,22 +190,22 @@ namespace HandyControl.Controls
|
||||
builder.Append(Environment.NewLine);
|
||||
if (_showOk)
|
||||
{
|
||||
builder.Append(Properties.Langs.Lang.Confirm);
|
||||
builder.Append(Lang.Confirm);
|
||||
builder.Append(" ");
|
||||
}
|
||||
if (_showYes)
|
||||
{
|
||||
builder.Append(Properties.Langs.Lang.Yes);
|
||||
builder.Append(Lang.Yes);
|
||||
builder.Append(" ");
|
||||
}
|
||||
if (_showNo)
|
||||
{
|
||||
builder.Append(Properties.Langs.Lang.No);
|
||||
builder.Append(Lang.No);
|
||||
builder.Append(" ");
|
||||
}
|
||||
if (_showCancel)
|
||||
{
|
||||
builder.Append(Properties.Langs.Lang.Cancel);
|
||||
builder.Append(Lang.Cancel);
|
||||
builder.Append(" ");
|
||||
}
|
||||
builder.Append(Environment.NewLine);
|
||||
@@ -144,7 +226,7 @@ namespace HandyControl.Controls
|
||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OK);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
||||
messageBox.ShowImage = true;
|
||||
messageBox.Image = ResourceHelper.GetResource<Geometry>(ResourceToken.SuccessGeometry);
|
||||
messageBox.ImageBrush = ResourceHelper.GetResource<Brush>(ResourceToken.SuccessBrush);
|
||||
@@ -166,7 +248,7 @@ namespace HandyControl.Controls
|
||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OK);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
||||
SetImage(messageBox, MessageBoxImage.Information);
|
||||
SystemSounds.Asterisk.Play();
|
||||
messageBox.ShowDialog();
|
||||
@@ -186,7 +268,7 @@ namespace HandyControl.Controls
|
||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OK);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
||||
SetImage(messageBox, MessageBoxImage.Warning);
|
||||
SystemSounds.Asterisk.Play();
|
||||
messageBox.ShowDialog();
|
||||
@@ -206,7 +288,7 @@ namespace HandyControl.Controls
|
||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OK);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
||||
SetImage(messageBox, MessageBoxImage.Error);
|
||||
SystemSounds.Asterisk.Play();
|
||||
messageBox.ShowDialog();
|
||||
@@ -226,7 +308,7 @@ namespace HandyControl.Controls
|
||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OK);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
||||
messageBox.ShowImage = true;
|
||||
messageBox.Image = ResourceHelper.GetResource<Geometry>(ResourceToken.FatalGeometry);
|
||||
messageBox.ImageBrush = ResourceHelper.GetResource<Brush>(ResourceToken.PrimaryTextBrush);
|
||||
@@ -248,7 +330,7 @@ namespace HandyControl.Controls
|
||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Cancel);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OKCancel);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OKCancel, MessageBoxResult.Cancel);
|
||||
SetImage(messageBox, MessageBoxImage.Question);
|
||||
SystemSounds.Asterisk.Play();
|
||||
messageBox.ShowDialog();
|
||||
@@ -268,7 +350,7 @@ namespace HandyControl.Controls
|
||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
messageBox = CreateMessageBox(null, info.Message, info.Caption, info.Button, MessageBoxImage.None, info.DefaultResult);
|
||||
SetButtonStatus(messageBox, info.Button);
|
||||
SetButtonStatus(messageBox, info.Button, info.DefaultResult);
|
||||
|
||||
if (!string.IsNullOrEmpty(info.IconKey))
|
||||
{
|
||||
@@ -318,7 +400,7 @@ namespace HandyControl.Controls
|
||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
messageBox = CreateMessageBox(owner, messageBoxText, caption, button, icon, defaultResult);
|
||||
SetButtonStatus(messageBox, button);
|
||||
SetButtonStatus(messageBox, button, defaultResult);
|
||||
SetImage(messageBox, icon);
|
||||
SystemSounds.Asterisk.Play();
|
||||
messageBox.ShowDialog();
|
||||
@@ -363,25 +445,126 @@ namespace HandyControl.Controls
|
||||
};
|
||||
}
|
||||
|
||||
private static void SetButtonStatus(MessageBox messageBox, MessageBoxButton messageBoxButton)
|
||||
private static void SetButtonStatus(MessageBox messageBox, MessageBoxButton messageBoxButton, MessageBoxResult defaultResult)
|
||||
{
|
||||
switch (messageBoxButton)
|
||||
{
|
||||
case MessageBoxButton.OK:
|
||||
messageBox._showOk = true;
|
||||
messageBox._buttonOk = new Button
|
||||
{
|
||||
IsCancel = true,
|
||||
IsDefault = true,
|
||||
Content = Lang.Confirm,
|
||||
Command = ControlCommands.Confirm,
|
||||
Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle")
|
||||
};
|
||||
|
||||
break;
|
||||
case MessageBoxButton.OKCancel:
|
||||
messageBox._showOk = true;
|
||||
messageBox._buttonOk = new Button
|
||||
{
|
||||
Content = Lang.Confirm,
|
||||
Command = ControlCommands.Confirm
|
||||
};
|
||||
|
||||
messageBox._showCancel = true;
|
||||
messageBox._buttonCancel = new Button
|
||||
{
|
||||
IsCancel = true,
|
||||
Content = Lang.Cancel,
|
||||
Command = ControlCommands.Cancel
|
||||
};
|
||||
|
||||
if (defaultResult == MessageBoxResult.Cancel)
|
||||
{
|
||||
messageBox._buttonOk.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
||||
messageBox._buttonCancel.Style = ResourceHelper.GetResource<Style>("MessageBoxPrimaryButtonStyle");
|
||||
messageBox._buttonCancel.IsDefault = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
messageBox._buttonOk.Style = ResourceHelper.GetResource<Style>("MessageBoxPrimaryButtonStyle");
|
||||
messageBox._buttonOk.IsDefault = true;
|
||||
messageBox._buttonCancel.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
||||
}
|
||||
|
||||
break;
|
||||
case MessageBoxButton.YesNo:
|
||||
messageBox._showYes = true;
|
||||
messageBox._buttonYes = new Button
|
||||
{
|
||||
Content = Lang.Yes,
|
||||
Command = ControlCommands.Yes
|
||||
};
|
||||
|
||||
messageBox._showNo = true;
|
||||
messageBox._buttonNo = new Button
|
||||
{
|
||||
Content = Lang.No,
|
||||
Command = ControlCommands.No
|
||||
};
|
||||
|
||||
if (defaultResult == MessageBoxResult.No)
|
||||
{
|
||||
messageBox._buttonYes.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
||||
messageBox._buttonNo.Style = ResourceHelper.GetResource<Style>("MessageBoxPrimaryButtonStyle");
|
||||
messageBox._buttonNo.IsDefault = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
messageBox._buttonYes.Style = ResourceHelper.GetResource<Style>("MessageBoxPrimaryButtonStyle");
|
||||
messageBox._buttonYes.IsDefault = true;
|
||||
messageBox._buttonNo.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
||||
}
|
||||
|
||||
break;
|
||||
case MessageBoxButton.YesNoCancel:
|
||||
messageBox._showYes = true;
|
||||
messageBox._buttonYes = new Button
|
||||
{
|
||||
Content = Lang.Yes,
|
||||
Command = ControlCommands.Yes
|
||||
};
|
||||
|
||||
messageBox._showNo = true;
|
||||
messageBox._buttonNo = new Button
|
||||
{
|
||||
Content = Lang.No,
|
||||
Command = ControlCommands.No
|
||||
};
|
||||
|
||||
messageBox._showCancel = true;
|
||||
messageBox._buttonCancel = new Button
|
||||
{
|
||||
IsCancel = true,
|
||||
Content = Lang.Cancel,
|
||||
Command = ControlCommands.Cancel
|
||||
};
|
||||
|
||||
if (defaultResult == MessageBoxResult.No)
|
||||
{
|
||||
messageBox._buttonYes.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
||||
messageBox._buttonNo.Style = ResourceHelper.GetResource<Style>("MessageBoxPrimaryButtonStyle");
|
||||
messageBox._buttonNo.IsDefault = true;
|
||||
messageBox._buttonCancel.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
||||
}
|
||||
else if (defaultResult == MessageBoxResult.Cancel)
|
||||
{
|
||||
messageBox._buttonYes.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
||||
messageBox._buttonNo.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
||||
messageBox._buttonCancel.Style = ResourceHelper.GetResource<Style>("MessageBoxPrimaryButtonStyle");
|
||||
messageBox._buttonCancel.IsDefault = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
messageBox._buttonYes.Style = ResourceHelper.GetResource<Style>("MessageBoxPrimaryButtonStyle");
|
||||
messageBox._buttonYes.IsDefault = true;
|
||||
messageBox._buttonNo.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
||||
messageBox._buttonCancel.Style = ResourceHelper.GetResource<Style>("MessageBoxButtonStyle");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,25 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="clr-namespace:HandyControl.Controls"
|
||||
xmlns:langs="clr-namespace:HandyControl.Properties.Langs"
|
||||
xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
|
||||
xmlns:ex="clr-namespace:HandyControl.Tools.Extension"
|
||||
xmlns:themes="clr-namespace:HandyControl.Themes">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/Window.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="MessageBoxButtonStyle" BasedOn="{StaticResource {x:Type Button}}" TargetType="Button">
|
||||
<Setter Property="MinWidth" Value="88"/>
|
||||
<Setter Property="Visibility" Value="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}"/>
|
||||
<Setter Property="Margin" Value="5,0"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="MessageBoxPrimaryButtonStyle" BasedOn="{StaticResource ButtonPrimary}" TargetType="Button">
|
||||
<Setter Property="MinWidth" Value="88"/>
|
||||
<Setter Property="Visibility" Value="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}"/>
|
||||
<Setter Property="Margin" Value="5,0"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="hc:MessageBox" BasedOn="{StaticResource WindowWin10}">
|
||||
<Setter Property="MinHeight" Value="172"/>
|
||||
<Setter Property="ShowInTaskbar" Value="False"/>
|
||||
@@ -33,7 +43,7 @@
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel WindowChrome.IsHitTestVisibleInChrome="True" UseLayoutRounding="True" VerticalAlignment="Top" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<Button Background="{TemplateBinding CloseButtonBackground}" Foreground="{TemplateBinding CloseButtonForeground}" Command="SystemCommands.CloseWindowCommand" IsTabStop="False" Name="ButtonClose" Height="29" Style="{StaticResource ButtonIcon}" Width="46" hc:IconElement.Geometry="{StaticResource CloseGeometry}" BorderThickness="1,0,0,0" hc:IconElement.Width="10" hc:IconElement.Height="10"/>
|
||||
<Button Background="{TemplateBinding CloseButtonBackground}" Foreground="{TemplateBinding CloseButtonForeground}" IsTabStop="False" Name="PART_ButtonClose" Height="29" Style="{StaticResource ButtonIcon}" Width="46" hc:IconElement.Geometry="{StaticResource CloseGeometry}" BorderThickness="1,0,0,0" hc:IconElement.Width="10" hc:IconElement.Height="10"/>
|
||||
</StackPanel>
|
||||
<Grid Grid.Column="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -75,12 +85,7 @@
|
||||
<ScrollViewer Grid.Column="1" Grid.Row="0">
|
||||
<TextBlock Margin="10,39,10,10" Text="{TemplateBinding Message}" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
||||
</ScrollViewer>
|
||||
<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Margin="0,10,0,16" Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsCancel="True" MinWidth="88" Command="interactivity:ControlCommands.Cancel" Content="{ex:Lang Key={x:Static langs:LangKeys.Cancel}}" Margin="5,0"/>
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsDefault="True" MinWidth="88" Command="interactivity:ControlCommands.Confirm" Content="{ex:Lang Key={x:Static langs:LangKeys.Confirm}}" Margin="5,0" Style="{StaticResource ButtonPrimary}"/>
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsCancel="True" MinWidth="88" Command="interactivity:ControlCommands.No" Content="{ex:Lang Key={x:Static langs:LangKeys.No}}" Margin="5,0"/>
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsDefault="True" MinWidth="88" Command="interactivity:ControlCommands.Yes" Content="{ex:Lang Key={x:Static langs:LangKeys.Yes}}" Margin="5,0" Style="{StaticResource ButtonPrimary}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Name="PART_Panel" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Margin="0,10,0,16" Orientation="Horizontal" HorizontalAlignment="Center"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
@@ -88,9 +93,9 @@
|
||||
<Trigger Property="IsActive" Value="False">
|
||||
<Setter Property="Opacity" Value=".8" TargetName="ContentPresenterMain"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonClose">
|
||||
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
<Trigger Property="IsMouseOver" Value="True" SourceName="PART_ButtonClose">
|
||||
<Setter Property="Background" TargetName="PART_ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
<Setter Property="Foreground" TargetName="PART_ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
@@ -91,6 +91,9 @@ namespace HandyControl.Tools.Interop
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern bool EnableMenuItem(IntPtr hMenu, int UIDEnabledItem, int uEnable);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern bool InsertMenu(IntPtr hMenu, int wPosition, int wFlags, int wIDNewItem, string lpNewItem);
|
||||
|
||||
|
||||
@@ -73,7 +73,9 @@ namespace HandyControl.Tools.Interop
|
||||
WM_CLIPBOARDUPDATE = 0x031D,
|
||||
WM_USER = 0x0400,
|
||||
WS_VISIBLE = 0x10000000,
|
||||
MF_BYCOMMAND = 0x00000000,
|
||||
MF_BYPOSITION = 0x400,
|
||||
MF_GRAYED = 0x00000001,
|
||||
MF_SEPARATOR = 0x800,
|
||||
TB_GETBUTTON = WM_USER + 23,
|
||||
TB_BUTTONCOUNT = WM_USER + 24,
|
||||
@@ -82,6 +84,7 @@ namespace HandyControl.Tools.Interop
|
||||
DESKTOPVERTRES = 117,
|
||||
LOGPIXELSX = 88,
|
||||
LOGPIXELSY = 90,
|
||||
SC_CLOSE = 0xF060,
|
||||
SC_SIZE = 0xF000,
|
||||
SC_MOVE = 0xF010,
|
||||
SC_MINIMIZE = 0xF020,
|
||||
|
||||
Reference in new issue
Block a user