コード例 #1
0
        protected override void OnTileBrushChanged()
        {
            base.OnTileBrushChanged();

            var currentlyUsingShader = this.useTileShader;

            this.useTileShader = this.TileBrush is GradientBrush;

            if (!this.useTileShader)
            {
                var tileImages = TileBoardBase.CreateTileImage(this.TileBrush, this.TileSize);
                this.tileUnsetData = tileImages.Item1.GetPixelData();
                this.tileSetData   = tileImages.Item2.GetPixelData();
                this.tileSetBrush  = new ImageBrush(tileImages.Item2);
                if (this.boardTopVisual != null)
                {
                    this.proxy = new WriteableBitmapProxy(this.boardBitmap);
                    this.InitBoard();
                    return;
                }

                this.DrawBoard();
            }
            else
            {
                this.tileUnsetData = TileBoard.defaultTileUnsetData;
                this.tileSetData   = TileBoard.defaultTileSetData;
                this.tileSetBrush  = new ImageBrush(TileBoardBase.DefaultTileSetImage);

                this.InitBoard();
            }
        }
コード例 #2
0
        protected override void OnTileBrushChanged()
        {
            if (this.TileBrush is GradientBrush)
            {
                this.useTilerShader = true;
                this.tileUnsetImage = TileBoardBase.DefaultTileUnsetImage;
                this.tileSetImage   = TileBoardBase.DefaultTileSetImage;
            }
            else
            {
                var tileImages = TileBoardBase.CreateTileImage(this.TileBrush, this.TileSize);
                this.tileUnsetImage = tileImages.Item1;
                this.tileSetImage   = tileImages.Item2;
            }

            this.RedrawBoard();
        }
コード例 #3
0
        static TileBoardBase()
        {
            var tileImages = TileBoardBase.CreateTileImage(
                TileBoardBase.defaultTileBrush,
                TileBoardBase.defaultTileSize);

            TileBoardBase.defaultTileUnsetImage = tileImages.Item1;
            TileBoardBase.defaultTileSetImage   = tileImages.Item2;

            TileBoardBase.tileTypeImages = new Dictionary <TileType, BitmapSource>();
            for (var i = 1; i < TileType.MineCountMaximum + 1; i++)
            {
                TileBoardBase.tileTypeImages.Add(
                    TileType.Number(i),
                    new BitmapImage(
                        new Uri(
                            "pack://application:,,,/WpfMinesweeper;component/Resources/Images/" + i + ".png",
                            UriKind.Absolute)));
            }

            TileBoardBase.tileTypeImages.Add(
                TileType.Mine,
                new BitmapImage(
                    new Uri(
                        "pack://application:,,,/WpfMinesweeper;component/Resources/Images/Mine.png",
                        UriKind.Absolute)));
            TileBoardBase.flagImage =
                new BitmapImage(
                    new Uri(
                        "pack://application:,,,/WpfMinesweeper;component/Resources/Images/Flag.png",
                        UriKind.Absolute));
            TileBoardBase.questionMarkImage =
                new BitmapImage(
                    new Uri(
                        "pack://application:,,,/WpfMinesweeper;component/Resources/Images/QuestionMark.png",
                        UriKind.Absolute));
        }