Esempio n. 1
0
        private void AddTileImage(TileViewModel aTileViewModel)
        {
            if (this.ViewModel.Image == null || aTileViewModel == null)
            {
                return;
            }

            PointCollection _baseTilePoints = StructureImage.GetBasePoints(
                (this.ViewModel.MinXPosRelToBase - 1) * StructureImage.TileWidth,
                (this.ViewModel.MinYPosRelToBase - 1) * StructureImage.TileHeight);

            if (this.ViewModel.Image != null)
            {
                _baseTilePoints = this.ViewModel.Image.BaseTilePoints;
            }
            int _xShift = aTileViewModel.XPosRelToBase - aTileViewModel.YPosRelToBase;
            int _yShift = aTileViewModel.XPosRelToBase + aTileViewModel.YPosRelToBase;

            Point _p0 = new Point(_baseTilePoints[0].X + _xShift * StructureImage.TileWidth / 2,
                                  _baseTilePoints[0].Y + _yShift * StructureImage.TileHeight / 2);
            Point _p1 = new Point(_baseTilePoints[1].X + _xShift * StructureImage.TileWidth / 2,
                                  _baseTilePoints[1].Y + _yShift * StructureImage.TileHeight / 2);
            Point _p2 = new Point(_baseTilePoints[2].X + _xShift * StructureImage.TileWidth / 2,
                                  _baseTilePoints[2].Y + _yShift * StructureImage.TileHeight / 2);
            Point _p3 = new Point(_baseTilePoints[3].X + _xShift * StructureImage.TileWidth / 2,
                                  _baseTilePoints[3].Y + _yShift * StructureImage.TileHeight / 2);

            Polygon _polygon = new Polygon();

            _polygon.Tag        = aTileViewModel;
            _polygon.MouseDown += TileImage_MouseDown;

            _polygon.Stroke          = aTileViewModel == this.ViewModel.SelectedTile ? this.FImageSelectedTileBrush : this.FImageTileBrush;
            _polygon.StrokeThickness = 2;
            _polygon.Fill            = Brushes.Transparent;
            _polygon.Points          = new PointCollection(4);
            _polygon.Points.Add(_p0);
            _polygon.Points.Add(_p1);
            _polygon.Points.Add(_p2);
            _polygon.Points.Add(_p3);
            this.FImageTiles.Add(_polygon);
            this.cStructureImage.Children.Add(_polygon);
        }
Esempio n. 2
0
        private void AddTileLocImage(RelTileLoc aTileLoc, double aShiftX)
        {
            if (aTileLoc == null || this.ViewModel.Image == null)
            {
                return;
            }

            PointCollection _baseTilePoints =
                StructureImage.GetBasePoints(aShiftX, StructureImage.TileHeight - this.ViewModel.Image.Height);
            int _xShift = aTileLoc.X - aTileLoc.Y;
            int _yShift = aTileLoc.X + aTileLoc.Y;

            Point _p0 = new Point(_baseTilePoints[0].X + _xShift * StructureImage.TileWidth / 2,
                                  _baseTilePoints[0].Y + _yShift * StructureImage.TileHeight / 2);
            Point _p1 = new Point(_baseTilePoints[1].X + _xShift * StructureImage.TileWidth / 2,
                                  _baseTilePoints[1].Y + _yShift * StructureImage.TileHeight / 2);
            Point _p2 = new Point(_baseTilePoints[2].X + _xShift * StructureImage.TileWidth / 2,
                                  _baseTilePoints[2].Y + _yShift * StructureImage.TileHeight / 2);
            Point _p3 = new Point(_baseTilePoints[3].X + _xShift * StructureImage.TileWidth / 2,
                                  _baseTilePoints[3].Y + _yShift * StructureImage.TileHeight / 2);

            Polygon _polygon = new Polygon();

            _polygon.Tag        = aTileLoc;
            _polygon.MouseDown += TileLoc_MouseDown;

            _polygon.Stroke =
                aTileLoc == this.ViewModel.SelectedTileLocData ? this.FImageSelectedTileBrush : this.FImageTileBrush;
            _polygon.StrokeThickness = 2;
            _polygon.Fill            = Brushes.Transparent;
            _polygon.Points          = new PointCollection(4);
            _polygon.Points.Add(_p0);
            _polygon.Points.Add(_p1);
            _polygon.Points.Add(_p2);
            _polygon.Points.Add(_p3);
            this.FImageTiles.Add(_polygon);
            this.cStructureImage.Children.Add(_polygon);
        }