You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
688 lines
28 KiB
688 lines
28 KiB
using GummingBusiness;
|
|
using GummingCommon;
|
|
using GummingControl;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading;
|
|
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.Interop;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
using System.Windows.Controls.Primitives;
|
|
|
|
namespace Gumming
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for MainWindow.xaml
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
#region Window Initialization
|
|
public MainWindow()
|
|
{
|
|
this.StateChanged += MainWindow_StateChanged;
|
|
this.Loaded += MainWindow_Loaded;
|
|
this.WindowStyle = WindowStyle.None;
|
|
this.MinHeight = 600;
|
|
this.MinWidth = 800;
|
|
|
|
this.BorderThickness = new Thickness(0);
|
|
this.AllowsTransparency = true;
|
|
UpdateMaxHeightAndWidth();
|
|
InitializeComponent();
|
|
//ScreenControl.ChangeScreenRangeBehavior(this);
|
|
this.MouseDown += new MouseButtonEventHandler(Window_MouseDown);
|
|
this.MouseMove += new MouseEventHandler(Window_MouseMove);
|
|
//this.MouseDoubleClick += new MouseButtonEventHandler(Window_DoubleClick);
|
|
|
|
//删除日志
|
|
Thread tr = new Thread(new ThreadStart((Action)(() =>
|
|
{
|
|
try
|
|
{
|
|
var now = DateTime.Now;
|
|
foreach (var f in Directory.GetFileSystemEntries(FilesDirectory.SystemLogPath).Where(f => File.Exists(f)))
|
|
{
|
|
var t = File.GetCreationTime(f);
|
|
var elapsedTicks = now.Ticks - t.Ticks;
|
|
var elaspsedSpan = new TimeSpan(elapsedTicks);
|
|
if (elaspsedSpan.TotalDays > 2)
|
|
{
|
|
File.Delete(f);
|
|
}
|
|
}
|
|
//clear backup db
|
|
foreach (var f in Directory.GetFileSystemEntries(FilesDirectory.DbBackupPath).Where(f => File.Exists(f)))
|
|
{
|
|
var t = File.GetCreationTime(f);
|
|
var elapsedTicks = now.Ticks - t.Ticks;
|
|
var elaspsedSpan = new TimeSpan(elapsedTicks);
|
|
if (elaspsedSpan.TotalDays > 10)
|
|
{
|
|
File.Delete(f);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Global.WriteErrorLog(ex);
|
|
}
|
|
})));
|
|
tr.IsBackground = true;
|
|
tr.Start();
|
|
|
|
Helpering.IsRestart = false;
|
|
Style = (Style)FindResource(typeof(Window));
|
|
if (!SystemInfoService.Instance().Systems.IsRelease)
|
|
{
|
|
this.WindowState = System.Windows.WindowState.Maximized;
|
|
this.ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip;
|
|
//this.Height = 768;
|
|
//this.Width = 1366;
|
|
}
|
|
else
|
|
{
|
|
//Taskbar.Hide();
|
|
this.WindowState = WindowState.Maximized;
|
|
this.ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip;
|
|
}
|
|
this.SourceInitialized += new EventHandler(MainWindow_SourceInitialized);
|
|
ComponentDispatcher.ThreadPreprocessMessage += (ref MSG m, ref bool handled) =>
|
|
{
|
|
if (m.message == 0x100)//WM_KEYDOWN
|
|
{
|
|
System.Windows.Forms.Keys keyData = ((System.Windows.Forms.Keys)((int)(m.wParam))) | System.Windows.Forms.Control.ModifierKeys;
|
|
if (keyData == System.Windows.Forms.Keys.Left)//((int)m.wParam == 37)//VK_LEFT
|
|
{
|
|
AppEventAggregator.GetEventAggregator().GetEvent<KeyChangedEvent>().Publish(new KeyEventParameter
|
|
{ KeyType = KeyType.VK_LEFT, KeyContent = m.lParam, FromType = FromType.System });
|
|
}
|
|
else if (keyData == System.Windows.Forms.Keys.Up)//((int)m.wParam == 38)//VK_UP
|
|
{
|
|
AppEventAggregator.GetEventAggregator().GetEvent<KeyChangedEvent>().Publish(new KeyEventParameter()
|
|
{ KeyType = KeyType.VK_UP, KeyContent = m.lParam, FromType = FromType.System });
|
|
}
|
|
else if (keyData == System.Windows.Forms.Keys.Right)//((int)m.wParam == 39)//VK_RIGHT
|
|
{
|
|
AppEventAggregator.GetEventAggregator().GetEvent<KeyChangedEvent>().Publish(new KeyEventParameter()
|
|
{ KeyType = KeyType.VK_RIGHT, KeyContent = m.lParam, FromType = FromType.System });
|
|
}
|
|
else if (keyData == System.Windows.Forms.Keys.Down)//((int)m.wParam == 40) //VK_DOWN
|
|
{
|
|
AppEventAggregator.GetEventAggregator().GetEvent<KeyChangedEvent>().Publish(new KeyEventParameter()
|
|
{ KeyType = KeyType.VK_DOWN, KeyContent = m.lParam, FromType = FromType.System });
|
|
}
|
|
else if (keyData == System.Windows.Forms.Keys.NumPad0 ||
|
|
keyData == System.Windows.Forms.Keys.NumPad1 ||
|
|
keyData == System.Windows.Forms.Keys.NumPad3 ||
|
|
keyData == System.Windows.Forms.Keys.NumPad5 ||
|
|
keyData == System.Windows.Forms.Keys.NumPad7 ||
|
|
keyData == System.Windows.Forms.Keys.NumPad9 ||
|
|
keyData == System.Windows.Forms.Keys.Multiply ||
|
|
keyData == System.Windows.Forms.Keys.Add ||
|
|
keyData == System.Windows.Forms.Keys.Subtract ||
|
|
keyData.Equals(System.Windows.Forms.Keys.A | System.Windows.Forms.Keys.Control) ||
|
|
keyData.Equals(System.Windows.Forms.Keys.D | System.Windows.Forms.Keys.Control) ||
|
|
keyData.Equals(System.Windows.Forms.Keys.J | System.Windows.Forms.Keys.Control) ||
|
|
keyData.Equals(System.Windows.Forms.Keys.P | System.Windows.Forms.Keys.Control) ||
|
|
keyData.Equals(System.Windows.Forms.Keys.O | System.Windows.Forms.Keys.Control) ||
|
|
keyData.Equals(System.Windows.Forms.Keys.X | System.Windows.Forms.Keys.Control))
|
|
{
|
|
|
|
}
|
|
}
|
|
else if (m.message == 0x101)//WM_KEYUP
|
|
{
|
|
if ((int)m.wParam == 37)//VK_LEFT
|
|
{
|
|
AppEventAggregator.GetEventAggregator().GetEvent<KeyChangedEvent>().Publish(new KeyEventParameter
|
|
{ KeyType = KeyType.VK_LEFTUP, KeyContent = m.lParam });
|
|
}
|
|
else if ((int)m.wParam == 38)//VK_UP
|
|
{
|
|
AppEventAggregator.GetEventAggregator().GetEvent<KeyChangedEvent>().Publish(new KeyEventParameter()
|
|
{ KeyType = KeyType.VK_UPUP, KeyContent = m.lParam });
|
|
}
|
|
else if ((int)m.wParam == 39)//VK_RIGHT
|
|
{
|
|
AppEventAggregator.GetEventAggregator().GetEvent<KeyChangedEvent>().Publish(new KeyEventParameter()
|
|
{ KeyType = KeyType.VK_RIGHTUP, KeyContent = m.lParam });
|
|
}
|
|
else if ((int)m.wParam == 40) //VK_DOWN
|
|
{
|
|
AppEventAggregator.GetEventAggregator().GetEvent<KeyChangedEvent>().Publish(new KeyEventParameter()
|
|
{ KeyType = KeyType.VK_DOWNUP, KeyContent = m.lParam });
|
|
}
|
|
}
|
|
else if (m.message == 0x202 || m.message == 0x205)//WM_LBUTTONUP , WM_RBUTTONUP
|
|
{
|
|
|
|
}
|
|
};
|
|
|
|
//LoadDog();
|
|
}
|
|
|
|
private void LoadDog()
|
|
{
|
|
//加密狗检测
|
|
if (Global.IsRelease)
|
|
{
|
|
IniFile ini = new IniFile(FilesDirectory.MyTrace);
|
|
string loadcountStr = ini.Read("Application", "OpenCount");
|
|
int loadcount = -1;
|
|
if (!string.IsNullOrWhiteSpace(loadcountStr))
|
|
{
|
|
loadcountStr = Encryption.Decrypt(loadcountStr);
|
|
loadcount = Convert.ToInt32(loadcountStr) + 1;
|
|
ini.Write("Application", "OpenCount", Encryption.Encrypt(Convert.ToString(loadcount)));
|
|
}
|
|
|
|
Thread tr = new Thread(new ThreadStart((Action)(() =>
|
|
{
|
|
while (PatternControlViewModule.keepRunning)
|
|
{
|
|
try
|
|
{
|
|
bool isBlock = false;
|
|
bool isLimit = false;
|
|
if (string.IsNullOrWhiteSpace(SystemInfoService.Instance().Systems.SystemSign))
|
|
{
|
|
isBlock = true;
|
|
isLimit = true;
|
|
}
|
|
else
|
|
{
|
|
string password = Encryption.Decrypt(SystemInfoService.Instance().Systems.SystemSign);
|
|
string[] passwords = password.Split(';');
|
|
if (passwords.Length != 4)
|
|
{
|
|
isBlock = true;
|
|
}
|
|
else
|
|
{
|
|
//*
|
|
if (DogRead.Read(passwords[1], passwords[2]) != SystemInfoService.Instance().Systems.SystemSign)
|
|
{
|
|
isBlock = true;
|
|
Application.Current.Dispatcher.Invoke((Action)(() =>
|
|
{
|
|
GetCurrentMv().ShowMessageBox("加密狗信息不匹配或加密狗不在线,请联系厂商解决!");
|
|
}));
|
|
}//*/
|
|
else
|
|
{
|
|
if (string.IsNullOrWhiteSpace(SystemInfoService.Instance().Systems.CurrentSign))
|
|
{
|
|
isLimit = true;
|
|
Application.Current.Dispatcher.Invoke((Action)(() =>
|
|
{
|
|
GetCurrentMv().ShowMessageBox("系统初次使用,需要提供试用密码!");
|
|
}));
|
|
}
|
|
else
|
|
{
|
|
string[] pass2 = passwords[3].Split(',');
|
|
bool existItem = false;
|
|
foreach (var pass in pass2)
|
|
{
|
|
//index|num|date|pass
|
|
string[] pass3 = pass.Split('|');
|
|
if (pass3[3].Equals(SystemInfoService.Instance().Systems.CurrentSign))
|
|
{
|
|
existItem = true;
|
|
if (loadcount > Convert.ToInt32(pass3[1]))
|
|
{
|
|
isLimit = true;
|
|
Application.Current.Dispatcher.Invoke((Action)(() =>
|
|
{
|
|
GetCurrentMv().ShowMessageBox("系统使用次数已超过预设限制,请联系厂商提供正式版本密码!");
|
|
}));
|
|
}
|
|
if (Convert.ToDateTime(pass3[2]) < System.DateTime.Now)
|
|
{
|
|
isLimit = true;
|
|
Application.Current.Dispatcher.Invoke((Action)(() =>
|
|
{
|
|
GetCurrentMv().ShowMessageBox("系统默认试用时间已超过预设限制,请联系厂商提供正式版本密码!");
|
|
}));
|
|
}
|
|
}
|
|
}
|
|
if (!existItem)
|
|
{
|
|
isLimit = true;
|
|
Application.Current.Dispatcher.Invoke((Action)(() =>
|
|
{
|
|
GetCurrentMv().ShowMessageBox("未能正确匹配厂家提供密码,请联系厂商提供正式版本密码!");
|
|
}));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (isBlock)
|
|
{
|
|
this.Dispatcher.Invoke((Action)(() =>
|
|
{
|
|
InputViewModule ivm = new InputViewModule();
|
|
ivm.InputTitle = "系统初次试用,需要拷贝加密锁信息到下面输入框后再进行确认保存!";
|
|
ivm.ShowDialog();
|
|
if (ivm.IsConfirm)
|
|
{
|
|
SystemInfoService.Instance().Systems.SystemSign = ivm.InputText;
|
|
SystemInfoService.Instance().Save();
|
|
|
|
//设置起始参数
|
|
if (!System.IO.File.Exists(FilesDirectory.MyTrace))
|
|
{
|
|
ini.Write("Application", "OpenCount", Encryption.Encrypt("1"));
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
|
|
if (isLimit)
|
|
{
|
|
this.Dispatcher.Invoke((Action)(() =>
|
|
{
|
|
InputViewModule ivm = new InputViewModule();
|
|
ivm.InputTitle = "请输入厂家提供解密码后进行确认保存!";
|
|
ivm.ShowDialog();
|
|
if (ivm.IsConfirm)
|
|
{
|
|
SystemInfoService.Instance().Systems.CurrentSign = ivm.InputText;
|
|
SystemInfoService.Instance().Save();
|
|
|
|
//设置起始参数
|
|
if (!System.IO.File.Exists(FilesDirectory.MyTrace))
|
|
{
|
|
ini.Write("Application", "OpenCount", Encryption.Encrypt("1"));
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
|
|
//默认值
|
|
loadcountStr = ini.Read("Application", "OpenCount");
|
|
if (string.IsNullOrWhiteSpace(loadcountStr))
|
|
{
|
|
ini.Write("Application", "OpenCount", Encryption.Encrypt("1"));
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
this.Dispatcher.Invoke((Action)(() =>
|
|
{
|
|
InputViewModule ivm = new InputViewModule();
|
|
ivm.InputTitle = "系统初次试用,需要拷贝加密锁信息到下面输入框后再进行确认保存!";
|
|
ivm.ShowDialog();
|
|
if (ivm.IsConfirm)
|
|
{
|
|
SystemInfoService.Instance().Systems.SystemSign = ivm.InputText;
|
|
SystemInfoService.Instance().Save();
|
|
|
|
//设置起始参数
|
|
if (!System.IO.File.Exists(FilesDirectory.MyTrace))
|
|
{
|
|
ini.Write("Application", "OpenCount", Encryption.Encrypt("1"));
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
|
|
Thread.Sleep(120000);
|
|
}
|
|
})));
|
|
tr.IsBackground = true;
|
|
tr.Start();
|
|
}
|
|
}
|
|
|
|
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
protected override void OnClosed(EventArgs e)
|
|
{
|
|
base.OnClosed(e);
|
|
}
|
|
void MainWindow_SourceInitialized(object sender, EventArgs e)
|
|
{
|
|
IntPtr hwnd = new WindowInteropHelper(this).Handle;
|
|
HwndSource.FromHwnd(hwnd).AddHook(new HwndSourceHook(WndProc));
|
|
}
|
|
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
|
{
|
|
//txtTitle.Text = string.Format("{0}{1}{2}{3}", msg, wParam, lParam, handled);
|
|
if (msg == 0x0112)//WM_SYSCOMMAND
|
|
{
|
|
if ((int)wParam == 0xF030)//SC_MAXIMIZE
|
|
{
|
|
this.ResizeMode = ResizeMode.NoResize;
|
|
this.WindowStyle = WindowStyle.None;
|
|
this.WindowState = WindowState.Maximized;
|
|
}
|
|
}
|
|
|
|
return IntPtr.Zero;
|
|
}
|
|
|
|
|
|
private void Headerborder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (e.ClickCount == 2)
|
|
{
|
|
Style normalStyle, maxStyle;
|
|
try
|
|
{
|
|
normalStyle = (Style)FindResource("btnNormStyle");
|
|
maxStyle = (Style)FindResource("btnMaxStyle");
|
|
|
|
if (normalStyle == null || maxStyle == null)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
return;
|
|
}
|
|
|
|
UpdateMaxHeightAndWidth();
|
|
|
|
if (this.WindowState == WindowState.Maximized)
|
|
{
|
|
//Taskbar.Show();
|
|
//btWindowMax.Style = normalStyle;
|
|
WindowState = WindowState.Normal;
|
|
}
|
|
else
|
|
{
|
|
//Taskbar.Hide();
|
|
//btWindowMax.Style = maxStyle;
|
|
this.WindowState = WindowState.Maximized;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void OnActivated(EventArgs e)
|
|
{
|
|
base.OnActivated(e);
|
|
|
|
Helpering.ShowActivedDialog();
|
|
}
|
|
|
|
MainWindowViewModule _vm = null;
|
|
private MainWindowViewModule GetCurrentMv()
|
|
{
|
|
if (null == _vm)
|
|
{
|
|
_vm = this.DataContext as MainWindowViewModule;
|
|
}
|
|
return _vm;
|
|
}
|
|
|
|
private void MainWindow_StateChanged(object sender, EventArgs e)
|
|
{
|
|
if (WindowState == System.Windows.WindowState.Minimized)
|
|
{
|
|
this.Opacity = 0;
|
|
//TopLogo.Visibility = System.Windows.Visibility.Hidden;
|
|
}
|
|
else
|
|
{
|
|
this.Opacity = 0;
|
|
//TopLogo.Visibility = System.Windows.Visibility.Hidden;
|
|
Thread tr = new Thread(new ThreadStart((Action)(() =>
|
|
{
|
|
Thread.Sleep(100);
|
|
this.Dispatcher.Invoke((Action)(() =>
|
|
{
|
|
this.Opacity = 1;
|
|
//TopLogo.Visibility = System.Windows.Visibility.Visible;
|
|
}));
|
|
})));
|
|
tr.IsBackground = true;
|
|
tr.Start();
|
|
}
|
|
}
|
|
|
|
private void UpdateMaxHeightAndWidth()
|
|
{
|
|
//If primary monitor, then set to max width and max height to primary screen size to prevent it from hiding the task bar
|
|
if (System.Windows.Forms.Screen.FromPoint(System.Windows.Forms.Cursor.Position).Primary)
|
|
{
|
|
this.MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
|
|
this.MaxWidth = SystemParameters.MaximizedPrimaryScreenWidth;
|
|
}
|
|
else
|
|
{
|
|
this.MaxWidth = double.PositiveInfinity;
|
|
this.MaxHeight = double.PositiveInfinity;
|
|
}
|
|
}
|
|
|
|
private void Window_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
{
|
|
ScreenZoom.SetMouseState(this, true, e);
|
|
}
|
|
|
|
private void Window_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
|
|
{
|
|
ScreenZoom.SetMouseState(this, false, e);
|
|
}
|
|
|
|
private void MainWindow_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.Key == Key.Escape)
|
|
{
|
|
this.Close();
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region Title Band with Windows Buttons (min, max, close)
|
|
/// <summary>
|
|
/// control windows size click
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="System.Windows.Input.MouseButtonEventArgs"/> instance containing the event data.</param>
|
|
private void Window_DoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
{
|
|
//add by kenneth
|
|
Window win = sender as Window;
|
|
Point pt = e.GetPosition(win);
|
|
if (pt.Y > 26/*LayoutValue.SystemTopHeader*/)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Style normalStyle, maxStyle;
|
|
try
|
|
{
|
|
normalStyle = (Style)FindResource("btnNormStyle");
|
|
maxStyle = (Style)FindResource("btnMaxStyle");
|
|
|
|
if (normalStyle == null || maxStyle == null)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
return;
|
|
}
|
|
|
|
UpdateMaxHeightAndWidth();
|
|
|
|
if (this.WindowState == WindowState.Maximized)
|
|
{
|
|
//btWindowMax.Style = normalStyle;
|
|
WindowState = WindowState.Normal;
|
|
}
|
|
else
|
|
{
|
|
//btWindowMax.Style = maxStyle;
|
|
this.WindowState = WindowState.Maximized;
|
|
}
|
|
}
|
|
|
|
private void Header_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
{
|
|
if (e.LeftButton == MouseButtonState.Pressed)
|
|
this.DragMove();
|
|
}
|
|
|
|
|
|
private void btWindowClose_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Helpering.IsTerminate = true;
|
|
//Taskbar.Show();
|
|
this.Close();
|
|
if (GetCurrentMv().IsCloseVisibility == Visibility.Visible)
|
|
{
|
|
if (Helpering.IsRunning)
|
|
{
|
|
GetCurrentMv().ShowMessageBox(SystemConst.ApplicationLeaveConfirm);
|
|
return;
|
|
}
|
|
Helpering.IsTerminate = true;
|
|
//Taskbar.Show();
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
GetCurrentMv().SubContentControl.OnGotoTopLevel();
|
|
}
|
|
}
|
|
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
if (Helpering.IsRunning)
|
|
{
|
|
GetCurrentMv().ShowMessageBox(SystemConst.ApplicationLeaveConfirm);
|
|
e.Cancel = true;
|
|
}
|
|
//Todo: 关机
|
|
|
|
//KillSelf();
|
|
//AppEventAggregator.GetEventAggregator().GetEvent<CaptureChangedEvent>().Publish(new CaptureEventParameter()
|
|
//{ NotifyType = CaptureType.ApplicationExit });
|
|
|
|
//GetCurrentMv().cameraModule.View.CloseCamera();
|
|
|
|
//this.Visibility = Visibility.Hidden;
|
|
//Helpering.Sleep(4000);
|
|
//no longer user, contorl by itself
|
|
|
|
base.OnClosing(e);
|
|
}
|
|
|
|
private void KillSelf()
|
|
{
|
|
Helpering.Sleep(500);
|
|
Process current = Process.GetCurrentProcess();
|
|
current.Kill();
|
|
}
|
|
|
|
/// <summary>
|
|
/// click max window button
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
|
|
private void btWindowMax_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Style normalStyle, maxStyle;
|
|
try
|
|
{
|
|
normalStyle = (Style)FindResource("btnNormStyle");
|
|
maxStyle = (Style)FindResource("btnMaxStyle");
|
|
|
|
if (normalStyle == null || maxStyle == null)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
return;
|
|
}
|
|
|
|
UpdateMaxHeightAndWidth();
|
|
|
|
if (this.WindowState == WindowState.Maximized)
|
|
{
|
|
//btWindowMax.Style = normalStyle;
|
|
//Taskbar.Show();
|
|
WindowState = WindowState.Normal;
|
|
}
|
|
else
|
|
{
|
|
//Taskbar.Hide();
|
|
//btWindowMax.Style = maxStyle;
|
|
this.WindowState = WindowState.Maximized;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// click min window button
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
|
|
private void btWindowMin_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
//btWindowMin.Style = (Style)FindResource("btnMinStyle");
|
|
//Taskbar.Show();
|
|
UpdateMaxHeightAndWidth();
|
|
this.WindowState = WindowState.Minimized;
|
|
}
|
|
|
|
private void Hidden_Button_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
//Helpering.MessageBoxing("Hidden Button - Total Memory Usage: " + ((GC.GetTotalMemory(true) / 1024f) / 1024f).ToString("#,###") + "MB");
|
|
|
|
}
|
|
|
|
public void ShowDialogView()
|
|
{
|
|
pgBorder.Visibility = System.Windows.Visibility.Collapsed;
|
|
GetCurrentMv().IsInProcessVisibility = Visibility.Visible;
|
|
}
|
|
|
|
public void CloseDialogView()
|
|
{
|
|
pgBorder.Visibility = System.Windows.Visibility.Visible;
|
|
GetCurrentMv().IsInProcessVisibility = Visibility.Hidden;
|
|
}
|
|
#endregion //Title Band with Windows Buttons (min, max, close)
|
|
|
|
private void BtnAuto(object sender, RoutedEventArgs e)
|
|
{
|
|
if (Auto.Content == "自动")
|
|
{
|
|
Auto.Content = "手动";
|
|
}
|
|
else if (Auto.Content == "手动")
|
|
{
|
|
Auto.Content = "自动";
|
|
}
|
|
}
|
|
}
|
|
}
|