ThemeEditor.Common.Themes.Theme.Read_Textures C# (CSharp) Метод

Read_Textures() приватный статический Метод

private static Read_Textures ( Stream s, Flags flags, TextureOffsets offsets ) : Textures
s Stream
flags Flags
offsets ThemeEditor.Common.Themes.Offsets.TextureOffsets
Результат Textures
        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;
        }