private void SensorLoadPrefs() { mSensorPrefs = new SensorPrefs_s(); try { String exePath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); String filePath = Path.Combine(exePath, "Layout.dat"); if (filePath.StartsWith("file:\\")) { filePath = filePath.Substring(6); } BinaryReader reader = new BinaryReader(new FileStream(filePath, FileMode.Open)); mSensorPrefs.Page = reader.ReadByte(); mSensorPrefs.SupportedPids = reader.ReadUInt32();; mSensorPrefs.Imperial = reader.ReadBoolean(); mSensorPrefs.Sensor = new byte[PAGEMAX, ROWMAX]; mSensorPrefs.SensorCount = new byte[PAGEMAX]; int page, row; for (page = 0; page < PAGEMAX; page++) { for (row = 0; row < ROWMAX; row++) { mSensorPrefs.Sensor[page, row] = reader.ReadByte(); } } mSensorPrefs.SensorCount = reader.ReadBytes(PAGEMAX); reader.Close(); } catch (System.IO.FileNotFoundException) { // initialize mSensorPrefs mSensorPrefs.Page = 0; mSensorPrefs.SupportedPids = 0; mSensorPrefs.Imperial = false; mSensorPrefs.Sensor = new byte[PAGEMAX, ROWMAX]; mSensorPrefs.SensorCount = new byte[PAGEMAX]; } }
private void SensorLoadPrefs() { mSensorPrefs = new SensorPrefs_s(); try { String exePath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); String filePath = Path.Combine(exePath, "Layout.dat"); BinaryReader reader = new BinaryReader(new FileStream(filePath, FileMode.Open)); mSensorPrefs.Page = reader.ReadByte(); mSensorPrefs.SupportedPids = reader.ReadUInt32();; mSensorPrefs.Imperial = reader.ReadBoolean(); mSensorPrefs.Sensor = new byte[PAGEMAX,ROWMAX]; mSensorPrefs.SensorCount = new byte[PAGEMAX]; int page, row; for (page = 0; page < PAGEMAX; page++) for (row = 0; row < ROWMAX; row++) mSensorPrefs.Sensor[page, row] = reader.ReadByte(); mSensorPrefs.SensorCount = reader.ReadBytes(PAGEMAX); reader.Close(); } catch (System.IO.FileNotFoundException) { // initialize mSensorPrefs mSensorPrefs.Page = 0; mSensorPrefs.SupportedPids = 0; mSensorPrefs.Imperial = false; mSensorPrefs.Sensor = new byte[PAGEMAX,ROWMAX]; mSensorPrefs.SensorCount = new byte[PAGEMAX]; } }