整理了下代码,摸一摸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

@@ -43,5 +43,18 @@ namespace AIStudio.Wpf.DiagramDesigner
ColorViewModel.LineColor.Color = Colors.Transparent;
ColorViewModel.FillColor.Color = Colors.Transparent;
}
public override bool CanAttachTo(ConnectorInfoBase port)
{
if (port is BlockConnectorInfo blockConnectorInfo)
{
return port != this && !port.IsReadOnly && DataItem != blockConnectorInfo.DataItem;
}
else
{
return false;
}
}
}
}

View File

@@ -1187,7 +1187,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
else if (parameter is IEnumerable<SelectableDesignerItemViewModelBase> items)
{
if (items.Select(p => AddVerify(p)).Any() != true) return;
if (items.Select(p => AddVerify(p)).ToList().Any() != true) return;
foreach (var item in items)
{

View File

@@ -88,7 +88,7 @@ namespace AIStudio.Wpf.DiagramDesigner
get { return _suffix; }
set
{
SetProperty(ref _suffix, filter.Contains(value) ? value : ".txt");
SetProperty(ref _suffix, value != null && filter.Contains(value) ? value : ".txt");
}
}
@@ -167,8 +167,10 @@ namespace AIStudio.Wpf.DiagramDesigner
return;
}
System.Diagnostics.Process.Start(Icon);
if (!string.IsNullOrEmpty(Icon))
{
System.Diagnostics.Process.Start(Icon);
}
}
public void InitWidthAndHeight()

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;