void stopRecorder_Click(object sender, EventArgs e) { try { _stopRecorder.Enabled = !(_startRecorder.Enabled = true); BluetoothHidWriter.RecorderList data = _hidWriter.StopRecorder(); string fileName = string.Empty; if (Platform.IsWindowsMobileStandard) { // TODO: allow for other macros using (StringInput stringInput = new StringInput("Enter Name", "Enter Recorded File Name:")) { if (DialogResult.OK == stringInput.ShowDialog(this) && !string.IsNullOrEmpty(stringInput.Value)) { fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), string.Format("{0}.mrm", stringInput.Value)); } else { return; } } } else { using (SaveFileDialog sfd = new SaveFileDialog()) { sfd.Filter = "MobileRemote Macro|.mrm"; if (DialogResult.OK == sfd.ShowDialog()) { fileName = sfd.FileName; } } } if (!string.IsNullOrEmpty(fileName)) { using (FileStream fs = File.Create(fileName)) { using (BinaryWriter bw = new BinaryWriter(fs)) { byte[] binaryData = data.Serialize(); bw.Write(binaryData); bw.Flush(); } } } } catch { MessageBox.Show("There was an error saving your recording", "Error Saving Recording", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } }
void ExecuteMacro(string macroFile) { if (File.Exists(macroFile)) { BluetoothHidWriter.RecorderList data = new BluetoothHidWriter.RecorderList(); using (FileStream fs = File.OpenRead(macroFile)) { using (BinaryReader bw = new BinaryReader(fs)) { data.Deserialize(bw); } } Cursor.Current = Cursors.WaitCursor; _hidWriter.ExecuteRecorder(data, 10); Cursor.Current = Cursors.Default; } }