HintDialog.xaml.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Shapes;
  14. namespace AwInitilizer
  15. {
  16. /// <summary>
  17. /// Interaction logic for HintDialog.xaml
  18. /// </summary>
  19. public partial class HintDialog : Window
  20. {
  21. public string Message
  22. {
  23. get => (string) uxConentText.Content;
  24. set => uxConentText.Content = value;
  25. }
  26. public string BtnText
  27. {
  28. get => (string)uxBtnText.Content;
  29. set => uxBtnText.Content = value;
  30. }
  31. public string Caption
  32. {
  33. get => (string)uxTitle.Content;
  34. set => uxTitle.Content = value;
  35. }
  36. private string _ImgPath;
  37. public string ImgPath
  38. {
  39. get => _ImgPath;
  40. set
  41. {
  42. if(_ImgPath!=value)
  43. {
  44. _ImgPath = value;
  45. if(string.IsNullOrEmpty(_ImgPath))
  46. {
  47. uxImage.Visibility = Visibility.Collapsed;
  48. }
  49. else
  50. {
  51. uxImage.Visibility = Visibility.Visible;
  52. uxImage.Source = new BitmapImage(new Uri(_ImgPath)) { };
  53. }
  54. }
  55. }
  56. }
  57. public bool IsCancelAble
  58. {
  59. get => uxCancelContainer.Visibility == Visibility.Visible;
  60. set
  61. {
  62. uxCancelContainer.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
  63. }
  64. }
  65. public HintDialog()
  66. {
  67. InitializeComponent();
  68. }
  69. private void Button_Click(object sender, RoutedEventArgs e)
  70. {
  71. this.Close();
  72. }
  73. private static ImageSource GetBitMap(string imgpath)
  74. {
  75. try
  76. {
  77. BitmapImage bitmapImg = new BitmapImage();
  78. bitmapImg.BeginInit();
  79. bitmapImg.UriSource = new Uri(imgpath, UriKind.RelativeOrAbsolute);
  80. bitmapImg.CreateOptions = BitmapCreateOptions.IgnoreColorProfile | BitmapCreateOptions.IgnoreImageCache;
  81. bitmapImg.CacheOption = BitmapCacheOption.OnLoad;
  82. bitmapImg.EndInit();
  83. bitmapImg.Freeze();
  84. return bitmapImg;
  85. }
  86. catch (Exception e)
  87. {
  88. Console.WriteLine(e.Message);
  89. return null;
  90. }
  91. }
  92. }
  93. }