巨石化纤
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.

80 lines
2.1 KiB

using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace SSWMS.Client.UC
{
public partial class ucWindowTopHeader : UserControl
{
public ucWindowTopHeader()
{
InitializeComponent();
this.Loaded += WindowTopHeader_Loaded;
}
public string U_Title
{
set { this.tbTitle.Text = value; }
}
private Window ParentWindow = null;
private Window GetParentWindow(DependencyObject child)
{
DependencyObject parent = LogicalTreeHelper.GetParent(child);
if (parent == null)
{
return null;
}
else if (parent is Window)
{
return parent as Window;
}
else
{
return GetParentWindow(parent);
}
}
private void WindowTopHeader_Loaded(object sender, RoutedEventArgs e)
{
this.ParentWindow = this.GetParentWindow(this);
}
private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
{
try
{
if (e.LeftButton == MouseButtonState.Pressed &&
this.ParentWindow != null)
{
this.ParentWindow.DragMove();
}
}
catch
{
}
}
private void Min_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
if (this.ParentWindow != null)
{
this.ParentWindow.WindowState = WindowState.Minimized;
}
}
}
private void Close_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
if (this.ParentWindow != null)
{
this.ParentWindow.Close();
}
}
}
}
}