123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- 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>
- /// 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();
- 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;
- Width = 408;
- Grid.SetColumn(MiddleCancelBtn, 2);
- Grid.SetColumn(OkBtn, 1);
- Grid.SetColumn(ChbDonotAskAgain, 0);
- BtnGrid.ColumnDefinitions.Clear();
- var column = new ColumnDefinition();
- var column2 = new ColumnDefinition();
- var column0 = new ColumnDefinition();
- column.Width = new GridLength(1, GridUnitType.Star);
- column2.Width = new GridLength(1, GridUnitType.Star);
- column0.Width = new GridLength(2, GridUnitType.Star);
- BtnGrid.ColumnDefinitions.Add(column0);
- BtnGrid.ColumnDefinitions.Add(column);
- BtnGrid.ColumnDefinitions.Add(column2);
- 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;
- Width = 408;
- Grid.SetColumn(OkBtn, 3);
- BtnGrid.ColumnDefinitions.Clear();
- var column = new ColumnDefinition();
- var column2 = new ColumnDefinition();
- var column3 = new ColumnDefinition();
- column.Width = new GridLength(1, GridUnitType.Star);
- column2.Width = new GridLength(1, GridUnitType.Star);
- column3.Width = new GridLength(1, GridUnitType.Star);
- BtnGrid.ColumnDefinitions.Add(column);
- BtnGrid.ColumnDefinitions.Add(column2);
- BtnGrid.ColumnDefinitions.Add(column3);
- 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;
- Width = 408;
- Grid.SetColumn(MiddleCancelBtn, 1);
- Grid.SetColumn(OkBtn, 0);
- BtnGrid.ColumnDefinitions.Clear();
- var column = new ColumnDefinition();
- var column2 = new ColumnDefinition();
- column.Width = new GridLength(1, GridUnitType.Star);
- column2.Width = new GridLength(1, GridUnitType.Star);
- BtnGrid.ColumnDefinitions.Add(column);
- BtnGrid.ColumnDefinitions.Add(column2);
- 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;
- Grid.SetColumn(CancelBtn, 2);
- Grid.SetColumn(MiddleCancelBtn, 1);
- Grid.SetColumn(OkBtn, 0);
- BtnGrid.ColumnDefinitions.Clear();
- var column = new ColumnDefinition();
- var column2 = new ColumnDefinition();
- var column3 = new ColumnDefinition();
- column.Width = new GridLength(1, GridUnitType.Star);
- column2.Width = new GridLength(1, GridUnitType.Star);
- column3.Width = new GridLength(1, GridUnitType.Star);
- BtnGrid.ColumnDefinitions.Add(column);
- BtnGrid.ColumnDefinitions.Add(column2);
- BtnGrid.ColumnDefinitions.Add(column3);
- 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;
- Width = 408;
- Grid.SetColumn(OkBtn, 3);
- BtnGrid.ColumnDefinitions.Clear();
- var column = new ColumnDefinition();
- var column2 = new ColumnDefinition();
- var column3 = new ColumnDefinition();
- column.Width = new GridLength(1, GridUnitType.Star);
- column2.Width = new GridLength(1, GridUnitType.Star);
- column3.Width = new GridLength(1, GridUnitType.Star);
- BtnGrid.ColumnDefinitions.Add(column);
- BtnGrid.ColumnDefinitions.Add(column2);
- BtnGrid.ColumnDefinitions.Add(column3);
- if (ownerWindow != null)
- {
- Owner = ownerWindow;
- WindowStartupLocation = WindowStartupLocation.CenterOwner;
- ShowDialog();
- }
- }
- public void ShowDialog(string title, string content, string cancelBtn, string okBtn)
- {
- TitleText.Text = title;
- ContentText.Text = content;
- CancelBtn.Visibility = Visibility.Collapsed;
- MiddleCancelBtn.Content = cancelBtn;
- OkBtn.Content = okBtn;
- Width = 408;
- Grid.SetColumn(MiddleCancelBtn, 1);
- Grid.SetColumn(OkBtn, 0);
- BtnGrid.ColumnDefinitions.Clear();
- var column = new ColumnDefinition();
- var column2 = new ColumnDefinition();
- column.Width = new GridLength(1, GridUnitType.Star);
- column2.Width = new GridLength(1, GridUnitType.Star);
- BtnGrid.ColumnDefinitions.Add(column);
- BtnGrid.ColumnDefinitions.Add(column2);
- 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;
- Grid.SetColumn(CancelBtn, 2);
- Grid.SetColumn(MiddleCancelBtn, 1);
- Grid.SetColumn(OkBtn, 0);
- BtnGrid.ColumnDefinitions.Clear();
- var column = new ColumnDefinition();
- var column2 = new ColumnDefinition();
- var column3 = new ColumnDefinition();
- column.Width = new GridLength(1, GridUnitType.Star);
- column2.Width = new GridLength(1, GridUnitType.Star);
- column3.Width = new GridLength(1, GridUnitType.Star);
- BtnGrid.ColumnDefinitions.Add(column);
- BtnGrid.ColumnDefinitions.Add(column2);
- BtnGrid.ColumnDefinitions.Add(column3);
- if (ownerWindow != null)
- {
- Owner = ownerWindow;
- WindowStartupLocation = WindowStartupLocation.CenterOwner;
- ShowDialog();
- }
- }
- 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)
- {
- isChecked = true;
- }
- private void ChbDonotAskAgain_Unchecked(object sender, RoutedEventArgs e)
- {
- isChecked = false;
- }
- }
- }
|