using System; using System.ComponentModel; using System.Drawing; using Newtonsoft.Json; namespace AGVNavigationCore.Models { /// /// 맵 상의 마그넷(Magnet) 정보를 나타내는 클래스 /// public class MapMagnet : NodeBase { public MapMagnet() { Type = NodeType.Magnet; } [Category("위치 정보")] [Description("시작점 좌표")] public MagnetPoint P1 { get; set; } = new MagnetPoint(); [Category("위치 정보")] [Description("끝점 좌표")] public MagnetPoint P2 { get; set; } = new MagnetPoint(); [Category("위치 정보")] [Description("제어점 좌표 (곡선인 경우)")] public MagnetPoint ControlPoint { get; set; } = null; public class MagnetPoint { public double X { get; set; } public double Y { get; set; } } [JsonIgnore] public override Point Position { get => new Point((int)P1.X, (int)P1.Y); set { double dx = value.X - P1.X; double dy = value.Y - P1.Y; P1.X += dx; P1.Y += dy; P2.X += dx; P2.Y += dy; if (ControlPoint != null) { ControlPoint.X += dx; ControlPoint.Y += dy; } } } /// /// 시작점 Point 반환 /// [Browsable(false)] [JsonIgnore] public Point StartPoint => new Point((int)P1.X, (int)P1.Y); /// /// 끝점 Point 반환 /// [Browsable(false)] [JsonIgnore] public Point EndPoint => new Point((int)P2.X, (int)P2.Y); } }