Exemple #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            String bc_name   = "Process";
            IntPtr broadcast = plEngine1.FindBroadcastName(bc_name);

            if (broadcast == IntPtr.Zero)
            {
                MessageBox.Show(String.Format("The model does not have a broadcast called {0}", bc_name));
            }
            else
            if (callback == null)
            {
                // 1) only register callback once to protect against PL (in own thread)
                //    being in process of doing callback to old handler
                // 2) use KeepAlive to avoid GC disposing of apparently unused object

                callback = new PLEngineCore.tPL_BroadcastCallback(broadcast_callback_function);
                GC.KeepAlive(callback);
                ePLRESULT reg_res = plEngine1.RegisterBroadcastCallback(broadcast, callback);
            }

            double[] values = new double[] { Convert.ToDouble(numericUpDown1.Value), 999.0 };
            string[] names  = new string[] { "_height", "_width" };

            ePLRESULT brd_res = plEngine1.SendBroadcast(broadcast, names.Length, names, values);
        }
Exemple #2
0
        public Form1()
        {
            InitializeComponent();
            ePLRESULT init_result = plEngineForm.InitPLEngine("demo.mdl");

            if (init_result != ePLRESULT.PLR_OK)
            {
                MessageBox.Show(String.Format("Failed to load Planimate, code {0}", (int)init_result));
            }
            else
            {
                plEngine1 = plEngineForm.plengine;
                dataGridView1.DataSource = plEngine1.GetDataTable("Input_1", true, true);
                dataGridView2.DataSource = plEngine1.GetDataTable("Formats", true, true);
                DataTable dt = (DataTable)dataGridView2.DataSource;
                plEngine1.SetFromDataTable(dt, plEngine1.FindDataObjectName("formats_copy"));
            }
        }