Esempio n. 1
0
        private static void AlignPointSegment(GenericPosture posture, GenericPostureImpactLineAlign impact)
        {
            if (impact == null)
            {
                return;
            }

            PointF start = posture.PointList[impact.Start];
            PointF end   = posture.PointList[impact.End];

            if (start == end)
            {
                posture.PointList[impact.PointToAlign] = start;
                return;
            }

            PointF result = GeometryHelper.GetClosestPoint(start, end, posture.PointList[impact.PointToAlign], PointLinePosition.Anywhere, 10);

            posture.PointList[impact.PointToAlign] = result;
        }
        private void ParseImpacts(XmlReader r)
        {
            r.ReadStartElement();

            while (r.NodeType == XmlNodeType.Element)
            {
                if (r.Name == "Align")
                {
                    GenericPostureImpactLineAlign impact = new GenericPostureImpactLineAlign(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else if (r.Name == "VerticalAlign")
                {
                    GenericPostureImpactVerticalAlign impact = new GenericPostureImpactVerticalAlign(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else if (r.Name == "HorizontalAlign")
                {
                    GenericPostureImpactHorizontalAlign impact = new GenericPostureImpactHorizontalAlign(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else if (r.Name == "Pivot")
                {
                    GenericPostureImpactPivot impact = new GenericPostureImpactPivot(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else if (r.Name == "KeepAngle")
                {
                    GenericPostureImpactKeepAngle impact = new GenericPostureImpactKeepAngle(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else if (r.Name == "HorizontalSymmetry")
                {
                    GenericPostureImpactHorizontalSymmetry impact = new GenericPostureImpactHorizontalSymmetry(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else if (r.Name == "SegmentCenter")
                {
                    GenericPostureImpactSegmentCenter impact = new GenericPostureImpactSegmentCenter(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else if (r.Name == "PerdpendicularAlign")
                {
                    GenericPosturePerpendicularAlign impact = new GenericPosturePerpendicularAlign(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else if (r.Name == "ParallelAlign")
                {
                    GenericPostureParallelAlign impact = new GenericPostureParallelAlign(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else
                {
                    string outerXml = r.ReadOuterXml();
                    log.DebugFormat("Unparsed content in XML: {0}", outerXml);
                }
            }

            r.ReadEndElement();
        }