예제 #1
0
        public static BoardThemeConfig FromJson(JsonValue json)
        {
            var config = new BoardThemeConfig();

            config.Indicators = BoardThemeIndicatorsConfig.FromJson(json["indicators"]);

            if (json.ContainsKey("rim"))
            {
                config.Rim = BoardThemeRimConfig.FromJson(json["rim"]);
            }

            return(config);
        }
예제 #2
0
        public BoardTheme(string path)
        {
            try
            {
                LightSquare = Image.FromFile(path + "/light_square.png");
                DarkSquare  = Image.FromFile(path + "/dark_square.png");

                Name = System.IO.Path.GetFileName(path.TrimEnd(System.IO.Path.DirectorySeparatorChar));
                try
                {
                    Name = File.ReadAllText(path + "/name");
                }
                catch (Exception)
                {
                }

                Config = BoardThemeConfig.FromJsonFile(path + "/config.json");
            }
            catch (System.IO.FileNotFoundException)
            {
                SetDefaultImages();
            }

            try
            {
                var lightRimSideLeft      = Image.FromFile(path + "/light_rim_side.png");
                var lightRimCornerTopLeft = Image.FromFile(path + "/light_rim_corner.png");

                var darkRimSideLeft      = Image.FromFile(path + "/dark_rim_side.png");
                var darkRimCornerTopLeft = Image.FromFile(path + "/dark_rim_corner.png");

                LightRimSide   = new EnumArray <RimSide, Image>();
                DarkRimSide    = new EnumArray <RimSide, Image>();
                LightRimCorner = new EnumArray <RimCorner, Image>();
                DarkRimCorner  = new EnumArray <RimCorner, Image>();

                LightRimSide[RimSide.Left]   = lightRimSideLeft;
                LightRimSide[RimSide.Right]  = (Image)lightRimSideLeft.Clone();
                LightRimSide[RimSide.Top]    = (Image)lightRimSideLeft.Clone();
                LightRimSide[RimSide.Bottom] = (Image)lightRimSideLeft.Clone();

                LightRimSide[RimSide.Top].RotateFlip(RotateFlipType.Rotate90FlipNone);
                LightRimSide[RimSide.Right].RotateFlip(RotateFlipType.Rotate180FlipNone);
                LightRimSide[RimSide.Bottom].RotateFlip(RotateFlipType.Rotate270FlipNone);


                DarkRimSide[RimSide.Left]   = darkRimSideLeft;
                DarkRimSide[RimSide.Right]  = (Image)darkRimSideLeft.Clone();
                DarkRimSide[RimSide.Top]    = (Image)darkRimSideLeft.Clone();
                DarkRimSide[RimSide.Bottom] = (Image)darkRimSideLeft.Clone();

                DarkRimSide[RimSide.Top].RotateFlip(RotateFlipType.Rotate90FlipNone);
                DarkRimSide[RimSide.Right].RotateFlip(RotateFlipType.Rotate180FlipNone);
                DarkRimSide[RimSide.Bottom].RotateFlip(RotateFlipType.Rotate270FlipNone);


                LightRimCorner[RimCorner.TopLeft]     = lightRimCornerTopLeft;
                LightRimCorner[RimCorner.TopRight]    = (Image)lightRimCornerTopLeft.Clone();
                LightRimCorner[RimCorner.BottomLeft]  = (Image)lightRimCornerTopLeft.Clone();
                LightRimCorner[RimCorner.BottomRight] = (Image)lightRimCornerTopLeft.Clone();

                LightRimCorner[RimCorner.TopRight].RotateFlip(RotateFlipType.Rotate90FlipNone);
                LightRimCorner[RimCorner.BottomRight].RotateFlip(RotateFlipType.Rotate180FlipNone);
                LightRimCorner[RimCorner.BottomLeft].RotateFlip(RotateFlipType.Rotate270FlipNone);


                DarkRimCorner[RimCorner.TopLeft]     = darkRimCornerTopLeft;
                DarkRimCorner[RimCorner.TopRight]    = (Image)darkRimCornerTopLeft.Clone();
                DarkRimCorner[RimCorner.BottomLeft]  = (Image)darkRimCornerTopLeft.Clone();
                DarkRimCorner[RimCorner.BottomRight] = (Image)darkRimCornerTopLeft.Clone();

                DarkRimCorner[RimCorner.TopRight].RotateFlip(RotateFlipType.Rotate90FlipNone);
                DarkRimCorner[RimCorner.BottomRight].RotateFlip(RotateFlipType.Rotate180FlipNone);
                DarkRimCorner[RimCorner.BottomLeft].RotateFlip(RotateFlipType.Rotate270FlipNone);
            }
            catch (System.IO.FileNotFoundException)
            {
                SetDefaultRimImages();
            }
        }