public static FrameworkElement StarControlFactory(Point location, double scale)
        {
            FrameworkElement star;

            switch (_random.Next(3))
            {
            case 0:
                star = new Rectangle();
                ((Rectangle)star).Fill   = new SolidColorBrush(StarColorRandomizer());
                ((Rectangle)star).Width  = 2;
                ((Rectangle)star).Height = 2;
                break;

            case 1:
                star = new Ellipse();
                ((Ellipse)star).Fill   = new SolidColorBrush(StarColorRandomizer());
                ((Ellipse)star).Width  = 2;
                ((Ellipse)star).Height = 2;
                break;

            default:
                star = new StarControl();
                ((StarControl)star).SetFill(new SolidColorBrush(StarColorRandomizer()));
                break;
            }

            SetCanvasLocation(star, location.X * scale, location.Y * scale);
            Canvas.SetZIndex(star, -1000);
            return(star);
        }
Beispiel #2
0
        public static void ScaleStar(StarControl star, double scale)
        {
            const double scaleCoefficient = 0.5;

            star.RenderTransformOrigin = new Point(0.5, 0.5);
            star.ScaleTransform.ScaleX = scale * scaleCoefficient;
            star.ScaleTransform.ScaleY = scale * scaleCoefficient;
        }
Beispiel #3
0
        internal static FrameworkElement StarControlFactory(Point star, double scale)
        {
            StarControl starControl = new StarControl();

            SetCanvasLocation(starControl, star.X * scale, star.Y * scale);
            Canvas.SetZIndex(starControl, -1000);
            return(starControl);
        }
Beispiel #4
0
        public static FrameworkElement StarControlFactory(Point point, double scale)
        {
            FrameworkElement star;

            switch (_random.Next(3))
            {
                case 0:
                    star = new Rectangle()
                    {
                        Width = 2,
                        Height = 2,
                        Fill = new SolidColorBrush(GetRandomStarColor()),
                    };
                    break;
                case 1:
                    star = new Ellipse()
                    {
                        Width = 2,
                        Height = 2,
                        Fill = new SolidColorBrush(GetRandomStarColor()),
                    };
                    break;
                default:
                    star = new StarControl();
                    ((StarControl)star).SetFill(new SolidColorBrush(GetRandomStarColor()));
                    break;
            };

            SetCanvasLocation(star, point.X * scale, point.Y * scale);
            SendToBack(star);

            return star;
        }