拆分按钮样式
This commit is contained in:
1 parent
d03a1e1466
commit
167885814e
37 files changed
+1009
-219
No files matched your search
@@ -0,0 +1,114 @@
|
||||
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;
|
||||
|
||||
namespace _29WxOrderWpf.UserControls
|
||||
{
|
||||
/// <summary>
|
||||
/// WindowBox.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class WindowBoxes : UserControl
|
||||
{
|
||||
public static readonly DependencyProperty MaxBoxVisibilityProperty =
|
||||
DependencyProperty.Register("MaxBoxVisibility", typeof(Visibility), typeof(WindowBoxes),
|
||||
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(WindowBoxes),
|
||||
new PropertyMetadata(default(Visibility)));
|
||||
public Visibility MinBoxVisibility
|
||||
{
|
||||
get { return (Visibility)GetValue(MinBoxVisibilityProperty); }
|
||||
set { SetValue(MinBoxVisibilityProperty, value); btnMin.Visibility = value; }
|
||||
}
|
||||
|
||||
public WindowBoxes()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = this;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user