Example #1
0
 /// <summary>
 /// ContextMenu ItemClick event saves all registers to file.
 /// </summary>
 private void regContextMenu_ItemClick_saveAllToFile(object sender, EventArgs e)
 {
     SaveFileDialog saveFileDialog = new SaveFileDialog();
     saveFileDialog.Title = "Select File";
     saveFileDialog.Filter = "x-IMU Binary Files (*.bin)|*.bin|All files (*.*)|*.*";
     saveFileDialog.FileName = "savedRegisters" + registerTreeNodeTextBox_deviceID.TextBox.Text + ".bin";
     if (saveFileDialog.ShowDialog() == DialogResult.OK)
     {
         x_IMU_API.xIMUfile xIMUfile = new x_IMU_API.xIMUfile(saveFileDialog.FileName.ToString(), true);
         foreach (TreeNode rootNode in registerTreeView.Nodes)
         {
             WriteAllChildRegisterTreeNode(xIMUfile, rootNode);
         }
         xIMUfile.Close();
     }
 }
Example #2
0
 /// <summary>
 /// ContextMenu ItemClick event loads registers from file.
 /// </summary>
 private void regContextMenu_ItemClick_loadFromFile(object sender, EventArgs e)
 {
     OpenFileDialog openFileDialog = new OpenFileDialog();
     openFileDialog.Title = "Select File";
     openFileDialog.Filter = "x-IMU Binary Files (*.bin)|*.bin|All files (*.*)|*.*";
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         x_IMU_API.xIMUfile xIMUfile = new x_IMU_API.xIMUfile(openFileDialog.FileName.ToString());
         xIMUfile.RegisterDataRead += new x_IMU_API.xIMUfile.onRegisterDataRead(delegate(object s, x_IMU_API.RegisterData r) { registerTreeView.ApplyRegisterData(r, false); });
         xIMUfile.Read();
         if (xIMUfile.ReadErrors != 0)
         {
             MessageBox.Show(xIMUfile.ReadErrors.ToString() + " read errors occurred.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         xIMUfile.Close();
     }
 }