public VariantMap ReadVariantMap() { ResInfoHandle rh = ResourceUnsafeNativeMethods.FindResourceEx( neutralModule, "VMAP", "VMAP", 0); if (rh.IsInvalid) { throw new InvalidOperationException("VMAP resource not found."); } var stream = neutralModule.LoadResourceStream(rh); using (var reader = new BinaryReader(stream)) { var vmap = new VariantMap(); vmap.Name = reader.ReadAlignedPascalZString(4); vmap.Size = reader.ReadAlignedPascalZString(4); vmap.Color = reader.ReadAlignedPascalZString(4); if (reader.BaseStream.Position != reader.BaseStream.Length) { throw new Exception("Trailing unread data in VMAP."); } return(vmap); } }
private ThemeBitmap LoadReferencedImage(ThemeFile themeFile, int resRef) { ResInfoHandle resInfo = themeFile.Theme.FindResource("IMAGE", resRef); if (resInfo.IsInvalid) { return(null); } return(new ThemeBitmap(resRef, themeFile.Theme, resInfo)); }
private bool LoadImageFileRes(SafeModuleHandle module, uint resId, out object value) { ResInfoHandle resInfo = module.FindResourceEx("IMAGE", (int)resId, 0); if (resInfo.IsInvalid) { value = null; return(false); } value = new ThemeBitmap((int)resId, module, resInfo); return(true); }
private void ReadProperties(ThemeFile themeFile, string type, string name) { ResInfoHandle rh = themeFile.Theme.FindResourceEx(type, name, 0); var data = themeFile.Theme.LoadResourceAccessor(rh); bool globals = false; ThemeClass cls = null; int recordCount = 0; int currClass = -1; for (long offset = 0; offset < data.Capacity;) { var recordOffset = offset; var recordId = recordCount++; var record = data.Read <VSRecord>(ref offset); if (cls == null || record.Class != currClass) { string fullName = themeFile.ClassNames[record.Class]; string className = fullName; ParseClassName(ref className, out string appName); globals = className == "globals"; cls = themeFile.AddClass(fullName, appName, className); currClass = record.Class; } if (LoadRecordValue(themeFile, record, data, offset, out var value)) { } var prop = cls.AddProperty( recordId, recordOffset, record.Part, record.State, record.Type, record.SymbolVal, value, globals); if (record.ResId == 0) { offset += record.ByteLength; } DataExtensions.AlignTo(ref offset, 8); } }
public BaseClassMap ReadBaseClassMap() { ResInfoHandle rh = neutralModule.FindResourceEx("BCMAP", "BCMAP", 0); if (rh.IsInvalid) { return(new BaseClassMap()); } var stream = neutralModule.LoadResourceStream(rh); using (var reader = new BinaryReader(stream)) { var bcmap = new BaseClassMap(); int baseClassCount = reader.ReadInt32(); for (int i = 0; i < baseClassCount; ++i) { bcmap.AddBaseClass(i, reader.ReadInt32()); } return(bcmap); } }
public List <string> ReadClassMap() { ResInfoHandle rh = neutralModule.FindResourceEx("CMAP", "CMAP", 0); if (rh.IsInvalid) { throw new InvalidOperationException("CMAP resource not found."); } var classNames = new List <string>(); var stream = neutralModule.LoadResourceStream(rh); using (var reader = new BinaryReader(stream)) { while (stream.Position < stream.Length) { classNames.Add(reader.ReadZString()); reader.AlignTo(8); } } return(classNames); }
public ThemeBitmap(int imageId, SafeModuleHandle module, ResInfoHandle resource) { this.module = module; this.resource = resource; ImageId = imageId; }