123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace AwInitilizer
- {
- /// <summary>
- /// Interaction logic for HintDialog.xaml
- /// </summary>
- public partial class HintDialog : Window
- {
- public static void ShowMessage(string msg)
- {
- var confirmString = Resx.AppResources.Confirm;
- var dialog = new HintDialog() { Title = "",Message = msg,BtnText= confirmString };
- try
- {
- dialog.Owner = Application.Current.MainWindow;
- }
- catch
- {
- }
- dialog.ShowDialog();
- }
- public string Message
- {
- get => (string) uxConentText.Text;
- set => uxConentText.Text = value;
- }
- public string BtnText
- {
- get => (string)uxBtnText.Content;
- set => uxBtnText.Content = value;
- }
- public string Caption
- {
- get => (string)uxTitle.Content;
- set => uxTitle.Content = value;
- }
- private string _ImgPath;
- public string ImgPath
- {
- get => _ImgPath;
- set
- {
- if(_ImgPath!=value)
- {
- _ImgPath = value;
- if(string.IsNullOrEmpty(_ImgPath))
- {
- uxImage.Visibility = Visibility.Collapsed;
- }
- else
- {
- uxImage.Visibility = Visibility.Visible;
- uxImage.Source = new BitmapImage(new Uri(_ImgPath)) { };
- }
- }
- }
- }
- public bool IsCancelAble
- {
- get => uxCancelContainer.Visibility == Visibility.Visible;
- set
- {
- uxCancelContainer.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
- }
- }
- public HintDialog()
- {
- InitializeComponent();
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- this.Close();
- }
- private static ImageSource GetBitMap(string imgpath)
- {
- try
- {
- BitmapImage bitmapImg = new BitmapImage();
- bitmapImg.BeginInit();
- bitmapImg.UriSource = new Uri(imgpath, UriKind.RelativeOrAbsolute);
- bitmapImg.CreateOptions = BitmapCreateOptions.IgnoreColorProfile | BitmapCreateOptions.IgnoreImageCache;
- bitmapImg.CacheOption = BitmapCacheOption.OnLoad;
- bitmapImg.EndInit();
- bitmapImg.Freeze();
- return bitmapImg;
- }
- catch (Exception e)
- {
- Console.WriteLine(e.Message);
- return null;
- }
- }
- }
- }
|