首次提交:本地项目同步到Gitea
This commit is contained in:
37
LibShapes/Core/State/ChangeStrategy/IChangeStrategy.cs
Normal file
37
LibShapes/Core/State/ChangeStrategy/IChangeStrategy.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Io.Github.Kerwinxu.LibShapes.Core.Shape;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Io.Github.Kerwinxu.LibShapes.Core.State.ChangeStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// 更改策略
|
||||
/// </summary>
|
||||
interface IChangeStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否合适这个策略
|
||||
/// </summary>
|
||||
/// <param name="pointFs"></param>
|
||||
/// <param name="start_pointF"></param>
|
||||
/// <returns></returns>
|
||||
bool isRight(PointF [] pointFs, PointF start_pointF);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 这个策略的执行,
|
||||
/// </summary>
|
||||
/// <param name="shape"></param>
|
||||
void action(ShapeEle shape, PointF start_pointF, PointF end_pointF);
|
||||
|
||||
/// <summary>
|
||||
/// 更改成的鼠标样式
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Cursor changeCursor();
|
||||
}
|
||||
}
|
||||
39
LibShapes/Core/State/ChangeStrategy/MoveMode.cs
Normal file
39
LibShapes/Core/State/ChangeStrategy/MoveMode.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Io.Github.Kerwinxu.LibShapes.Core.Shape;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Io.Github.Kerwinxu.LibShapes.Core.State.ChangeStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// 移动
|
||||
/// </summary>
|
||||
public class MoveMode : IChangeStrategy
|
||||
{
|
||||
public void action(ShapeEle shape, PointF start_pointF, PointF end_pointF)
|
||||
{
|
||||
// 这个是更改xy的
|
||||
RectangleF rect = new RectangleF() {
|
||||
X = end_pointF.X-start_pointF.X,
|
||||
Y = end_pointF.Y - start_pointF.Y
|
||||
};
|
||||
shape.Change(rect);
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Cursor changeCursor()
|
||||
{
|
||||
return Cursors.Hand;
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool isRight(PointF[] pointFs, PointF start_pointF)
|
||||
{
|
||||
return true;// 一般是最后一项。
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
45
LibShapes/Core/State/ChangeStrategy/ResizeModeEast.cs
Normal file
45
LibShapes/Core/State/ChangeStrategy/ResizeModeEast.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Io.Github.Kerwinxu.LibShapes.Core.Shape;
|
||||
using Io.Github.Kerwinxu.LibShapes.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Io.Github.Kerwinxu.LibShapes.Core.State.ChangeStrategy
|
||||
{
|
||||
public class ResizeModeEast : IChangeStrategy
|
||||
{
|
||||
public void action(ShapeEle shape, PointF start_pointF, PointF end_pointF)
|
||||
{
|
||||
// 右边的话,是更改x,或者width,
|
||||
RectangleF rect = new RectangleF();
|
||||
var diff = end_pointF.X - start_pointF.X;
|
||||
if (shape.Width < 0)
|
||||
{
|
||||
rect.X = diff;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.Width = diff;
|
||||
}
|
||||
shape.Change(rect);
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Cursor changeCursor()
|
||||
{
|
||||
return Cursors.PanEast;
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool isRight(PointF[] pointFs, PointF start_pointF)
|
||||
{
|
||||
// 判断一句是跟右边的线足够的近。
|
||||
return DistanceCalculation.pointToLine(start_pointF, pointFs[1], pointFs[2]) <= DistanceCalculation.select_tolerance;
|
||||
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
54
LibShapes/Core/State/ChangeStrategy/ResizeModeNorth.cs
Normal file
54
LibShapes/Core/State/ChangeStrategy/ResizeModeNorth.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using Io.Github.Kerwinxu.LibShapes.Core.Shape;
|
||||
using Io.Github.Kerwinxu.LibShapes.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Io.Github.Kerwinxu.LibShapes.Core.State.ChangeStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// 北方更改大小
|
||||
/// </summary>
|
||||
public class ResizeModeNorth : IChangeStrategy
|
||||
{
|
||||
public void action(ShapeEle shape, PointF start_pointF, PointF end_pointF)
|
||||
{
|
||||
// 右边的话,是更改x,或者width,
|
||||
RectangleF rect = new RectangleF();
|
||||
var diff = end_pointF.Y - start_pointF.Y;
|
||||
if (shape.Height < 0)
|
||||
{
|
||||
rect.Height = -diff;
|
||||
rect.Height = diff;
|
||||
Trace.WriteLine($"修改h:{rect}");
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.Y = diff;
|
||||
rect.Height = -diff;
|
||||
Trace.WriteLine($"修改y:{rect}");
|
||||
}
|
||||
shape.Change(rect);
|
||||
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Cursor changeCursor()
|
||||
{
|
||||
return Cursors.PanNorth;
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool isRight(PointF[] pointFs, PointF start_pointF)
|
||||
{
|
||||
|
||||
return DistanceCalculation.pointToLine(start_pointF, pointFs[0], pointFs[1]) <= DistanceCalculation.select_tolerance;
|
||||
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
59
LibShapes/Core/State/ChangeStrategy/ResizeModeNorthEast.cs
Normal file
59
LibShapes/Core/State/ChangeStrategy/ResizeModeNorthEast.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using Io.Github.Kerwinxu.LibShapes.Core.Shape;
|
||||
using Io.Github.Kerwinxu.LibShapes.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Io.Github.Kerwinxu.LibShapes.Core.State.ChangeStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// 东北方向更改
|
||||
/// </summary>
|
||||
public class ResizeModeNorthEast : IChangeStrategy
|
||||
{
|
||||
public void action(ShapeEle shape, PointF start_pointF, PointF end_pointF)
|
||||
{
|
||||
RectangleF rect = new RectangleF();
|
||||
var diffx = end_pointF.X - start_pointF.X;
|
||||
var diffy = end_pointF.Y - start_pointF.Y;
|
||||
if (shape.Width < 0)
|
||||
{
|
||||
rect.X = diffx;
|
||||
rect.Width = -diffx;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.Width = diffx;
|
||||
}
|
||||
|
||||
if (shape.Height < 0)
|
||||
{
|
||||
rect.Y = -diffy;
|
||||
rect.Height = diffy;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.Y = diffy;
|
||||
rect.Height = -diffy;
|
||||
}
|
||||
Trace.WriteLine($"更改:{rect}");
|
||||
shape.Change(rect);
|
||||
}
|
||||
|
||||
public Cursor changeCursor()
|
||||
{
|
||||
return Cursors.PanNE;
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool isRight(PointF[] pointFs, PointF start_pointF)
|
||||
{
|
||||
return DistanceCalculation.distance(start_pointF, pointFs[1]) <= DistanceCalculation.select_tolerance * 2;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
54
LibShapes/Core/State/ChangeStrategy/ResizeModeNorthWest.cs
Normal file
54
LibShapes/Core/State/ChangeStrategy/ResizeModeNorthWest.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using Io.Github.Kerwinxu.LibShapes.Core.Shape;
|
||||
using Io.Github.Kerwinxu.LibShapes.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Io.Github.Kerwinxu.LibShapes.Core.State.ChangeStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// 西北
|
||||
/// </summary>
|
||||
public class ResizeModeNorthWest : IChangeStrategy
|
||||
{
|
||||
public void action(ShapeEle shape, PointF start_pointF, PointF end_pointF)
|
||||
{
|
||||
RectangleF rect = new RectangleF();
|
||||
var diffx = end_pointF.X - start_pointF.X;
|
||||
var diffy = end_pointF.Y - start_pointF.Y;
|
||||
if (shape.Width < 0)
|
||||
{
|
||||
rect.Width = -diffx;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.X = diffx;
|
||||
rect.Width = -diffx;
|
||||
}
|
||||
if (shape.Height < 0)
|
||||
{
|
||||
rect.Height = -diffy;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.Y = diffy;
|
||||
rect.Height = -diffy;
|
||||
}
|
||||
shape.Change(rect);
|
||||
}
|
||||
|
||||
public Cursor changeCursor()
|
||||
{
|
||||
return Cursors.PanNW;
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool isRight(PointF[] pointFs, PointF start_pointF)
|
||||
{
|
||||
return DistanceCalculation.distance(start_pointF, pointFs[0]) <= DistanceCalculation.select_tolerance * 2 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
53
LibShapes/Core/State/ChangeStrategy/ResizeModeSorthWest.cs
Normal file
53
LibShapes/Core/State/ChangeStrategy/ResizeModeSorthWest.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using Io.Github.Kerwinxu.LibShapes.Core.Shape;
|
||||
using Io.Github.Kerwinxu.LibShapes.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Io.Github.Kerwinxu.LibShapes.Core.State.ChangeStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// 西南
|
||||
/// </summary>
|
||||
public class ResizeModeSorthWest : IChangeStrategy
|
||||
{
|
||||
public void action(ShapeEle shape, PointF start_pointF, PointF end_pointF)
|
||||
{
|
||||
RectangleF rect = new RectangleF();
|
||||
var diffx = end_pointF.X - start_pointF.X;
|
||||
var diffy = end_pointF.Y - start_pointF.Y;
|
||||
if (shape.Width < 0)
|
||||
{
|
||||
rect.Width = -diffx;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.X = diffx;
|
||||
rect.Width = -diffx;
|
||||
}
|
||||
if (shape.Height < 0)
|
||||
{
|
||||
rect.Y = diffy;
|
||||
rect.Height = -diffy;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.Height = diffy;
|
||||
}
|
||||
shape.Change(rect);
|
||||
}
|
||||
|
||||
public Cursor changeCursor()
|
||||
{
|
||||
return Cursors.PanSW;
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
public bool isRight(PointF[] pointFs, PointF start_pointF)
|
||||
{
|
||||
return DistanceCalculation.distance(start_pointF, pointFs[3]) <= DistanceCalculation.select_tolerance * 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
44
LibShapes/Core/State/ChangeStrategy/ResizeModeSouth.cs
Normal file
44
LibShapes/Core/State/ChangeStrategy/ResizeModeSouth.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Io.Github.Kerwinxu.LibShapes.Core.Shape;
|
||||
using Io.Github.Kerwinxu.LibShapes.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Io.Github.Kerwinxu.LibShapes.Core.State.ChangeStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// 南方更改
|
||||
/// </summary>
|
||||
public class ResizeModeSouth : IChangeStrategy
|
||||
{
|
||||
public void action(ShapeEle shape, PointF start_pointF, PointF end_pointF)
|
||||
{
|
||||
// 右边的话,是更改x,或者width,
|
||||
RectangleF rect = new RectangleF();
|
||||
var diff = end_pointF.Y - start_pointF.Y;
|
||||
if (shape.Height < 0)
|
||||
{
|
||||
rect.Y = diff;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.Height = diff;
|
||||
}
|
||||
shape.Change(rect);
|
||||
}
|
||||
|
||||
public Cursor changeCursor()
|
||||
{
|
||||
return Cursors.PanSouth;
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool isRight(PointF[] pointFs, PointF start_pointF)
|
||||
{
|
||||
return DistanceCalculation.pointToLine(start_pointF, pointFs[2], pointFs[3]) <= DistanceCalculation.select_tolerance;
|
||||
}
|
||||
}
|
||||
}
|
||||
52
LibShapes/Core/State/ChangeStrategy/ResizeModeSouthEast.cs
Normal file
52
LibShapes/Core/State/ChangeStrategy/ResizeModeSouthEast.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Io.Github.Kerwinxu.LibShapes.Core.Shape;
|
||||
using Io.Github.Kerwinxu.LibShapes.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Io.Github.Kerwinxu.LibShapes.Core.State.ChangeStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// 东南方向更改
|
||||
/// </summary>
|
||||
public class ResizeModeSouthEast : IChangeStrategy
|
||||
{
|
||||
public void action(ShapeEle shape, PointF start_pointF, PointF end_pointF)
|
||||
{
|
||||
RectangleF rect = new RectangleF();
|
||||
var diffx = end_pointF.X - start_pointF.X;
|
||||
var diffy = end_pointF.Y - start_pointF.Y;
|
||||
if (shape.Width < 0)
|
||||
{
|
||||
rect.X = diffx;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.Width = diffx;
|
||||
}
|
||||
if (shape.Height < 0)
|
||||
{
|
||||
rect.Y = diffy;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.Height = diffy;
|
||||
}
|
||||
shape.Change(rect);
|
||||
}
|
||||
|
||||
public Cursor changeCursor()
|
||||
{
|
||||
return Cursors.PanSE;
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool isRight(PointF[] pointFs, PointF start_pointF)
|
||||
{
|
||||
return DistanceCalculation.distance(start_pointF, pointFs[2]) <= DistanceCalculation.select_tolerance * 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
42
LibShapes/Core/State/ChangeStrategy/ResizeModeWest.cs
Normal file
42
LibShapes/Core/State/ChangeStrategy/ResizeModeWest.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Io.Github.Kerwinxu.LibShapes.Core.Shape;
|
||||
using Io.Github.Kerwinxu.LibShapes.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Io.Github.Kerwinxu.LibShapes.Core.State.ChangeStrategy
|
||||
{
|
||||
public class ResizeModeWest : IChangeStrategy
|
||||
{
|
||||
public void action(ShapeEle shape, PointF start_pointF, PointF end_pointF)
|
||||
{
|
||||
// 右边的话,是更改x,或者width,
|
||||
RectangleF rect = new RectangleF();
|
||||
var diff = end_pointF.X - start_pointF.X;
|
||||
if (shape.Width < 0)
|
||||
{
|
||||
rect.Width = -diff;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.X = diff;
|
||||
rect.Width = -diff;
|
||||
}
|
||||
shape.Change(rect);
|
||||
}
|
||||
|
||||
public Cursor changeCursor()
|
||||
{
|
||||
return Cursors.PanWest;
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool isRight(PointF[] pointFs, PointF start_pointF)
|
||||
{
|
||||
return DistanceCalculation.pointToLine(start_pointF, pointFs[0], pointFs[3]) <= DistanceCalculation.select_tolerance;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user