public override void Draw(System.Drawing.Graphics g)
        {
            System.Drawing.StringFormat format = new System.Drawing.StringFormat();
            format.Alignment     = this.m_HorizontalAlignment;
            format.LineAlignment = this.m_VerticalAlignment;
            System.Drawing.Drawing2D.GraphicsContainer gContainer = g.BeginContainer();
            System.Drawing.Drawing2D.Matrix            myMatrix   = g.Transform;
            float X = (float)this.X;
            float Y = (float)this.Y;

            if (m_Rotation != 0)
            {
                myMatrix.RotateAt((float)(m_Rotation), new System.Drawing.PointF(X, Y), System.Drawing.Drawing2D.MatrixOrder.Append);
                g.Transform = myMatrix;
            }
            if (m_AutoSize)
            {
                System.Drawing.SizeF mySize = g.MeasureString(m_Text, m_Font);
                m_Size.Width  = (int)mySize.Width;
                m_Size.Height = (int)mySize.Height;
                g.DrawString(m_Text, m_Font, new System.Drawing.SolidBrush(m_Color), X, Y, format);
            }
            else
            {
                System.Drawing.RectangleF rect = new System.Drawing.RectangleF(X, Y, (float)m_Size.Width, (float)m_Size.Height);
                g.DrawString(m_Text, m_Font, new System.Drawing.SolidBrush(m_Color), rect, format);
            }
            g.EndContainer(gContainer);
        }
Esempio n. 2
0
        public override void Draw(System.Drawing.Graphics g)
        {
            System.Drawing.Drawing2D.GraphicsContainer gContainer = g.BeginContainer();
            System.Drawing.Drawing2D.Matrix            myMatrix   = g.Transform;
            this.DetermineOffset();
            float X = (float)this.m_parentAtom.X;
            float Y = (float)this.m_parentAtom.Y;

            if (m_Rotation != 0)
            {
                myMatrix.RotateAt((float)(m_Rotation), new System.Drawing.PointF(X, Y), System.Drawing.Drawing2D.MatrixOrder.Append);
                g.Transform = myMatrix;
            }
            System.Drawing.Pen myPen = new System.Drawing.Pen(m_lineColor, (float)m_lineWidth);
            if (this.m_BondType == ChemInfo.BondType.Single || this.m_BondType == ChemInfo.BondType.Aromatic)
            {
                g.DrawLine(myPen, X, Y, m_connectedAtom.X, m_connectedAtom.Y);
            }
            if (this.m_BondType == ChemInfo.BondType.Double)
            {
                g.DrawLine(myPen, X + m_OffsetX, Y + m_OffsetY, m_connectedAtom.X + m_OffsetX, m_connectedAtom.Y + m_OffsetY);
                g.DrawLine(myPen, X - m_OffsetX, Y - m_OffsetY, m_connectedAtom.X - m_OffsetX, m_connectedAtom.Y - m_OffsetY);
            }
            if (this.m_BondType == ChemInfo.BondType.Triple)
            {
                g.DrawLine(myPen, X + m_OffsetX, Y + m_OffsetY, m_connectedAtom.X + m_OffsetX, m_connectedAtom.Y + m_OffsetY);
                g.DrawLine(myPen, X, Y, m_connectedAtom.X, m_connectedAtom.Y);
                g.DrawLine(myPen, X - m_OffsetX, Y - m_OffsetY, m_connectedAtom.X - m_OffsetX, m_connectedAtom.Y - m_OffsetY);
            }
            g.EndContainer(gContainer);
        }
        void Draw(System.Drawing.Graphics g, System.Drawing.Drawing2D.AdjustableArrowCap customStartCap, System.Drawing.Drawing2D.AdjustableArrowCap customEndCap)
        {
            System.Drawing.Drawing2D.GraphicsContainer gContainer = g.BeginContainer();
            System.Drawing.Drawing2D.Matrix            myMatrix   = g.Transform;

            float X = (float)this.X;
            float Y = (float)this.Y;

            if (m_Rotation != 0)
            {
                myMatrix.RotateAt((float)m_Rotation, new System.Drawing.PointF(X, Y), System.Drawing.Drawing2D.MatrixOrder.Append);
                g.Transform = myMatrix;
            }
            System.Drawing.Pen myPen = new System.Drawing.Pen(m_lineColor, (float)m_lineWidth);

            // put startcaps and endcaps on lines
            if (customStartCap != null)
            {
                myPen.CustomStartCap = customStartCap;
            }
            if (customEndCap != null)
            {
                myPen.CustomEndCap = customEndCap;
            }

            g.DrawLine(myPen, X, Y, X + m_Size.Width, Y + m_Size.Height);
            g.EndContainer(gContainer);
        }
Esempio n. 4
0
 public void DrawObjects(System.Drawing.Graphics g, double Scale)
 {
     System.Drawing.Drawing2D.GraphicsContainer gCon = g.BeginContainer();
     System.Drawing.Drawing2D.Matrix myOriginalMatrix = g.Transform;
     g.PageUnit = System.Drawing.GraphicsUnit.Pixel;
     g.ScaleTransform((float)Scale, (float)Scale);
     foreach (GraphicObject obj in this)
     {
         obj.Draw(g);
     }
     g.EndContainer(gCon);
     g.Transform = myOriginalMatrix;
 }
Esempio n. 5
0
        public void DrawSelectedObject(System.Drawing.Graphics g, GraphicObject selectedObject, double Scale)
        {
            System.Drawing.Drawing2D.GraphicsContainer gCon1 = g.BeginContainer();
            g.ScaleTransform((float)Scale, (float)Scale, System.Drawing.Drawing2D.MatrixOrder.Append);
            System.Drawing.Drawing2D.GraphicsContainer gCon2 = g.BeginContainer();
            g.PageUnit = System.Drawing.GraphicsUnit.Pixel;

            if (selectedObject != null)
            {
                System.Drawing.Pen selectionPen = new System.Drawing.Pen(System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.HotTrack));
                selectionPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                selectionPen.Width = 1;

                if (selectedObject.Rotation != 0)
                {
                    System.Drawing.Drawing2D.Matrix myMatrix = g.Transform;
                    myMatrix.RotateAt((float)selectedObject.Rotation, new System.Drawing.PointF((float)selectedObject.X, (float)selectedObject.Y), System.Drawing.Drawing2D.MatrixOrder.Append);
                    g.Transform = myMatrix;
                }
            }
            g.EndContainer(gCon2);
            g.EndContainer(gCon1);
        }
        public override void Draw(System.Drawing.Graphics g)
        {
            System.Drawing.Drawing2D.GraphicsContainer gContainer = g.BeginContainer();
            System.Drawing.Drawing2D.Matrix            myMatrix   = g.Transform;
            float X = (float)this.X;
            float Y = (float)this.Y;

            if (m_Rotation != 0)
            {
                myMatrix.RotateAt((float)(m_Rotation), new System.Drawing.PointF(X, Y), System.Drawing.Drawing2D.MatrixOrder.Append);
                g.Transform = myMatrix;
            }
            System.Drawing.Pen myPen = new System.Drawing.Pen(m_lineColor, (float)m_lineWidth);

            g.DrawLine(myPen, X, Y, X + m_Size.Width, Y + m_Size.Height);
            g.EndContainer(gContainer);
        }