using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace RichCreator.Editor.Tools.CV
{
///
/// DialogReplica.xaml 的交互逻辑
///
public partial class SplitArea : UserControl
{
private Cursor _cursor;
public SplitArea()
{
InitializeComponent();
}
private void OnResizeThumbDragStarted(object sender, DragStartedEventArgs e)
{
_cursor = Cursor;
Cursor = Cursors.SizeNWSE;
}
private void OnResizeThumbDragCompleted(object sender, DragCompletedEventArgs e)
{
Cursor = _cursor;
}
private void OnResizeThumbDragDelta(object sender, DragDeltaEventArgs e)
{
double width = double.IsNaN(sizableContent.Width)?0:sizableContent.Width;
double height =double.IsNaN(sizableContent.Height)?0:sizableContent.Height;
double xAdjust = width + e.HorizontalChange;
double yAdjust = height + e.VerticalChange;
//make sure not to resize to negative width or heigth
xAdjust = xAdjust < sizableContent.MinWidth ? sizableContent.MinWidth: xAdjust ;
yAdjust = yAdjust < sizableContent.MinHeight ? sizableContent.MinHeight:yAdjust ;
sizableContent.Width = xAdjust;
sizableContent.Height = yAdjust;
}
private void Thumb_DragStarted(object sender, DragStartedEventArgs e)
{
_cursor = Cursor;
Cursor = Cursors.Arrow;
}
private void Thumb_DragCompleted(object sender, DragCompletedEventArgs e)
{
Cursor = _cursor;
}
private void Thumb_DragDelta(object sender, DragDeltaEventArgs e)
{
double left = Canvas.GetLeft(this);
double top = Canvas.GetTop(this);
double xAdjust =(double.IsNaN(left)?0:left) + e.HorizontalChange;
double yAdjust = (double.IsNaN(top)?0:top)+ e.VerticalChange;
Canvas.SetLeft(this, xAdjust);
Canvas.SetTop(this, yAdjust);
}
///
/// 得到控件的Rect
///
///
public Rect GetRect()
{
return new Rect(Canvas.GetLeft(this), Canvas.GetTop(this), this.ActualWidth, this.ActualHeight);
}
public event Action OnClose;
private void raiseOnClose()
{
if (OnClose != null)
{
OnClose(this);
}
}
///
/// 关闭点击
///
///
///
private void Button_Click(object sender, RoutedEventArgs e)
{
raiseOnClose();
}
}
}