using System; using System.Windows; using System.Windows.Controls; using System.Windows.Input; namespace BeWo.View { /// /// Interaktionslogik für BeWoWindow.xaml /// public partial class BeWoWindow : System.Windows.Window { private object _GroupBoxContent; public object GroupBoxContent { get { return _GroupBoxContent; } set { _GroupBoxContent = value; rootGroupBox.Content = value; } } public bool IsMaximizable = true; public BeWoWindow() { InitializeComponent(); CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => Close())); } public BeWoWindow(FrameworkElement fe) { InitializeComponent(); rootGroupBox.Content = fe; CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => Close())); } public BeWoWindow(FrameworkElement fe, string stylestring) { InitializeComponent(); rootGroupBox.Content = fe; rootGroupBox.Style = (Style)FindResource(stylestring); CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => Close())); } private void RootGroupBox_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { try { var p = e.GetPosition(this); if (p.Y <= 40) { DragMove(); } } catch (Exception){} } private void RootGroupBox_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) { if(!IsVisible) { return; } if (!IsMaximizable) { return; } var pos = PointToScreen(Mouse.GetPosition(this)); if (!(e.OriginalSource is Border) && !(e.OriginalSource is TextBlock) || pos.Y > 200d || e.OriginalSource is TextBlock && Mouse.DirectlyOver is Button) { return; } if (WindowState == WindowState.Maximized) { WindowState = WindowState.Normal; return; } if (WindowState == WindowState.Normal) { WindowState = WindowState.Maximized; } } public void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { } public void Window_Closed(object sender, EventArgs e) { } } }