1. 程式人生 > WINDOWS開發 >用C#載入、儲存ViaionPro的'.vpp'檔案

用C#載入、儲存ViaionPro的'.vpp'檔案

1.載入VisionPro的‘.vpp‘檔案

1.1載入ViaionPro的控制元件,命名為‘cogToolBlockEditV21‘

技術分享圖片

技術分享圖片

1.2 載入檔案程式 引數:“path” VisionPro的‘.vpp‘檔案儲存地址

private void button24_Click(object sender,EventArgs e)
        {
            try
            {
                //載入除錯所用VPP
                cogToolBlockEditV21.Subject = CogSerializer.LoadObjectFromFile("
path") as CogToolBlock; cogToolBlockEditV21.Subject.Ran += new EventHandler(Subject_Ran); txtStatus.Text = "載入成功"; } catch (Exception ex) { txtStatus.Text = "載入失敗"; } }
void Subject_Ran(object sender,EventArgs e)
        {
        }

2.儲存VisionPro的‘.vpp‘檔案

private void btnSave_Click(object sender,EventArgs e)
        {
            CogSerializer.SaveObjectToFile(cogToolBlockEditV21.Subject,"path");
            MessageBox.Show("儲存成功");
        }