public binfile DeSerializeNow(string filename) { binfile c = new binfile(); try { using (FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) { BinaryFormatter b = new BinaryFormatter(); c = b.Deserialize(fileStream) as binfile; fileStream.Close(); } } catch (Exception e1) { c = new binfile(); MessageBox.Show(e1.Message, "读取文件"); } finally { } return(c); }
public UserControl东光() { mybinfile = new TabHeaderDemo.UserControl东光.binfile(); InitializeComponent(); cboctrl.Items.Clear(); cboctrl.Items.Add("位移"); cboctrl.Items.Add("负荷"); cboctrl.SelectedIndex = 0; cbowave.Items.Clear(); cbowave.Items.Add("正弦波"); cbowave.Items.Add("三角波"); cbowave.SelectedIndex = 0; //Application.StartupPath SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景. SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲 this.tableLayoutPanel1.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(this.tableLayoutPanel1, true, null); this.tableLayoutPanel2.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(this.tableLayoutPanel2, true, null); this.tableLayoutPanel8.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(this.tableLayoutPanel8, true, null); this.tableLayoutPanel11.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(this.tableLayoutPanel11, true, null); this.tableLayoutPanel9.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(this.tableLayoutPanel9, true, null); }
private void switch2_ValueChanged_1(object sender, EventArgs e) { if (this.switchLink.Value == true) { if (CComLibrary.GlobeVal.filesave == null) { MessageBox.Show("请先设置试验方法"); return; } else { } GlobeVal.myarm.mdemo = GlobeVal.mysys.demo; GlobeVal.myarm.Init((int)this.Handle); GlobeVal.FormmainLab.timer1.Enabled = true; if (GlobeVal.myarm.mdemo == true) { GlobeVal.myarm.readdemo(System.Windows.Forms.Application.StartupPath + "\\AppleLabJ" + "\\demo\\拉伸1演示.txt"); } GlobeVal.FormmainLab.InitMeter(); GlobeVal.FormmainLab.InitKey(); //GlobeVal.myarm.Connected()= true; mybinfile = mybinfile.DeSerializeNow(System.Windows.Forms.Application.StartupPath + "\\AppleLabJ" + "\\sys\\东光.参数"); Init(); timer1.Enabled = true; } }
private void button1_Click_1(object sender, EventArgs e) { mybinfile = mybinfile.DeSerializeNow(System.Windows.Forms.Application.StartupPath + "\\AppleLabJ" + "\\sys\\东光.参数"); Init(); }