2023-05-07 23:01:38 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
|
|
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner
|
|
|
|
|
|
{
|
|
|
|
|
|
public class PolylineDrawingDesignerItemViewModel : DrawingDesignerItemViewModelBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public PolylineDrawingDesignerItemViewModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public PolylineDrawingDesignerItemViewModel(IDiagramViewModel root) : base(root)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-11 10:57:08 +08:00
|
|
|
|
public PolylineDrawingDesignerItemViewModel(IDiagramViewModel root, Point startPoint, bool erasable) : base(root, DrawMode.ErasableLine, startPoint, erasable)
|
2023-05-07 23:01:38 +08:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-11 10:57:08 +08:00
|
|
|
|
public PolylineDrawingDesignerItemViewModel(IDiagramViewModel root, List<Point> points, bool erasable) : base(root, DrawMode.ErasableLine, points, erasable)
|
2023-05-07 23:01:38 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool OnMouseMove(IInputElement sender, MouseEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.LeftButton == MouseButtonState.Pressed)
|
|
|
|
|
|
{
|
|
|
|
|
|
var point = e.GetPosition(sender);
|
|
|
|
|
|
if (Points == null || Points.Count == 0)//没有起始点
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((Points.LastOrDefault() - point).Length < ColorViewModel.LineWidth)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Points.Add(point);
|
|
|
|
|
|
|
|
|
|
|
|
if (Geometry is PathGeometry geometry)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
geometry = new PathGeometry();
|
|
|
|
|
|
var figure = new PathFigure { StartPoint = Points[0] };
|
|
|
|
|
|
geometry.Figures.Add(figure);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LineSegment arc = new LineSegment(point, true);// { IsSmoothJoin = true };
|
|
|
|
|
|
geometry.Figures[0].Segments.Add(arc);
|
|
|
|
|
|
Geometry = geometry;
|
|
|
|
|
|
|
|
|
|
|
|
IsFinish = true;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool OnMouseDown(IInputElement sender, MouseButtonEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool OnMouseUp(IInputElement sender, MouseButtonEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
return base.OnMouseUp(sender, e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|