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 AIRS
{
    /// <summary>
    /// AdminWindow.xaml 的交互逻辑
    /// </summary>
    public partial class AdminWindow : Window
    {
        private Boolean mousedown = false;
        public AdminWindow()
        {
            InitializeComponent();
            //窗体变化事件和最大化
            //this.SizeChanged += new System.Windows.SizeChangedEventHandler(MainWindow_Resize);
            //this.WindowState = WindowState.Maximized;
            this.WindowState = WindowState.Normal;
            this.imgmin1.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(window_min_PreviewMouseLeftButtonDown);
            this.imgmax1.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(window_max_PreviewMouseLeftButtonDown);
            this.imgclosed1.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(window_close_PreviewMouseLeftButtonDown);

        }

        #region 窗体变化获取大小
        /// <summary>
        /// 窗体变化获取大小
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainWindow_Resize(object sender, System.EventArgs e)
        {
            //tab_num = MainWindow_Width();
            //tab_num = this.Width;
        }

        //#region 获取窗体宽度
        ///// <summary>
        ///// //获取窗体宽度
        ///// </summary>
        ///// <returns></returns>
        //private int MainWindow_Width()
        //{
        //    int width = 0;
        //    width = (int)(this.cantab.Width - (157 + 57)) / 142;
        //    //Console.WriteLine("窗体宽" + this.cantab.Width + " " + width.ToString());
        //    return width;
        //    //int width = 0;
        //    //width = (int)(this.Width - (157 + 57)) / 142;
        //    //Console.WriteLine("窗体宽"+ this.Width+" "+width.ToString());
        //    //return width;
        //}
        //#endregion

        //选项卡宽度，本机为选项卡宽为142，任务标签共计157，窗体1350,142*8=1136,1350-1136=214,214-157=57，
        //选项卡宽为(1350-157-57)/142
        //private int tab_num = 0;//tab_num = 8;
        #endregion
        /// <summary>
        /// 窗体启动时
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //隐藏pagetitle控件
            //this.pagetitle.task.Visibility = Visibility.Hidden;
            //this.pagetitle.start_grade.Visibility = Visibility.Hidden;
            //this.pagetitle.field.Visibility = Visibility.Hidden;
            //this.pagetitle.canfill.Visibility = Visibility.Hidden;
            //this.pagetitle.history.Visibility = Visibility.Hidden;
            //this.pagetitle.out_export.Visibility = Visibility.Hidden;

        }

        /// <summary>
        /// 窗口移动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                this.DragMove();
            }
        }

        /// <summary>
        /// 窗体加载完成后执行事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_ContentRendered(object sender, EventArgs e)
        {
            //MessageBox.Show(this.pagetitle.imgmax1.Visibility.ToString());
            //this.pagetitle.imgmax.Visibility = Visibility.Hidden;
            //this.pagetitle.imgclosed.Visibility = Visibility.Hidden;
            //this.pagetitle.imgmin.Visibility = Visibility.Hidden;
        }

        private void Window_Drop(object sender, DragEventArgs e)
        {

        }
        #region 抬起Ctrl键后允许滚轮操作
        /// <summary>
        /// 抬起Ctrl键后允许滚轮操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_PreviewKeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl)
            {
                mousedown = false;
                //svshowimg.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            }
        }
        #endregion

        private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
        {

            if (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl)
            {
                mousedown = true;
            }
        }


        #region 窗体最小化
        /// <summary>
        /// 最小化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void window_min_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }
        #endregion

        #region 窗体最大化
        /// <summary>
        /// 最大化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void window_max_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (this.WindowState == WindowState.Maximized)
            {
                this.WindowState = WindowState.Normal;
            }
            else
            {
                this.WindowState = WindowState.Maximized;
            }
        }
        #endregion

        #region 关闭窗体
        /// <summary>
        /// 关闭窗体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void window_close_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
                Application.Current.Shutdown();
        }
        #endregion
    }
}
