public TexturesViewModel(Textures model, string tag) : base(model, tag) { Top = new TextureViewModel(model.Top, tag); TopAlt = new TextureViewModel(model.TopExt, tag); Bottom = new TextureViewModel(model.Bottom, tag); FolderClosed = new TextureViewModel(model.FolderClosed, tag); FolderOpen = new TextureViewModel(model.FolderOpen, tag); FileLarge = new TextureViewModel(model.FileLarge, tag); FileSmall = new TextureViewModel(model.FileSmall, tag); Top.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(TextureViewModel.Bitmap)) RaiseViewModelChanged(nameof(Top), null, null); }; TopAlt.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(TextureViewModel.Bitmap)) RaiseViewModelChanged(nameof(TopAlt), null, null); }; Bottom.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(TextureViewModel.Bitmap)) RaiseViewModelChanged(nameof(Bottom), null, null); }; FolderClosed.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(TextureViewModel.Bitmap)) RaiseViewModelChanged(nameof(FolderClosed), null, null); }; FolderOpen.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(TextureViewModel.Bitmap)) RaiseViewModelChanged(nameof(FolderOpen), null, null); }; FileLarge.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(TextureViewModel.Bitmap)) RaiseViewModelChanged(nameof(FileLarge), null, null); }; FileSmall.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(TextureViewModel.Bitmap)) RaiseViewModelChanged(nameof(FileSmall), null, null); }; }
private static Textures Read_Textures(Stream s, Flags flags, TextureOffsets offsets) { var texes = new Textures(); using (var br = new BinaryReader(s, Encoding.ASCII, true)) { // Top if (flags.TopDrawType == TopDrawType.Texture) { s.Position = offsets.Top; switch (flags.TopFrameType) { case TopFrameType.Single: texes.Top = new RawTexture(512, 256, RawTexture.DataFormat.Bgr565); break; case TopFrameType.SlowScroll: case TopFrameType.FastScroll: texes.Top = new RawTexture(1024, 256, RawTexture.DataFormat.Bgr565); break; default: throw new ArgumentException("Invalid Texture Format", nameof(flags) + "." + nameof(flags.TopFrameType)); } texes.Top.Read(s); texes.TopExt = new RawTexture(); } else if (flags.TopDrawType == TopDrawType.SolidColorTexture) { s.Position = offsets.Top; texes.Top = new RawTexture(64, 64, RawTexture.DataFormat.A8); texes.Top.Read(s); if (offsets.TopExt != 0) { s.Position = offsets.TopExt; texes.TopExt = new RawTexture(64, 64, RawTexture.DataFormat.A8); texes.TopExt.Read(s); } else { texes.TopExt = new RawTexture(); } } else { texes.Top = new RawTexture(); texes.TopExt = new RawTexture(); } // Bottom if (flags.BottomDrawType == BottomDrawType.Texture) { s.Position = offsets.Bottom; switch (flags.BottomFrameType) { case BottomFrameType.Single: texes.Bottom = new RawTexture(512, 256, RawTexture.DataFormat.Bgr565); break; case BottomFrameType.SlowScroll: case BottomFrameType.FastScroll: case BottomFrameType.BounceScroll: case BottomFrameType.PageScroll: texes.Bottom = new RawTexture(1024, 256, RawTexture.DataFormat.Bgr565); break; default: throw new ArgumentException("Invalid Texture Format", nameof(flags) + "." + nameof(flags.BottomFrameType)); } texes.Bottom.Read(s); } else { texes.Bottom = new RawTexture(); } if (flags.FolderTexture) { // Folder Closed s.Position = offsets.FolderClosed; texes.FolderClosed = new RawTexture(128, 64, RawTexture.DataFormat.Bgr888); texes.FolderClosed.Read(s); // Folder Open s.Position = offsets.FolderOpen; texes.FolderOpen = new RawTexture(128, 64, RawTexture.DataFormat.Bgr888); texes.FolderOpen.Read(s); } else { texes.FolderOpen = new RawTexture(); texes.FolderClosed = new RawTexture(); } if (flags.FileTexture) { // Folder Closed s.Position = offsets.FileLarge; texes.FileLarge = new RawTexture(64, 128, RawTexture.DataFormat.Bgr888); texes.FileLarge.Read(s); // Folder Open s.Position = offsets.FileSmall; texes.FileSmall = new RawTexture(32, 64, RawTexture.DataFormat.Bgr888); texes.FileSmall.Read(s); } else { texes.FileLarge = new RawTexture(); texes.FileSmall = new RawTexture(); } } return texes; }