fixed a bug of messagebox
This commit is contained in:
1 parent
fa0fc32eee
commit
30575922fe
5 files changed
+189
-161
No files matched your search
@@ -1,14 +1,10 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Interactivity;
|
||||
using HandyControl.Tools;
|
||||
using HandyControl.Tools.Extension;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
@@ -17,14 +13,6 @@ namespace HandyControl.Controls
|
||||
/// </summary>
|
||||
public sealed class MessageBox : Window
|
||||
{
|
||||
#region Constants
|
||||
|
||||
private const string ElementImage = "PART_Image";
|
||||
|
||||
private const string ElementMessage = "PART_Message";
|
||||
|
||||
#endregion Constants
|
||||
|
||||
private MessageBoxResult _messageBoxResult = MessageBoxResult.Cancel;
|
||||
|
||||
private bool _showOk;
|
||||
@@ -35,13 +23,41 @@ namespace HandyControl.Controls
|
||||
|
||||
private bool _showNo;
|
||||
|
||||
private string _message;
|
||||
public static readonly DependencyProperty MessageProperty = DependencyProperty.Register(
|
||||
"Message", typeof(string), typeof(MessageBox), new PropertyMetadata(default(string)));
|
||||
|
||||
private Geometry _image;
|
||||
public string Message
|
||||
{
|
||||
get => (string) GetValue(MessageProperty);
|
||||
set => SetValue(MessageProperty, value);
|
||||
}
|
||||
|
||||
private Brush _imageBrush;
|
||||
public static readonly DependencyProperty ImageProperty = DependencyProperty.Register(
|
||||
"Image", typeof(Geometry), typeof(MessageBox), new PropertyMetadata(default(Geometry)));
|
||||
|
||||
private bool _showImage;
|
||||
public Geometry Image
|
||||
{
|
||||
get => (Geometry) GetValue(ImageProperty);
|
||||
set => SetValue(ImageProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ImageBrushProperty = DependencyProperty.Register(
|
||||
"ImageBrush", typeof(Brush), typeof(MessageBox), new PropertyMetadata(default(Brush)));
|
||||
|
||||
public Brush ImageBrush
|
||||
{
|
||||
get => (Brush) GetValue(ImageBrushProperty);
|
||||
set => SetValue(ImageBrushProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ShowImageProperty = DependencyProperty.Register(
|
||||
"ShowImage", typeof(bool), typeof(MessageBox), new PropertyMetadata(ValueBoxes.FalseBox));
|
||||
|
||||
public bool ShowImage
|
||||
{
|
||||
get => (bool) GetValue(ShowImageProperty);
|
||||
set => SetValue(ShowImageProperty, value);
|
||||
}
|
||||
|
||||
private MessageBox()
|
||||
{
|
||||
@@ -67,23 +83,6 @@ namespace HandyControl.Controls
|
||||
}, (s, e) => e.CanExecute = _showNo));
|
||||
}
|
||||
|
||||
protected override void OnSourceInitialized(EventArgs e)
|
||||
{
|
||||
base.OnSourceInitialized(e);
|
||||
|
||||
if (LogicalTreeHelper.FindLogicalNode(this, ElementMessage) is TextBlock message) message.Text = _message;
|
||||
|
||||
if (_showImage)
|
||||
{
|
||||
if (LogicalTreeHelper.FindLogicalNode(this, ElementImage) is Path image)
|
||||
{
|
||||
image.Data = _image;
|
||||
image.Fill = _imageBrush;
|
||||
image.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 成功
|
||||
/// </summary>
|
||||
@@ -96,9 +95,9 @@ namespace HandyControl.Controls
|
||||
{
|
||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OK);
|
||||
messageBox._showImage = true;
|
||||
messageBox._image = ResourceHelper.GetResource<Geometry>(ResourceToken.SuccessGeometry);
|
||||
messageBox._imageBrush = ResourceHelper.GetResource<Brush>(ResourceToken.SuccessBrush);
|
||||
messageBox.ShowImage = true;
|
||||
messageBox.Image = ResourceHelper.GetResource<Geometry>(ResourceToken.SuccessGeometry);
|
||||
messageBox.ImageBrush = ResourceHelper.GetResource<Brush>(ResourceToken.SuccessBrush);
|
||||
messageBox.ShowDialog();
|
||||
});
|
||||
|
||||
@@ -174,9 +173,9 @@ namespace HandyControl.Controls
|
||||
{
|
||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OK);
|
||||
messageBox._showImage = true;
|
||||
messageBox._image = ResourceHelper.GetResource<Geometry>(ResourceToken.FatalGeometry);
|
||||
messageBox._imageBrush = ResourceHelper.GetResource<Brush>(ResourceToken.PrimaryTextBrush);
|
||||
messageBox.ShowImage = true;
|
||||
messageBox.Image = ResourceHelper.GetResource<Geometry>(ResourceToken.FatalGeometry);
|
||||
messageBox.ImageBrush = ResourceHelper.GetResource<Brush>(ResourceToken.PrimaryTextBrush);
|
||||
messageBox.ShowDialog();
|
||||
});
|
||||
|
||||
@@ -217,9 +216,9 @@ namespace HandyControl.Controls
|
||||
|
||||
if (!string.IsNullOrEmpty(info.IconKey))
|
||||
{
|
||||
messageBox._showImage = true;
|
||||
messageBox._image = ResourceHelper.GetResource<Geometry>(info.IconKey);
|
||||
messageBox._imageBrush = ResourceHelper.GetResource<Brush>(info.IconBrushKey);
|
||||
messageBox.ShowImage = true;
|
||||
messageBox.Image = ResourceHelper.GetResource<Geometry>(info.IconKey);
|
||||
messageBox.ImageBrush = ResourceHelper.GetResource<Brush>(info.IconBrushKey);
|
||||
}
|
||||
|
||||
messageBox.Style = info.Style;
|
||||
@@ -293,9 +292,9 @@ namespace HandyControl.Controls
|
||||
|
||||
return new MessageBox
|
||||
{
|
||||
_message = messageBoxText,
|
||||
Message = messageBoxText,
|
||||
Owner = ownerWindow,
|
||||
WindowStartupLocation = ownerIsNull ? WindowStartupLocation.CenterScreen : WindowStartupLocation.CenterOwner,
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen,
|
||||
ShowTitle = true,
|
||||
Title = caption ?? string.Empty,
|
||||
Topmost = ownerIsNull,
|
||||
@@ -352,9 +351,9 @@ namespace HandyControl.Controls
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(iconKey)) return;
|
||||
messageBox._showImage = true;
|
||||
messageBox._image = ResourceHelper.GetResource<Geometry>(iconKey);
|
||||
messageBox._imageBrush = ResourceHelper.GetResource<Brush>(iconBrushKey);
|
||||
messageBox.ShowImage = true;
|
||||
messageBox.Image = ResourceHelper.GetResource<Geometry>(iconKey);
|
||||
messageBox.ImageBrush = ResourceHelper.GetResource<Brush>(iconBrushKey);
|
||||
}
|
||||
|
||||
private static bool IsValidMessageBoxButton(MessageBoxButton value)
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools;
|
||||
using HandyControl.Tools.Extension;
|
||||
#if netle40
|
||||
using Microsoft.Windows.Shell;
|
||||
@@ -81,14 +79,14 @@ namespace HandyControl.Controls
|
||||
|
||||
private bool _isFullScreen;
|
||||
|
||||
private Thickness _actualBorderThickness;
|
||||
|
||||
private UIElement _nonClientArea;
|
||||
|
||||
private bool _showNonClientArea = true;
|
||||
|
||||
private double _tempNonClientAreaHeight;
|
||||
|
||||
private Thickness _tempThickness;
|
||||
|
||||
private WindowState _tempWindowState;
|
||||
|
||||
private WindowStyle _tempWindowStyle;
|
||||
@@ -106,31 +104,7 @@ namespace HandyControl.Controls
|
||||
new Binding(NonClientAreaHeightProperty.Name) {Source = this});
|
||||
WindowChrome.SetWindowChrome(this, chrome);
|
||||
|
||||
Loaded += delegate
|
||||
{
|
||||
_tempThickness = BorderThickness;
|
||||
if (WindowState == WindowState.Maximized)
|
||||
{
|
||||
BorderThickness = new Thickness();
|
||||
}
|
||||
|
||||
CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand,
|
||||
(s, e) => WindowState = WindowState.Minimized));
|
||||
CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand,
|
||||
(s, e) => WindowState = WindowState.Maximized));
|
||||
CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand,
|
||||
(s, e) => WindowState = WindowState.Normal));
|
||||
CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, (s, e) => Close()));
|
||||
CommandBindings.Add(new CommandBinding(SystemCommands.ShowSystemMenuCommand, ShowSystemMenu));
|
||||
|
||||
_tempNonClientAreaHeight = NonClientAreaHeight;
|
||||
_tempWindowState = WindowState;
|
||||
_tempWindowStyle = WindowStyle;
|
||||
_tempResizeMode = ResizeMode;
|
||||
|
||||
SwitchIsFullScreen(_isFullScreen);
|
||||
SwitchShowNonClientArea(_showNonClientArea);
|
||||
};
|
||||
Loaded += (s, e) => OnLoaded(e);
|
||||
}
|
||||
|
||||
public Brush CloseButtonBackground
|
||||
@@ -317,15 +291,34 @@ namespace HandyControl.Controls
|
||||
}
|
||||
else if (WindowState == WindowState.Normal)
|
||||
{
|
||||
BorderThickness = _tempThickness;
|
||||
BorderThickness = _actualBorderThickness;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
protected void OnLoaded(RoutedEventArgs args)
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
_actualBorderThickness = BorderThickness;
|
||||
if (WindowState == WindowState.Maximized)
|
||||
{
|
||||
BorderThickness = new Thickness();
|
||||
}
|
||||
|
||||
_nonClientArea = GetTemplateChild(ElementNonClientArea) as UIElement;
|
||||
CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand,
|
||||
(s, e) => WindowState = WindowState.Minimized));
|
||||
CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand,
|
||||
(s, e) => WindowState = WindowState.Maximized));
|
||||
CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand,
|
||||
(s, e) => WindowState = WindowState.Normal));
|
||||
CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, (s, e) => Close()));
|
||||
CommandBindings.Add(new CommandBinding(SystemCommands.ShowSystemMenuCommand, ShowSystemMenu));
|
||||
|
||||
_tempNonClientAreaHeight = NonClientAreaHeight;
|
||||
_tempWindowState = WindowState;
|
||||
_tempWindowStyle = WindowStyle;
|
||||
_tempResizeMode = ResizeMode;
|
||||
|
||||
SwitchIsFullScreen(_isFullScreen);
|
||||
SwitchShowNonClientArea(_showNonClientArea);
|
||||
|
||||
if (SizeToContent != SizeToContent.WidthAndHeight)
|
||||
return;
|
||||
@@ -334,11 +327,18 @@ namespace HandyControl.Controls
|
||||
Dispatcher.BeginInvoke(new Action(() => { SizeToContent = SizeToContent.WidthAndHeight; }));
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
_nonClientArea = GetTemplateChild(ElementNonClientArea) as UIElement;
|
||||
}
|
||||
|
||||
private void ShowSystemMenu(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
var point = WindowState == WindowState.Maximized
|
||||
? new Point(0, 28)
|
||||
: new Point(Left, Top + 28);
|
||||
? new Point(0, NonClientAreaHeight)
|
||||
: new Point(Left, Top + NonClientAreaHeight);
|
||||
SystemCommands.ShowSystemMenu(this, point);
|
||||
}
|
||||
|
||||
@@ -348,28 +348,5 @@ namespace HandyControl.Controls
|
||||
if (SizeToContent == SizeToContent.WidthAndHeight)
|
||||
InvalidateMeasure();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取自定义窗口
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Window GetCustomWindow(FrameworkElement content)
|
||||
{
|
||||
var window = new Window
|
||||
{
|
||||
Style = ResourceHelper.GetResource<Style>(ResourceToken.WindowWin10),
|
||||
Content = content
|
||||
};
|
||||
window.Loaded += (s, e) =>
|
||||
{
|
||||
window.Width = window.BorderThickness.Left + window.BorderThickness.Right + content.Width;
|
||||
if (!(window.Template.FindName("GridMenu", window) is Grid nemuArea))
|
||||
throw new NullReferenceException("can not find GridMenu in template");
|
||||
window.Height = window.BorderThickness.Top + window.BorderThickness.Bottom + content.Height +
|
||||
nemuArea.ActualHeight;
|
||||
};
|
||||
|
||||
return window;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,30 +17,106 @@
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="ResizeMode" Value="NoResize"/>
|
||||
<Setter Property="SizeToContent" Value="WidthAndHeight"/>
|
||||
<Setter Property="Content">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Path x:Name="PART_Image" HorizontalAlignment="Center" Visibility="Collapsed" Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" Margin="20,32,0,0" Width="30" Height="30" Stretch="Uniform"/>
|
||||
<ScrollViewer Grid.Column="1" Grid.Row="0">
|
||||
<TextBlock Margin="10,39,10,10" x:Name="PART_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" Background="{DynamicResource RegionBrush}" HorizontalAlignment="Center">
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsCancel="True" MinWidth="88" Command="interactivity:ControlCommands.Cancel" Content="{x:Static langs:Lang.Cancel}" Margin="5,0"/>
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsDefault="True" MinWidth="88" Command="interactivity:ControlCommands.Confirm" Content="{x:Static langs:Lang.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="{x:Static langs:Lang.No}" Margin="5,0"/>
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsDefault="True" MinWidth="88" Command="interactivity:ControlCommands.Yes" Content="{x:Static langs:Lang.Yes}" Margin="5,0" Style="{StaticResource ButtonPrimary}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<ControlTemplate TargetType="controls:MessageBox">
|
||||
<Border SnapsToDevicePixels="True" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
|
||||
<Grid Margin="{TemplateBinding Padding}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Background="{TemplateBinding NonClientAreaBackground}" Name="PART_NonClientArea" TextElement.Foreground="{TemplateBinding NonClientAreaForeground}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel WindowChrome.IsHitTestVisibleInChrome="True" UseLayoutRounding="True" VerticalAlignment="Top" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.MinimizeWindowCommand" IsTabStop="False" Name="ButtonMin" Height="29" Style="{StaticResource ButtonIcon}" Width="45" controls:IconElement.Geometry="{StaticResource WindowMinGeometry}" BorderThickness="1,0,1,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
|
||||
<Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.MaximizeWindowCommand" IsTabStop="False" Name="ButtonMax" Height="29" Style="{StaticResource ButtonIcon}" Width="46" controls:IconElement.Geometry="{StaticResource WindowMaxGeometry}" BorderThickness="1,0,1,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
|
||||
<Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.RestoreWindowCommand" IsTabStop="False" Name="ButtonRestore" Height="29" Style="{StaticResource ButtonIcon}" Width="46" controls:IconElement.Geometry="{StaticResource WindowRestoreGeometry}" BorderThickness="1,0,1,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
|
||||
<Button Background="{TemplateBinding CloseButtonBackground}" Foreground="{TemplateBinding CloseButtonForeground}" Command="SystemCommands.CloseWindowCommand" IsTabStop="False" Name="ButtonClose" Height="29" Style="{StaticResource ButtonIcon}" Width="46" controls:IconElement.Geometry="{StaticResource CloseGeometry}" BorderThickness="1,0,0,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
|
||||
</StackPanel>
|
||||
<Grid Grid.Column="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Name="Icon" Margin="10,0,0,0" Source="{TemplateBinding Icon}" VerticalAlignment="Center" Width="16" Height="16"/>
|
||||
<TextBlock Name="Title" Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center"/>
|
||||
<ContentPresenter WindowChrome.IsHitTestVisibleInChrome="True" Grid.Column="2" x:Name="ContentPresenterMain" Content="{TemplateBinding NonClientAreaContent}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Path Data="{TemplateBinding Image}" Fill="{TemplateBinding ImageBrush}" HorizontalAlignment="Center" Visibility="{TemplateBinding ShowImage,Converter={StaticResource Boolean2VisibilityConverter}}" Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" Margin="20,32,0,0" Width="30" Height="30" Stretch="Uniform"/>
|
||||
<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" Background="{DynamicResource RegionBrush}" HorizontalAlignment="Center">
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsCancel="True" MinWidth="88" Command="interactivity:ControlCommands.Cancel" Content="{x:Static langs:Lang.Cancel}" Margin="5,0"/>
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsDefault="True" MinWidth="88" Command="interactivity:ControlCommands.Confirm" Content="{x:Static langs:Lang.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="{x:Static langs:Lang.No}" Margin="5,0"/>
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsDefault="True" MinWidth="88" Command="interactivity:ControlCommands.Yes" Content="{x:Static langs:Lang.Yes}" Margin="5,0" Style="{StaticResource ButtonPrimary}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsActive" Value="False">
|
||||
<Setter Property="Opacity" Value=".8" TargetName="ContentPresenterMain"/>
|
||||
</Trigger>
|
||||
<Trigger Property="Icon" Value="{x:Null}">
|
||||
<Setter Property="Visibility" Value="Collapsed" TargetName="Icon"/>
|
||||
</Trigger>
|
||||
<Trigger Property="WindowState" Value="Maximized">
|
||||
<Setter Property="Padding" Value="8"/>
|
||||
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
|
||||
<Setter Property="Visibility" Value="Visible" TargetName="ButtonRestore"/>
|
||||
</Trigger>
|
||||
<Trigger Property="WindowState" Value="Normal">
|
||||
<Setter Property="Visibility" Value="Visible" TargetName="ButtonMax"/>
|
||||
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
|
||||
</Trigger>
|
||||
<Trigger Property="ResizeMode" Value="NoResize">
|
||||
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMin"/>
|
||||
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
|
||||
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
|
||||
</Trigger>
|
||||
<Trigger Property="ResizeMode" Value="CanMinimize">
|
||||
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
|
||||
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonClose">
|
||||
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
|
||||
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMax">
|
||||
<Setter Property="Background" TargetName="ButtonMax" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
|
||||
<Setter Property="Foreground" TargetName="ButtonMax" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonRestore">
|
||||
<Setter Property="Background" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
|
||||
<Setter Property="Foreground" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMin">
|
||||
<Setter Property="Background" TargetName="ButtonMin" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
|
||||
<Setter Property="Foreground" TargetName="ButtonMin" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="ShowTitle" Value="False">
|
||||
<Setter Property="Visibility" Value="Collapsed" TargetName="Title"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -46,25 +46,26 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="WindowDefault" BasedOn="{x:Null}" TargetType="Window">
|
||||
<Style x:Key="WindowDefault" TargetType="Window">
|
||||
<Setter Property="Background" Value="{DynamicResource BackgroundBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="WindowWin10" BasedOn="{x:Null}" TargetType="controls:Window">
|
||||
<Style x:Key="WindowWin10" TargetType="controls:Window">
|
||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ReverseTextBrush}"/>
|
||||
<Setter Property="UseLayoutRounding" Value="True"/>
|
||||
<Setter Property="NonClientAreaBackground" Value="White"/>
|
||||
<Setter Property="NonClientAreaForeground" Value="{DynamicResource ReverseTextBrush}"/>
|
||||
<Setter Property="NonClientAreaBackground" Value="{DynamicResource RegionBrush}"/>
|
||||
<Setter Property="NonClientAreaForeground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="CloseButtonBackground" Value="Transparent"/>
|
||||
<Setter Property="CloseButtonForeground" Value="{DynamicResource ReverseTextBrush}"/>
|
||||
<Setter Property="CloseButtonForeground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="CloseButtonHoverBackground" Value="#e81123"/>
|
||||
<Setter Property="CloseButtonHoverForeground" Value="White"/>
|
||||
<Setter Property="OtherButtonBackground" Value="Transparent"/>
|
||||
<Setter Property="OtherButtonForeground" Value="{DynamicResource ReverseTextBrush}"/>
|
||||
<Setter Property="OtherButtonForeground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="OtherButtonHoverBackground" Value="#e5e5e5"/>
|
||||
<Setter Property="OtherButtonHoverForeground" Value="{DynamicResource ReverseTextBrush}"/>
|
||||
<Setter Property="OtherButtonHoverForeground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:Window">
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<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;assembly=HandyControl"
|
||||
xmlns:interactivity="clr-namespace:HandyControl.Interactivity;assembly=HandyControl"
|
||||
xmlns:langs="clr-namespace:HandyControl.Properties.Langs;assembly=HandyControl">
|
||||
xmlns:interactivity="clr-namespace:HandyControl.Interactivity;assembly=HandyControl">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="../Basic/Geometries.xaml"/>
|
||||
@@ -98,30 +97,6 @@
|
||||
<Setter Property="OtherButtonHoverForeground" Value="White"/>
|
||||
<Setter Property="NonClientAreaForeground" Value="White"/>
|
||||
<Setter Property="CloseButtonForeground" Value="White"/>
|
||||
<Setter Property="Content">
|
||||
<Setter.Value>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Path x:Name="PART_Image" HorizontalAlignment="Center" Visibility="Collapsed" Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" Margin="20,32,0,0" Width="30" Height="30" Stretch="Uniform"/>
|
||||
<ScrollViewer Grid.Column="1" Grid.Row="0">
|
||||
<TextBlock Margin="10,39,10,10" x:Name="PART_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" Background="{DynamicResource RegionBrush}" HorizontalAlignment="Center">
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsCancel="True" MinWidth="88" Command="interactivity:ControlCommands.Cancel" Content="{x:Static langs:Lang.Cancel}" Margin="5,0"/>
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsDefault="True" MinWidth="88" Command="interactivity:ControlCommands.Confirm" Content="{x:Static langs:Lang.Confirm}" Margin="5,0" Background="#262e2f" Style="{StaticResource ButtonPrimary}"/>
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsCancel="True" MinWidth="88" Command="interactivity:ControlCommands.No" Content="{x:Static langs:Lang.No}" Margin="5,0"/>
|
||||
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsDefault="True" MinWidth="88" Command="interactivity:ControlCommands.Yes" Content="{x:Static langs:Lang.Yes}" Margin="5,0" Background="#262e2f" Style="{StaticResource ButtonPrimary}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
Reference in new issue
Block a user