Exemple #1
0
        //General reference:
        //https://stackoverflow.com/questions/7053172/how-can-i-call-ironpython-code-from-a-c-sharp-app

        public string ReferenceHostMethods(string inputvalue, TestApp.Form1 TestApp1)
        {
            //How to call host object methods:
            //https://stackoverflow.com/questions/6234355/access-host-class-from-ironpython-script

            var engine = Python.CreateEngine();
            var scope  = engine.CreateScope();



            string strRunHostMethod = @"
def RunHostMethod(name):
    msg = Host.GetAString() + '  ' + name
    return msg
";

            ScriptSource source = engine.CreateScriptSourceFromString(strRunHostMethod, SourceCodeKind.Statements);

            source.Execute(scope);

            //Pass the host form to the scripting environment as a global:
            scope.SetVariable("Host", TestApp1);

            //Get a function pointer to the method:
            var fRunHostMethod = scope.GetVariable <Func <string, string> >("RunHostMethod");

            var result = fRunHostMethod("Michal");

            return(result);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

            TestApp.Form1 f = new TestApp.Form1();
            f.ShowDialog();
            return;
            string ftest = @"C:\_garbage_\TEST_3_CGM.cgm";
            //ftest = "ICN-S1000DBIKE-AAA-DA51000-0-U8025-00519-A-04-1.CGM";
            //ftest = @"C:\_garbage_\TEST_3_CGM.cgm";
            net.sf.jcgm.core.CGM cgmm = new net.sf.jcgm.core.CGM(
                new java.io.File(ftest));
            cgmm.showCGMCommands(new java.io.PrintStream(@"jcgmout.txt"));
            return;
            CGMSharp.CGMImage img = new CGMSharp.CGMImage(ftest);
            System.Drawing.Bitmap bp = new System.Drawing.Bitmap(img.Size.Width, img.Size.Height);
            System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bp);
            gr.Clear(System.Drawing.Color.White);
            System.Drawing.Size sz = img.Size;
            //string x = ((CGMSharp.CGMPolyLine)img.structuresFocused[8]).Map;
            for (int i = 0; i < img.structuresFocused.Count; i++)
            {
                if (img.structuresFocused[i] is CGMSharp.CGMPolyLine)
                {
                    ((CGMSharp.CGMPolyLine)img.structuresFocused[i]).Draw(gr, sz);
                }
            }
            img.getSize(96);
            //((CGMSharp.CGMPolyLine)img.structuresFocused[8]).Draw(ref gr);
            bp.Save("test.png", System.Drawing.Imaging.ImageFormat.Png);
            System.IO.File.WriteAllText("dump.txt", img.TraceLoading);
            Console.ReadLine();
        }