예제 #1
0
 private void UpdatePosition(Shape ellipse, Particle particle)
 {
     if (particle.IsStopped())
         ellipse.Fill = _cholesterolBrush;
     ellipse.SetValue(Canvas.LeftProperty, particle.Position.X - _particleSize /2);
     ellipse.SetValue(Canvas.TopProperty, particle.Position.Y - _particleSize / 2);
 }
예제 #2
0
        internal static Shape InitializeShape(this Canvas canvas, Rectangle rect, Shape shape, double scaleX, double scaleY, Brush color)
        {
            shape.SetValue(WindowData.RectLeftProperty, rect.X * scaleX);
            shape.SetValue(WindowData.RectTopProperty, rect.Y * scaleY);
            shape.Width = rect.W * scaleX;
            shape.Height = rect.H * scaleY;

            shape.Stroke = color;
            shape.StrokeThickness = 2;

            return shape;
        }
예제 #3
0
 private void SetShapeSize(Shape shape, Abstraction.Rectangle rectangle)
 {
     shape.SetValue(Canvas.LeftProperty, rectangle.X);
     shape.SetValue(Canvas.TopProperty, rectangle.Y);
     shape.Width = rectangle.Width;
     shape.Height = rectangle.Height;
 }
예제 #4
0
 private void SetShapeSize(Shape shape, Point currentPosition, Point startPosition)
 {
     shape.SetValue(Canvas.LeftProperty, Math.Min(currentPosition.X, startPosition.X));
     shape.SetValue(Canvas.TopProperty, Math.Min(currentPosition.Y, startPosition.Y));
     shape.Width = Math.Abs(currentPosition.X - startPosition.X);
     shape.Height = Math.Abs(currentPosition.Y - startPosition.Y);
 }
예제 #5
0
        void PositionEscaperInsideCell(Shape figure, Cell cell)
        {
            // Cell dimensions are computed from canvas size.
            var cellWidth = Canvas.ActualWidth / _currentMaze.Width;
            var cellHeight = Canvas.ActualHeight / _currentMaze.Height;

            // Useful methods to compute cell offsets.
            Func<uint, double> xOffset = x => x * cellWidth;
            Func<uint, double> yOffset = y => y * cellHeight;

            figure.Fill = new SolidColorBrush(Colors.Magenta);
            figure.SetValue(Canvas.LeftProperty, xOffset(cell.X));
            figure.SetValue(Canvas.TopProperty, yOffset(cell.Y));
            figure.Width = figure.Height = 15;
        }
        /// <summary>
        /// The set stroke.
        /// </summary>
        /// <param name="shape">
        /// The shape.
        /// </param>
        /// <param name="stroke">
        /// The stroke.
        /// </param>
        /// <param name="thickness">
        /// The thickness.
        /// </param>
        /// <param name="lineJoin">
        /// The line join.
        /// </param>
        /// <param name="dashArray">
        /// The dash array.
        /// </param>
        /// <param name="aliased">
        /// The aliased.
        /// </param>
        private void SetStroke(
            Shape shape,
            OxyColor stroke,
            double thickness,
            OxyPenLineJoin lineJoin = OxyPenLineJoin.Miter,
            IEnumerable<double> dashArray = null,
            bool aliased = false)
        {
            if (stroke != null && thickness > 0)
            {
                shape.Stroke = this.GetCachedBrush(stroke);

                switch (lineJoin)
                {
                    case OxyPenLineJoin.Round:
                        shape.StrokeLineJoin = PenLineJoin.Round;
                        break;
                    case OxyPenLineJoin.Bevel:
                        shape.StrokeLineJoin = PenLineJoin.Bevel;
                        break;

                    // The default StrokeLineJoin is Miter
                }

                if (Math.Abs(thickness - 1) > double.Epsilon)
                {
                    // only set if different from the default value (1)
                    shape.StrokeThickness = thickness;
                }

                if (dashArray != null)
                {
                    shape.StrokeDashArray = new DoubleCollection(dashArray);
                }
            }

            if (aliased)
            {
                shape.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased);
                shape.SnapsToDevicePixels = true;
            }
        }
예제 #7
0
 /// <summary>
 /// Set the position in grid
 /// </summary>
 /// <param name="p"></param>
 /// <param name="s"></param>
 private static void MoveToPoint(System.Drawing.Point p, Shape s)
 {
     s.SetValue(Grid.ColumnProperty, p.X);
     s.SetValue(Grid.RowProperty, p.Y);
 }