You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
5.0 KiB
C#
133 lines
5.0 KiB
C#
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.Navigation;
|
|
using System.Windows.Shapes;
|
|
using Txgy.EWS.Client.Common;
|
|
using Txgy.EWS.Client.Common.Extensions;
|
|
|
|
namespace Txgy.EWS.Client.Start.Views
|
|
{
|
|
/// <summary>
|
|
/// MainWindow.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
Rect rcnormal;//定义一个全局rect记录还原状态下窗口的位置和大小。
|
|
bool windowMaximized = true;
|
|
public MainWindow(IDialogHostService dialogHostService)
|
|
{
|
|
InitializeComponent();
|
|
DialogHostService = dialogHostService;
|
|
btnMin.Click += (s, e) => { this.WindowState = WindowState.Minimized; };
|
|
//btnMax.Click += (s, e) =>
|
|
//{
|
|
// //if (this.WindowState == WindowState.Maximized)
|
|
// // this.WindowState = WindowState.Normal;
|
|
// //else
|
|
// // this.WindowState = WindowState.Maximized;
|
|
// if (windowMaximized)
|
|
// {
|
|
// this.Left = rcnormal.Left;
|
|
// this.Top = rcnormal.Top;
|
|
// this.Width = rcnormal.Width;
|
|
// this.Height = rcnormal.Height;
|
|
// windowMaximized = false;
|
|
// //this.btnMaximize.Visibility = Visibility.Visible;
|
|
// //this.btnNormal.Visibility = Visibility.Collapsed;
|
|
// }
|
|
// else
|
|
// {
|
|
// //this.btnMaximize.Visibility = Visibility.Collapsed;
|
|
// //this.btnNormal.Visibility = Visibility.Visible;
|
|
// rcnormal = new Rect(this.Left, this.Top, this.Width, this.Height);//保存下当前位置与大小
|
|
// this.Left = 0;//设置位置
|
|
// this.Top = 0;
|
|
// Rect rc = SystemParameters.WorkArea;//获取工作区大小
|
|
// this.Width = rc.Width;
|
|
// this.Height = rc.Height;
|
|
// windowMaximized = true;
|
|
// }
|
|
//};
|
|
btnClose.Click += (s, e) =>
|
|
{
|
|
if (MessageBox.Show("确认退出系统?", "提示", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
|
{
|
|
this.Close();
|
|
}
|
|
//var dialogResult = await dialogHostService.Question("温馨提示", "确认退出系统?");
|
|
//if (dialogResult.Result != Prism.Services.Dialogs.ButtonResult.OK) return;
|
|
//this.Close();
|
|
};
|
|
ColorZone.MouseMove += (s, e) =>
|
|
{
|
|
if (e.LeftButton == MouseButtonState.Pressed)
|
|
this.DragMove();
|
|
};
|
|
|
|
}
|
|
|
|
public IDialogHostService DialogHostService { get; }
|
|
|
|
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
{
|
|
if (this.ActualHeight > SystemParameters.WorkArea.Height || this.ActualWidth > SystemParameters.WorkArea.Width)
|
|
{
|
|
this.WindowState = System.Windows.WindowState.Normal;
|
|
windowMaximized = false;
|
|
btnMax_Click(null, null);
|
|
}
|
|
}
|
|
|
|
private void btnMax_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (windowMaximized)
|
|
{
|
|
this.Left = rcnormal.Left;
|
|
this.Top = rcnormal.Top;
|
|
this.Width = rcnormal.Width;
|
|
this.Height = rcnormal.Height;
|
|
windowMaximized = false;
|
|
//this.btnMaximize.Visibility = Visibility.Visible;
|
|
//this.btnNormal.Visibility = Visibility.Collapsed;
|
|
}
|
|
else
|
|
{
|
|
//this.btnMaximize.Visibility = Visibility.Collapsed;
|
|
//this.btnNormal.Visibility = Visibility.Visible;
|
|
rcnormal = new Rect(this.Left, this.Top, this.Width, this.Height);//保存下当前位置与大小
|
|
this.Left = 0;//设置位置
|
|
this.Top = 0;
|
|
Rect rc = SystemParameters.WorkArea;//获取工作区大小
|
|
this.Width = rc.Width;
|
|
this.Height = rc.Height;
|
|
windowMaximized = true;
|
|
}
|
|
}
|
|
private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
//双击标题栏改变大小
|
|
//if (e.ClickCount == 2)
|
|
//{
|
|
// if (this.ActualWidth == SystemParameters.WorkArea.Width)
|
|
// {
|
|
// btnNormal_Click(null, null);
|
|
// }
|
|
// else
|
|
// {
|
|
// btnMaximize_Click(null, null);
|
|
// }
|
|
//}
|
|
}
|
|
}
|
|
}
|