123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- /**
- *
- * @author seagle
- * @date 2024-7-22
- * @Description 管路图元件对象封装
- */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MECF.Framework.UI.Core.DxfScript
- {
- public class GasButton : GasBaseShape
- {
- public GasPolyLine InnerPolyLine { get; set; } = null;
- public GasText InnerText { get; set; } = null;
- public string Text { get; set; }
- public string DataKey { get; set; }
- public GasButton(GasPolyLine polyLine,GasText text)
- {
- InnerPolyLine = polyLine;
- InnerText = text;
- //按上、右、下、左的顺序排线段
- GasLine topLine = null;
- GasLine rightLine = null;
- GasLine bottomLine = null;
- GasLine leftLine = null;
- foreach(GasLine line in InnerPolyLine.InnerLines)
- {
- if (line.IsHorizental)
- {
- if (topLine == null)
- {
- topLine = line;
- }
- else
- {
- if (line.Y1 > topLine.Y1)
- {
- bottomLine = topLine;
- topLine = line;
- }
- else
- {
- bottomLine = line;
- }
- }
- }
- else
- {
- //矩形,这里肯定就是竖线了
- if (rightLine == null)
- {
- rightLine = line;
- }
- else
- {
- if (line.X1 > rightLine.X1)
- {
- leftLine = rightLine;
- rightLine = line;
- }
- else
- {
- leftLine = line;
- }
- }
- }
- }
- InnerPolyLine.InnerLines.Clear();
- InnerPolyLine.InnerLines.Add(topLine);
- InnerPolyLine.InnerLines.Add(rightLine);
- InnerPolyLine.InnerLines.Add(bottomLine);
- InnerPolyLine.InnerLines.Add(leftLine);
- Id = InnerPolyLine.Id;
- SetDataKey();
- }
- public override bool Contains(double x, double y)
- {
- return InnerPolyLine.Contains(x, y);
- }
- public override void Move(double x, double y)
- {
- InnerPolyLine.Move(x, y);
- InnerText.Move(x, y);
- }
- private void SetDataKey()
- {
- DataKey = $"PM1.{InnerText.Text}Enable";
- }
- }
- }
|