123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- using OTSCLRINTERFACE;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml;
- namespace OTSDataType
- {
- public class CHole : CDomain
- {
- private string m_strName;
- public CHole()
- {
- Init();
- // initialization
- m_strName = "";
- }
- public void Duplicate(CHole a_oSource)
- {
- // initialization
- base.Init();
- // base class duplication
- base.Duplicate(a_oSource);
- // copy data over
- m_strName = a_oSource.m_strName;
- }
- public CHole(string a_strName, otsdataconst.DOMAIN_SHAPE a_nShape, Rectangle a_rectDomain)
- {
- // initialization
- Init();
- // assign class members
- m_strName = a_strName;
- m_nShape = a_nShape;
- m_rectangle = a_rectDomain;
- }
- public CHole(string a_strName, CDomain cDomain)
- {
- // initialization
- Init();
- // assign class members
- m_strName = a_strName;
- m_nShape = cDomain.GetShape();
- var r = cDomain.GetRectDomain();
- m_rectangle = new Rectangle(new Point((int)r.X,(int)r.Y),new Size((int)r.Width,(int)r.Height));
- //myDomainClr = new CDomainClr((int)cDomain.GetShape(), cDomain.GetRectDomain());
- }
- public string GetName() { return m_strName; }
- // copy constructor
- public CHole(CHole a_oSource)
- {
- // copy data over
- Duplicate(a_oSource);
- }
- // public Rectangle GetRectDomain() { return null; }
- public bool equals(CHole a_oSource)
- {
- return m_strName == a_oSource.m_strName && m_nShape == a_oSource.m_nShape && m_rectangle == a_oSource.m_rectangle;
- }
- public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
- {
- Slo slo = new Slo();
- xInt xnShape = new xInt();
- xRect xRecDomain = new xRect();
- xString xnstrName = new xString();
- slo.Register("HoleName", xnstrName);
- slo.Register("shape", xnShape);
- slo.Register("rectDomian", xRecDomain);
- if (isStoring)
- {
- xnstrName.AssignValue(m_strName);
- xnShape.AssignValue((int)m_nShape);
- //we have to save the rectangle parameter according to the previouse rule.(left,top,width,height or centerX centerY,diamiter,0)
- System.Drawing.RectangleF rect = new System.Drawing.Rectangle();
- rect.X = m_rectangle.X;
- rect.Y = m_rectangle.Y;
- rect.Width = m_rectangle.Width;
- rect.Height = m_rectangle.Height;
- xRecDomain.AssignValue(rect, (int)m_nShape);
- slo.Serialize(true, classDoc, rootNode);
- }
- else
- {
- slo.Serialize(false, classDoc, rootNode);
- m_strName = xnstrName.value();
- m_nShape = (otsdataconst.DOMAIN_SHAPE)xnShape.value();
- List<string> rectDomain = xRecDomain.toString().Split(',').ToList();
- m_rectangle = new Rectangle(Convert.ToInt32(rectDomain[0]), Convert.ToInt32(rectDomain[1]), 0, 0);
- //do the regulation
- float nCentreX = m_rectangle.Left;
- float nCentreY = m_rectangle.Top;
- float nWidth;
- float nHeight;
- int nDiameter;
- if (m_nShape == otsdataconst.DOMAIN_SHAPE.ROUND)
- {
- nDiameter = Convert.ToInt32(rectDomain[2]);
- // create domain
- m_rectangle = new Rectangle(0, 0, nDiameter, nDiameter);
- OffsetDomain(new PointF(nCentreX - (nDiameter / 2), nCentreY - (nDiameter / 2)));
- }
- else if (m_nShape == otsdataconst.DOMAIN_SHAPE.RECTANGLE)
- {
- nWidth = m_rectangle.Right;
- nHeight = m_rectangle.Bottom;
- m_rectangle = new Rectangle(0, 0, (int)nWidth, (int)nHeight);
- OffsetDomain(new PointF(nCentreX - (nWidth / 2), nCentreY - (nHeight / 2)));
- }
- }
- }
- }
- }
|