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
    }

    /// <summary>
    /// AlertsMessage.xaml 的交互逻辑
    /// 因为是纯UI的逻辑显示，所以没有再创建VM
    /// </summary>
    public partial class AlertsMessage : Window
    {
        public ContentResult result = ContentResult.Cancel;

        private Window ownerWindow;
        public AlertsMessage()
        {
            InitializeComponent();

            ownerWindow = App.Current.MainWindow;
        }

        /// <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, 0);
            Grid.SetColumn(OkBtn, 1);

            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, 0);
            Grid.SetColumn(MiddleCancelBtn, 1);
            Grid.SetColumn(OkBtn, 2);

            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, 0);
            Grid.SetColumn(OkBtn, 1);

            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, 0);
            Grid.SetColumn(MiddleCancelBtn, 1);
            Grid.SetColumn(OkBtn, 2);

            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();
        }
    }
}
