diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj index 2cc9110e..931bb4fa 100644 --- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj +++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj @@ -292,6 +292,7 @@ + diff --git a/BPASmartClient.CustomResource/Converters/ToastIconConverter.cs b/BPASmartClient.CustomResource/Converters/ToastIconConverter.cs new file mode 100644 index 00000000..53a665ab --- /dev/null +++ b/BPASmartClient.CustomResource/Converters/ToastIconConverter.cs @@ -0,0 +1,76 @@ +using BPASmartClient.CustomResource.UserControls.Enum; +using MahApps.Metro.IconPacks; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; + +namespace BPASmartClient.CustomResource.Converters +{ + public class ToastIconConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + object value = values[0]; + object grid = values[1]; + object txt = values[2]; + Grid _grid = grid as Grid; + TextBlock _txt = txt as TextBlock; + + void WithoutIcon() + { + if (_grid != null) + { + _grid.ColumnDefinitions.RemoveAt(0); + } + + if (_txt != null) + { + _txt.HorizontalAlignment = HorizontalAlignment.Center; + } + } + + if (value == null) + { + WithoutIcon(); + return PackIconFontAwesomeKind.None; + } + + ToastIcons _value; + try + { + _value = (ToastIcons)value; + } + catch + { + WithoutIcon(); + return PackIconFontAwesomeKind.None; + } + + switch (_value) + { + case ToastIcons.Information: + return PackIconFontAwesomeKind.CheckCircleSolid; + case ToastIcons.Error: + return PackIconFontAwesomeKind.TimesSolid; + case ToastIcons.Warning: + return PackIconFontAwesomeKind.ExclamationSolid; + case ToastIcons.Busy: + return PackIconFontAwesomeKind.ClockSolid; + } + + WithoutIcon(); + return PackIconFontAwesomeKind.None; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/BPASmartClient.CustomResource/Fonts/iconfont.ttf b/BPASmartClient.CustomResource/Fonts/iconfont.ttf index cfd9141e..9dabe193 100644 Binary files a/BPASmartClient.CustomResource/Fonts/iconfont.ttf and b/BPASmartClient.CustomResource/Fonts/iconfont.ttf differ diff --git a/BPASmartClient.CustomResource/Pages/Model/TextToImage.cs b/BPASmartClient.CustomResource/Pages/Model/TextToImage.cs new file mode 100644 index 00000000..8a68c256 --- /dev/null +++ b/BPASmartClient.CustomResource/Pages/Model/TextToImage.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.CustomResource.Pages.Model +{ + internal class TextToImage + { + public Image CreateTextImage(string text, Font font, Color backgroundColor, Color foreColor, int margin = 5, RotateFlipType rotate = RotateFlipType.RotateNoneFlipNone) + { + SizeF sizeF = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(text, font); + Bitmap bitmap = new Bitmap((int)sizeF.Width + margin * 2, (int)sizeF.Height + margin * 2); + Graphics g = Graphics.FromImage(bitmap); + g = Graphics.FromImage(bitmap); + g.SmoothingMode = SmoothingMode.HighQuality; + g.FillRegion(new SolidBrush(backgroundColor), g.Clip); + g.DrawString(text, font, new SolidBrush(foreColor), margin, margin); + g.Dispose(); + bitmap.RotateFlip(rotate); + return bitmap; + } + } +} diff --git a/BPASmartClient.CustomResource/Pages/View/LoginView.xaml.cs b/BPASmartClient.CustomResource/Pages/View/LoginView.xaml.cs index 7e6147e7..e98b6cf0 100644 --- a/BPASmartClient.CustomResource/Pages/View/LoginView.xaml.cs +++ b/BPASmartClient.CustomResource/Pages/View/LoginView.xaml.cs @@ -27,7 +27,7 @@ namespace BPASmartClient.CustomResource.Pages.View { InitializeComponent(); grid.Visibility = Visibility.Collapsed; - Username.Focus(); + Username.SelectionStart = Username.Text.Trim().Length; this.Loaded += LoginView_Loaded; ActionManage.GetInstance.Register(new Action(() => { this.DialogResult = true; this.Close(); }), "LoginOk", true); @@ -52,6 +52,7 @@ namespace BPASmartClient.CustomResource.Pages.View private void Player_MediaOpened(object sender, RoutedEventArgs e) { grid.Visibility = Visibility.Visible; + Username.Focus(); } private void media_Loaded(object sender, RoutedEventArgs e) diff --git a/BPASmartClient.CustomResource/Pages/View/MainView.xaml.cs b/BPASmartClient.CustomResource/Pages/View/MainView.xaml.cs index f47c3783..3e516b5e 100644 --- a/BPASmartClient.CustomResource/Pages/View/MainView.xaml.cs +++ b/BPASmartClient.CustomResource/Pages/View/MainView.xaml.cs @@ -39,5 +39,6 @@ namespace BPASmartClient.CustomResource.Pages.View if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; } + } } diff --git a/BPASmartClient.CustomResource/Themes/Generic.xaml b/BPASmartClient.CustomResource/Themes/Generic.xaml index 4bbc2757..edf01d18 100644 --- a/BPASmartClient.CustomResource/Themes/Generic.xaml +++ b/BPASmartClient.CustomResource/Themes/Generic.xaml @@ -8,7 +8,7 @@ - + - + @@ -184,10 +184,10 @@ - + - + - + - + - + - - + + - + - - - - -