Exemplo n.º 1
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            if (ParentBond.OrderValue == 1.5)
            {
                Point point1, point2, point3, point4;

                Point?centroid = null;
                if (ParentBond.IsCyclic())
                {
                    centroid = ParentBond.PrimaryRing?.Centroid;
                }
                _enclosingPoly = BondGeometry.GetDoubleBondPoints(StartPoint.Value, EndPoint.Value,
                                                                  Placement, centroid, out point1,
                                                                  out point2, out point3, out point4);
                Pen solidPen = new Pen(Fill, StrokeThickness);

                Pen dashedPen = solidPen.Clone();

                dashedPen.DashStyle = DashStyles.Dash;

                drawingContext.DrawLine(solidPen, point1, point2);
                drawingContext.DrawLine(dashedPen, point3, point4);

                //drawingContext.Close();
            }
            else
            {
                base.OnRender(drawingContext);
            }
        }
Exemplo n.º 2
0
        public System.Windows.Media.Geometry GetBondGeometry(Point?startPoint, Point?endPoint)
        {
            //Vector startOffset = new Vector();
            //Vector endOffset = new Vector();

            if (startPoint != null & endPoint != null)
            {
                //check to see if it's a wedge or a hatch yet
                if (ParentBond.Stereo == BondStereo.Wedge | ParentBond.Stereo == BondStereo.Hatch)
                {
                    return(BondGeometry.WedgeBondGeometry(startPoint.Value, endPoint.Value));
                }

                if (ParentBond.Stereo == BondStereo.Indeterminate && ParentBond.OrderValue == 1.0)
                {
                    return(BondGeometry.WavyBondGeometry(startPoint.Value, endPoint.Value));
                }

                //single or dotted bond
                if (ParentBond.OrderValue <= 1)
                {
                    return(BondGeometry.SingleBondGeometry(startPoint.Value, endPoint.Value));
                }
                if (ParentBond.OrderValue == 1.5)
                {
                    //it's a resonance bond, so we deal with this in OnRender
                    //return BondGeometry.SingleBondGeometry(startPoint.Value, endPoint.Value);
                    return(new StreamGeometry());
                }

                //double bond
                if (ParentBond.OrderValue == 2)
                {
                    if (ParentBond.Stereo == BondStereo.Indeterminate)
                    {
                        return(BondGeometry.CrossedDoubleGeometry(startPoint.Value, endPoint.Value, ref _enclosingPoly));
                    }
                    Point?centroid = null;
                    if (ParentBond.IsCyclic())
                    {
                        centroid = ParentBond.PrimaryRing?.Centroid;
                    }
                    return(BondGeometry.DoubleBondGeometry(startPoint.Value, endPoint.Value, Placement,
                                                           ref _enclosingPoly, centroid));
                }
                //tripe bond
                if (ParentBond.OrderValue == 3)
                {
                    return(BondGeometry.TripleBondGeometry(startPoint.Value, endPoint.Value, ref _enclosingPoly));
                }

                return(null);
            }

            return(null);
        }