Ejemplo n.º 1
0
        public string GenerateCode()
        {
            sbShapeCode1 = null;
            sbBeginCode  = null;
            sbEndCode    = null;
            if (manager.ShapeCount == 0)
            {
                sbBeginCode.Append("No shapes are available to generate GDI+ code.");
            }
            else
            {
                //allocate 1500 characters of code per shape
                sbShapeCode1 = new StringBuilder(manager.ShapeCount * 1500);
                sbBeginCode  = new StringBuilder(1800);
                sbEndCode    = new StringBuilder(2400);

                blnHasGradientBrush = false;
                blnEditBlend        = false;
                blnEditBounds       = false;
                blnEditColor        = false;
                blnEditText         = false;

                colorEnumCount  = 0;
                boundsEnumCount = 0;
                blendEnumCount  = 0;
                textEnumCount   = 0;

                blnWriteScalePoints = false;


                if (!manager.ClipRectIsOn)
                {
                    Rectangle rectArea = manager.GetTotalShapeArea();
                    AreaBounds = rectArea;
                }
                else
                {
                    AreaBounds = manager.ClipBounds;
                }


                //writes all the GDI+ code and sets some important helper
                //flags in code generation. Look inside method fot more info
                writeShapeCode();

                writeInit();
                write_Constructor();
                start_Method();

                end_Method();
                write_helperMethods();
                write_End();
                write_EndingText();
            }


            return(sbBeginCode.ToString() + sbShapeCode1.ToString() + sbEndCode.ToString());
        }