using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace WpfApplication1
{
public class WindowResizer
{
private Window target = null;
private bool resizeRight = false;
private bool resizeLeft = false;
private bool resizeUp = false;
private bool resizeDown = false;
private Dictionary<UIElement, short> leftElements = new Dictionary<UIElement, short>();
private Dictionary<UIElement, short> rightElements = new Dictionary<UIElement, short>();
private Dictionary<UIElement, short> upElements = new Dictionary<UIElement, short>();
private Dictionary<UIElement, short> downElements = new Dictionary<UIElement, short>();
private PointAPI resizePoint = new PointAPI();
private Size resizeSize = new Size();
private Point resizeWindowPoint = new Point();
private delegate void RefreshDelegate();
public WindowResizer(Window target)
{
this.target = target;
if (target == null)
{
throw new Exception("Invalid Window handle");
}
}
#region add resize components
private void connectMouseHandlers(UIElement element)
{
element.MouseLeftButtonDown += new MouseButtonEventHandler(element_MouseLeftButtonDown);
element.MouseEnter += new System.Windows.Input.MouseEventHandler(element_MouseEnter);
element.MouseLeave += new System.Windows.Input.MouseEventHandler(setArrowCursor);
}
public void addResizerRight(UIElement element)
{
connectMouseHandlers(element);
rightElements.Add(element, 0);
}
public void addResizerLeft(UIElement element)
{
connectMouseHandlers(element);
leftElements.Add(element, 0);
}
public void addResizerUp(UIElement element)
{
connectMouseHandlers(element);
upElements.Add(element, 0);
C# WPF 可拉伸窗口大小,当Resize=NoResize时可用
最新推荐文章于 2024-06-05 09:51:17 发布
本文介绍了如何在C# WPF应用中,即使设置Resize为NoResize,也能实现窗口大小的可拉伸功能。通过特定的代码调用,开发者可以实现这一特性。
摘要由CSDN通过智能技术生成