Ejemplo n.º 1
0
        public override void WriteShape(ShapeBase Shape, IO.TextWriter Writer)
        {
            var Dic = new Dictionary<PointF, Int32>();
            var Sz = 0;

            ShapeWalker.Instance.TypedWalk<LinesShape>(Shape, S => { Sz++; });
            Writer.WriteLine(Sz);
            ShapeWalker.Instance.TypedWalk<LinesShape>(Shape, S => { Writer.WriteLine(S.Lines.Count); });

            Sz = 0;
            ShapeWalker.Instance.TypedWalk<LinesShape>(Shape,
                S =>
                {
                    foreach (var L in S.Lines)
                    {
                        if (!Dic.ContainsKey(L.P1))
                        {
                            Dic.Add(L.P1, Sz++);
                        }
                        if (!Dic.ContainsKey(L.P2))
                        {
                            Dic.Add(L.P2, Sz++);
                        }
                    }
                });

            Writer.WriteLine(Sz);
            foreach (var KV in Dic.OrderBy(KV => KV.Value))
            {
                Writer.Write(KV.Key.X);
                Writer.Write(" ");
                Writer.Write(KV.Key.Y);
                Writer.WriteLine();
            }

            ShapeWalker.Instance.TypedWalk<LinesShape>(Shape,
                S =>
                {
                    Writer.WriteLine();
                    foreach (var l in S.Lines)
                    {
                        Writer.Write(Dic[l.P1]);
                        Writer.Write(" ");
                        Writer.Write(Dic[l.P2]);
                        Writer.WriteLine();
                    }
                });
        }
        public override void WriteShape(ShapeBase Shape, IO.TextWriter Writer)
        {
            ShapeWalker.Instance.TypedWalk<LinesShape>(Shape,
                S =>
                {
                    foreach (var l in S.Lines)
                    {
                        Writer.WriteLine(" zone");

                        Writer.Write(l.P1.X);
                        Writer.Write(" ");
                        Writer.Write(l.P1.Y);
                        Writer.WriteLine();

                        Writer.Write(l.P2.X);
                        Writer.Write(" ");
                        Writer.Write(l.P2.Y);
                        Writer.WriteLine();
                    }
                });
        }
Ejemplo n.º 3
0
        static void WriteFunctionBody(IO.StreamWriter sourceFile, MethodInfo theMethod)
        {
            sourceFile.WriteLine("{");
            sourceFile.WriteLine("DOT_NET_EXCEL_BEGIN");

            string castString = "";

            if (!Primitives.Contains(theMethod.ReturnType))
                castString = "*(" + WriteCType(theMethod.ReturnType, false) +
                             "*)(xlwTypes::" + WriteCType(theMethod.ReturnType, false) + "::getInner(";

            if (theMethod.ReturnType == typeof(String))
                castString = "(CLR2WCPP(";

            const string tabString = "        ";
            sourceFile.WriteLine(tabString + "return " + castString + cppify(theMethod.DeclaringType.FullName + "." + theMethod.Name) + "(");

            ParameterInfo[] paramInfo = theMethod.GetParameters();
            for (int index = 0; index < paramInfo.Length; ++index)
            {
                ParameterInfo param = paramInfo[index];
                sourceFile.Write(tabString + tabString);
                Type parameterType = param.ParameterType;
                bool isCustomType = false;
                if (CustomTypes.Contains(parameterType))
                {
                    int j = CustomTypes.IndexOf(parameterType);
                    parameterType = CustomInputTypes[j]; // substitute the parameterType for its custom conversion
                    isCustomType = true;
                    sourceFile.Write(CustomConversionMethodNames[j] + "(");
                }

                /////// Primitive Type
                if (Primitives.Contains(parameterType))
                    sourceFile.Write(param.Name);
                else
                {
                    /////// A String
                    if (param.ParameterType == typeof (String))
                        sourceFile.Write("gcnew String(" + param.Name + ".c_str())");
                    else
                        sourceFile.Write("gcnew xlwTypes::" + WriteCType(parameterType, false) + "(IntPtr((void*)& " + param.Name + "))");
                }

                if (isCustomType) sourceFile.Write(")");
                if (index + 1 != paramInfo.Length) sourceFile.Write(",");
                sourceFile.WriteLine();
            }
            sourceFile.Write(tabString + ")");

            if (!Primitives.Contains(theMethod.ReturnType))
                sourceFile.Write("))");

            sourceFile.WriteLine(";");
            sourceFile.WriteLine("DOT_NET_EXCEL_END");

            sourceFile.WriteLine("}");
        }