public OBDPrefs(Prefs_s newPrefs) { InitializeComponent(); mPrefs = newPrefs; languageComboBox.SelectedIndex = mPrefs.Language; unitsComboBox.SelectedIndex = (int)mPrefs.Units; scanComboBox.SelectedIndex = mPrefs.Query; graphComboBox.SelectedIndex = mPrefs.GraphType; interfaceComboBox.SelectedIndex = (int)mPrefs.Interface; if (mPrefs.Port != null && mPrefs.Port.StartsWith("COM")) { portComboBox.SelectedItem = mPrefs.Port; } else { foreach (BluetoothDeviceInfo di in bluetoothDeviceInfo) { if (di.DeviceAddress.ToString() == mPrefs.Port) { portComboBox.SelectedItem = (string)di.DeviceName.ToString(); break; } } } }
//const String REGKEY = "Software\\OBD Gauge"; public OBDPrefs(Prefs_s newPrefs) { InitializeComponent(); mPrefs = newPrefs; languageComboBox.SelectedIndex = mPrefs.Language; unitsComboBox.SelectedIndex = (int)mPrefs.Units; scanComboBox.SelectedIndex = mPrefs.Query; graphComboBox.SelectedIndex = mPrefs.GraphType; interfaceComboBox.SelectedIndex = (int)mPrefs.Interface; portComboBox.SelectedIndex = mPrefs.Port; }
public OBDPrefsMultiplex(Prefs_s newPrefs) { InitializeComponent(); int i; for (i = 1; i < 256; i++) addressComboBox.Items.Add(i.ToString("X2")); mPrefs = newPrefs; baudComboBox.SelectedIndex = (int)mPrefs.Baud; if (mPrefs.Address == 0) addressComboBox.SelectedIndex = 0x25 - 1; else addressComboBox.SelectedIndex = mPrefs.Address - 1; protocolComboBox.SelectedIndex = (int)mPrefs.Protocol; }
public static void LoadPrefs(Prefs_s Prefs) { BinaryReader reader = null; try { String exePath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); String filePath = Path.Combine(exePath, "Preference.dat"); if (filePath.StartsWith("file:\\")) { filePath = filePath.Substring(6); } reader = new BinaryReader(new FileStream(filePath, FileMode.Open)); Prefs.Language = reader.ReadByte(); Prefs.Units = (eUnits)reader.ReadByte(); Prefs.Query = reader.ReadByte(); Prefs.GraphType = reader.ReadByte(); Prefs.Interface = (eInterface)reader.ReadByte(); Prefs.Timeout = reader.ReadByte(); Prefs.Baud = (eBaud)reader.ReadByte(); Prefs.Address = reader.ReadByte(); Prefs.Protocol = (eProtocol)reader.ReadByte(); Prefs.Port = reader.ReadString(); reader.Close(); } catch (System.IO.FileNotFoundException) { Prefs.Language = 0; Prefs.Units = eUnits.UNITS_SI; Prefs.Query = 0; Prefs.GraphType = 0; Prefs.Interface = eInterface.INTERFACE_ELM; Prefs.Timeout = 0; Prefs.Baud = eBaud.BAUD_19200; Prefs.Address = 0x25; Prefs.Protocol = eProtocol.PROTOCOL_DISABLE; Prefs.Port = "COM1"; } catch (System.IO.EndOfStreamException) { if (reader != null) { reader.Close(); } } }
public OBDPrefsMultiplex(Prefs_s newPrefs) { InitializeComponent(); int i; for (i = 1; i < 256; i++) { addressComboBox.Items.Add(i.ToString("X2")); } mPrefs = newPrefs; baudComboBox.SelectedIndex = (int)mPrefs.Baud; if (mPrefs.Address == 0) { addressComboBox.SelectedIndex = 0x25 - 1; } else { addressComboBox.SelectedIndex = mPrefs.Address - 1; } protocolComboBox.SelectedIndex = (int)mPrefs.Protocol; }
public OBDPrefs(Prefs_s newPrefs) { InitializeComponent(); mPrefs = newPrefs; languageComboBox.SelectedIndex = mPrefs.Language; unitsComboBox.SelectedIndex = (int)mPrefs.Units; scanComboBox.SelectedIndex = mPrefs.Query; graphComboBox.SelectedIndex = mPrefs.GraphType; interfaceComboBox.SelectedIndex = (int)mPrefs.Interface; if (mPrefs.Port != null && mPrefs.Port.StartsWith("COM")) { portComboBox.SelectedItem = mPrefs.Port; }else{ foreach(BluetoothDeviceInfo di in bluetoothDeviceInfo) { if (di.DeviceAddress.ToString() == mPrefs.Port) { portComboBox.SelectedItem = (string)di.DeviceName.ToString(); break; } } } }
public static void SavePrefs(Prefs_s Prefs) { String exePath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); String filePath = Path.Combine(exePath, "Preference.dat"); if (filePath.StartsWith("file:\\")) { filePath = filePath.Substring(6); } BinaryWriter writer = new BinaryWriter(new FileStream(filePath, FileMode.Create)); writer.Write(Prefs.Language); writer.Write((byte)Prefs.Units); writer.Write(Prefs.Query); writer.Write(Prefs.GraphType); writer.Write((byte)Prefs.Interface); writer.Write(Prefs.Timeout); writer.Write((byte)Prefs.Baud); writer.Write(Prefs.Address); writer.Write((byte)Prefs.Protocol); writer.Write(Prefs.Port); writer.Close(); }
public static void LoadPrefs(Prefs_s Prefs) { BinaryReader reader = null; try { String exePath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); String filePath = Path.Combine(exePath, "Preference.dat"); reader = new BinaryReader(new FileStream(filePath, FileMode.Open)); Prefs.Language = reader.ReadByte(); Prefs.Units = (eUnits)reader.ReadByte(); Prefs.Query = reader.ReadByte(); Prefs.GraphType = reader.ReadByte(); Prefs.Interface = (eInterface)reader.ReadByte(); Prefs.Timeout = reader.ReadByte(); Prefs.Baud = (eBaud)reader.ReadByte(); Prefs.Address = reader.ReadByte(); Prefs.Protocol = (eProtocol)reader.ReadByte(); Prefs.Port = reader.ReadByte(); reader.Close(); } catch (System.IO.FileNotFoundException) { Prefs.Language = 0; Prefs.Units = eUnits.UNITS_SI; Prefs.Query = 0; Prefs.GraphType = 0; Prefs.Interface = eInterface.INTERFACE_ELM; Prefs.Timeout = 0; Prefs.Baud = eBaud.BAUD_19200; Prefs.Address = 0x25; Prefs.Protocol = eProtocol.PROTOCOL_DISABLE; Prefs.Port = 0; } catch (System.IO.EndOfStreamException) { if (reader != null) reader.Close(); } }
public static void SavePrefs(Prefs_s Prefs) { String exePath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); String filePath = Path.Combine(exePath, "Preference.dat"); BinaryWriter writer = new BinaryWriter(new FileStream(filePath, FileMode.Create)); writer.Write(Prefs.Language); writer.Write((byte)Prefs.Units); writer.Write(Prefs.Query); writer.Write(Prefs.GraphType); writer.Write((byte)Prefs.Interface); writer.Write(Prefs.Timeout); writer.Write((byte)Prefs.Baud); writer.Write(Prefs.Address); writer.Write((byte)Prefs.Protocol); writer.Write(Prefs.Port); writer.Close(); }
public OBDPrefsElm(Prefs_s newPrefs) { InitializeComponent(); mPrefs = newPrefs; timeoutComboBox.SelectedIndex = mPrefs.Timeout; }