整理了下代码,摸一摸bug

This commit is contained in:
艾竹
2023-05-21 23:03:28 +08:00
parent fde899cfa9
commit b11d39024a
13 changed files with 51 additions and 20 deletions

View File

@@ -41,11 +41,14 @@ namespace AIStudio.Wpf.DiagramDesigner
if (IsFinish)
{
var path = GetPath();
var rect = new Rect(Points[0], Points[1]);
var point0 = rect.TopLeft;
var point1 = rect.BottomRight;
PathGeometry pathGeometry = PathGeometry.CreateFromGeometry(Geometry.Parse(path));
var transformGroup = new TransformGroup();
double radiox = Math.Abs(Points[1].X - Points[0].X) / pathGeometry.Bounds.Width;
double radioy = Math.Abs(Points[1].Y - Points[0].Y) / pathGeometry.Bounds.Height;
transformGroup.Children.Add(new TranslateTransform((Points[0].X) / radiox - pathGeometry.Bounds.Left, (Points[0].Y) / radioy - pathGeometry.Bounds.Top));
double radiox = Math.Abs(point1.X - point0.X) / pathGeometry.Bounds.Width;
double radioy = Math.Abs(point1.Y - point0.Y) / pathGeometry.Bounds.Height;
transformGroup.Children.Add(new TranslateTransform((point0.X) / radiox - pathGeometry.Bounds.Left, (point0.Y) / radioy - pathGeometry.Bounds.Top));
transformGroup.Children.Add(new ScaleTransform(radiox, radioy));
pathGeometry.Transform = transformGroup;
Geometry = pathGeometry;
@@ -85,11 +88,15 @@ namespace AIStudio.Wpf.DiagramDesigner
}
var path = GetPath();
var rect = new Rect(Points[0], Points[1]);
var point0 = rect.TopLeft;
var point1 = rect.BottomRight;
PathGeometry pathGeometry = PathGeometry.CreateFromGeometry(Geometry.Parse(path));
var transformGroup = new TransformGroup();
double radiox = Math.Abs(point.X - Points[0].X) / pathGeometry.Bounds.Width;
double radioy = Math.Abs(point.Y - Points[0].Y) / pathGeometry.Bounds.Height;
transformGroup.Children.Add(new TranslateTransform((Points[0].X) / radiox - pathGeometry.Bounds.Left, (Points[0].Y) / radioy - pathGeometry.Bounds.Top));
double radiox = Math.Abs(point1.X - point0.X) / pathGeometry.Bounds.Width;
double radioy = Math.Abs(point1.Y - point0.Y) / pathGeometry.Bounds.Height;
transformGroup.Children.Add(new TranslateTransform((point0.X) / radiox - pathGeometry.Bounds.Left, (point0.Y) / radioy - pathGeometry.Bounds.Top));
transformGroup.Children.Add(new ScaleTransform(radiox, radioy));
pathGeometry.Transform = transformGroup;
Geometry = pathGeometry;