2025-03-28 09:49:56 +08:00

96 lines
2.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HiiShe.WPFUI.Util;
using System.Windows;
namespace HiiShe.WPFUI.Controls
{
public class HSWindow : Window
{
public HSWindow()
{
this.DefaultStyleKey = typeof(HSWindow);
//缩放,最大化修复
WindowBehaviorHelper wh = new WindowBehaviorHelper(this);
wh.RepairBehavior();
this.MouseDoubleClick += HSWindow_MouseDoubleClick;
this.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(HSWindow_MouseLeftButtonDown);
}
void HSWindow_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (this.WindowState == System.Windows.WindowState.Maximized)
{
this.WindowState = System.Windows.WindowState.Normal;
}
else
{
this.WindowState = System.Windows.WindowState.Maximized;
}
}
void HSWindow_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
//if (this.WindowState == System.Windows.WindowState.Maximized)
//{
// this.WindowState = System.Windows.WindowState.Normal;
//}
try
{
this.DragMove();
}
catch
{
}
}
}
public class HSNormalWindow : Window
{
public HSNormalWindow()
{
this.DefaultStyleKey = typeof(HSNormalWindow);
//缩放,最大化修复
WindowBehaviorHelper wh = new WindowBehaviorHelper(this);
wh.RepairBehavior();
this.MouseDoubleClick += HSNormalWindow_MouseDoubleClick;
this.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(HSNormalWindow_MouseLeftButtonDown);
}
void HSNormalWindow_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
//if (this.WindowState == System.Windows.WindowState.Maximized)
//{
// this.WindowState = System.Windows.WindowState.Normal;
//}
//else
//{
// this.WindowState = System.Windows.WindowState.Maximized;
//}
}
void HSNormalWindow_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
//if (this.WindowState == System.Windows.WindowState.Maximized)
//{
// this.WindowState = System.Windows.WindowState.Normal;
//}
try
{
this.DragMove();
}
catch
{
}
}
}
}