200 lines
4.5 KiB
C#
200 lines
4.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using static DH.Commons.Enums.EnumHelper;
|
|
|
|
|
|
namespace DH.UI.Model.Winform
|
|
{
|
|
//public static class AOIEnumHelper
|
|
//{
|
|
// public enum ElementState
|
|
// {
|
|
// New = 1,
|
|
// MouseHover = 2,
|
|
// MouseInSide = 3,
|
|
// Selected = 4,
|
|
// Moving = 5,
|
|
|
|
// Normal = 11,
|
|
|
|
// Measuring = 21,
|
|
// MeasureDoneOK = 22,
|
|
// MeasureDoneNG = 23,
|
|
// }
|
|
|
|
// public enum MouseState
|
|
// {
|
|
// Normal = 1,
|
|
// HoverElement = 2,
|
|
// InSideElement = 3,
|
|
|
|
// StretchingLeft = 11,
|
|
// StretchingRight = 12,
|
|
// StretchingUp = 13,
|
|
// StretchingDown = 14,
|
|
// MoveElement = 15,
|
|
|
|
// New = 21,
|
|
// Editing = 22,
|
|
// SelectedElement = 23,
|
|
|
|
// MovingAll = 31,
|
|
|
|
// SelectionZone = 41,
|
|
// SelectionZoneDoing = 42,
|
|
// }
|
|
|
|
// public enum RunMode
|
|
// {
|
|
// [Description("设置模式")]
|
|
// SetMode = 0,
|
|
// [Description("运行模式")]
|
|
// RunMode = 1,
|
|
// }
|
|
//}
|
|
|
|
public static class EventRouter
|
|
{
|
|
/// <summary>
|
|
/// ElementBase 基元
|
|
/// 1st MouseState 初始状态
|
|
/// 2nd MouseState 变化状态
|
|
/// </summary>
|
|
public static event Action<ElementBase, ElementState, ElementState> ChangeElementsMouseState;
|
|
|
|
public static void TriggerElementsMouseStateChanged(ElementBase ele, ElementState preState, ElementState curState)
|
|
{
|
|
ChangeElementsMouseState?.Invoke(ele, preState, curState);
|
|
}
|
|
}
|
|
|
|
public class NoticedPoints : List<PointF>
|
|
{
|
|
public Action OnItemChanged;
|
|
|
|
public NoticedPoints() { }
|
|
|
|
public NoticedPoints(List<PointF> points)
|
|
{
|
|
AddRange(points);
|
|
}
|
|
|
|
public new PointF this[int index]
|
|
{
|
|
get
|
|
{
|
|
if (index >= 0 && index < Count)
|
|
{
|
|
return base[index];
|
|
}
|
|
else
|
|
{
|
|
return new Point();
|
|
}
|
|
|
|
}
|
|
set
|
|
{
|
|
if (base[index] != value)
|
|
{
|
|
base[index] = value;
|
|
OnItemChanged?.Invoke();
|
|
}
|
|
}
|
|
}
|
|
|
|
public new void Add(PointF item)
|
|
{
|
|
lock (this)
|
|
{
|
|
base.Add(item);
|
|
OnItemChanged?.Invoke();
|
|
}
|
|
}
|
|
|
|
public new void AddRange(IEnumerable<PointF> collection)
|
|
{
|
|
lock (this)
|
|
{
|
|
base.AddRange(collection);
|
|
OnItemChanged?.Invoke();
|
|
}
|
|
}
|
|
|
|
public new void Clear()
|
|
{
|
|
lock (this)
|
|
{
|
|
base.Clear();
|
|
OnItemChanged?.Invoke();
|
|
}
|
|
}
|
|
|
|
public new void Insert(int index, PointF item)
|
|
{
|
|
lock (this)
|
|
{
|
|
base.Insert(index, item);
|
|
OnItemChanged?.Invoke();
|
|
}
|
|
}
|
|
|
|
public new void InsertRange(int index, IEnumerable<PointF> collection)
|
|
{
|
|
lock (this)
|
|
{
|
|
base.InsertRange(index, collection);
|
|
OnItemChanged?.Invoke();
|
|
}
|
|
}
|
|
|
|
public new bool Remove(PointF item)
|
|
{
|
|
lock (this)
|
|
{
|
|
bool flag = base.Remove(item);
|
|
|
|
if (flag)
|
|
{
|
|
OnItemChanged?.Invoke();
|
|
}
|
|
|
|
return flag;
|
|
}
|
|
}
|
|
|
|
public new int RemoveAll(Predicate<PointF> match)
|
|
{
|
|
lock (this)
|
|
{
|
|
int i = base.RemoveAll(match);
|
|
if (i > 0)
|
|
{
|
|
OnItemChanged?.Invoke();
|
|
}
|
|
|
|
return i;
|
|
}
|
|
}
|
|
|
|
public new void RemoveAt(int index)
|
|
{
|
|
lock (this)
|
|
{
|
|
base.RemoveAt(index);
|
|
OnItemChanged?.Invoke();
|
|
}
|
|
}
|
|
|
|
public new void RemoveRange(int index, int count)
|
|
{
|
|
lock (this)
|
|
{
|
|
base.RemoveRange(index, count);
|
|
OnItemChanged?.Invoke();
|
|
}
|
|
}
|
|
}
|
|
}
|