首次上传
This commit is contained in:
+54
@@ -0,0 +1,54 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace WpfStyleableWindow.StyleableWindow
|
||||
{
|
||||
public static class ControlDoubleClickBehavior
|
||||
{
|
||||
public static readonly DependencyProperty ExecuteCommand = DependencyProperty.RegisterAttached("ExecuteCommand", typeof(ICommand), typeof(ControlDoubleClickBehavior), new UIPropertyMetadata(null, OnExecuteCommandChanged));
|
||||
|
||||
public static readonly DependencyProperty ExecuteCommandParameter = DependencyProperty.RegisterAttached("ExecuteCommandParameter", typeof(Window), typeof(ControlDoubleClickBehavior));
|
||||
|
||||
public static ICommand GetExecuteCommand(DependencyObject obj)
|
||||
{
|
||||
return (ICommand)obj.GetValue(ExecuteCommand);
|
||||
}
|
||||
|
||||
public static void SetExecuteCommand(DependencyObject obj, ICommand command)
|
||||
{
|
||||
obj.SetValue(ExecuteCommand, command);
|
||||
}
|
||||
|
||||
public static Window GetExecuteCommandParameter(DependencyObject obj)
|
||||
{
|
||||
return (Window)obj.GetValue(ExecuteCommandParameter);
|
||||
}
|
||||
|
||||
public static void SetExecuteCommandParameter(DependencyObject obj, ICommand command)
|
||||
{
|
||||
obj.SetValue(ExecuteCommandParameter, command);
|
||||
}
|
||||
|
||||
private static void OnExecuteCommandChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is Control control)
|
||||
{
|
||||
control.MouseDoubleClick += control_MouseDoubleClick;
|
||||
}
|
||||
}
|
||||
|
||||
private static void control_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender is Control control)
|
||||
{
|
||||
ICommand command = control.GetValue(ExecuteCommand) as ICommand;
|
||||
object value = control.GetValue(ExecuteCommandParameter);
|
||||
if (command.CanExecute(e))
|
||||
{
|
||||
command.Execute(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace WpfStyleableWindow.StyleableWindow
|
||||
{
|
||||
internal static class NativeMethods
|
||||
{
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
internal static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern int TrackPopupMenuEx(IntPtr hmenu, uint fuFlags, int x, int y, IntPtr hwnd, IntPtr lptpm);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern bool EnableMenuItem(IntPtr hMenu, uint uIDEnableItem, uint uEnable);
|
||||
}
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace WpfStyleableWindow.StyleableWindow
|
||||
{
|
||||
public static class ShowSystemMenuBehavior
|
||||
{
|
||||
public static readonly DependencyProperty TargetWindow = DependencyProperty.RegisterAttached("TargetWindow", typeof(Window), typeof(ShowSystemMenuBehavior));
|
||||
|
||||
public static readonly DependencyProperty LeftButtonShowAt = DependencyProperty.RegisterAttached("LeftButtonShowAt", typeof(UIElement), typeof(ShowSystemMenuBehavior), new UIPropertyMetadata(null, LeftButtonShowAtChanged));
|
||||
|
||||
public static readonly DependencyProperty RightButtonShow = DependencyProperty.RegisterAttached("RightButtonShow", typeof(bool), typeof(ShowSystemMenuBehavior), new UIPropertyMetadata(false, RightButtonShowChanged));
|
||||
|
||||
private static bool leftButtonToggle = true;
|
||||
|
||||
public static Window GetTargetWindow(DependencyObject obj)
|
||||
{
|
||||
return (Window)obj.GetValue(TargetWindow);
|
||||
}
|
||||
|
||||
public static void SetTargetWindow(DependencyObject obj, Window window)
|
||||
{
|
||||
obj.SetValue(TargetWindow, window);
|
||||
}
|
||||
|
||||
public static UIElement GetLeftButtonShowAt(DependencyObject obj)
|
||||
{
|
||||
return (UIElement)obj.GetValue(LeftButtonShowAt);
|
||||
}
|
||||
|
||||
public static void SetLeftButtonShowAt(DependencyObject obj, UIElement element)
|
||||
{
|
||||
obj.SetValue(LeftButtonShowAt, element);
|
||||
}
|
||||
|
||||
public static bool GetRightButtonShow(DependencyObject obj)
|
||||
{
|
||||
return (bool)obj.GetValue(RightButtonShow);
|
||||
}
|
||||
|
||||
public static void SetRightButtonShow(DependencyObject obj, bool arg)
|
||||
{
|
||||
obj.SetValue(RightButtonShow, arg);
|
||||
}
|
||||
|
||||
private static void LeftButtonShowAtChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is UIElement uIElement)
|
||||
{
|
||||
uIElement.MouseLeftButtonDown += LeftButtonDownShow;
|
||||
}
|
||||
}
|
||||
|
||||
private static void LeftButtonDownShow(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (leftButtonToggle)
|
||||
{
|
||||
object value = ((UIElement)sender).GetValue(LeftButtonShowAt);
|
||||
Point menuLocation = ((Visual)value).PointToScreen(new Point(0.0, 0.0));
|
||||
Window targetWindow = ((UIElement)sender).GetValue(TargetWindow) as Window;
|
||||
SystemMenuManager.ShowMenu(targetWindow, menuLocation);
|
||||
leftButtonToggle = !leftButtonToggle;
|
||||
}
|
||||
else
|
||||
{
|
||||
leftButtonToggle = !leftButtonToggle;
|
||||
}
|
||||
}
|
||||
|
||||
private static void RightButtonShowChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is UIElement uIElement)
|
||||
{
|
||||
uIElement.MouseRightButtonDown += RightButtonDownShow;
|
||||
}
|
||||
}
|
||||
|
||||
private static void RightButtonDownShow(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
UIElement uIElement = (UIElement)sender;
|
||||
Window window = uIElement.GetValue(TargetWindow) as Window;
|
||||
Point menuLocation = window.PointToScreen(Mouse.GetPosition(window));
|
||||
SystemMenuManager.ShowMenu(window, menuLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace WpfStyleableWindow.StyleableWindow
|
||||
{
|
||||
public static class SystemMenuManager
|
||||
{
|
||||
public static void ShowMenu(Window targetWindow, Point menuLocation)
|
||||
{
|
||||
if (targetWindow == null)
|
||||
{
|
||||
throw new ArgumentNullException("TargetWindow is null.");
|
||||
}
|
||||
int x;
|
||||
int y;
|
||||
try
|
||||
{
|
||||
x = Convert.ToInt32(menuLocation.X);
|
||||
y = Convert.ToInt32(menuLocation.Y);
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
uint msg = 274u;
|
||||
uint num = 0u;
|
||||
uint num2 = 256u;
|
||||
IntPtr handle = new WindowInteropHelper(targetWindow).Handle;
|
||||
IntPtr systemMenu = NativeMethods.GetSystemMenu(handle, bRevert: false);
|
||||
int num3 = NativeMethods.TrackPopupMenuEx(systemMenu, num | num2, x, y, handle, IntPtr.Zero);
|
||||
if (num3 != 0)
|
||||
{
|
||||
NativeMethods.PostMessage(handle, msg, new IntPtr(num3), IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace WpfStyleableWindow.StyleableWindow
|
||||
{
|
||||
public class WindowCloseCommand : ICommand
|
||||
{
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
if (parameter is Window window)
|
||||
{
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace WpfStyleableWindow.StyleableWindow
|
||||
{
|
||||
public static class WindowDragBehavior
|
||||
{
|
||||
public static readonly DependencyProperty LeftMouseButtonDrag = DependencyProperty.RegisterAttached("LeftMouseButtonDrag", typeof(Window), typeof(WindowDragBehavior), new UIPropertyMetadata(null, OnLeftMouseButtonDragChanged));
|
||||
|
||||
public static Window GetLeftMouseButtonDrag(DependencyObject obj)
|
||||
{
|
||||
return (Window)obj.GetValue(LeftMouseButtonDrag);
|
||||
}
|
||||
|
||||
public static void SetLeftMouseButtonDrag(DependencyObject obj, Window window)
|
||||
{
|
||||
obj.SetValue(LeftMouseButtonDrag, window);
|
||||
}
|
||||
|
||||
private static void OnLeftMouseButtonDragChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is UIElement uIElement)
|
||||
{
|
||||
uIElement.MouseLeftButtonDown += buttonDown;
|
||||
}
|
||||
}
|
||||
|
||||
private static void buttonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
UIElement uIElement = sender as UIElement;
|
||||
if (uIElement.GetValue(LeftMouseButtonDrag) is Window window)
|
||||
{
|
||||
window.DragMove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace WpfStyleableWindow.StyleableWindow
|
||||
{
|
||||
public class WindowMaximizeCommand : ICommand
|
||||
{
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
if (parameter is Window window)
|
||||
{
|
||||
if (window.WindowState == WindowState.Maximized)
|
||||
{
|
||||
window.WindowState = WindowState.Normal;
|
||||
}
|
||||
else
|
||||
{
|
||||
window.WindowState = WindowState.Maximized;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace WpfStyleableWindow.StyleableWindow
|
||||
{
|
||||
public class WindowMinimizeCommand : ICommand
|
||||
{
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
if (parameter is Window window)
|
||||
{
|
||||
window.WindowState = WindowState.Minimized;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+298
@@ -0,0 +1,298 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
|
||||
namespace WpfStyleableWindow.StyleableWindow
|
||||
{
|
||||
public static class WindowResizeBehavior
|
||||
{
|
||||
public static readonly DependencyProperty TopLeftResize = DependencyProperty.RegisterAttached("TopLeftResize", typeof(Window), typeof(WindowResizeBehavior), new UIPropertyMetadata(null, OnTopLeftResizeChanged));
|
||||
|
||||
public static readonly DependencyProperty TopRightResize = DependencyProperty.RegisterAttached("TopRightResize", typeof(Window), typeof(WindowResizeBehavior), new UIPropertyMetadata(null, OnTopRightResizeChanged));
|
||||
|
||||
public static readonly DependencyProperty BottomRightResize = DependencyProperty.RegisterAttached("BottomRightResize", typeof(Window), typeof(WindowResizeBehavior), new UIPropertyMetadata(null, OnBottomRightResizeChanged));
|
||||
|
||||
public static readonly DependencyProperty BottomLeftResize = DependencyProperty.RegisterAttached("BottomLeftResize", typeof(Window), typeof(WindowResizeBehavior), new UIPropertyMetadata(null, OnBottomLeftResizeChanged));
|
||||
|
||||
public static readonly DependencyProperty LeftResize = DependencyProperty.RegisterAttached("LeftResize", typeof(Window), typeof(WindowResizeBehavior), new UIPropertyMetadata(null, OnLeftResizeChanged));
|
||||
|
||||
public static readonly DependencyProperty RightResize = DependencyProperty.RegisterAttached("RightResize", typeof(Window), typeof(WindowResizeBehavior), new UIPropertyMetadata(null, OnRightResizeChanged));
|
||||
|
||||
public static readonly DependencyProperty TopResize = DependencyProperty.RegisterAttached("TopResize", typeof(Window), typeof(WindowResizeBehavior), new UIPropertyMetadata(null, OnTopResizeChanged));
|
||||
|
||||
public static readonly DependencyProperty BottomResize = DependencyProperty.RegisterAttached("BottomResize", typeof(Window), typeof(WindowResizeBehavior), new UIPropertyMetadata(null, OnBottomResizeChanged));
|
||||
|
||||
public static Window GetTopLeftResize(DependencyObject obj)
|
||||
{
|
||||
return (Window)obj.GetValue(TopLeftResize);
|
||||
}
|
||||
|
||||
public static void SetTopLeftResize(DependencyObject obj, Window window)
|
||||
{
|
||||
obj.SetValue(TopLeftResize, window);
|
||||
}
|
||||
|
||||
private static void OnTopLeftResizeChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is Thumb thumb)
|
||||
{
|
||||
thumb.DragDelta += DragTopLeft;
|
||||
}
|
||||
}
|
||||
|
||||
public static Window GetTopRightResize(DependencyObject obj)
|
||||
{
|
||||
return (Window)obj.GetValue(TopRightResize);
|
||||
}
|
||||
|
||||
public static void SetTopRightResize(DependencyObject obj, Window window)
|
||||
{
|
||||
obj.SetValue(TopRightResize, window);
|
||||
}
|
||||
|
||||
private static void OnTopRightResizeChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is Thumb thumb)
|
||||
{
|
||||
thumb.DragDelta += DragTopRight;
|
||||
}
|
||||
}
|
||||
|
||||
public static Window GetBottomRightResize(DependencyObject obj)
|
||||
{
|
||||
return (Window)obj.GetValue(BottomRightResize);
|
||||
}
|
||||
|
||||
public static void SetBottomRightResize(DependencyObject obj, Window window)
|
||||
{
|
||||
obj.SetValue(BottomRightResize, window);
|
||||
}
|
||||
|
||||
private static void OnBottomRightResizeChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is Thumb thumb)
|
||||
{
|
||||
thumb.DragDelta += DragBottomRight;
|
||||
}
|
||||
}
|
||||
|
||||
public static Window GetBottomLeftResize(DependencyObject obj)
|
||||
{
|
||||
return (Window)obj.GetValue(BottomLeftResize);
|
||||
}
|
||||
|
||||
public static void SetBottomLeftResize(DependencyObject obj, Window window)
|
||||
{
|
||||
obj.SetValue(BottomLeftResize, window);
|
||||
}
|
||||
|
||||
private static void OnBottomLeftResizeChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is Thumb thumb)
|
||||
{
|
||||
thumb.DragDelta += DragBottomLeft;
|
||||
}
|
||||
}
|
||||
|
||||
public static Window GetLeftResize(DependencyObject obj)
|
||||
{
|
||||
return (Window)obj.GetValue(LeftResize);
|
||||
}
|
||||
|
||||
public static void SetLeftResize(DependencyObject obj, Window window)
|
||||
{
|
||||
obj.SetValue(LeftResize, window);
|
||||
}
|
||||
|
||||
private static void OnLeftResizeChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is Thumb thumb)
|
||||
{
|
||||
thumb.DragDelta += DragLeft;
|
||||
}
|
||||
}
|
||||
|
||||
public static Window GetRightResize(DependencyObject obj)
|
||||
{
|
||||
return (Window)obj.GetValue(RightResize);
|
||||
}
|
||||
|
||||
public static void SetRightResize(DependencyObject obj, Window window)
|
||||
{
|
||||
obj.SetValue(RightResize, window);
|
||||
}
|
||||
|
||||
private static void OnRightResizeChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is Thumb thumb)
|
||||
{
|
||||
thumb.DragDelta += DragRight;
|
||||
}
|
||||
}
|
||||
|
||||
public static Window GetTopResize(DependencyObject obj)
|
||||
{
|
||||
return (Window)obj.GetValue(TopResize);
|
||||
}
|
||||
|
||||
public static void SetTopResize(DependencyObject obj, Window window)
|
||||
{
|
||||
obj.SetValue(TopResize, window);
|
||||
}
|
||||
|
||||
private static void OnTopResizeChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is Thumb thumb)
|
||||
{
|
||||
thumb.DragDelta += DragTop;
|
||||
}
|
||||
}
|
||||
|
||||
public static Window GetBottomResize(DependencyObject obj)
|
||||
{
|
||||
return (Window)obj.GetValue(BottomResize);
|
||||
}
|
||||
|
||||
public static void SetBottomResize(DependencyObject obj, Window window)
|
||||
{
|
||||
obj.SetValue(BottomResize, window);
|
||||
}
|
||||
|
||||
private static void OnBottomResizeChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is Thumb thumb)
|
||||
{
|
||||
thumb.DragDelta += DragBottom;
|
||||
}
|
||||
}
|
||||
|
||||
private static void DragLeft(object sender, DragDeltaEventArgs e)
|
||||
{
|
||||
Thumb thumb = sender as Thumb;
|
||||
if (thumb.GetValue(LeftResize) is Window window)
|
||||
{
|
||||
double num = window.SafeWidthChange(e.HorizontalChange, positive: false);
|
||||
window.Width -= num;
|
||||
window.Left += num;
|
||||
}
|
||||
}
|
||||
|
||||
private static void DragRight(object sender, DragDeltaEventArgs e)
|
||||
{
|
||||
Thumb thumb = sender as Thumb;
|
||||
if (thumb.GetValue(RightResize) is Window window)
|
||||
{
|
||||
double num = window.SafeWidthChange(e.HorizontalChange);
|
||||
window.Width += num;
|
||||
}
|
||||
}
|
||||
|
||||
private static void DragTop(object sender, DragDeltaEventArgs e)
|
||||
{
|
||||
Thumb thumb = sender as Thumb;
|
||||
if (thumb.GetValue(TopResize) is Window window)
|
||||
{
|
||||
double num = window.SafeHeightChange(e.VerticalChange, positive: false);
|
||||
window.Height -= num;
|
||||
window.Top += num;
|
||||
}
|
||||
}
|
||||
|
||||
private static void DragBottom(object sender, DragDeltaEventArgs e)
|
||||
{
|
||||
Thumb thumb = sender as Thumb;
|
||||
if (thumb.GetValue(BottomResize) is Window window)
|
||||
{
|
||||
double num = window.SafeHeightChange(e.VerticalChange);
|
||||
window.Height += num;
|
||||
}
|
||||
}
|
||||
|
||||
private static void DragTopLeft(object sender, DragDeltaEventArgs e)
|
||||
{
|
||||
Thumb thumb = sender as Thumb;
|
||||
if (thumb.GetValue(TopLeftResize) is Window window)
|
||||
{
|
||||
double num = window.SafeHeightChange(e.VerticalChange, positive: false);
|
||||
double num2 = window.SafeWidthChange(e.HorizontalChange, positive: false);
|
||||
window.Width -= num2;
|
||||
window.Left += num2;
|
||||
window.Height -= num;
|
||||
window.Top += num;
|
||||
}
|
||||
}
|
||||
|
||||
private static void DragTopRight(object sender, DragDeltaEventArgs e)
|
||||
{
|
||||
Thumb thumb = sender as Thumb;
|
||||
if (thumb.GetValue(TopRightResize) is Window window)
|
||||
{
|
||||
double num = window.SafeHeightChange(e.VerticalChange, positive: false);
|
||||
double num2 = window.SafeWidthChange(e.HorizontalChange);
|
||||
window.Width += num2;
|
||||
window.Height -= num;
|
||||
window.Top += num;
|
||||
}
|
||||
}
|
||||
|
||||
private static void DragBottomRight(object sender, DragDeltaEventArgs e)
|
||||
{
|
||||
Thumb thumb = sender as Thumb;
|
||||
if (thumb.GetValue(BottomRightResize) is Window window)
|
||||
{
|
||||
double num = window.SafeHeightChange(e.VerticalChange);
|
||||
double num2 = window.SafeWidthChange(e.HorizontalChange);
|
||||
window.Width += num2;
|
||||
window.Height += num;
|
||||
}
|
||||
}
|
||||
|
||||
private static void DragBottomLeft(object sender, DragDeltaEventArgs e)
|
||||
{
|
||||
Thumb thumb = sender as Thumb;
|
||||
if (thumb.GetValue(BottomLeftResize) is Window window)
|
||||
{
|
||||
double num = window.SafeHeightChange(e.VerticalChange);
|
||||
double num2 = window.SafeWidthChange(e.HorizontalChange, positive: false);
|
||||
window.Width -= num2;
|
||||
window.Left += num2;
|
||||
window.Height += num;
|
||||
}
|
||||
}
|
||||
|
||||
private static double SafeWidthChange(this Window window, double change, bool positive = true)
|
||||
{
|
||||
double num = (positive ? (window.Width + change) : (window.Width - change));
|
||||
if (num <= window.MinWidth)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
if (num >= window.MaxWidth)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
if (num < 0.0)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
||||
private static double SafeHeightChange(this Window window, double change, bool positive = true)
|
||||
{
|
||||
double num = (positive ? (window.Height + change) : (window.Height - change));
|
||||
if (num <= window.MinHeight)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
if (num >= window.MaxHeight)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
if (num < 0.0)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
return change;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user