Example #1
0
 public SimplePipe this[Tile e]
 {
     get
     {
         return this[e.IndexX, e.IndexY];
     }
     set
     {
         this[e.IndexX, e.IndexY] = value;
     }
 }
Example #2
0
        public TileField(int SizeX, int SizeY)
        {
            this.SizeX = SizeX;
            this.SizeY = SizeY;

            this.Width = Tile.Size * SizeX + Tile.ShadowBorder * 2;
            this.Height = Tile.SurfaceHeight * (SizeY - 1) + Tile.Size + Tile.ShadowBorder * 2;

            this.Shadow = new Canvas
            {
                Width = this.Width,
                Height = this.Height,
            };

            this.Content = new Canvas
            {
                Width = this.Width,
                Height = this.Height,
            };

            this.Overlay = new Canvas
            {
                Width = this.Width,
                Height = this.Height,
            };

            this.Container = new Canvas
            {
                Width = this.Width,
                Height = this.Height,
            };

            this.Shadow.AttachTo(this.Container);
            this.Content.AttachTo(this.Container);

            for (int ix = 0; ix < SizeX; ix++)
                for (int iy = 0; iy < SizeY; iy++)
                {
                    var tile = new Tile
                    {
                        IndexX = ix,
                        IndexY = iy
                    };

                    TileList.Add(tile);

                    tile.Shadow.MoveTo(64 * ix, 52 * iy).AttachTo(this.Shadow);
                    tile.Container.MoveTo(64 * ix + Tile.ShadowBorder, 52 * iy + Tile.ShadowBorder).AttachTo(this.Content);
                    tile.Overlay.MoveTo(64 * ix + Tile.ShadowBorder, 52 * iy + Tile.ShadowBorder).AttachTo(this.Overlay);

                    tile.Overlay.MouseEnter +=
                        delegate
                        {
                            FocusTile = tile;

                            if (Focus != null)
                                Focus(tile);

                            //tile.YellowFilter.Visibility = System.Windows.Visibility.Visible;
                            tile.Select.Show();
                        };

                    tile.Overlay.MouseLeave +=
                        delegate
                        {
                            FocusTile = null;

                            if (Unfocus != null)
                                Unfocus(tile);

                            tile.Select.Hide();
                            //tile.YellowFilter.Visibility = System.Windows.Visibility.Hidden;
                        };
                }

            this.Overlay.MouseLeftButtonUp +=
                delegate
                {
                    if (Click != null)
                        Click(FocusTile);
                };
        }