예제 #1
0
        // Methods
        public static bool class2(CGMElement element, SVGContext mycontext, XmlTextWriter myxml)
        {
            switch (element.ElementId)
            {
            case 3:
                mycontext.linewidthmode = mycontext.Reader.ReadE();
                break;

            case 5:
                mycontext.edgewidthmode = mycontext.Reader.ReadE();
                break;

            case 6:
            {
                mycontext.vdclb = mycontext.Reader.ReadP();
                mycontext.vdcrt = mycontext.Reader.ReadP();
                mycontext.ow    = Convert.ToDouble(Math.Abs(decimal.Subtract(mycontext.vdclb.X, mycontext.vdcrt.X)));
                mycontext.oh    = Convert.ToDouble(Math.Abs(decimal.Subtract(mycontext.vdclb.Y, mycontext.vdcrt.Y)));
                CGM.Scanner.Point point = new CGM.Scanner.Point(new decimal(mycontext.options.ViewBox.Location.X), new decimal(mycontext.options.ViewBox.Location.Y));
                mycontext.rtl   = point;
                mycontext.rw    = Convert.ToInt32(Math.Round(mycontext.ow));
                mycontext.rh    = Convert.ToInt32(Math.Round(mycontext.oh));
                mycontext.scale = 1.0;
                if (mycontext.options.FitInBox || mycontext.options.EnlargeInBox)
                {
                    double num2 = mycontext.ow / ((double)mycontext.options.ViewBox.Width);
                    double num  = mycontext.oh / ((double)mycontext.options.ViewBox.Height);
                    if (num2 < num)
                    {
                        if (((num > 1.0) && mycontext.options.FitInBox) || ((num < 1.0) && mycontext.options.EnlargeInBox))
                        {
                            mycontext.scale = num;
                            mycontext.rw    = Convert.ToInt32(Math.Round(mycontext.ow / num));
                            mycontext.rh    = Convert.ToInt32(Math.Round((double)mycontext.options.ViewBox.Width));
                        }
                    }
                    else if (((num2 > 1.0) && mycontext.options.FitInBox) || ((num2 < 1.0) && mycontext.options.EnlargeInBox))
                    {
                        mycontext.scale = num2;
                        mycontext.rw    = Convert.ToInt32(Math.Round((double)mycontext.options.ViewBox.Width));
                        mycontext.rh    = Convert.ToInt32(Math.Round(mycontext.oh / num2));
                    }
                }
                break;
            }

            case 7:
                mycontext.BackColor = mycontext.convertColor(mycontext.Reader.ReadCD());
                break;

            case 11:
            {
                SVGContext.linebundlestruct linebundlestruct;
                int index = mycontext.Reader.ReadIX();
                linebundlestruct.type  = mycontext.Reader.ReadIX();
                linebundlestruct.width = Convert.ToDouble(mycontext.Reader.ReadSS(true));
                linebundlestruct.color = (Color)mycontext.Reader.ReadCO();
                if ((mycontext.linebundle.Length - 1) < index)
                {
                    mycontext.linebundle = mycontext.linebundle.Concat(new SVGContext.linebundlestruct[(index - 1) + 1]).ToArray();//mycontext.linebundle = Utils.CopyArray((Array)mycontext.linebundle, new SVGContext.linebundlestruct[(index - 1) + 1]);
                }
                mycontext.linebundle[index] = linebundlestruct;
                break;
            }

            case 13:
            {
                SVGContext.textbundlestruct textbundlestruct;
                int num4 = mycontext.Reader.ReadIX();
                textbundlestruct.fontindex = mycontext.Reader.ReadIX().ToString();
                textbundlestruct.precision = mycontext.Reader.ReadE();
                textbundlestruct.spacing   = mycontext.Reader.ReadR();
                textbundlestruct.expansion = mycontext.Reader.ReadR();
                textbundlestruct.color     = (Color)mycontext.Reader.ReadCO();
                if ((mycontext.textbundle.Length - 1) < num4)
                {
                    //mycontext.textbundle = Utils.CopyArray((Array)mycontext.textbundle, new SVGContext.textbundlestruct[(num4 - 1) + 1]);
                    mycontext.textbundle = mycontext.textbundle.Concat(new SVGContext.textbundlestruct[(num4 - 1) + 1]).ToArray();
                }
                mycontext.textbundle[num4] = textbundlestruct;
                break;
            }

            case 14:
            {
                SVGContext.fillbundlestruct fillbundlestruct;
                int num5 = mycontext.Reader.ReadIX();
                fillbundlestruct.style   = mycontext.Reader.ReadE();
                fillbundlestruct.color   = (Color)mycontext.Reader.ReadCO();
                fillbundlestruct.hatch   = mycontext.Reader.ReadIX();
                fillbundlestruct.pattern = mycontext.Reader.ReadIX();
                if ((mycontext.fillbundle.Length - 1) < num5)
                {
                    //mycontext.fillbundle = Utils.CopyArray((Array)mycontext.fillbundle, new SVGContext.fillbundlestruct[(num5 - 1) + 1]);
                    mycontext.fillbundle = mycontext.fillbundle.Concat(new SVGContext.fillbundlestruct[(num5 - 1) + 1]).ToArray();
                }
                mycontext.fillbundle[num5] = fillbundlestruct;
                break;
            }

            case 15:
            {
                SVGContext.edgebundlestruct edgebundlestruct;
                int num6 = mycontext.Reader.ReadIX();
                edgebundlestruct.type  = mycontext.Reader.ReadIX();
                edgebundlestruct.width = Convert.ToDouble(mycontext.Reader.ReadSS(true));
                edgebundlestruct.color = (Color)mycontext.Reader.ReadCO();
                if ((mycontext.edgebundle.Length - 1) < num6)
                {
                    //mycontext.edgebundle = Utils.CopyArray((Array)mycontext.edgebundle, new SVGContext.edgebundlestruct[(num6 - 1) + 1]);
                    mycontext.edgebundle = mycontext.edgebundle.Concat(new SVGContext.edgebundlestruct[(num6 - 1) + 1]).ToArray();
                }
                mycontext.edgebundle[num6] = edgebundlestruct;
                break;
            }

            default:
                return(false);
            }
            return(true);
        }
예제 #2
0
        // Methods
        public static bool class5(CGMElement element, SVGContext mycontext, XmlTextWriter myxml)
        {
            switch (element.ElementId)
            {
            case 1:
                mycontext.linebundleindex = mycontext.Reader.ReadIX();
                break;

            case 2:
                mycontext.Linetype = mycontext.Reader.ReadIX();
                break;

            case 3:
                if (mycontext.linewidthmode != 0)
                {
                    mycontext.Linewidth = mycontext.Reader.ReadR();
                }
                else
                {
                    mycontext.Linewidth = Convert.ToDouble(mycontext.Reader.ReadVDC());
                }
                break;

            case 4:
                mycontext.LineColorC = RuntimeHelpers.GetObjectValue(mycontext.Reader.ReadCO());
                break;

            case 9:
                mycontext.textbundleindex = mycontext.Reader.ReadIX();
                break;

            case 10:
            {
                int index = mycontext.Reader.ReadIX() - 1;
                if (mycontext.Fonts == null || (index >= mycontext.Fonts.Length))
                {
                    mycontext.Font = "Arial";
                }
                else
                {
                    mycontext.Font = mycontext.Fonts[index];
                }
                break;
            }

            case 13:
                mycontext.TextSpacing = mycontext.Reader.ReadR();
                break;

            case 14:
                mycontext.TextColorC = RuntimeHelpers.GetObjectValue(mycontext.Reader.ReadCO());
                break;

            case 15:
                mycontext.FontSize = Convert.ToDouble(mycontext.Reader.ReadVDC());
                break;

            case 0x10:
            {
                double num3  = 0;
                double num6  = 0;
                double num8  = 0;
                double num10 = 0;
                double num12 = 0;
                double num13 = 0;
                int    num7  = Convert.ToInt32(mycontext.Reader.ReadVDC());
                int    num11 = Convert.ToInt32(mycontext.Reader.ReadVDC());
                int    num5  = Convert.ToInt32(mycontext.Reader.ReadVDC());
                int    num9  = Convert.ToInt32(mycontext.Reader.ReadVDC());
                double num4  = Math.Sqrt((double)((num7 * num7) + (num11 * num11)));
                double num2  = Math.Sqrt((double)((num5 * num5) + (num9 * num9)));
                if (num4 != 0.0)
                {
                    num8  = ((double)num7) / num4;
                    num12 = ((double)num11) / num4;
                }
                if (num2 != 0.0)
                {
                    num6  = ((double)num5) / num2;
                    num10 = ((double)num9) / num2;
                }
                if (mycontext.GetInversion() == 3)
                {
                    num3  = -1.0;
                    num13 = 0.0;
                }
                else if (mycontext.GetInversion() == 4)
                {
                    num3  = -1.0;
                    num13 = 0.0;
                    num10 = -num10;
                }
                else
                {
                    num3  = 1.0;
                    num13 = 0.0;
                }
                if ((num6 != 0.0) | (num10 != 0.0))
                {
                    mycontext.TextRotateAngle = (Math.Acos(((num3 * num6) + (num13 * num10)) / (Math.Sqrt(1.0) * Math.Sqrt(Math.Pow(num10, 2.0) + Math.Pow(num6, 2.0)))) * 180.0) / 3.1415926535897931;
                    if (num10 < 0.0)
                    {
                        mycontext.TextRotateAngle = -mycontext.TextRotateAngle;
                    }
                }
                else
                {
                    mycontext.TextRotateAngle = 0.0;
                }
                if ((((Math.Acos(((num8 * num6) + (num12 * num10)) / (Math.Sqrt(1.0) * Math.Sqrt(Math.Pow(num10, 2.0) + Math.Pow(num6, 2.0)))) * 180.0) / 3.1415926535897931) < 89.0) | (((Math.Acos(((num8 * num6) + (num12 * num10)) / (Math.Sqrt(1.0) * Math.Sqrt(Math.Pow(num10, 2.0) + Math.Pow(num6, 2.0)))) * 180.0) / 3.1415926535897931) > 91.0))
                {
                    mycontext.TextAngle = Math.Acos(((num8 * num6) + (num12 * num10)) / (Math.Sqrt(1.0) * Math.Sqrt(Math.Pow(num10, 2.0) + Math.Pow(num6, 2.0))));
                }
                break;
            }

            case 0x11:
                mycontext.TextPath = mycontext.Reader.ReadE();
                break;

            case 0x12:
                mycontext.TextAlignment     = mycontext.Reader.ReadE();
                mycontext.TextAlignmentVert = mycontext.Reader.ReadE();
                mycontext.TextHContinuous   = mycontext.Reader.ReadR();
                mycontext.TextVContinuous   = mycontext.Reader.ReadR();
                break;

            case 0x15:
                mycontext.fillbundleindex = mycontext.Reader.ReadIX();
                break;

            case 0x16:
                mycontext.interiorstyle = mycontext.Reader.ReadE();
                if (mycontext.interiorstyle == 3)
                {
                    mycontext.getHatch(myxml);
                }
                break;

            case 0x17:
                mycontext.FillColorC = RuntimeHelpers.GetObjectValue(mycontext.Reader.ReadCO());
                break;

            case 0x18:
                mycontext.HatchIndex = mycontext.Reader.ReadIX();
                break;

            case 0x1a:
                mycontext.edgebundleindex = mycontext.Reader.ReadIX();
                break;

            case 0x1b:
                mycontext.edgetype = mycontext.Reader.ReadIX();
                break;

            case 0x1c:
                if (mycontext.edgewidthmode != 0)
                {
                    mycontext.edgewidth = mycontext.Reader.ReadR();
                }
                else
                {
                    mycontext.edgewidth = Convert.ToDouble(mycontext.Reader.ReadVDC());
                }
                break;

            case 0x1d:
                mycontext.EdgeColorC = RuntimeHelpers.GetObjectValue(mycontext.Reader.ReadCO());
                break;

            case 30:
                mycontext.edgevis = mycontext.Reader.ReadE();
                break;

            case 0x22:
            {
                mycontext.startcolorindex = Convert.ToInt32(mycontext.Reader.ReadCI());
                ArrayList list = new ArrayList();
                while (!mycontext.Reader.EOF)
                {
                    list.Add(mycontext.convertColor(mycontext.Reader.ReadCD()));
                }
                int num14 = list.Count;
                if (mycontext.colortable.Length < (mycontext.startcolorindex + num14))
                {
                    mycontext.colortable = mycontext.colortable.Concat(new Color[((mycontext.startcolorindex + num14) - 1) + 1]).ToArray();//mycontext.colortable = Utils.CopyArray((Array)mycontext.colortable, new Color[((mycontext.startcolorindex + num14) - 1) + 1]);
                }
                Array.Copy(list.ToArray(typeof(Color)), 0, mycontext.colortable, mycontext.startcolorindex, list.Count);
                if (mycontext.startcolorindex == 0)
                {
                    mycontext.BackColor = Color.Empty;
                }
                break;
            }

            case 0x23:
                while (!mycontext.Reader.EOF)
                {
                    int num15 = mycontext.Reader.ReadE();
                    mycontext.ASF[num15] = mycontext.Reader.ReadE();
                }
                break;

            case 0x25:
                mycontext.linecap = mycontext.Reader.ReadIX();
                break;

            case 0x26:
                mycontext.linejoin = mycontext.Reader.ReadIX();
                break;

            case 0x2c:
                mycontext.edgecap = mycontext.Reader.ReadIX();
                break;

            case 0x2d:
                mycontext.edgejoin = mycontext.Reader.ReadIX();
                break;

            default:
                return(false);
            }
            return(true);
        }