improve growl
According to @ghost1372 suggestion, growl has been improved.
This commit is contained in:
1 parent
fffbdbb4a9
commit
b144c2ec39
33 files changed
+409
-77
No files matched your search
@@ -10,6 +10,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Interactivity;
|
||||
using HandyControl.Tools;
|
||||
|
||||
@@ -268,7 +269,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
var button = new Button
|
||||
{
|
||||
Style = TryFindResource("ButtonCustom") as Style,
|
||||
Style = ResourceHelper.GetResource<Style>(ResourceToken.ButtonCustom),
|
||||
Content = new Border
|
||||
{
|
||||
Width = 10,
|
||||
@@ -277,7 +278,7 @@ namespace HandyControl.Controls
|
||||
Background = Brushes.White,
|
||||
Margin = new Thickness(5, 0, 5, 0),
|
||||
BorderThickness = new Thickness(1),
|
||||
BorderBrush = TryFindResource("PrimaryBrush") as Brush
|
||||
BorderBrush = ResourceHelper.GetResource<Brush>(ResourceToken.PrimaryBrush)
|
||||
}
|
||||
};
|
||||
return button;
|
||||
@@ -289,7 +290,7 @@ namespace HandyControl.Controls
|
||||
borderOri.Background = Brushes.White;
|
||||
_selectedButton = e.OriginalSource as Button;
|
||||
if (_selectedButton != null && _selectedButton.Content is Border border)
|
||||
border.Background = TryFindResource("PrimaryBrush") as Brush;
|
||||
border.Background = ResourceHelper.GetResource<Brush>(ResourceToken.PrimaryBrush);
|
||||
var index = _panelPage.Children.IndexOf(_selectedButton);
|
||||
if (index != -1)
|
||||
PageIndex = index;
|
||||
|
||||
+183
-34
@@ -6,6 +6,8 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Threading;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Data.Enum;
|
||||
using HandyControl.Interactivity;
|
||||
using HandyControl.Tools;
|
||||
using HandyControl.Tools.Extension;
|
||||
@@ -78,18 +80,6 @@ namespace HandyControl.Controls
|
||||
/// </summary>
|
||||
private const int MaxTickCount = 6;
|
||||
|
||||
public static readonly DependencyProperty MessageProperty = DependencyProperty.Register(
|
||||
"Message", typeof(string), typeof(Growl), new PropertyMetadata(default(string)));
|
||||
|
||||
public static readonly DependencyProperty TimeProperty = DependencyProperty.Register(
|
||||
"Time", typeof(DateTime), typeof(Growl), new PropertyMetadata(default(DateTime)));
|
||||
|
||||
public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
|
||||
"Icon", typeof(Geometry), typeof(Growl), new PropertyMetadata(default(Geometry)));
|
||||
|
||||
public static readonly DependencyProperty IconBrushProperty = DependencyProperty.Register(
|
||||
"IconBrush", typeof(Brush), typeof(Growl), new PropertyMetadata(default(Brush)));
|
||||
|
||||
/// <summary>
|
||||
/// 消息容器
|
||||
/// </summary>
|
||||
@@ -107,6 +97,54 @@ namespace HandyControl.Controls
|
||||
|
||||
private Func<bool, bool> ActionBeforeClose { get; set; }
|
||||
|
||||
internal static readonly DependencyProperty CancelStrProperty = DependencyProperty.Register(
|
||||
"CancelStr", typeof(string), typeof(Growl), new PropertyMetadata(default(string)));
|
||||
|
||||
internal static readonly DependencyProperty ConfirmStrProperty = DependencyProperty.Register(
|
||||
"ConfirmStr", typeof(string), typeof(Growl), new PropertyMetadata(default(string)));
|
||||
|
||||
public static readonly DependencyProperty ShowDateTimeProperty = DependencyProperty.Register(
|
||||
"ShowDateTime", typeof(bool), typeof(Growl), new PropertyMetadata(true));
|
||||
|
||||
public static readonly DependencyProperty MessageProperty = DependencyProperty.Register(
|
||||
"Message", typeof(string), typeof(Growl), new PropertyMetadata(default(string)));
|
||||
|
||||
public static readonly DependencyProperty TimeProperty = DependencyProperty.Register(
|
||||
"Time", typeof(DateTime), typeof(Growl), new PropertyMetadata(default(DateTime)));
|
||||
|
||||
public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
|
||||
"Icon", typeof(Geometry), typeof(Growl), new PropertyMetadata(default(Geometry)));
|
||||
|
||||
public static readonly DependencyProperty IconBrushProperty = DependencyProperty.Register(
|
||||
"IconBrush", typeof(Brush), typeof(Growl), new PropertyMetadata(default(Brush)));
|
||||
|
||||
public static readonly DependencyProperty TypeProperty = DependencyProperty.Register(
|
||||
"Type", typeof(InfoType), typeof(Growl), new PropertyMetadata(default(InfoType)));
|
||||
|
||||
public InfoType Type
|
||||
{
|
||||
get => (InfoType) GetValue(TypeProperty);
|
||||
set => SetValue(TypeProperty, value);
|
||||
}
|
||||
|
||||
internal string CancelStr
|
||||
{
|
||||
get => (string)GetValue(CancelStrProperty);
|
||||
set => SetValue(CancelStrProperty, value);
|
||||
}
|
||||
|
||||
internal string ConfirmStr
|
||||
{
|
||||
get => (string)GetValue(ConfirmStrProperty);
|
||||
set => SetValue(ConfirmStrProperty, value);
|
||||
}
|
||||
|
||||
public bool ShowDateTime
|
||||
{
|
||||
get => (bool)GetValue(ShowDateTimeProperty);
|
||||
set => SetValue(ShowDateTimeProperty, value);
|
||||
}
|
||||
|
||||
public string Message
|
||||
{
|
||||
get => (string)GetValue(MessageProperty);
|
||||
@@ -211,18 +249,22 @@ namespace HandyControl.Controls
|
||||
/// <summary>
|
||||
/// 显示信息
|
||||
/// </summary>
|
||||
private static void Show(string message, string iconKey, string iconBrushKey, Func<bool, bool> actionBeforeClose = null,
|
||||
bool staysOpen = false, bool showCloseButton = true)
|
||||
/// <param name="growlInfo"></param>
|
||||
private static void Show(GrowlInfo growlInfo)
|
||||
{
|
||||
var ctl = new Growl
|
||||
{
|
||||
Message = message,
|
||||
Message = growlInfo.Message,
|
||||
Time = DateTime.Now,
|
||||
Icon = ResourceHelper.GetResource<Geometry>(iconKey),
|
||||
IconBrush = ResourceHelper.GetResource<Brush>(iconBrushKey),
|
||||
_showCloseButton = showCloseButton,
|
||||
ActionBeforeClose = actionBeforeClose,
|
||||
_staysOpen = staysOpen
|
||||
Icon = ResourceHelper.GetResource<Geometry>(growlInfo.IconKey),
|
||||
IconBrush = ResourceHelper.GetResource<Brush>(growlInfo.IconBrushKey),
|
||||
_showCloseButton = growlInfo.ShowCloseButton,
|
||||
ActionBeforeClose = growlInfo.ActionBeforeClose,
|
||||
_staysOpen = growlInfo.StaysOpen,
|
||||
ShowDateTime = growlInfo.ShowDateTime,
|
||||
ConfirmStr = growlInfo.ConfirmStr,
|
||||
CancelStr = growlInfo.CancelStr,
|
||||
Type = growlInfo.Type
|
||||
};
|
||||
GrowlPanel.Children.Insert(0, ctl);
|
||||
}
|
||||
@@ -230,38 +272,141 @@ namespace HandyControl.Controls
|
||||
/// <summary>
|
||||
/// 成功
|
||||
/// </summary>
|
||||
public static void Success(string message) => Show(message, "SuccessGeometry", "SuccessBrush");
|
||||
/// <param name="message"></param>
|
||||
public static void Success(string message) => Success(new GrowlInfo
|
||||
{
|
||||
Message = message
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// 成功
|
||||
/// </summary>
|
||||
/// <param name="growlInfo"></param>
|
||||
public static void Success(GrowlInfo growlInfo)
|
||||
{
|
||||
if (growlInfo == null) throw new NullReferenceException("growlInfo is null");
|
||||
growlInfo.IconKey = ResourceToken.SuccessGeometry;
|
||||
growlInfo.IconBrushKey = ResourceToken.SuccessBrush;
|
||||
growlInfo.Type = InfoType.Success;
|
||||
Show(growlInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 消息
|
||||
/// </summary>
|
||||
public static void Info(string message) => Show(message, "InfoGeometry", "InfoBrush");
|
||||
/// <param name="message"></param>
|
||||
public static void Info(string message) => Info(new GrowlInfo
|
||||
{
|
||||
Message = message
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// 错误
|
||||
/// 消息
|
||||
/// </summary>
|
||||
public static void Error(string message) => Show(message, "ErrorGeometry", "DangerBrush", null, true);
|
||||
/// <param name="growlInfo"></param>
|
||||
public static void Info(GrowlInfo growlInfo)
|
||||
{
|
||||
if (growlInfo == null) throw new NullReferenceException("growlInfo is null");
|
||||
growlInfo.IconKey = ResourceToken.InfoGeometry;
|
||||
growlInfo.IconBrushKey = ResourceToken.InfoBrush;
|
||||
growlInfo.Type = InfoType.Info;
|
||||
Show(growlInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 警告
|
||||
/// </summary>
|
||||
public static void Warning(string message) => Show(message, "WarningGeometry", "WarningBrush");
|
||||
/// <param name="message"></param>
|
||||
public static void Warning(string message) => Warning(new GrowlInfo
|
||||
{
|
||||
Message = message
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// 警告
|
||||
/// </summary>
|
||||
/// <param name="growlInfo"></param>
|
||||
public static void Warning(GrowlInfo growlInfo)
|
||||
{
|
||||
if (growlInfo == null) throw new NullReferenceException("growlInfo is null");
|
||||
growlInfo.IconKey = ResourceToken.WarningGeometry;
|
||||
growlInfo.IconBrushKey = ResourceToken.WarningBrush;
|
||||
growlInfo.Type = InfoType.Warning;
|
||||
Show(growlInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 错误
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
public static void Error(string message) => Error(new GrowlInfo
|
||||
{
|
||||
Message = message
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// 错误
|
||||
/// </summary>
|
||||
/// <param name="growlInfo"></param>
|
||||
public static void Error(GrowlInfo growlInfo)
|
||||
{
|
||||
if (growlInfo == null) throw new NullReferenceException("growlInfo is null");
|
||||
growlInfo.IconKey = ResourceToken.ErrorGeometry;
|
||||
growlInfo.IconBrushKey = ResourceToken.DangerBrush;
|
||||
growlInfo.StaysOpen = true;
|
||||
growlInfo.Type = InfoType.Error;
|
||||
Show(growlInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 严重
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="showContextMenu"></param>
|
||||
public static void Fatal(string message, bool showContextMenu = true)
|
||||
public static void Fatal(string message) => Fatal(new GrowlInfo
|
||||
{
|
||||
if (!showContextMenu)
|
||||
{
|
||||
GrowlPanel.ContextMenu.Collapse();
|
||||
}
|
||||
Show(message, "FatalGeometry", "PrimaryTextBrush", null, true, false);
|
||||
Message = message
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// 严重
|
||||
/// </summary>
|
||||
/// <param name="growlInfo"></param>
|
||||
public static void Fatal(GrowlInfo growlInfo)
|
||||
{
|
||||
if (growlInfo == null) throw new NullReferenceException("growlInfo is null");
|
||||
growlInfo.IconKey = ResourceToken.FatalGeometry;
|
||||
growlInfo.IconBrushKey = ResourceToken.PrimaryTextBrush;
|
||||
growlInfo.StaysOpen = true;
|
||||
growlInfo.ShowCloseButton = false;
|
||||
growlInfo.Type = InfoType.Fatal;
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
GrowlPanel.ContextMenu.Opacity = 0;
|
||||
Show(growlInfo);
|
||||
}
|
||||
|
||||
public static void Ask(string message, Func<bool, bool> actionBeforeClose) => Show(message, "AskGeometry", "AccentBrush", actionBeforeClose);
|
||||
/// <summary>
|
||||
/// 询问
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
public static void Ask(string message) => Ask(new GrowlInfo
|
||||
{
|
||||
Message = message
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// 询问
|
||||
/// </summary>
|
||||
/// <param name="growlInfo"></param>
|
||||
public static void Ask(GrowlInfo growlInfo)
|
||||
{
|
||||
if (growlInfo == null) throw new NullReferenceException("growlInfo is null");
|
||||
growlInfo.IconKey = ResourceToken.AskGeometry;
|
||||
growlInfo.IconBrushKey = ResourceToken.AccentBrush;
|
||||
growlInfo.StaysOpen = true;
|
||||
growlInfo.ShowCloseButton = false;
|
||||
growlInfo.Type = InfoType.Ask;
|
||||
Show(growlInfo);
|
||||
}
|
||||
|
||||
private void ButtonClose_OnClick(object sender, RoutedEventArgs e) => Close();
|
||||
|
||||
@@ -284,7 +429,11 @@ namespace HandyControl.Controls
|
||||
public static void Clear()
|
||||
{
|
||||
GrowlPanel.Children.Clear();
|
||||
GrowlPanel.Show();
|
||||
if (GrowlPanel.ContextMenu != null)
|
||||
{
|
||||
GrowlPanel.ContextMenu.IsOpen = false;
|
||||
GrowlPanel.ContextMenu.Opacity = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_OnClick(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace HandyControl.Controls
|
||||
|
||||
public bool IsRunning
|
||||
{
|
||||
get { return (bool) GetValue(IsRunningProperty); }
|
||||
set { SetValue(IsRunningProperty, value); }
|
||||
get => (bool) GetValue(IsRunningProperty);
|
||||
set => SetValue(IsRunningProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty DotCountProperty = DependencyProperty.Register(
|
||||
@@ -124,11 +124,11 @@ namespace HandyControl.Controls
|
||||
protected Ellipse CreateEllipse(int index)
|
||||
{
|
||||
var ellipse = new Ellipse();
|
||||
ellipse.SetBinding(WidthProperty, new Binding("DotDiameter") {Source = this});
|
||||
ellipse.SetBinding(HeightProperty, new Binding("DotDiameter") {Source = this});
|
||||
ellipse.SetBinding(Shape.FillProperty, new Binding("Foreground") {Source = this});
|
||||
ellipse.SetBinding(Shape.StrokeThicknessProperty, new Binding("DotBorderThickness") {Source = this});
|
||||
ellipse.SetBinding(Shape.StrokeProperty, new Binding("DotBorderBrush") {Source = this});
|
||||
ellipse.SetBinding(WidthProperty, new Binding(DotDiameterProperty.Name) {Source = this});
|
||||
ellipse.SetBinding(HeightProperty, new Binding(DotDiameterProperty.Name) {Source = this});
|
||||
ellipse.SetBinding(Shape.FillProperty, new Binding(ForegroundProperty.Name) {Source = this});
|
||||
ellipse.SetBinding(Shape.StrokeThicknessProperty, new Binding(DotBorderThicknessProperty.Name) {Source = this});
|
||||
ellipse.SetBinding(Shape.StrokeProperty, new Binding(DotBorderBrushProperty.Name) {Source = this});
|
||||
return ellipse;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Interactivity;
|
||||
using HandyControl.Tools;
|
||||
using HandyControl.Tools.Extension;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
@@ -261,37 +262,37 @@ namespace HandyControl.Controls
|
||||
_buttonRight.IsEnabled = PageIndex < MaxPageCount;
|
||||
if (MaxPageInterval == 0)
|
||||
{
|
||||
_buttonFirst.Visibility = Visibility.Collapsed;
|
||||
_buttonLast.Visibility = Visibility.Collapsed;
|
||||
_textBlockLeft.Visibility = Visibility.Collapsed;
|
||||
_textBlockRight.Visibility = Visibility.Collapsed;
|
||||
_buttonFirst.Collapse();
|
||||
_buttonLast.Collapse();
|
||||
_textBlockLeft.Collapse();
|
||||
_textBlockRight.Collapse();
|
||||
_panelMain.Children.Clear();
|
||||
var selectButton = CreateButton(PageIndex);
|
||||
_panelMain.Children.Add(selectButton);
|
||||
selectButton.IsChecked = true;
|
||||
return;
|
||||
}
|
||||
_buttonFirst.Visibility = Visibility.Visible;
|
||||
_buttonLast.Visibility = Visibility.Visible;
|
||||
_textBlockLeft.Visibility = Visibility.Visible;
|
||||
_textBlockRight.Visibility = Visibility.Visible;
|
||||
_buttonFirst.Show();
|
||||
_buttonLast.Show();
|
||||
_textBlockLeft.Show();
|
||||
_textBlockRight.Show();
|
||||
|
||||
//更新最后一页
|
||||
if (MaxPageCount == 1)
|
||||
{
|
||||
_buttonLast.Visibility = Visibility.Collapsed;
|
||||
_buttonLast.Collapse();
|
||||
}
|
||||
else
|
||||
{
|
||||
_buttonLast.Visibility = Visibility.Visible;
|
||||
_buttonLast.Show();
|
||||
_buttonLast.Tag = MaxPageCount.ToString();
|
||||
}
|
||||
|
||||
//更新省略号
|
||||
var right = MaxPageCount - PageIndex;
|
||||
var left = PageIndex - 1;
|
||||
_textBlockRight.Visibility = right > MaxPageInterval ? Visibility.Visible : Visibility.Collapsed;
|
||||
_textBlockLeft.Visibility = left > MaxPageInterval ? Visibility.Visible : Visibility.Collapsed;
|
||||
_textBlockRight.Show(right > MaxPageInterval);
|
||||
_textBlockLeft.Show(left > MaxPageInterval);
|
||||
|
||||
//更新中间部分
|
||||
_panelMain.Children.Clear();
|
||||
@@ -344,7 +345,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
return new RadioButton
|
||||
{
|
||||
Style = FindResource("PaginationButtonStyle") as Style,
|
||||
Style = ResourceHelper.GetResource<Style>(ResourceToken.PaginationButtonStyle),
|
||||
Tag = page.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
@@ -54,15 +55,15 @@ namespace HandyControl.Controls
|
||||
{
|
||||
if (Status == true)
|
||||
{
|
||||
Foreground = ResourceHelper.GetResource<Brush>("PrimaryTextBrush");
|
||||
Foreground = ResourceHelper.GetResource<Brush>(ResourceToken.PrimaryTextBrush);
|
||||
}
|
||||
else if (Status == false)
|
||||
{
|
||||
Foreground = ResourceHelper.GetResource<Brush>("PrimaryBrush");
|
||||
Foreground = ResourceHelper.GetResource<Brush>(ResourceToken.PrimaryBrush);
|
||||
}
|
||||
else
|
||||
{
|
||||
Foreground = ResourceHelper.GetResource<Brush>("ThirdlyTextBrush");
|
||||
Foreground = ResourceHelper.GetResource<Brush>(ResourceToken.ThirdlyTextBrush);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -534,8 +534,6 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
//private void ButtonScreenChange_OnClick(object sender, RoutedEventArgs e) => WindowState = IsFullScreen ? WindowState.Maximized : WindowState.Normal;
|
||||
|
||||
private void ButtonClose_OnClick(object sender, RoutedEventArgs e) => Close();
|
||||
|
||||
private void GridTop_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Interactivity;
|
||||
using HandyControl.Tools;
|
||||
|
||||
@@ -188,7 +189,7 @@ namespace HandyControl.Controls
|
||||
ContentStr = message,
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen
|
||||
};
|
||||
window.Background = window.FindResource("PrimaryBrush") as SolidColorBrush;
|
||||
window.Background = ResourceHelper.GetResource<Brush>(ResourceToken.PrimaryBrush);
|
||||
window.Show();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shell;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace HandyControl.Controls
|
||||
@@ -258,14 +260,14 @@ namespace HandyControl.Controls
|
||||
{
|
||||
var window = new WindowBorderless
|
||||
{
|
||||
Style = Application.Current.TryFindResource("CustomWindowStyle") as Style,
|
||||
Style = ResourceHelper.GetResource<Style>(ResourceToken.CustomWindowStyle),
|
||||
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("在样式中未找到名称为GridMenu的元素");
|
||||
throw new NullReferenceException("can not find GridMenu in template");
|
||||
window.Height = window.BorderThickness.Top + window.BorderThickness.Bottom + content.Height +
|
||||
nemuArea.ActualHeight;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace HandyControl.Data.Enum
|
||||
{
|
||||
public enum InfoType
|
||||
{
|
||||
Success = 0,
|
||||
Info,
|
||||
Warning,
|
||||
Error,
|
||||
Fatal,
|
||||
Ask
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using HandyControl.Data.Enum;
|
||||
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
public class GrowlInfo
|
||||
{
|
||||
public string Message { get; set; }
|
||||
|
||||
public bool ShowDateTime { get; set; } = true;
|
||||
|
||||
public string CancelStr { get; set; } = Properties.Langs.Lang.Cancel;
|
||||
|
||||
public string ConfirmStr { get; set; } = Properties.Langs.Lang.Confirm;
|
||||
|
||||
public Func<bool, bool> ActionBeforeClose { get; set; }
|
||||
|
||||
internal InfoType Type { get; set; }
|
||||
|
||||
internal string IconKey { get; set; }
|
||||
|
||||
internal string IconBrushKey { get; set; }
|
||||
|
||||
internal bool StaysOpen { get; set; }
|
||||
|
||||
internal bool ShowCloseButton { get; set; } = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
internal class ResourceToken
|
||||
{
|
||||
public static readonly string SuccessGeometry = nameof(SuccessGeometry);
|
||||
|
||||
public static readonly string InfoGeometry = nameof(InfoGeometry);
|
||||
|
||||
public static readonly string ErrorGeometry = nameof(ErrorGeometry);
|
||||
|
||||
public static readonly string WarningGeometry = nameof(WarningGeometry);
|
||||
|
||||
public static readonly string AskGeometry = nameof(AskGeometry);
|
||||
|
||||
public static readonly string FatalGeometry = nameof(FatalGeometry);
|
||||
|
||||
public static readonly string PrimaryBrush = nameof(PrimaryBrush);
|
||||
|
||||
public static readonly string SuccessBrush = nameof(SuccessBrush);
|
||||
|
||||
public static readonly string InfoBrush = nameof(InfoBrush);
|
||||
|
||||
public static readonly string DangerBrush = nameof(DangerBrush);
|
||||
|
||||
public static readonly string WarningBrush = nameof(WarningBrush);
|
||||
|
||||
public static readonly string AccentBrush = nameof(AccentBrush);
|
||||
|
||||
public static readonly string PrimaryTextBrush = nameof(PrimaryTextBrush);
|
||||
|
||||
public static readonly string ThirdlyTextBrush = nameof(ThirdlyTextBrush);
|
||||
|
||||
public static readonly string ButtonCustom = nameof(ButtonCustom);
|
||||
|
||||
public static readonly string PaginationButtonStyle = nameof(PaginationButtonStyle);
|
||||
|
||||
public static readonly string CustomWindowStyle = nameof(CustomWindowStyle);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<#@ template debug="false" hostspecific="false" language="C#" #>
|
||||
<#@ import namespace="System.Collections.Generic"#>
|
||||
<#@ output extension=".cs" #>
|
||||
<#
|
||||
var geometryList = new List<string>
|
||||
{
|
||||
"SuccessGeometry",
|
||||
"InfoGeometry",
|
||||
"ErrorGeometry",
|
||||
"WarningGeometry",
|
||||
"AskGeometry",
|
||||
"FatalGeometry",
|
||||
"PrimaryBrush"
|
||||
};
|
||||
var brushList = new List<string>
|
||||
{
|
||||
"SuccessBrush",
|
||||
"InfoBrush",
|
||||
"DangerBrush",
|
||||
"WarningBrush",
|
||||
"AccentBrush",
|
||||
"PrimaryTextBrush",
|
||||
"ThirdlyTextBrush"
|
||||
};
|
||||
var styleList = new List<string>
|
||||
{
|
||||
"ButtonCustom",
|
||||
"PaginationButtonStyle",
|
||||
"CustomWindowStyle"
|
||||
};
|
||||
#>
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
internal class ResourceToken
|
||||
{
|
||||
<#foreach(var item in geometryList){#>
|
||||
public static readonly string <#=item#> = nameof(<#=item#>);
|
||||
|
||||
<#}#>
|
||||
<#foreach(var item in brushList){#>
|
||||
public static readonly string <#=item#> = nameof(<#=item#>);
|
||||
|
||||
<#}#>
|
||||
<#foreach(var item in styleList){#>
|
||||
public static readonly string <#=item#> = nameof(<#=item#>);
|
||||
|
||||
<#}#>
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,13 @@
|
||||
<Compile Include="Controls\Loading\LoadingBase.cs" />
|
||||
<Compile Include="Controls\Loading\LoadingCircle.cs" />
|
||||
<Compile Include="Controls\Loading\LoadingLine.cs" />
|
||||
<Compile Include="Data\Enum\InfoType.cs" />
|
||||
<Compile Include="Data\GrowlInfo.cs" />
|
||||
<Compile Include="Data\ResourceToken.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ResourceToken.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Tools\SingleOpenHelper.cs" />
|
||||
<Compile Include="Controls\Steps\StepBar.cs" />
|
||||
<Compile Include="Controls\Steps\StepItem.cs" />
|
||||
@@ -432,5 +439,14 @@
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Data\ResourceToken.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>ResourceToken.cs</LastGenOutput>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -5,6 +5,7 @@
|
||||
xmlns:interactivity="clr-namespace:HandyControl.Interactivity">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="../Basic/Converters.xaml"/>
|
||||
<ResourceDictionary Source="../Basic/Geometries.xaml"/>
|
||||
<ResourceDictionary Source="../Basic/Effects.xaml"/>
|
||||
<ResourceDictionary Source="TextBlock.xaml"/>
|
||||
@@ -36,19 +37,19 @@
|
||||
</Grid.RowDefinitions>
|
||||
<Border Grid.ColumnSpan="3" Grid.RowSpan="2" Effect="{StaticResource EffectShadow2}" Background="White" CornerRadius="8" Width="320"/>
|
||||
<Path Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" Margin="0,15,0,0" Width="30" Height="30" Data="{TemplateBinding Icon}" Stretch="Uniform" Fill="{TemplateBinding IconBrush}"/>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" Margin="0,12,10,10">
|
||||
<StackPanel VerticalAlignment="Center" Grid.Row="0" Grid.Column="1" Margin="0,10,10,10">
|
||||
<TextBlock Text="{TemplateBinding Message}" Style="{StaticResource TextBlockDefault}" HorizontalAlignment="Left" TextWrapping="Wrap"/>
|
||||
<TextBlock Text="{Binding Time,RelativeSource={RelativeSource FindAncestor,AncestorType=controls:Growl},StringFormat=yyyy/MM/dd HH:mm:ss}" Style="{StaticResource TextBlockDefault}" Foreground="{DynamicResource SecondaryTextBrush}" HorizontalAlignment="Left" Margin="0,4,0,0"/>
|
||||
<TextBlock Visibility="{Binding ShowDateTime,RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource Boolean2VisibilityConverter}}" Text="{Binding Time,RelativeSource={RelativeSource FindAncestor,AncestorType=controls:Growl},StringFormat=yyyy/MM/dd HH:mm:ss}" Style="{StaticResource TextBlockDefault}" Foreground="{DynamicResource SecondaryTextBrush}" HorizontalAlignment="Left" Margin="0,4,0,0"/>
|
||||
</StackPanel>
|
||||
<Button Grid.Row="0" Visibility="Collapsed" Margin="11,0" Name="PART_ButtonClose" Command="interactivity:ControlCommands.Close" Grid.Column="2" Background="Transparent" Style="{StaticResource ButtonCustom}" VerticalAlignment="Center" HorizontalAlignment="Center" Width="18" Height="18">
|
||||
<Path Data="{StaticResource ErrorGeometry}" Stretch="Uniform" Fill="{DynamicResource SecondaryTextBrush}"/>
|
||||
</Button>
|
||||
<StackPanel Name="PART_PanelMore" IsEnabled="False" Visibility="Collapsed" Orientation="Horizontal" Grid.Row="1" Grid.ColumnSpan="3" Height="28" Grid.Column="0">
|
||||
<Button Command="interactivity:ControlCommands.Cancel" Style="{StaticResource ButtonCustom}" Width="160">
|
||||
<TextBlock Text="{x:Static langs:Lang.Cancel}" HorizontalAlignment="Center" Foreground="{DynamicResource DangerBrush}"/>
|
||||
<TextBlock Text="{Binding CancelStr,RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Center" Foreground="{DynamicResource DangerBrush}"/>
|
||||
</Button>
|
||||
<Button Command="interactivity:ControlCommands.Confirm" Style="{StaticResource ButtonCustom}" Width="160">
|
||||
<TextBlock Text="{x:Static langs:Lang.Confirm}" HorizontalAlignment="Center" Foreground="{DynamicResource PrimaryBrush}"/>
|
||||
<TextBlock Text="{Binding ConfirmStr,RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Center" Foreground="{DynamicResource PrimaryBrush}"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
Reference in new issue
Block a user