11 changed files with 1024 additions and 5 deletions
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
@ -0,0 +1,396 @@ |
|||
using System; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Media; |
|||
using System.Windows.Controls.Primitives; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
[TemplateVisualState(Name = VisualStates.OK, GroupName = VisualStates.MessageBoxButtonsGroup)] |
|||
[TemplateVisualState(Name = VisualStates.OKCancel, GroupName = VisualStates.MessageBoxButtonsGroup)] |
|||
[TemplateVisualState(Name = VisualStates.YesNo, GroupName = VisualStates.MessageBoxButtonsGroup)] |
|||
[TemplateVisualState(Name = VisualStates.YesNoCancel, GroupName = VisualStates.MessageBoxButtonsGroup)] |
|||
public class MessageBox : Control |
|||
{ |
|||
#region Private Members
|
|||
|
|||
/// <summary>
|
|||
/// Tracks the MessageBoxButon value passed into the InitializeContainer method
|
|||
/// </summary>
|
|||
private MessageBoxButton _button = MessageBoxButton.OK; |
|||
|
|||
#endregion //Private Members
|
|||
|
|||
#region Constructors
|
|||
|
|||
static MessageBox() |
|||
{ |
|||
DefaultStyleKeyProperty.OverrideMetadata(typeof(MessageBox), new FrameworkPropertyMetadata(typeof(MessageBox))); |
|||
} |
|||
|
|||
internal MessageBox() |
|||
{ /*user cannot create instance */ } |
|||
|
|||
#endregion //Constructors
|
|||
|
|||
#region Properties
|
|||
|
|||
#region Protected Properties
|
|||
|
|||
/// <summary>
|
|||
/// A System.Windows.MessageBoxResult value that specifies which message box button was clicked by the user.
|
|||
/// </summary>
|
|||
protected MessageBoxResult MessageBoxResult = MessageBoxResult.None; |
|||
|
|||
protected Window Container { get; private set; } |
|||
protected Thumb DragWidget { get; private set; } |
|||
protected Button CloseButton { get; private set; } |
|||
|
|||
protected Button OkButton { get; private set; } |
|||
protected Button CancelButton { get; private set; } |
|||
protected Button YesButton { get; private set; } |
|||
protected Button NoButton { get; private set; } |
|||
|
|||
protected Button OkButton1 { get; private set; } |
|||
protected Button CancelButton1 { get; private set; } |
|||
protected Button YesButton1 { get; private set; } |
|||
protected Button NoButton1 { get; private set; } |
|||
|
|||
#endregion //Protected Properties
|
|||
|
|||
#region Dependency Properties
|
|||
|
|||
public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register("Caption", typeof(string), typeof(MessageBox), new UIPropertyMetadata(String.Empty)); |
|||
/// <summary>
|
|||
/// Gets or sets the caption.
|
|||
/// </summary>
|
|||
/// <value>The caption.</value>
|
|||
public string Caption |
|||
{ |
|||
get { return (string)GetValue(CaptionProperty); } |
|||
set { SetValue(CaptionProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(MessageBox), new UIPropertyMetadata(default(ImageSource))); |
|||
/// <summary>
|
|||
/// Gets or sets the message image source.
|
|||
/// </summary>
|
|||
/// <value>The message image source.</value>
|
|||
public ImageSource ImageSource |
|||
{ |
|||
get { return (ImageSource)GetValue(ImageSourceProperty); } |
|||
set { SetValue(ImageSourceProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(MessageBox), new UIPropertyMetadata(String.Empty)); |
|||
/// <summary>
|
|||
/// Gets or sets the message text.
|
|||
/// </summary>
|
|||
/// <value>The message text.</value>
|
|||
public string Text |
|||
{ |
|||
get { return (string)GetValue(TextProperty); } |
|||
set { SetValue(TextProperty, value); } |
|||
} |
|||
|
|||
#endregion //Dependency Properties
|
|||
|
|||
#endregion //Properties
|
|||
|
|||
#region Base Class Overrides
|
|||
|
|||
/// <summary>
|
|||
/// Overrides the OnApplyTemplate method.
|
|||
/// </summary>
|
|||
public override void OnApplyTemplate() |
|||
{ |
|||
base.OnApplyTemplate(); |
|||
|
|||
DragWidget = (Thumb)GetTemplateChild("PART_DragWidget"); |
|||
if (DragWidget != null) |
|||
DragWidget.DragDelta += (o, e) => ProcessMove(e); |
|||
|
|||
CloseButton = (Button)GetTemplateChild("PART_CloseButton"); |
|||
if (CloseButton != null) |
|||
CloseButton.Click += (o, e) => Close(); |
|||
|
|||
NoButton = (Button)GetTemplateChild("PART_NoButton"); |
|||
if (NoButton != null) |
|||
NoButton.Click += (o, e) => Button_Click(o, e); |
|||
|
|||
NoButton1 = (Button)GetTemplateChild("PART_NoButton1"); |
|||
if (NoButton1 != null) |
|||
NoButton1.Click += (o, e) => Button_Click(o, e); |
|||
|
|||
YesButton = (Button)GetTemplateChild("PART_YesButton"); |
|||
if (YesButton != null) |
|||
YesButton.Click += (o, e) => Button_Click(o, e); |
|||
|
|||
YesButton1 = (Button)GetTemplateChild("PART_YesButton1"); |
|||
if (YesButton1 != null) |
|||
YesButton1.Click += (o, e) => Button_Click(o, e); |
|||
|
|||
CancelButton = (Button)GetTemplateChild("PART_CancelButton"); |
|||
if (CancelButton != null) |
|||
CancelButton.Click += (o, e) => Button_Click(o, e); |
|||
|
|||
CancelButton1 = (Button)GetTemplateChild("PART_CancelButton1"); |
|||
if (CancelButton1 != null) |
|||
CancelButton1.Click += (o, e) => Button_Click(o, e); |
|||
|
|||
OkButton = (Button)GetTemplateChild("PART_OkButton"); |
|||
if (OkButton != null) |
|||
OkButton.Click += (o, e) => Button_Click(o, e); |
|||
|
|||
OkButton1 = (Button)GetTemplateChild("PART_OkButton1"); |
|||
if (OkButton1 != null) |
|||
OkButton1.Click += (o, e) => Button_Click(o, e); |
|||
|
|||
ChangeVisualState(_button.ToString(), true); |
|||
} |
|||
|
|||
#endregion //Base Class Overrides
|
|||
|
|||
#region Methods
|
|||
|
|||
#region Public Static
|
|||
|
|||
/// <summary>
|
|||
/// Displays a message box that has a message and that returns a result.
|
|||
/// </summary>
|
|||
/// <param name="messageText">A System.String that specifies the text to display.</param>
|
|||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
|||
public static MessageBoxResult Show(string messageText) |
|||
{ |
|||
return Show(messageText, string.Empty, MessageBoxButton.OK); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Displays a message box that has a message and title bar caption; and that returns a result.
|
|||
/// </summary>
|
|||
/// <param name="messageText">A System.String that specifies the text to display.</param>
|
|||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
|||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
|||
public static MessageBoxResult Show(string messageText, string caption) |
|||
{ |
|||
return Show(messageText, caption, MessageBoxButton.OK); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Displays a message box that has a message and that returns a result.
|
|||
/// </summary>
|
|||
/// <param name="messageText">A System.String that specifies the text to display.</param>
|
|||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
|||
/// <param name="button">A System.Windows.MessageBoxButton value that specifies which button or buttons to display.</param>
|
|||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
|||
public static MessageBoxResult Show(string messageText, string caption, MessageBoxButton button) |
|||
{ |
|||
return ShowCore(messageText, caption, button, MessageBoxImage.None); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Displays a message box that has a message and that returns a result.
|
|||
/// </summary>
|
|||
/// <param name="messageText">A System.String that specifies the text to display.</param>
|
|||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
|||
/// <param name="button">A System.Windows.MessageBoxButton value that specifies which button or buttons to display.</param>
|
|||
/// <param name="image"> A System.Windows.MessageBoxImage value that specifies the icon to display.</param>
|
|||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
|||
public static MessageBoxResult Show(string messageText, string caption, MessageBoxButton button, MessageBoxImage icon) |
|||
{ |
|||
return ShowCore(messageText, caption, button, icon); |
|||
} |
|||
|
|||
#endregion //Public Static
|
|||
|
|||
#region Private Static
|
|||
|
|||
private static MessageBoxResult ShowCore(string messageText, string caption, MessageBoxButton button, MessageBoxImage icon) |
|||
{ |
|||
MessageBox msgBox = new MessageBox(); |
|||
msgBox.InitializeMessageBox(messageText, caption, button, icon); |
|||
msgBox.Show(); |
|||
return msgBox.MessageBoxResult; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Resolves the owner Window of the MessageBox.
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
private static FrameworkElement ResolveOwner() |
|||
{ |
|||
FrameworkElement owner = null; |
|||
if (Application.Current != null) |
|||
{ |
|||
foreach (Window w in Application.Current.Windows) |
|||
{ |
|||
if (w.IsActive) |
|||
{ |
|||
owner = w; |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
return owner; |
|||
} |
|||
|
|||
#endregion //Private Static
|
|||
|
|||
#region Protected
|
|||
|
|||
/// <summary>
|
|||
/// Shows the MessageBox
|
|||
/// </summary>
|
|||
protected void Show() |
|||
{ |
|||
Container.ShowDialog(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initializes the MessageBox.
|
|||
/// </summary>
|
|||
/// <param name="text">The text.</param>
|
|||
/// <param name="caption">The caption.</param>
|
|||
/// <param name="button">The button.</param>
|
|||
/// <param name="image">The image.</param>
|
|||
protected void InitializeMessageBox(string text, string caption, MessageBoxButton button, MessageBoxImage image) |
|||
{ |
|||
Text = text; |
|||
Caption = caption; |
|||
_button = button; |
|||
SetImageSource(image); |
|||
Container = CreateContainer(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Changes the control's visual state(s).
|
|||
/// </summary>
|
|||
/// <param name="name">name of the state</param>
|
|||
/// <param name="useTransitions">True if state transitions should be used.</param>
|
|||
protected void ChangeVisualState(string name, bool useTransitions) |
|||
{ |
|||
VisualStateManager.GoToState(this, name, useTransitions); |
|||
} |
|||
|
|||
#endregion //Protected
|
|||
|
|||
#region Private
|
|||
|
|||
/// <summary>
|
|||
/// Sets the message image source.
|
|||
/// </summary>
|
|||
/// <param name="image">The image to show.</param>
|
|||
private void SetImageSource(MessageBoxImage image) |
|||
{ |
|||
String iconName = String.Empty; |
|||
|
|||
switch (image) |
|||
{ |
|||
case MessageBoxImage.Error: |
|||
{ |
|||
iconName = "Error48.png"; |
|||
break; |
|||
} |
|||
case MessageBoxImage.Information: |
|||
{ |
|||
iconName = "Information48.png"; |
|||
break; |
|||
} |
|||
case MessageBoxImage.Question: |
|||
{ |
|||
iconName = "Question48.png"; |
|||
break; |
|||
} |
|||
case MessageBoxImage.Warning: |
|||
{ |
|||
iconName = "Warning48.png"; |
|||
break; |
|||
} |
|||
case MessageBoxImage.None: |
|||
default: |
|||
{ |
|||
return; |
|||
} |
|||
} |
|||
|
|||
ImageSource = (ImageSource)new ImageSourceConverter().ConvertFromString(String.Format("pack://application:,,,/WPFToolkit.Extended;component/MessageBox/Icons/{0}", iconName)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Creates the container which will host the MessageBox control.
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
private Window CreateContainer() |
|||
{ |
|||
return new Window() |
|||
{ |
|||
AllowsTransparency = true, |
|||
Background = Brushes.Transparent, |
|||
Content = this, |
|||
Owner = Window.GetWindow(ResolveOwner()), |
|||
ShowInTaskbar = false, |
|||
SizeToContent = System.Windows.SizeToContent.WidthAndHeight, |
|||
ResizeMode = System.Windows.ResizeMode.NoResize, |
|||
WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner, |
|||
WindowStyle = System.Windows.WindowStyle.None |
|||
}; |
|||
} |
|||
|
|||
#endregion //Private
|
|||
|
|||
#endregion //Methods
|
|||
|
|||
#region Event Handlers
|
|||
|
|||
/// <summary>
|
|||
/// Processes the move of a drag operation on the header.
|
|||
/// </summary>
|
|||
/// <param name="e">The <see cref="System.Windows.Controls.Primitives.DragDeltaEventArgs"/> instance containing the event data.</param>
|
|||
private void ProcessMove(DragDeltaEventArgs e) |
|||
{ |
|||
Container.Left = Container.Left + e.HorizontalChange; |
|||
Container.Top = Container.Top + e.VerticalChange; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Sets the MessageBoxResult according to the button pressed and then closes the MessageBox.
|
|||
/// </summary>
|
|||
/// <param name="sender">The source of the event.</param>
|
|||
/// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
|
|||
private void Button_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
Button button = e.Source as Button; |
|||
switch (button.Name) |
|||
{ |
|||
case "PART_NoButton": |
|||
case "PART_NoButton1": |
|||
MessageBoxResult = MessageBoxResult.No; |
|||
break; |
|||
case "PART_YesButton": |
|||
case "PART_YesButton1": |
|||
MessageBoxResult = MessageBoxResult.Yes; |
|||
break; |
|||
case "PART_CancelButton": |
|||
case "PART_CancelButton1": |
|||
MessageBoxResult = MessageBoxResult.Cancel; |
|||
break; |
|||
case "PART_OkButton": |
|||
case "PART_OkButton1": |
|||
MessageBoxResult = MessageBoxResult.OK; |
|||
break; |
|||
} |
|||
|
|||
Close(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Closes the MessageBox.
|
|||
/// </summary>
|
|||
private void Close() |
|||
{ |
|||
Container.Close(); |
|||
} |
|||
|
|||
#endregion //Event Handlers
|
|||
} |
|||
} |
|||
@ -0,0 +1,300 @@ |
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:local="clr-namespace:Microsoft.Windows.Controls"> |
|||
|
|||
<!-- =============================================================================== --> |
|||
<!-- MessageBox --> |
|||
<!-- =============================================================================== --> |
|||
|
|||
<SolidColorBrush x:Key="MessageBoxMainBrushColor" Color="#FF3C688D"/> |
|||
<LinearGradientBrush x:Key="BorderBrush" EndPoint="0.5,1" StartPoint="0.5,0"> |
|||
<GradientStop Color="#7FFFFFFF" Offset="0.05"/> |
|||
<GradientStop Color="#B2FFFFFF" Offset="0.07"/> |
|||
<GradientStop Color="#00FFFFFF" Offset="1"/> |
|||
</LinearGradientBrush> |
|||
|
|||
<LinearGradientBrush x:Key="MessageBoxDarkBrush" EndPoint="0.5,1" StartPoint="0.5,0"> |
|||
<GradientStop Color="#FFA3AEB9" Offset="0"/> |
|||
<GradientStop Color="#FF8399A9" Offset="0.375"/> |
|||
<GradientStop Color="#FF718597" Offset="0.375"/> |
|||
<GradientStop Color="#FF617584" Offset="1"/> |
|||
</LinearGradientBrush> |
|||
|
|||
<LinearGradientBrush x:Key="MessageBoxBorderBrush" StartPoint="0,0" EndPoint="0,1"> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStopCollection> |
|||
<GradientStop Offset="0" Color="#FFffffff"/> |
|||
<GradientStop Offset="0.479" Color="#FFf4f5f6"/> |
|||
<GradientStop Offset="1" Color="#FFd0d6db"/> |
|||
</GradientStopCollection> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
|
|||
<LinearGradientBrush x:Key="MessageBoxButtonHoverBrush" StartPoint="0,0" EndPoint="0,1"> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStopCollection> |
|||
<GradientStop Offset="0" Color="#FFb5bdc8"/> |
|||
<GradientStop Offset="0.370" Color="#FF8399a9"/> |
|||
<GradientStop Offset="0.370" Color="#FF718597"/> |
|||
<GradientStop Offset="0.906" Color="#FFb9c1ca"/> |
|||
<GradientStop Offset="1" Color="#FFb9c1ca"/> |
|||
</GradientStopCollection> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
<LinearGradientBrush x:Key="MessageBoxButtonPressedBrush" StartPoint="0,0" EndPoint="0,1"> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStopCollection> |
|||
<GradientStop Offset="0" Color="#FF6b7c8d"/> |
|||
<GradientStop Offset="0.370" Color="#FF4d606f"/> |
|||
<GradientStop Offset="0.370" Color="#FF465460"/> |
|||
<GradientStop Offset="0.906" Color="#FF262d33"/> |
|||
<GradientStop Offset="1" Color="#FF262d33"/> |
|||
</GradientStopCollection> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
|
|||
<Style x:Key="MessageBoxCloseButtonStyle" TargetType="Button"> |
|||
<Setter Property="Foreground" Value="#FF000000"/> |
|||
<Setter Property="Padding" Value="3"/> |
|||
<Setter Property="BorderThickness" Value="1"/> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="Button"> |
|||
<Grid> |
|||
<VisualStateManager.VisualStateGroups> |
|||
<VisualStateGroup x:Name="CommonStates"> |
|||
<VisualState x:Name="Normal"/> |
|||
<VisualState x:Name="MouseOver"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background)"> |
|||
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource MessageBoxButtonHoverBrush}"></DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
<VisualState x:Name="Pressed"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background)"> |
|||
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource MessageBoxButtonPressedBrush}"></DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
<VisualState x:Name="Disabled"> |
|||
<Storyboard> |
|||
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity"> |
|||
<SplineDoubleKeyFrame KeyTime="0" Value=".55"/> |
|||
</DoubleAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
</VisualStateGroup> |
|||
<VisualStateGroup x:Name="FocusStates"> |
|||
<VisualState x:Name="Focused"> |
|||
<Storyboard> |
|||
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity"> |
|||
<SplineDoubleKeyFrame KeyTime="0" Value="1"/> |
|||
</DoubleAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
<VisualState x:Name="Unfocused"/> |
|||
</VisualStateGroup> |
|||
</VisualStateManager.VisualStateGroups> |
|||
<Border x:Name="Background" CornerRadius="0,0,2,0" Background="{StaticResource MessageBoxDarkBrush}"> |
|||
<Border Margin="1,0,1,1" BorderBrush="#59FFFFFF" BorderThickness="1" CornerRadius="0,0,1,0"/> |
|||
</Border> |
|||
<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/> |
|||
<Path x:Name="path" |
|||
Height="6" |
|||
Width="7" |
|||
Stretch="Fill" |
|||
Opacity="1" |
|||
Data="M 2,6 C2,6 3,6 3,6 3,6 3,5 3,5 3,5 4,5 4,5 4,5 4,6 4,6 4,6 5,6 5,6 5,6 7,6 7,6 7,6 7,5 7,5 7,5 6,5 6,5 6,5 6,4 6,4 6,4 5,4 5,4 5,4 5,2 5,2 5,2 6,2 6,2 6,2 6,1 6,1 6,1 7,1 7,1 7,1 7,0 7,0 7,0 5,0 5,0 5,0 4,0 4,0 4,0 4,1 4,1 4,1 3,1 3,1 3,1 3,0 3,0 3,0 2,0 2,0 2,0 0,0 0,0 0,0 0,1 0,1 0,1 1,1 1,1 1,1 1,2 1,2 1,2 2,2 2,2 2,2 2,4 2,4 2,4 1,4 1,4 1,4 1,5 1,5 1,5 0,5 0,5 0,5 0,6 0,6 0,6 2,6 2,6 z" |
|||
Fill="White" Margin="0,0,0,1" Visibility="Collapsed" /> |
|||
<Border x:Name="DisabledVisualElement" Background="#FFFFFFFF" CornerRadius="0,0,4,0" IsHitTestVisible="false" Opacity="0"/> |
|||
<Border x:Name="FocusVisualElement" BorderBrush="#FF6DBDD1" BorderThickness="1" CornerRadius="0,0,3,0" Margin="1" IsHitTestVisible="false" Opacity="0"/> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<ControlTemplate x:Key="MessageBoxDragWidgetTemplate" TargetType="{x:Type Thumb}"> |
|||
<Border Background="Transparent"> |
|||
</Border> |
|||
</ControlTemplate> |
|||
|
|||
<Style TargetType="{x:Type local:MessageBox}"> |
|||
<Setter Property="IsEnabled" Value="true" /> |
|||
<Setter Property="Background" Value="#FFFFFFFF"/> |
|||
<Setter Property="BorderThickness" Value="1" /> |
|||
<Setter Property="HorizontalContentAlignment" Value="Left" /> |
|||
<Setter Property="VerticalContentAlignment" Value="Top" /> |
|||
<Setter Property="HorizontalAlignment" Value="Left" /> |
|||
<Setter Property="VerticalAlignment" Value="Top" /> |
|||
<Setter Property="MinWidth" Value="350" /> |
|||
<Setter Property="MinHeight" Value="50" /> |
|||
<Setter Property="BorderBrush" Value="{StaticResource MessageBoxDarkBrush}" /> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type local:MessageBox}"> |
|||
<Grid x:Name="Root"> |
|||
<VisualStateManager.VisualStateGroups> |
|||
<VisualStateGroup x:Name="group1"> |
|||
<VisualState x:Name="OK"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="OkGrid" Storyboard.TargetProperty="Visibility"> |
|||
<DiscreteObjectKeyFrame KeyTime="0"> |
|||
<DiscreteObjectKeyFrame.Value> |
|||
<Visibility>Visible</Visibility> |
|||
</DiscreteObjectKeyFrame.Value> |
|||
</DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
<VisualState x:Name="OKCancel"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="OkCancelGrid" Storyboard.TargetProperty="Visibility"> |
|||
<DiscreteObjectKeyFrame KeyTime="0"> |
|||
<DiscreteObjectKeyFrame.Value> |
|||
<Visibility>Visible</Visibility> |
|||
</DiscreteObjectKeyFrame.Value> |
|||
</DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
<VisualState x:Name="YesNo"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="YesNoGrid" Storyboard.TargetProperty="Visibility"> |
|||
<DiscreteObjectKeyFrame KeyTime="0"> |
|||
<DiscreteObjectKeyFrame.Value> |
|||
<Visibility>Visible</Visibility> |
|||
</DiscreteObjectKeyFrame.Value> |
|||
</DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
|
|||
<VisualState x:Name="YesNoCancel"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="YesNoCancelGrid" Storyboard.TargetProperty="Visibility"> |
|||
<DiscreteObjectKeyFrame KeyTime="0"> |
|||
<DiscreteObjectKeyFrame.Value> |
|||
<Visibility>Visible</Visibility> |
|||
</DiscreteObjectKeyFrame.Value> |
|||
</DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
</VisualStateGroup> |
|||
</VisualStateManager.VisualStateGroups> |
|||
|
|||
<!-- Borders --> |
|||
<Grid> |
|||
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5,5,0,0" Opacity="0.65"/> |
|||
<Grid x:Name="MessageBoxBorderGrid" Margin="0" Background="{x:Null}"> |
|||
<Border x:Name="MessageBoxBorder" Margin="1,1,1,1" Background="{StaticResource MessageBoxBorderBrush}" CornerRadius="4,4,0,0" Opacity="0.65"/> |
|||
<Border x:Name="MessageBoxOuterBorder" BorderBrush="White" BorderThickness="1" CornerRadius="4,4,0,0" Margin="1" Opacity="0.7"/> |
|||
</Grid> |
|||
</Grid> |
|||
|
|||
<Grid> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition Height="Auto" MinHeight="26"/> |
|||
<RowDefinition /> |
|||
</Grid.RowDefinitions> |
|||
|
|||
<!-- Content Border --> |
|||
<Grid Margin="6,0,6,6" x:Name="ContentGrid" Grid.Row="1"> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition/> |
|||
<RowDefinition Height="Auto" /> |
|||
</Grid.RowDefinitions> |
|||
<Border BorderBrush="#FFFFFFFF" BorderThickness="1" CornerRadius="1"/> |
|||
<Border Margin="1" BorderThickness="1" CornerRadius="0.1" BorderBrush="{StaticResource MessageBoxMainBrushColor}"/> |
|||
<Border Margin="1" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0.1" Background="{TemplateBinding Background}" BorderBrush="{StaticResource MessageBoxDarkBrush}"> |
|||
|
|||
<Grid MinWidth="350"> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition /> |
|||
<RowDefinition Height="Auto" /> |
|||
</Grid.RowDefinitions> |
|||
|
|||
<Grid Margin="24,16,24,22"> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="Auto"/> |
|||
<ColumnDefinition Width="*"/> |
|||
</Grid.ColumnDefinitions> |
|||
|
|||
<!-- Message Image --> |
|||
<Image x:Name="MessageBoxImage" VerticalAlignment="Top" SnapsToDevicePixels="True" Stretch="None" Margin="-6,-1,10,-4" Source="{TemplateBinding ImageSource}"></Image> |
|||
|
|||
<!-- Message Text --> |
|||
<TextBlock x:Name="MessageText" Grid.Column="1" Text="{TemplateBinding Text}" TextWrapping="Wrap" VerticalAlignment="Center" MaxWidth="450" /> |
|||
|
|||
</Grid> |
|||
|
|||
<!-- Buttons --> |
|||
<Grid Grid.Row="1" HorizontalAlignment="Right" Margin="12,0,12,12"> |
|||
<Grid x:Name="OkGrid" Visibility="Collapsed"> |
|||
<Button x:Name="PART_OkButton" MinWidth="65" Margin="6,0,0,0">OK</Button> |
|||
</Grid> |
|||
<Grid x:Name="OkCancelGrid" Visibility="Collapsed"> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="Auto"/> |
|||
<ColumnDefinition Width="Auto"/> |
|||
</Grid.ColumnDefinitions> |
|||
<Button x:Name="PART_OkButton1" MinWidth="65" Margin="6,0,0,0">OK</Button> |
|||
<Button Grid.Column="1" x:Name="PART_CancelButton" MinWidth="65" Margin="6,0,0,0">Cancel</Button> |
|||
</Grid> |
|||
<Grid x:Name="YesNoGrid" Visibility="Collapsed"> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="Auto"/> |
|||
<ColumnDefinition Width="Auto"/> |
|||
</Grid.ColumnDefinitions> |
|||
<Button x:Name="PART_YesButton" MinWidth="65" Margin="6,0,0,0">Yes</Button> |
|||
<Button Grid.Column="1" x:Name="PART_NoButton" MinWidth="65" Margin="6,0,0,0">No</Button> |
|||
</Grid> |
|||
<Grid x:Name="YesNoCancelGrid" Visibility="Collapsed"> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="Auto"/> |
|||
<ColumnDefinition Width="Auto"/> |
|||
<ColumnDefinition Width="Auto"/> |
|||
</Grid.ColumnDefinitions> |
|||
<Button x:Name="PART_YesButton1" MinWidth="65" Margin="6,0,0,0">Yes</Button> |
|||
<Button Grid.Column="1" x:Name="PART_NoButton1" MinWidth="65" Margin="6,0,0,0">No</Button> |
|||
<Button Grid.Column="2" x:Name="PART_CancelButton1" MinWidth="65" Margin="6,0,0,0">Cancel</Button> |
|||
</Grid> |
|||
</Grid> |
|||
</Grid> |
|||
</Border> |
|||
</Grid> |
|||
|
|||
<!-- Header --> |
|||
<Border x:Name="HeaderArea" Background="Transparent" Grid.Column="1" CornerRadius="5,5,0,0" Margin="1,1,1,0"> |
|||
<Grid> |
|||
<Grid x:Name="CaptionHeader" Margin="1,1,105,0" VerticalAlignment="Center"> |
|||
<!-- Caption --> |
|||
<ContentControl x:Name="Caption" Margin="5,0,0,0" Foreground="#FF000000" IsTabStop="False" HorizontalAlignment="Stretch" |
|||
Content="{TemplateBinding Caption}" /> |
|||
|
|||
</Grid> |
|||
<Thumb x:Name="PART_DragWidget" Template="{StaticResource MessageBoxDragWidgetTemplate}"/> |
|||
</Grid> |
|||
</Border> |
|||
|
|||
</Grid> |
|||
|
|||
<Border x:Name="Resize" BorderThickness="7" BorderBrush="Transparent" /> |
|||
|
|||
<!-- Close Button --> |
|||
<Border BorderBrush="#A5FFFFFF" BorderThickness="1,0,1,1" CornerRadius="0,0,3,3" VerticalAlignment="Top" Margin="0,1,7,0" HorizontalAlignment="Right"> |
|||
<Button x:Name="PART_CloseButton" Style="{StaticResource MessageBoxCloseButtonStyle}" Height="17" Width="43" IsTabStop="False"> |
|||
<Path Height="10" HorizontalAlignment="Center" VerticalAlignment="Center" Width="12" Fill="#E4FFFFFF" Stretch="Fill" Stroke="#FF535666" |
|||
Data="M0.5,0.5 L4.5178828,0.5 L6.0620003,3.125 L7.4936447,0.5 L11.5,0.5 L11.5,1.5476431 L8.7425003,6.1201854 L11.5,10.359666 L11.5,11.5 L7.4941902,11.5 L6.0620003,8.8740005 L4.5172949,11.5 L0.5,11.5 L0.5,10.43379 L3.3059995,6.1201582 L0.5,1.4676378 L0.5,0.5 z"/> |
|||
</Button> |
|||
</Border> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
</ResourceDictionary> |
|||
@ -0,0 +1,17 @@ |
|||
using System; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
internal static partial class VisualStates |
|||
{ |
|||
public const string MessageBoxButtonsGroup = "MessageBoxButtonsGroup"; |
|||
|
|||
public const string OK = "OK"; |
|||
|
|||
public const string OKCancel = "OKCancel"; |
|||
|
|||
public const string YesNo = "YesNo"; |
|||
|
|||
public const string YesNoCancel = "YesNoCancel"; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue