120 lines
3.9 KiB
C#
120 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.CompilerServices;
|
|
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;
|
|
|
|
namespace _29WxOrderWpf.UserControls
|
|
{
|
|
/// <summary>
|
|
/// WindowBox.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class UcWindowBoxes : UserControl
|
|
{
|
|
public static readonly DependencyProperty MaxBoxVisibilityProperty =
|
|
DependencyProperty.Register("MaxBoxVisibility", typeof(Visibility), typeof(UcWindowBoxes),
|
|
new PropertyMetadata(default(Visibility)));
|
|
public Visibility MaxBoxVisibility
|
|
{
|
|
get { return (Visibility)GetValue(MaxBoxVisibilityProperty); }
|
|
set
|
|
{
|
|
SetValue(MaxBoxVisibilityProperty, value);
|
|
Window_StateChanged(null, null);
|
|
}
|
|
}
|
|
|
|
public static readonly DependencyProperty MinBoxVisibilityProperty =
|
|
DependencyProperty.Register("MinBoxVisibility", typeof(Visibility), typeof(UcWindowBoxes),
|
|
new PropertyMetadata(default(Visibility)));
|
|
public Visibility MinBoxVisibility
|
|
{
|
|
get { return (Visibility)GetValue(MinBoxVisibilityProperty); }
|
|
set { SetValue(MinBoxVisibilityProperty, value); btnMin.Visibility = value; }
|
|
}
|
|
|
|
public UcWindowBoxes()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetWindowMax()
|
|
{
|
|
this.BtnMax_Click(null, null);
|
|
}
|
|
|
|
private void WindowBoxes_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
this.btnClose.Click += BtnClose_Click;
|
|
this.btnMax.Click += BtnMax_Click;
|
|
this.btnNormal.Click += BtnNormal_Click;
|
|
this.btnMin.Click += BtnMin_Click;
|
|
|
|
var window = Window.GetWindow(this);
|
|
if (window != null)
|
|
{
|
|
window.StateChanged += Window_StateChanged;
|
|
}
|
|
Window_StateChanged(null, null);
|
|
}
|
|
|
|
private void BtnMin_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var window = Window.GetWindow(this);
|
|
if (window != null)
|
|
window.WindowState = WindowState.Minimized;
|
|
}
|
|
|
|
private void BtnNormal_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var window = Window.GetWindow(this);
|
|
if (window != null)
|
|
window.WindowState = WindowState.Normal;
|
|
}
|
|
|
|
private void BtnMax_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var window = Window.GetWindow(this);
|
|
if (window != null)
|
|
window.WindowState = WindowState.Maximized;
|
|
}
|
|
|
|
private void BtnClose_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var window = Window.GetWindow(this);
|
|
if (window == null)
|
|
return;
|
|
|
|
window.Close();
|
|
}
|
|
|
|
private void Window_StateChanged(object sender, EventArgs e)
|
|
{
|
|
var window = Window.GetWindow(this);
|
|
if (window != null)
|
|
{
|
|
if (window.WindowState == WindowState.Maximized && MaxBoxVisibility == Visibility.Visible)
|
|
{
|
|
this.btnNormal.Visibility = Visibility.Visible;
|
|
this.btnMax.Visibility = Visibility.Collapsed;
|
|
}
|
|
if (window.WindowState == WindowState.Normal && MaxBoxVisibility == Visibility.Visible)
|
|
{
|
|
this.btnNormal.Visibility = Visibility.Collapsed;
|
|
this.btnMax.Visibility = Visibility.Visible;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|