Beispiel #1
0
        public static SMDH Read(Stream s)
        {
            if (!s.CanSeek)
            {
                throw new ArgumentException("Stream can't Seek", nameof(s));
            }

            var smdh = new SMDH(true);

            using (var br = new BinaryReader(s, Encoding.ASCII, true))
            {
                var flag = br.ReadUInt32() == BitConverter.ToUInt32(MAGIC, 0);
                if (!flag)
                {
                    throw new InvalidDataException("Not a SMDH File");
                }

                smdh.Version    = br.ReadInt16();
                smdh.Reserved_1 = br.ReadInt16();

                smdh.AppTitles = new AppTitle[16];
                for (int i = 0; i < 16; i++)
                {
                    smdh.AppTitles[i] = AppTitle.Read(s);
                }

                smdh.Settings = AppSettings.Read(s);

                smdh.Reserved_2 = br.ReadInt64();
                smdh.SmallIcon.Read(s);
                smdh.LargeIcon.Read(s);
            }
            return(smdh);
        }
Beispiel #2
0
        public static SMDH Read(Stream s)
        {
            if (!s.CanSeek)
                throw new ArgumentException("Stream can't Seek", nameof(s));

            var smdh = new SMDH(true);
            using (var br = new BinaryReader(s, Encoding.ASCII, true))
            {
                var flag = br.ReadUInt32() == BitConverter.ToUInt32(MAGIC, 0);
                if (!flag)
                    throw new InvalidDataException("Not a SMDH File");

                smdh.Version = br.ReadInt16();
                smdh.Reserved_1 = br.ReadInt16();

                smdh.AppTitles = new AppTitle[16];
                for (int i = 0; i < 16; i++)
                    smdh.AppTitles[i] = AppTitle.Read(s);

                smdh.Settings = AppSettings.Read(s);

                smdh.Reserved_2 = br.ReadInt64();
                smdh.SmallIcon.Read(s);
                smdh.LargeIcon.Read(s);
            }
            return smdh;
        }
        public ThemeViewModel(Theme model, SMDH info = null) : base(model, Guid.NewGuid().ToString())
        {
            Flags = new FlagsViewModel(model.Flags, Tag);
            Colors = new ColorsViewModel(model.Colors, Tag);
            Textures = new TexturesViewModel(model.Textures, Tag);

            Info = new ThemeInfoViewModel(info ?? new SMDH(), Tag);

            SetupRules();
        }
        public ThemeInfoViewModel(SMDH model, string tag) : base(model, tag)
        {
            SmallIcon = new TextureViewModel(model.SmallIcon, Tag);
            LargeIcon = new TextureViewModel(model.LargeIcon, Tag);

            SmallIcon.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(TextureViewModel.Bitmap))
                    RaiseViewModelChanged(nameof(SmallIcon), null, null);
            };
            LargeIcon.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(TextureViewModel.Bitmap))
                    RaiseViewModelChanged(nameof(LargeIcon), null, null);
            };
        }
Beispiel #5
0
        public static void Write(SMDH smdh, Stream s)
        {
            using (var bw = new BinaryWriter(s, Encoding.ASCII, true))
            {
                bw.Write(MAGIC);
                bw.Write(smdh.Version);
                bw.Write(smdh.Reserved_1);

                for (int i = 0; i < 16; i++)
                    AppTitle.Write(smdh.AppTitles[i], s);

                AppSettings.Write(smdh.Settings, s);
                bw.Write(smdh.Reserved_2);
                bw.Write(smdh.SmallIcon.Data);
                bw.Write(smdh.LargeIcon.Data);
            }
        }
Beispiel #6
0
        public static void Write(SMDH smdh, Stream s)
        {
            using (var bw = new BinaryWriter(s, Encoding.ASCII, true))
            {
                bw.Write(MAGIC);
                bw.Write(smdh.Version);
                bw.Write(smdh.Reserved_1);

                for (int i = 0; i < 16; i++)
                {
                    AppTitle.Write(smdh.AppTitles[i], s);
                }

                AppSettings.Write(smdh.Settings, s);
                bw.Write(smdh.Reserved_2);
                bw.Write(smdh.SmallIcon.Data);
                bw.Write(smdh.LargeIcon.Data);
            }
        }