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_Office.CustomControl { public enum ContentResult { Cancel, MiddleCancel, Ok } /// /// AlertsMessage.xaml 的交互逻辑 /// 因为是纯UI的逻辑显示,所以没有再创建VM /// 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; } /// /// 两个按钮弹窗 /// 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(); } } /// /// 一个按钮弹窗 /// 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(); } /// /// 两个按钮弹窗 /// 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(); } /// /// 三个按钮弹窗 /// 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; } } }