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);