internal Device(int id, Format.Device rawDevice) { Id = id; RawDevice = rawDevice; updateMidiDefinitions(); if (RawDevice.Data.Mappings != null) { _mappings = RawDevice.Data.Mappings.List.Mappings.Select(m => new Mapping(this, m)).ToList(); } updateEncoderMode(); }
internal Device(int id, Format.Device rawDevice, bool removeUnusedMIDIDefinitions) { RemoveUnusedMIDIDefinitions = removeUnusedMIDIDefinitions; Id = id; RawDevice = rawDevice; if (RawDevice.Data.Mappings != null) { _mappings = RawDevice.Data.Mappings.List.Mappings.Select(m => new Mapping(this, m)).ToList(); } if (RemoveUnusedMIDIDefinitions) { reduceDefinitions(); } updateMidiDefinitions(); updateEncoderMode(); }
public Device Copy(bool includeMappings) { Format.Device rawDeviceCopy; using (var copyStream = new System.IO.MemoryStream()) { RawDevice.Write(new Utils.Writer(copyStream)); copyStream.Seek(0, System.IO.SeekOrigin.Begin); rawDeviceCopy = new Format.Device(copyStream); } // reset revision rawDeviceCopy.Data.Version.MappingFileRevision = 0; if (!includeMappings) { rawDeviceCopy.Data.Mappings = new MappingsContainer(); } var copy = new Device(-1, rawDeviceCopy, RemoveUnusedMIDIDefinitions, this.IsKeyboard); copy.EncoderMode = EncoderMode; // encoder mode is not stored in Format.Device return(copy); }