123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- 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 PDF_Master.CustomControl
- {
- public enum ContentResult
- {
- Cancel,
- MiddleCancel,
- Ok
- }
- /// <summary>
- /// 图标类型
- /// </summary>
- public enum IconType
- {
- Tip,
- Ask,
- Error,
- None
- }
- /// <summary>
- /// AlertsMessage.xaml 的交互逻辑
- /// 因为是纯UI的逻辑显示,所以没有再创建VM
- /// </summary>
- public partial class AlertsMessage : Window
- {
- public ContentResult result = ContentResult.Cancel;
- public bool isChecked = false;
- private Window ownerWindow;
- public AlertsMessage()
- {
- InitializeComponent();
- if (App.Current.MainWindow != this)
- {
- ownerWindow = App.Current.MainWindow;
- }
- }
- public void ShowAskAgainCheck()
- {
- ChbDonotAskAgain.Visibility = Visibility.Visible;
- }
- /// <summary>
- /// 两个按钮弹窗
- /// </summary>
- public void HaveCheckBoxShow(string title, string content,string contentCheckBox, string cancelBtn, string okBtn)
- {
- TitleText.Text = title;
- ContentText.Text = content;
- CancelBtn.Visibility = Visibility.Collapsed;
- MiddleCancelBtn.Content = cancelBtn;
- OkBtn.Content = okBtn;
- ChbDonotAskAgain.Content = contentCheckBox;
- ChbDonotAskAgain.Visibility = Visibility.Visible;
- if (ownerWindow != null)
- {
- this.Owner = ownerWindow;
- ShowDialog();
- }
- }
- /// <summary>
- /// 一个按钮弹窗
- /// </summary>
- public void Show(string title, string content,string okBtn)
- {
- TitleText.Text = title;
- ContentText.Text = content;
- CancelBtn.Visibility = Visibility.Collapsed;
- MiddleCancelBtn.Visibility = Visibility.Collapsed;
- OkBtn.Content = okBtn;
- this.Show();
- }
- /// <summary>
- /// 两个按钮弹窗
- /// </summary>
- public void Show(string title,string content,string cancelBtn,string okBtn)
- {
- TitleText.Text = title;
- ContentText.Text = content;
- CancelBtn.Visibility = Visibility.Collapsed;
- MiddleCancelBtn.Content = cancelBtn;
- OkBtn.Content = okBtn;
- this.Show();
- }
- /// <summary>
- /// 三个按钮弹窗
- /// </summary>
- public void Show(string title, string content, string cancelBtn1, string cancelBtn2, string okBtn)
- {
- TitleText.Text = title;
- ContentText.Text = content;
- CancelBtn.Visibility = Visibility.Visible;
- CancelBtn.Content = cancelBtn1;
- MiddleCancelBtn.Content = cancelBtn2;
- OkBtn.Content = okBtn;
- this.Show();
- }
- public void ShowDialog(string title, string content, string okBtn)
- {
- TitleText.Text = title;
- ContentText.Text = content;
- CancelBtn.Visibility = Visibility.Collapsed;
- MiddleCancelBtn.Visibility = Visibility.Collapsed;
- OkBtn.Content = okBtn;
- if (ownerWindow != null)
- {
- Owner = ownerWindow;
- WindowStartupLocation = WindowStartupLocation.CenterOwner;
- ShowDialog();
- }
- }
- public void ShowDialog(string title, string content, string cancelBtn, string okBtn,IconType type = IconType.None)
- {
-
- TitleText.Text = title;
- ContentText.Text = content;
- CancelBtn.Visibility = Visibility.Collapsed;
- MiddleCancelBtn.Content = cancelBtn;
- OkBtn.Content = okBtn;
- ShowIcon(type);
- if (ownerWindow != null)
- {
- Owner = ownerWindow;
- WindowStartupLocation = WindowStartupLocation.CenterOwner;
- ShowDialog();
- }
- }
- public void ShowDialog(string title, string content, string okBtn, IconType type = IconType.None)
- {
- TitleText.Text = title;
- ContentText.Text = content;
- CancelBtn.Visibility = Visibility.Collapsed;
- MiddleCancelBtn.Visibility = Visibility.Collapsed;
- OkBtn.Content = okBtn;
- ShowIcon(type);
- if (ownerWindow != null)
- {
- Owner = ownerWindow;
- WindowStartupLocation = WindowStartupLocation.CenterOwner;
- ShowDialog();
- }
- }
- public void ShowDialog(string title, string content, string cancelBtn1, string cancelBtn2, string okBtn)
- {
- TitleText.Text = title;
- ContentText.Text = content;
- CancelBtn.Visibility = Visibility.Visible;
- CancelBtn.Content = cancelBtn1;
- MiddleCancelBtn.Content = cancelBtn2;
- OkBtn.Content = okBtn;
- if (ownerWindow != null)
- {
- Owner = ownerWindow;
- WindowStartupLocation = WindowStartupLocation.CenterOwner;
- ShowDialog();
- }
- }
- private void ShowIcon(IconType type)
- {
- //先隐藏所有图标
- ImgTips.Visibility = Visibility.Collapsed;
- switch (type)
- {
- case IconType.Tip:
- GridIcon.Visibility = Visibility.Visible;
- ImgTips.Visibility = Visibility.Visible;
- break;
- case IconType.Ask:
- break;
- case IconType.Error:
- break;
- case IconType.None:
- default:
- GridIcon.Visibility = Visibility.Collapsed;
- break;
- }
- }
- private void CancelBtn_Click(object sender, RoutedEventArgs e)
- {
- result = ContentResult.Cancel;
- Close();
- }
- private void MiddleCancelBtn_Click(object sender, RoutedEventArgs e)
- {
- result = ContentResult.MiddleCancel;
- Close();
- }
- private void OkBtn_Click(object sender, RoutedEventArgs e)
- {
- result = ContentResult.Ok;
- Close();
- }
- private void Border_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- this.DragMove();
- }
- private void ChbDonotAskAgain_Checked(object sender, RoutedEventArgs e)
- {
- if (IsLoaded)
- {
- isChecked = true;
- }
- }
- private void ChbDonotAskAgain_Unchecked(object sender, RoutedEventArgs e)
- {
- if (IsLoaded)
- {
- isChecked = false;
- }
- }
- }
- }
|