Merge branch 'master' into pr/1705
This commit is contained in:
commit
944830c442
8 files changed
+277
-207
No files matched your search
@@ -1,6 +1,3 @@
|
|||||||
## 找工作
|
|
||||||
由于个人原因,预计于年后离职,大家如果在上海,且有 python、wpf 空缺的岗位,可联系我,我的邮箱:836904362@qq.com。
|
|
||||||
|
|
||||||
## 友情链接
|
## 友情链接
|
||||||
|
|
||||||
[SimpleFactoryGenerator](https://github.com/DingpingZhang/SimpleFactoryGenerator) - A simple factory source generator that enables the pattern to not violate the open-close principle.
|
[SimpleFactoryGenerator](https://github.com/DingpingZhang/SimpleFactoryGenerator) - A simple factory source generator that enables the pattern to not violate the open-close principle.
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
## 找工作
|
|
||||||
由于个人原因,预计于年后离职,大家如果在上海,且有 python、wpf 空缺的岗位,可联系我,我的邮箱:836904362@qq.com。
|
|
||||||
|
|
||||||
## Blogroll
|
## Blogroll
|
||||||
|
|
||||||
[SimpleFactoryGenerator](https://github.com/DingpingZhang/SimpleFactoryGenerator) - A simple factory source generator that enables the pattern to not violate the open-close principle.
|
[SimpleFactoryGenerator](https://github.com/DingpingZhang/SimpleFactoryGenerator) - A simple factory source generator that enables the pattern to not violate the open-close principle.
|
||||||
|
|||||||
@@ -13625,6 +13625,7 @@
|
|||||||
<Style x:Key="TabControlCapsule" TargetType="TabControl">
|
<Style x:Key="TabControlCapsule" TargetType="TabControl">
|
||||||
<Setter Property="BorderThickness" Value="1" />
|
<Setter Property="BorderThickness" Value="1" />
|
||||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}" />
|
<Setter Property="Background" Value="{DynamicResource RegionBrush}" />
|
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}" />
|
||||||
<Setter Property="hc:TitleElement.BorderBrush" Value="{DynamicResource PrimaryBrush}" />
|
<Setter Property="hc:TitleElement.BorderBrush" Value="{DynamicResource PrimaryBrush}" />
|
||||||
<Setter Property="hc:TitleElement.Background" Value="{DynamicResource RegionBrush}" />
|
<Setter Property="hc:TitleElement.Background" Value="{DynamicResource RegionBrush}" />
|
||||||
<Setter Property="hc:TitleElement.Foreground" Value="{DynamicResource PrimaryBrush}" />
|
<Setter Property="hc:TitleElement.Foreground" Value="{DynamicResource PrimaryBrush}" />
|
||||||
@@ -13646,7 +13647,7 @@
|
|||||||
<RowDefinition x:Name="RowDefinition1" Height="*" />
|
<RowDefinition x:Name="RowDefinition1" Height="*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<UniformGrid Rows="1" KeyboardNavigation.TabNavigation="Once" KeyboardNavigation.DirectionalNavigation="Cycle" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="headerPanel" Background="Transparent" Grid.Column="0" IsItemsHost="true" Margin="0" Grid.Row="0" />
|
<UniformGrid Rows="1" KeyboardNavigation.TabNavigation="Once" KeyboardNavigation.DirectionalNavigation="Cycle" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="headerPanel" Background="Transparent" Grid.Column="0" IsItemsHost="true" Margin="0" Grid.Row="0" />
|
||||||
<Border x:Name="contentPanel" Margin="0,6,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{DynamicResource BorderBrush}" Background="{TemplateBinding Background}" Grid.Column="0" Grid.Row="1">
|
<Border x:Name="contentPanel" Margin="0,6,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Grid.Column="0" Grid.Row="1">
|
||||||
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<hc:SimplePanel Margin="32" VerticalAlignment="Center">
|
<hc:SimplePanel Margin="32" VerticalAlignment="Center">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||||
<GroupBox Header="ContextMenu" Padding="10">
|
<GroupBox Header="ContextMenu" Padding="10" Background="{DynamicResource RegionBrush}">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<GroupBox hc:TitleElement.TitlePlacement="Left" Style="{StaticResource GroupBoxOriginal}" Header="{ex:Lang Key={x:Static langs:LangKeys.Visibility}}">
|
<GroupBox hc:TitleElement.TitlePlacement="Left" Style="{StaticResource GroupBoxOriginal}" Header="{ex:Lang Key={x:Static langs:LangKeys.Visibility}}">
|
||||||
<ToggleButton IsChecked="{Binding ContextMenuIsShow}" Style="{StaticResource ToggleButtonSwitch}"/>
|
<ToggleButton IsChecked="{Binding ContextMenuIsShow}" Style="{StaticResource ToggleButtonSwitch}"/>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
</GroupBox>
|
</GroupBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
<GroupBox Header="ContextContent" Margin="16,0,0,0" Padding="10">
|
<GroupBox Header="ContextContent" Margin="16,0,0,0" Padding="10" Background="{DynamicResource RegionBrush}">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<GroupBox hc:TitleElement.TitlePlacement="Left" Style="{StaticResource GroupBoxOriginal}" Header="{ex:Lang Key={x:Static langs:LangKeys.Visibility}}">
|
<GroupBox hc:TitleElement.TitlePlacement="Left" Style="{StaticResource GroupBoxOriginal}" Header="{ex:Lang Key={x:Static langs:LangKeys.Visibility}}">
|
||||||
<ToggleButton IsChecked="{Binding ContextContentIsShow}" Style="{StaticResource ToggleButtonSwitch}"/>
|
<ToggleButton IsChecked="{Binding ContextContentIsShow}" Style="{StaticResource ToggleButtonSwitch}"/>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class NotifyIcon : FrameworkElement, IDisposable
|
|||||||
|
|
||||||
static NotifyIcon()
|
static NotifyIcon()
|
||||||
{
|
{
|
||||||
VisibilityProperty.OverrideMetadata(typeof(NotifyIcon), new PropertyMetadata(Visibility.Visible, OnVisibilityChanged));
|
VisibilityProperty.OverrideMetadata(typeof(NotifyIcon), new PropertyMetadata(ValueBoxes.VisibleBox, OnVisibilityChanged));
|
||||||
DataContextProperty.OverrideMetadata(typeof(NotifyIcon), new FrameworkPropertyMetadata(DataContextPropertyChanged));
|
DataContextProperty.OverrideMetadata(typeof(NotifyIcon), new FrameworkPropertyMetadata(DataContextPropertyChanged));
|
||||||
ContextMenuProperty.OverrideMetadata(typeof(NotifyIcon), new FrameworkPropertyMetadata(ContextMenuPropertyChanged));
|
ContextMenuProperty.OverrideMetadata(typeof(NotifyIcon), new FrameworkPropertyMetadata(ContextMenuPropertyChanged));
|
||||||
}
|
}
|
||||||
@@ -247,7 +247,19 @@ public class NotifyIcon : FrameworkElement, IDisposable
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
|
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
|
||||||
nameof(Text), typeof(string), typeof(NotifyIcon), new PropertyMetadata(default(string)));
|
nameof(Text), typeof(string), typeof(NotifyIcon), new PropertyMetadata(default(string), OnTextChanged));
|
||||||
|
|
||||||
|
private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var ctl = (NotifyIcon) d;
|
||||||
|
|
||||||
|
if (ctl._windowClassName == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctl.UpdateIcon(ctl._added, ctl._isTransparent);
|
||||||
|
}
|
||||||
|
|
||||||
public string Text
|
public string Text
|
||||||
{
|
{
|
||||||
@@ -309,7 +321,6 @@ public class NotifyIcon : FrameworkElement, IDisposable
|
|||||||
private static void OnIsBlinkChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
private static void OnIsBlinkChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
var ctl = (NotifyIcon) d;
|
var ctl = (NotifyIcon) d;
|
||||||
if (ctl.Visibility != Visibility.Visible) return;
|
|
||||||
if ((bool) e.NewValue)
|
if ((bool) e.NewValue)
|
||||||
{
|
{
|
||||||
if (ctl._dispatcherTimerBlink == null)
|
if (ctl._dispatcherTimerBlink == null)
|
||||||
@@ -326,7 +337,7 @@ public class NotifyIcon : FrameworkElement, IDisposable
|
|||||||
{
|
{
|
||||||
ctl._dispatcherTimerBlink?.Stop();
|
ctl._dispatcherTimerBlink?.Stop();
|
||||||
ctl._dispatcherTimerBlink = null;
|
ctl._dispatcherTimerBlink = null;
|
||||||
ctl.UpdateIcon(true);
|
ctl.UpdateIcon(ctl._added, ctl._isTransparent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,78 +16,44 @@ using HandyControl.Tools.Interop;
|
|||||||
namespace HandyControl.Controls;
|
namespace HandyControl.Controls;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 消息框
|
/// Displays a message box with text, buttons, and symbols to inform and instruct the user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SuppressMessage("ReSharper", "RedundantDelegateCreation")]
|
[SuppressMessage("ReSharper", "RedundantDelegateCreation")]
|
||||||
[TemplatePart(Name = ElementPanel, Type = typeof(Panel))]
|
[TemplatePart(Name = ElementPanel, Type = typeof(Panel))]
|
||||||
[TemplatePart(Name = ElementButtonClose, Type = typeof(Button))]
|
[TemplatePart(Name = ElementButtonClose, Type = typeof(Button))]
|
||||||
|
|
||||||
public sealed class MessageBox : Window
|
public sealed class MessageBox : Window
|
||||||
{
|
{
|
||||||
private const string ElementPanel = "PART_Panel";
|
private const string ElementPanel = "PART_Panel";
|
||||||
|
|
||||||
private const string ElementButtonClose = "PART_ButtonClose";
|
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;
|
|
||||||
|
|
||||||
private bool _showYes;
|
|
||||||
|
|
||||||
private bool _showNo;
|
|
||||||
|
|
||||||
private IntPtr _lastActiveWindowIntPtr;
|
|
||||||
|
|
||||||
public static readonly DependencyProperty MessageProperty = DependencyProperty.Register(
|
public static readonly DependencyProperty MessageProperty = DependencyProperty.Register(
|
||||||
nameof(Message), typeof(string), typeof(MessageBox), new PropertyMetadata(default(string)));
|
nameof(Message), typeof(string), typeof(MessageBox), new PropertyMetadata(default(string)));
|
||||||
|
|
||||||
public string Message
|
|
||||||
{
|
|
||||||
get => (string) GetValue(MessageProperty);
|
|
||||||
set => SetValue(MessageProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static readonly DependencyProperty ImageProperty = DependencyProperty.Register(
|
public static readonly DependencyProperty ImageProperty = DependencyProperty.Register(
|
||||||
nameof(Image), typeof(Geometry), typeof(MessageBox), new PropertyMetadata(default(Geometry)));
|
nameof(Image), typeof(Geometry), typeof(MessageBox), new PropertyMetadata(default(Geometry)));
|
||||||
|
|
||||||
public Geometry Image
|
|
||||||
{
|
|
||||||
get => (Geometry) GetValue(ImageProperty);
|
|
||||||
set => SetValue(ImageProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static readonly DependencyProperty ImageBrushProperty = DependencyProperty.Register(
|
public static readonly DependencyProperty ImageBrushProperty = DependencyProperty.Register(
|
||||||
nameof(ImageBrush), typeof(Brush), typeof(MessageBox), new PropertyMetadata(default(Brush)));
|
nameof(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(
|
public static readonly DependencyProperty ShowImageProperty = DependencyProperty.Register(
|
||||||
nameof(ShowImage), typeof(bool), typeof(MessageBox), new PropertyMetadata(ValueBoxes.FalseBox));
|
nameof(ShowImage), typeof(bool), typeof(MessageBox), new PropertyMetadata(ValueBoxes.FalseBox));
|
||||||
|
|
||||||
public bool ShowImage
|
private Button _buttonClose;
|
||||||
{
|
private Panel _panel;
|
||||||
get => (bool) GetValue(ShowImageProperty);
|
private MessageBoxResult _messageBoxResult = MessageBoxResult.Cancel;
|
||||||
set => SetValue(ShowImageProperty, ValueBoxes.BooleanBox(value));
|
private Button _buttonOk;
|
||||||
}
|
private Button _buttonCancel;
|
||||||
|
private Button _buttonYes;
|
||||||
|
private Button _buttonNo;
|
||||||
|
private bool _showOk;
|
||||||
|
private bool _showCancel;
|
||||||
|
private bool _showYes;
|
||||||
|
private bool _showNo;
|
||||||
|
private IntPtr _lastActiveWindowIntPtr;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This constructor is private so people aren't tempted to try and create instances of these -- they should just use the static methods.
|
||||||
|
/// </summary>
|
||||||
private MessageBox()
|
private MessageBox()
|
||||||
{
|
{
|
||||||
CommandBindings.Add(new CommandBinding(ControlCommands.Confirm, (s, e) =>
|
CommandBindings.Add(new CommandBinding(ControlCommands.Confirm, (s, e) =>
|
||||||
@@ -112,6 +78,30 @@ public sealed class MessageBox : Window
|
|||||||
}, (s, e) => e.CanExecute = _showNo));
|
}, (s, e) => e.CanExecute = _showNo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Message
|
||||||
|
{
|
||||||
|
get => (string) GetValue(MessageProperty);
|
||||||
|
set => SetValue(MessageProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Geometry Image
|
||||||
|
{
|
||||||
|
get => (Geometry) GetValue(ImageProperty);
|
||||||
|
set => SetValue(ImageProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Brush ImageBrush
|
||||||
|
{
|
||||||
|
get => (Brush) GetValue(ImageBrushProperty);
|
||||||
|
set => SetValue(ImageBrushProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ShowImage
|
||||||
|
{
|
||||||
|
get => (bool) GetValue(ShowImageProperty);
|
||||||
|
set => SetValue(ShowImageProperty, ValueBoxes.BooleanBox(value));
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnSourceInitialized(EventArgs e)
|
protected override void OnSourceInitialized(EventArgs e)
|
||||||
{
|
{
|
||||||
if (_showYes && !_showCancel)
|
if (_showYes && !_showCancel)
|
||||||
@@ -119,7 +109,8 @@ public sealed class MessageBox : Window
|
|||||||
var hMenu = InteropMethods.GetSystemMenu(this.GetHandle(), false);
|
var hMenu = InteropMethods.GetSystemMenu(this.GetHandle(), false);
|
||||||
if (hMenu != IntPtr.Zero)
|
if (hMenu != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
InteropMethods.EnableMenuItem(hMenu, InteropValues.SC_CLOSE, InteropValues.MF_BYCOMMAND | InteropValues.MF_GRAYED);
|
InteropMethods.EnableMenuItem(hMenu, InteropValues.SC_CLOSE,
|
||||||
|
InteropValues.MF_BYCOMMAND | InteropValues.MF_GRAYED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_buttonClose != null)
|
if (_buttonClose != null)
|
||||||
@@ -180,72 +171,88 @@ public sealed class MessageBox : Window
|
|||||||
|
|
||||||
protected override void OnPreviewKeyDown(KeyEventArgs e)
|
protected override void OnPreviewKeyDown(KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.System && e.SystemKey == Key.F4)
|
if (e is { Key: Key.System, SystemKey: Key.F4 })
|
||||||
{
|
{
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.C)
|
if (e.KeyboardDevice.Modifiers != ModifierKeys.Control || e.Key != Key.C)
|
||||||
{
|
{
|
||||||
var builder = new StringBuilder();
|
return;
|
||||||
var line = new string('-', 27);
|
}
|
||||||
builder.Append(line);
|
|
||||||
builder.Append(Environment.NewLine);
|
|
||||||
builder.Append(Title);
|
|
||||||
builder.Append(Environment.NewLine);
|
|
||||||
builder.Append(line);
|
|
||||||
builder.Append(Environment.NewLine);
|
|
||||||
builder.Append(Message);
|
|
||||||
builder.Append(Environment.NewLine);
|
|
||||||
builder.Append(line);
|
|
||||||
builder.Append(Environment.NewLine);
|
|
||||||
if (_showOk)
|
|
||||||
{
|
|
||||||
builder.Append(Lang.Confirm);
|
|
||||||
builder.Append(" ");
|
|
||||||
}
|
|
||||||
if (_showYes)
|
|
||||||
{
|
|
||||||
builder.Append(Lang.Yes);
|
|
||||||
builder.Append(" ");
|
|
||||||
}
|
|
||||||
if (_showNo)
|
|
||||||
{
|
|
||||||
builder.Append(Lang.No);
|
|
||||||
builder.Append(" ");
|
|
||||||
}
|
|
||||||
if (_showCancel)
|
|
||||||
{
|
|
||||||
builder.Append(Lang.Cancel);
|
|
||||||
builder.Append(" ");
|
|
||||||
}
|
|
||||||
builder.Append(Environment.NewLine);
|
|
||||||
builder.Append(line);
|
|
||||||
builder.Append(Environment.NewLine);
|
|
||||||
|
|
||||||
try
|
const int dashCount = 27;
|
||||||
{
|
var line = new string('-', dashCount);
|
||||||
Clipboard.SetDataObject(builder.ToString());
|
|
||||||
}
|
var builder = new StringBuilder()
|
||||||
catch
|
.Append(line)
|
||||||
{
|
.Append(Environment.NewLine)
|
||||||
// ignored
|
.Append(Title)
|
||||||
}
|
.Append(Environment.NewLine)
|
||||||
|
.Append(line)
|
||||||
|
.Append(Environment.NewLine)
|
||||||
|
.Append(Message)
|
||||||
|
.Append(Environment.NewLine)
|
||||||
|
.Append(line)
|
||||||
|
.Append(Environment.NewLine);
|
||||||
|
|
||||||
|
if (_showOk)
|
||||||
|
{
|
||||||
|
builder.Append(Lang.Confirm);
|
||||||
|
builder.Append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_showYes)
|
||||||
|
{
|
||||||
|
builder.Append(Lang.Yes);
|
||||||
|
builder.Append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_showNo)
|
||||||
|
{
|
||||||
|
builder.Append(Lang.No);
|
||||||
|
builder.Append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_showCancel)
|
||||||
|
{
|
||||||
|
builder.Append(Lang.Cancel);
|
||||||
|
builder.Append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.Append(Environment.NewLine);
|
||||||
|
builder.Append(line);
|
||||||
|
builder.Append(Environment.NewLine);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Clipboard.SetDataObject(builder.ToString());
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 成功
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="messageBoxText"></param>
|
|
||||||
/// <param name="caption"></param>
|
|
||||||
public static MessageBoxResult Success(string messageBoxText, string caption = null)
|
public static MessageBoxResult Success(string messageBoxText, string caption = null)
|
||||||
|
{
|
||||||
|
return Success(owner: null, messageBoxText, caption);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageBoxResult Success(System.Windows.Window owner, string messageBoxText, string caption = null)
|
||||||
{
|
{
|
||||||
MessageBox messageBox = null;
|
MessageBox messageBox = null;
|
||||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK);
|
messageBox = CreateMessageBox(
|
||||||
|
owner: owner,
|
||||||
|
messageBoxText: messageBoxText,
|
||||||
|
caption: caption,
|
||||||
|
button: MessageBoxButton.OK,
|
||||||
|
icon: MessageBoxImage.None,
|
||||||
|
defaultResult: MessageBoxResult.OK
|
||||||
|
);
|
||||||
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
||||||
messageBox.ShowImage = true;
|
messageBox.ShowImage = true;
|
||||||
messageBox.Image = ResourceHelper.GetResourceInternal<Geometry>(ResourceToken.SuccessGeometry);
|
messageBox.Image = ResourceHelper.GetResourceInternal<Geometry>(ResourceToken.SuccessGeometry);
|
||||||
@@ -257,17 +264,24 @@ public sealed class MessageBox : Window
|
|||||||
return messageBox._messageBoxResult;
|
return messageBox._messageBoxResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 消息
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="messageBoxText"></param>
|
|
||||||
/// <param name="caption"></param>
|
|
||||||
public static MessageBoxResult Info(string messageBoxText, string caption = null)
|
public static MessageBoxResult Info(string messageBoxText, string caption = null)
|
||||||
|
{
|
||||||
|
return Info(owner: null, messageBoxText, caption);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageBoxResult Info(System.Windows.Window owner, string messageBoxText, string caption = null)
|
||||||
{
|
{
|
||||||
MessageBox messageBox = null;
|
MessageBox messageBox = null;
|
||||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
|
messageBox = CreateMessageBox(
|
||||||
|
owner: owner,
|
||||||
|
messageBoxText: messageBoxText,
|
||||||
|
caption: caption,
|
||||||
|
button: MessageBoxButton.OK,
|
||||||
|
icon: MessageBoxImage.Information,
|
||||||
|
defaultResult: MessageBoxResult.OK
|
||||||
|
);
|
||||||
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
||||||
SetImage(messageBox, MessageBoxImage.Information);
|
SetImage(messageBox, MessageBoxImage.Information);
|
||||||
SystemSounds.Asterisk.Play();
|
SystemSounds.Asterisk.Play();
|
||||||
@@ -277,17 +291,24 @@ public sealed class MessageBox : Window
|
|||||||
return messageBox._messageBoxResult;
|
return messageBox._messageBoxResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 警告
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="messageBoxText"></param>
|
|
||||||
/// <param name="caption"></param>
|
|
||||||
public static MessageBoxResult Warning(string messageBoxText, string caption = null)
|
public static MessageBoxResult Warning(string messageBoxText, string caption = null)
|
||||||
|
{
|
||||||
|
return Warning(owner: null, messageBoxText, caption);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageBoxResult Warning(System.Windows.Window owner, string messageBoxText, string caption = null)
|
||||||
{
|
{
|
||||||
MessageBox messageBox = null;
|
MessageBox messageBox = null;
|
||||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
|
messageBox = CreateMessageBox(
|
||||||
|
owner: owner,
|
||||||
|
messageBoxText: messageBoxText,
|
||||||
|
caption: caption,
|
||||||
|
button: MessageBoxButton.OK,
|
||||||
|
icon: MessageBoxImage.Warning,
|
||||||
|
defaultResult: MessageBoxResult.OK
|
||||||
|
);
|
||||||
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
||||||
SetImage(messageBox, MessageBoxImage.Warning);
|
SetImage(messageBox, MessageBoxImage.Warning);
|
||||||
SystemSounds.Asterisk.Play();
|
SystemSounds.Asterisk.Play();
|
||||||
@@ -297,17 +318,24 @@ public sealed class MessageBox : Window
|
|||||||
return messageBox._messageBoxResult;
|
return messageBox._messageBoxResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 错误
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="messageBoxText"></param>
|
|
||||||
/// <param name="caption"></param>
|
|
||||||
public static MessageBoxResult Error(string messageBoxText, string caption = null)
|
public static MessageBoxResult Error(string messageBoxText, string caption = null)
|
||||||
|
{
|
||||||
|
return Error(owner: null, messageBoxText, caption);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageBoxResult Error(System.Windows.Window owner, string messageBoxText, string caption = null)
|
||||||
{
|
{
|
||||||
MessageBox messageBox = null;
|
MessageBox messageBox = null;
|
||||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
|
messageBox = CreateMessageBox(
|
||||||
|
owner: owner,
|
||||||
|
messageBoxText: messageBoxText,
|
||||||
|
caption: caption,
|
||||||
|
button: MessageBoxButton.OK,
|
||||||
|
icon: MessageBoxImage.Error,
|
||||||
|
defaultResult: MessageBoxResult.OK
|
||||||
|
);
|
||||||
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
||||||
SetImage(messageBox, MessageBoxImage.Error);
|
SetImage(messageBox, MessageBoxImage.Error);
|
||||||
SystemSounds.Asterisk.Play();
|
SystemSounds.Asterisk.Play();
|
||||||
@@ -317,17 +345,24 @@ public sealed class MessageBox : Window
|
|||||||
return messageBox._messageBoxResult;
|
return messageBox._messageBoxResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 严重
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="messageBoxText"></param>
|
|
||||||
/// <param name="caption"></param>
|
|
||||||
public static MessageBoxResult Fatal(string messageBoxText, string caption = null)
|
public static MessageBoxResult Fatal(string messageBoxText, string caption = null)
|
||||||
|
{
|
||||||
|
return Fatal(owner: null, messageBoxText, caption);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageBoxResult Fatal(System.Windows.Window owner, string messageBoxText, string caption = null)
|
||||||
{
|
{
|
||||||
MessageBox messageBox = null;
|
MessageBox messageBox = null;
|
||||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK);
|
messageBox = CreateMessageBox(
|
||||||
|
owner: owner,
|
||||||
|
messageBoxText: messageBoxText,
|
||||||
|
caption: caption,
|
||||||
|
button: MessageBoxButton.OK,
|
||||||
|
icon: MessageBoxImage.None,
|
||||||
|
defaultResult: MessageBoxResult.OK
|
||||||
|
);
|
||||||
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
SetButtonStatus(messageBox, MessageBoxButton.OK, MessageBoxResult.OK);
|
||||||
messageBox.ShowImage = true;
|
messageBox.ShowImage = true;
|
||||||
messageBox.Image = ResourceHelper.GetResourceInternal<Geometry>(ResourceToken.FatalGeometry);
|
messageBox.Image = ResourceHelper.GetResourceInternal<Geometry>(ResourceToken.FatalGeometry);
|
||||||
@@ -339,17 +374,24 @@ public sealed class MessageBox : Window
|
|||||||
return messageBox._messageBoxResult;
|
return messageBox._messageBoxResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 询问
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="messageBoxText"></param>
|
|
||||||
/// <param name="caption"></param>
|
|
||||||
public static MessageBoxResult Ask(string messageBoxText, string caption = null)
|
public static MessageBoxResult Ask(string messageBoxText, string caption = null)
|
||||||
|
{
|
||||||
|
return Ask(owner: null, messageBoxText, caption);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageBoxResult Ask(System.Windows.Window owner, string messageBoxText, string caption = null)
|
||||||
{
|
{
|
||||||
MessageBox messageBox = null;
|
MessageBox messageBox = null;
|
||||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Cancel);
|
messageBox = CreateMessageBox(
|
||||||
|
owner: owner,
|
||||||
|
messageBoxText: messageBoxText,
|
||||||
|
caption: caption,
|
||||||
|
button: MessageBoxButton.OKCancel,
|
||||||
|
icon: MessageBoxImage.Question,
|
||||||
|
defaultResult: MessageBoxResult.Cancel
|
||||||
|
);
|
||||||
SetButtonStatus(messageBox, MessageBoxButton.OKCancel, MessageBoxResult.Cancel);
|
SetButtonStatus(messageBox, MessageBoxButton.OKCancel, MessageBoxResult.Cancel);
|
||||||
SetImage(messageBox, MessageBoxImage.Question);
|
SetImage(messageBox, MessageBoxImage.Question);
|
||||||
SystemSounds.Asterisk.Play();
|
SystemSounds.Asterisk.Play();
|
||||||
@@ -359,17 +401,19 @@ public sealed class MessageBox : Window
|
|||||||
return messageBox._messageBoxResult;
|
return messageBox._messageBoxResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 自定义信息展示
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static MessageBoxResult Show(MessageBoxInfo info)
|
public static MessageBoxResult Show(MessageBoxInfo info)
|
||||||
{
|
{
|
||||||
MessageBox messageBox = null;
|
MessageBox messageBox = null;
|
||||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
messageBox = CreateMessageBox(null, info.Message, info.Caption, info.Button, MessageBoxImage.None, info.DefaultResult);
|
messageBox = CreateMessageBox(
|
||||||
|
owner: info.Owner,
|
||||||
|
messageBoxText: info.Message,
|
||||||
|
caption: info.Caption,
|
||||||
|
button: info.Button,
|
||||||
|
icon: MessageBoxImage.None,
|
||||||
|
defaultResult: info.DefaultResult
|
||||||
|
);
|
||||||
SetButtonStatus(messageBox, info.Button, info.DefaultResult);
|
SetButtonStatus(messageBox, info.Button, info.DefaultResult);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.IconKey))
|
if (!string.IsNullOrEmpty(info.IconKey))
|
||||||
@@ -383,6 +427,7 @@ public sealed class MessageBox : Window
|
|||||||
{
|
{
|
||||||
messageBox.Style = ResourceHelper.GetResource<Style>(info.StyleKey) ?? info.Style;
|
messageBox.Style = ResourceHelper.GetResource<Style>(info.StyleKey) ?? info.Style;
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemSounds.Asterisk.Play();
|
SystemSounds.Asterisk.Play();
|
||||||
messageBox.ShowDialog();
|
messageBox.ShowDialog();
|
||||||
}));
|
}));
|
||||||
@@ -390,31 +435,25 @@ public sealed class MessageBox : Window
|
|||||||
return messageBox._messageBoxResult;
|
return messageBox._messageBoxResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public static MessageBoxResult Show(
|
||||||
/// 信息展示
|
string messageBoxText,
|
||||||
/// </summary>
|
string caption = null,
|
||||||
/// <param name="messageBoxText"></param>
|
MessageBoxButton button = MessageBoxButton.OK,
|
||||||
/// <param name="caption"></param>
|
MessageBoxImage icon = MessageBoxImage.None,
|
||||||
/// <param name="button"></param>
|
MessageBoxResult defaultResult = MessageBoxResult.None
|
||||||
/// <param name="icon"></param>
|
)
|
||||||
/// <param name="defaultResult"></param>
|
{
|
||||||
/// <returns></returns>
|
return Show(owner: null, messageBoxText, caption, button, icon, defaultResult);
|
||||||
public static MessageBoxResult Show(string messageBoxText, string caption = null,
|
}
|
||||||
MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None,
|
|
||||||
MessageBoxResult defaultResult = MessageBoxResult.None) =>
|
|
||||||
Show(null, messageBoxText, caption, button, icon, defaultResult);
|
|
||||||
|
|
||||||
/// <summary>
|
public static MessageBoxResult Show(
|
||||||
/// 信息展示
|
System.Windows.Window owner,
|
||||||
/// </summary>
|
string messageBoxText,
|
||||||
/// <param name="owner"></param>
|
string caption = null,
|
||||||
/// <param name="messageBoxText"></param>
|
MessageBoxButton button = MessageBoxButton.OK,
|
||||||
/// <param name="caption"></param>
|
MessageBoxImage icon = MessageBoxImage.None,
|
||||||
/// <param name="button"></param>
|
MessageBoxResult defaultResult = MessageBoxResult.None
|
||||||
/// <param name="icon"></param>
|
)
|
||||||
/// <param name="defaultResult"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, string caption = null, MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.None)
|
|
||||||
{
|
{
|
||||||
MessageBox messageBox = null;
|
MessageBox messageBox = null;
|
||||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||||
@@ -435,19 +474,23 @@ public sealed class MessageBox : Window
|
|||||||
string caption,
|
string caption,
|
||||||
MessageBoxButton button,
|
MessageBoxButton button,
|
||||||
MessageBoxImage icon,
|
MessageBoxImage icon,
|
||||||
MessageBoxResult defaultResult)
|
MessageBoxResult defaultResult
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (!IsValidMessageBoxButton(button))
|
if (!IsValidMessageBoxButton(button))
|
||||||
{
|
{
|
||||||
throw new InvalidEnumArgumentException(nameof(button), (int) button, typeof(MessageBoxButton));
|
throw new InvalidEnumArgumentException(nameof(button), (int) button, typeof(MessageBoxButton));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsValidMessageBoxImage(icon))
|
if (!IsValidMessageBoxImage(icon))
|
||||||
{
|
{
|
||||||
throw new InvalidEnumArgumentException(nameof(icon), (int) icon, typeof(MessageBoxImage));
|
throw new InvalidEnumArgumentException(nameof(icon), (int) icon, typeof(MessageBoxImage));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsValidMessageBoxResult(defaultResult))
|
if (!IsValidMessageBoxResult(defaultResult))
|
||||||
{
|
{
|
||||||
throw new InvalidEnumArgumentException(nameof(defaultResult), (int) defaultResult, typeof(MessageBoxResult));
|
throw new InvalidEnumArgumentException(nameof(defaultResult), (int) defaultResult,
|
||||||
|
typeof(MessageBoxResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
var ownerWindow = owner ?? WindowHelper.GetActiveWindow();
|
var ownerWindow = owner ?? WindowHelper.GetActiveWindow();
|
||||||
@@ -457,7 +500,8 @@ public sealed class MessageBox : Window
|
|||||||
{
|
{
|
||||||
Message = messageBoxText,
|
Message = messageBoxText,
|
||||||
Owner = ownerWindow,
|
Owner = ownerWindow,
|
||||||
WindowStartupLocation = ownerIsNull ? WindowStartupLocation.CenterScreen : WindowStartupLocation.CenterOwner,
|
WindowStartupLocation =
|
||||||
|
ownerIsNull ? WindowStartupLocation.CenterScreen : WindowStartupLocation.CenterOwner,
|
||||||
ShowTitle = true,
|
ShowTitle = true,
|
||||||
Title = caption ?? string.Empty,
|
Title = caption ?? string.Empty,
|
||||||
Topmost = ownerIsNull,
|
Topmost = ownerIsNull,
|
||||||
@@ -465,7 +509,11 @@ public sealed class MessageBox : Window
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetButtonStatus(MessageBox messageBox, MessageBoxButton messageBoxButton, MessageBoxResult defaultResult)
|
private static void SetButtonStatus(
|
||||||
|
MessageBox messageBox,
|
||||||
|
MessageBoxButton messageBoxButton,
|
||||||
|
MessageBoxResult defaultResult
|
||||||
|
)
|
||||||
{
|
{
|
||||||
switch (messageBoxButton)
|
switch (messageBoxButton)
|
||||||
{
|
{
|
||||||
@@ -502,12 +550,14 @@ public sealed class MessageBox : Window
|
|||||||
if (defaultResult == MessageBoxResult.Cancel)
|
if (defaultResult == MessageBoxResult.Cancel)
|
||||||
{
|
{
|
||||||
messageBox._buttonOk.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
messageBox._buttonOk.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
messageBox._buttonCancel.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
messageBox._buttonCancel.Style =
|
||||||
|
ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
||||||
messageBox._buttonCancel.IsDefault = true;
|
messageBox._buttonCancel.IsDefault = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
messageBox._buttonOk.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
messageBox._buttonOk.Style =
|
||||||
|
ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
||||||
messageBox._buttonOk.IsDefault = true;
|
messageBox._buttonOk.IsDefault = true;
|
||||||
messageBox._buttonCancel.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
messageBox._buttonCancel.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
}
|
}
|
||||||
@@ -532,12 +582,14 @@ public sealed class MessageBox : Window
|
|||||||
if (defaultResult == MessageBoxResult.No)
|
if (defaultResult == MessageBoxResult.No)
|
||||||
{
|
{
|
||||||
messageBox._buttonYes.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
messageBox._buttonYes.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
messageBox._buttonNo.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
messageBox._buttonNo.Style =
|
||||||
|
ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
||||||
messageBox._buttonNo.IsDefault = true;
|
messageBox._buttonNo.IsDefault = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
messageBox._buttonYes.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
messageBox._buttonYes.Style =
|
||||||
|
ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
||||||
messageBox._buttonYes.IsDefault = true;
|
messageBox._buttonYes.IsDefault = true;
|
||||||
messageBox._buttonNo.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
messageBox._buttonNo.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
}
|
}
|
||||||
@@ -570,7 +622,8 @@ public sealed class MessageBox : Window
|
|||||||
if (defaultResult == MessageBoxResult.No)
|
if (defaultResult == MessageBoxResult.No)
|
||||||
{
|
{
|
||||||
messageBox._buttonYes.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
messageBox._buttonYes.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
messageBox._buttonNo.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
messageBox._buttonNo.Style =
|
||||||
|
ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
||||||
messageBox._buttonNo.IsDefault = true;
|
messageBox._buttonNo.IsDefault = true;
|
||||||
messageBox._buttonCancel.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
messageBox._buttonCancel.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
}
|
}
|
||||||
@@ -578,12 +631,14 @@ public sealed class MessageBox : Window
|
|||||||
{
|
{
|
||||||
messageBox._buttonYes.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
messageBox._buttonYes.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
messageBox._buttonNo.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
messageBox._buttonNo.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
messageBox._buttonCancel.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
messageBox._buttonCancel.Style =
|
||||||
|
ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
||||||
messageBox._buttonCancel.IsDefault = true;
|
messageBox._buttonCancel.IsDefault = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
messageBox._buttonYes.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
messageBox._buttonYes.Style =
|
||||||
|
ResourceHelper.GetResourceInternal<Style>("MessageBoxPrimaryButtonStyle");
|
||||||
messageBox._buttonYes.IsDefault = true;
|
messageBox._buttonYes.IsDefault = true;
|
||||||
messageBox._buttonNo.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
messageBox._buttonNo.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
messageBox._buttonCancel.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
messageBox._buttonCancel.Style = ResourceHelper.GetResourceInternal<Style>("MessageBoxButtonStyle");
|
||||||
@@ -618,7 +673,11 @@ public sealed class MessageBox : Window
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(iconKey)) return;
|
if (string.IsNullOrEmpty(iconKey))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
messageBox.ShowImage = true;
|
messageBox.ShowImage = true;
|
||||||
messageBox.Image = ResourceHelper.GetResourceInternal<Geometry>(iconKey);
|
messageBox.Image = ResourceHelper.GetResourceInternal<Geometry>(iconKey);
|
||||||
messageBox.ImageBrush = ResourceHelper.GetResourceInternal<Brush>(iconBrushKey);
|
messageBox.ImageBrush = ResourceHelper.GetResourceInternal<Brush>(iconBrushKey);
|
||||||
@@ -626,32 +685,34 @@ public sealed class MessageBox : Window
|
|||||||
|
|
||||||
private static bool IsValidMessageBoxButton(MessageBoxButton value)
|
private static bool IsValidMessageBoxButton(MessageBoxButton value)
|
||||||
{
|
{
|
||||||
return value == MessageBoxButton.OK
|
return value
|
||||||
|| value == MessageBoxButton.OKCancel
|
is MessageBoxButton.OK
|
||||||
|| value == MessageBoxButton.YesNo
|
or MessageBoxButton.OKCancel
|
||||||
|| value == MessageBoxButton.YesNoCancel;
|
or MessageBoxButton.YesNo
|
||||||
|
or MessageBoxButton.YesNoCancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
[SuppressMessage("ReSharper", "ConditionIsAlwaysTrueOrFalse")]
|
|
||||||
private static bool IsValidMessageBoxImage(MessageBoxImage value)
|
private static bool IsValidMessageBoxImage(MessageBoxImage value)
|
||||||
{
|
{
|
||||||
return value == MessageBoxImage.Asterisk
|
return value
|
||||||
|| value == MessageBoxImage.Error
|
is MessageBoxImage.Asterisk
|
||||||
|| value == MessageBoxImage.Exclamation
|
or MessageBoxImage.Error
|
||||||
|| value == MessageBoxImage.Hand
|
or MessageBoxImage.Exclamation
|
||||||
|| value == MessageBoxImage.Information
|
or MessageBoxImage.Hand
|
||||||
|| value == MessageBoxImage.None
|
or MessageBoxImage.Information
|
||||||
|| value == MessageBoxImage.Question
|
or MessageBoxImage.None
|
||||||
|| value == MessageBoxImage.Stop
|
or MessageBoxImage.Question
|
||||||
|| value == MessageBoxImage.Warning;
|
or MessageBoxImage.Stop
|
||||||
|
or MessageBoxImage.Warning;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsValidMessageBoxResult(MessageBoxResult value)
|
private static bool IsValidMessageBoxResult(MessageBoxResult value)
|
||||||
{
|
{
|
||||||
return value == MessageBoxResult.Cancel
|
return value
|
||||||
|| value == MessageBoxResult.No
|
is MessageBoxResult.Cancel
|
||||||
|| value == MessageBoxResult.None
|
or MessageBoxResult.No
|
||||||
|| value == MessageBoxResult.OK
|
or MessageBoxResult.None
|
||||||
|| value == MessageBoxResult.Yes;
|
or MessageBoxResult.OK
|
||||||
|
or MessageBoxResult.Yes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,4 +24,6 @@ public class MessageBoxInfo
|
|||||||
public Style Style { get; set; }
|
public Style Style { get; set; }
|
||||||
|
|
||||||
public string StyleKey { get; set; }
|
public string StyleKey { get; set; }
|
||||||
|
|
||||||
|
public Window Owner { get; set; }
|
||||||
}
|
}
|
||||||
@@ -13777,6 +13777,7 @@
|
|||||||
<Style x:Key="TabControlCapsule" TargetType="TabControl">
|
<Style x:Key="TabControlCapsule" TargetType="TabControl">
|
||||||
<Setter Property="BorderThickness" Value="1" />
|
<Setter Property="BorderThickness" Value="1" />
|
||||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}" />
|
<Setter Property="Background" Value="{DynamicResource RegionBrush}" />
|
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}" />
|
||||||
<Setter Property="hc:TitleElement.BorderBrush" Value="{DynamicResource PrimaryBrush}" />
|
<Setter Property="hc:TitleElement.BorderBrush" Value="{DynamicResource PrimaryBrush}" />
|
||||||
<Setter Property="hc:TitleElement.Background" Value="{DynamicResource RegionBrush}" />
|
<Setter Property="hc:TitleElement.Background" Value="{DynamicResource RegionBrush}" />
|
||||||
<Setter Property="hc:TitleElement.Foreground" Value="{DynamicResource PrimaryBrush}" />
|
<Setter Property="hc:TitleElement.Foreground" Value="{DynamicResource PrimaryBrush}" />
|
||||||
@@ -13798,7 +13799,7 @@
|
|||||||
<RowDefinition x:Name="RowDefinition1" Height="*" />
|
<RowDefinition x:Name="RowDefinition1" Height="*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<UniformGrid Rows="1" KeyboardNavigation.TabNavigation="Once" KeyboardNavigation.DirectionalNavigation="Cycle" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="headerPanel" Background="Transparent" Grid.Column="0" IsItemsHost="true" Margin="0" Grid.Row="0" />
|
<UniformGrid Rows="1" KeyboardNavigation.TabNavigation="Once" KeyboardNavigation.DirectionalNavigation="Cycle" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="headerPanel" Background="Transparent" Grid.Column="0" IsItemsHost="true" Margin="0" Grid.Row="0" />
|
||||||
<Border x:Name="contentPanel" Margin="0,6,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{DynamicResource BorderBrush}" Background="{TemplateBinding Background}" Grid.Column="0" Grid.Row="1">
|
<Border x:Name="contentPanel" Margin="0,6,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Grid.Column="0" Grid.Row="1">
|
||||||
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
Reference in new issue
Block a user