mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
选中状态代码整理
This commit is contained in:
@@ -25,7 +25,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
DrawMode = drawMode;
|
||||
Points = new List<Point> { startPoint };
|
||||
Erasable = erasable;
|
||||
DisableSelected = Erasable;
|
||||
if (Erasable)
|
||||
{
|
||||
if (Root?.DrawModeViewModel != null)
|
||||
@@ -75,7 +74,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
//this.Geometry.Transform = Transform.Parse(designer.Matrix.ToString());
|
||||
this.Points = designer.Points;
|
||||
this.DrawMode = designer.DrawMode;
|
||||
this.DisableSelected = Erasable;
|
||||
this.SelectedDisable = Erasable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,8 +92,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
if (IsFinish)
|
||||
{
|
||||
UpdateLocation();
|
||||
|
||||
if (Geometry != null)
|
||||
{
|
||||
if (Geometry.Transform is TransformGroup transformGroup)
|
||||
@@ -104,14 +101,16 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
transformGroup.Children.Add(new TranslateTransform(0 - Geometry.Bounds.Left, 0 - Geometry.Bounds.Top));
|
||||
}
|
||||
else
|
||||
Geometry.Transform = new TranslateTransform(0 - Left, 0 - Top);
|
||||
Geometry.Transform = new TranslateTransform(0 - Geometry.Bounds.Left, 0 - Geometry.Bounds.Top);
|
||||
|
||||
if (Erasable)
|
||||
{
|
||||
var aPen = new Pen(ColorViewModel.LineColor.ToBrush(), ColorViewModel.LineWidth);
|
||||
aPen.DashStyle = new DashStyle(StrokeDashArray.Dash[(int)ColorViewModel.LineDashStyle], 1);
|
||||
Geometry = Geometry.GetWidenedPathGeometry(aPen); //可擦除,需要把Geometry转成几何图像,所以不能有填充色
|
||||
|
||||
}
|
||||
UpdateLocation();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -180,10 +179,38 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
public void UpdateLocation()
|
||||
{
|
||||
ItemWidth = Geometry.Bounds.Width + ColorViewModel.LineWidth * 2;
|
||||
ItemHeight = Geometry.Bounds.Height + ColorViewModel.LineWidth * 2;
|
||||
Left = Geometry.Bounds.Left;
|
||||
Top = Geometry.Bounds.Top;
|
||||
if (Erasable)
|
||||
{
|
||||
ItemWidth = Geometry.Bounds.Width - ColorViewModel.LineWidth * 0.5;
|
||||
ItemHeight = Geometry.Bounds.Height - ColorViewModel.LineWidth * 0.5;
|
||||
Left = Points[0].X;
|
||||
Top = Points[0].Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemWidth = Geometry.Bounds.Width;
|
||||
ItemHeight = Geometry.Bounds.Height;
|
||||
Left = Points[0].X;
|
||||
Top = Points[0].Y;
|
||||
}
|
||||
}
|
||||
|
||||
public override void RemoveFromSelection()
|
||||
{
|
||||
if (Erasable == true)
|
||||
{
|
||||
this.SelectedDisable = true;
|
||||
}
|
||||
base.RemoveFromSelection();
|
||||
}
|
||||
|
||||
public override void AddToSelection(bool selected, bool clearother)
|
||||
{
|
||||
if (selected == true && _service.DrawModeViewModel.DrawingDrawMode == DrawMode.Select)
|
||||
{
|
||||
this.SelectedDisable = false;
|
||||
}
|
||||
base.AddToSelection(selected, clearother);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user