mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-11 11:46:37 +08:00
整理一下项目文件
This commit is contained in:
54
AIStudio.Wpf.DiagramDesigner/Controls/PointDragThumb.cs
Normal file
54
AIStudio.Wpf.DiagramDesigner/Controls/PointDragThumb.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Controls
|
||||
{
|
||||
public class PointDragThumb : Thumb
|
||||
{
|
||||
public PointDragThumb()
|
||||
{
|
||||
base.DragDelta += new DragDeltaEventHandler(DragThumb_DragDelta);
|
||||
base.DragStarted += DragThumb_DragStarted;
|
||||
base.DragCompleted += DragThumb_DragCompleted;
|
||||
}
|
||||
|
||||
|
||||
private void DragThumb_DragStarted(object sender, DragStartedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void DragThumb_DragCompleted(object sender, DragCompletedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
|
||||
{
|
||||
if (this.DataContext is PointInfoBase point)
|
||||
{
|
||||
double minLeft = double.MaxValue;
|
||||
double minTop = double.MaxValue;
|
||||
|
||||
double left = point.X;
|
||||
double top = point.Y;
|
||||
minLeft = double.IsNaN(left) ? 0 : Math.Min(left, minLeft);
|
||||
minTop = double.IsNaN(top) ? 0 : Math.Min(top, minTop);
|
||||
|
||||
double deltaHorizontal = Math.Max(-minLeft, e.HorizontalChange);
|
||||
double deltaVertical = Math.Max(-minTop, e.VerticalChange);
|
||||
|
||||
point.X += deltaHorizontal;
|
||||
point.Y += deltaVertical;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user