Beispiel #1
0
        private void DrawBackground()
        {
            if (CanvasBackground is null)
            {
                return;
            }

            _blockSize = Math.Min(CanvasBackground.ActualWidth / Map.Size.Width, CanvasBackground.ActualHeight / Map.Size.Height);
            CanvasBackground.Children.Clear();
            DrawForeground();

            for (var x = 0; x < Map.Size.Width; x++)
            {
                for (var y = 0; y < Map.Size.Height; y++)
                {
                    var rect = new Shapes.Rectangle()
                    {
                        Width  = _blockSize,
                        Height = _blockSize,
                        Fill   = new SolidColorBrush(Map.Blocks[x, y] switch
                        {
                            BlockType.Floor => ((x + y) % 2 == 0) ? Colors.DimGray : Colors.Gray,
                            BlockType.Start => Colors.PaleGreen,
                            BlockType.Checkpoint => Colors.Aquamarine,
                            BlockType.Finish => Map.FinishedUnlocked ? Colors.PaleTurquoise : Colors.IndianRed,
                            _ => Colors.Wheat,
                        })
                    };

                    CanvasBackground.Children.Add(rect);
                    Canvas.SetLeft(rect, x * _blockSize);
                    Canvas.SetTop(rect, y * _blockSize);
                }
            }
        }
Beispiel #2
0
        public static void PositionGeometry(XamlShapes.Shape renderedGeometry, IViewport viewport)
        {
            CounterScaleLineWidth(renderedGeometry, viewport.Resolution);
            var matrixTransform = new XamlMedia.MatrixTransform {Matrix = CreateTransformMatrix1(viewport)};
            renderedGeometry.RenderTransform = matrixTransform;

            if (renderedGeometry.Fill != null)
                renderedGeometry.Fill.Transform = matrixTransform.Inverse as XamlMedia.MatrixTransform;
        }