使用PointBase代替Point

This commit is contained in:
艾竹
2023-01-08 09:22:37 +08:00
parent 8fc69bc96d
commit 5d7717cc2b
65 changed files with 4317 additions and 403 deletions

View File

@@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
namespace AIStudio.Wpf.DiagramDesigner
{
public struct ConnectorInfo
{
public double DesignerItemLeft { get; set; }
public double DesignerItemTop { get; set; }
public Size DesignerItemSize { get; set; }
public Point Position { get; set; }
public ConnectorOrientation Orientation { get; set; }
}
}

View File

@@ -0,0 +1,10 @@
using System;
namespace AIStudio.Wpf.DiagramDesigner
{
public static class DoubleExtensions
{
public static bool AlmostEqualTo(this double double1, double double2, double tolerance = 0.0001)
=> Math.Abs(double1 - double2) < tolerance;
}
}

View File

@@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
namespace AIStudio.Wpf.DiagramDesigner
{
// Wraps info of the dragged object into a class
public class DragObject
{
public Size? DesiredSize { get; set; }
public Type ContentType { get; set; }
public string Icon { get; set; }
public IColorViewModel ColorViewModel { get; set; }
public DesignerItemBase DesignerItem { get; set; }
}
}

View File

@@ -1,25 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace AIStudio.Wpf.DiagramDesigner
{
public class EventToCommandArgs
{
public Object Sender { get; private set; }
public ICommand CommandRan { get; private set; }
public Object CommandParameter { get; private set; }
public EventArgs EventArgs { get; private set; }
public EventToCommandArgs(Object sender, ICommand commandRan, Object commandParameter, EventArgs eventArgs)
{
this.Sender = sender;
this.CommandRan = commandRan;
this.CommandParameter = commandParameter;
this.EventArgs = eventArgs;
}
}
}

View File

@@ -0,0 +1,9 @@
using System.Globalization;
namespace AIStudio.Wpf.DiagramDesigner
{
public static class NumberExtensions
{
public static string ToInvariantString(this double n) => n.ToString(CultureInfo.InvariantCulture);
}
}

View File

@@ -1,23 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using AIStudio.Wpf.DiagramDesigner.Geometry;
namespace AIStudio.Wpf.DiagramDesigner
{
public class PointHelper
{
public static Point GetPointForConnector(FullyCreatedConnectorInfo connector)
public static PointBase GetPointForConnector(FullyCreatedConnectorInfo connector)
{
Point point = new Point();
PointBase point = new PointBase();
if (connector == null)
{
return point;
}
if (connector.IsInnerPoint)
{
point = new Point(connector.DataItem.Left + connector.DataItem.ItemWidth * connector.XRatio,
point = new PointBase(connector.DataItem.Left + connector.DataItem.ItemWidth * connector.XRatio,
connector.DataItem.Top + connector.DataItem.ItemHeight * connector.YRatio);
}
else
@@ -26,16 +23,16 @@ namespace AIStudio.Wpf.DiagramDesigner
switch (connector.Orientation)
{
case ConnectorOrientation.Top:
point = new Point(connector.DataItem.Left + (connector.DataItem.ItemWidth / 2), connector.DataItem.Top);
point = new PointBase(connector.DataItem.Left + (connector.DataItem.ItemWidth / 2), connector.DataItem.Top);
break;
case ConnectorOrientation.Bottom:
point = new Point(connector.DataItem.Left + (connector.DataItem.ItemWidth / 2), (connector.DataItem.Top + connector.DataItem.ItemHeight));
point = new PointBase(connector.DataItem.Left + (connector.DataItem.ItemWidth / 2), (connector.DataItem.Top + connector.DataItem.ItemHeight));
break;
case ConnectorOrientation.Right:
point = new Point(connector.DataItem.Left + connector.DataItem.ItemWidth, connector.DataItem.Top + (connector.DataItem.ItemHeight / 2));
point = new PointBase(connector.DataItem.Left + connector.DataItem.ItemWidth, connector.DataItem.Top + (connector.DataItem.ItemHeight / 2));
break;
case ConnectorOrientation.Left:
point = new Point(connector.DataItem.Left, connector.DataItem.Top + (connector.DataItem.ItemHeight / 2));
point = new PointBase(connector.DataItem.Left, connector.DataItem.Top + (connector.DataItem.ItemHeight / 2));
break;
}
}

View File

@@ -1,32 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
namespace AIStudio.Wpf.DiagramDesigner.Helpers
{
public class ToolBoxData
{
public string Text { get; protected set; }
public string Icon { get; protected set; }
public Type Type { get; protected set; }
public IColorViewModel ColorViewModel { get; set; }
public double Width { get; set; }
public double Height { get; set; }
public Size? DesiredSize{ get; set; }
public object Addition { get; set; }
public ToolBoxData(string text, string icon, Type type, double width, double height, Size? desiredSize = null)
{
this.Text = text;
this.Icon = icon;
this.Type = type;
this.Width = width;
this.Height = height;
this.DesiredSize = desiredSize;
this.ColorViewModel = new ColorViewModel();
}
}
}