Beispiel #1
0
            private static Brush CreateBrush()
            {
                RadialGradientBrush brush = new RadialGradientBrush(Colors.Black, Colors.White);

                brush.Freeze();
                return(brush);
            }
        public AggregateComponent(Color _color, int _id)
        {
            p  = null;
            id = _id;
            component_model = new GeometryModel3D {
                Geometry = new MeshGeometry3D()
            };
            Ellipse ellipse = new Ellipse {
                Width  = 32.0,
                Height = 32.0
            };
            RadialGradientBrush rb = new RadialGradientBrush();

            rb.GradientStops.Add(new GradientStop(_color, 0.0));
            rb.GradientStops.Add(new GradientStop(Colors.Black, 1.0));
            rb.Freeze();
            ellipse.Fill = rb;
            ellipse.Measure(new Size(32.0, 32.0));
            ellipse.Arrange(new Rect(0.0, 0.0, 32.0, 32.0));
            //RenderTargetBitmap bm = new RenderTargetBitmap(32, 32, 96.0, 96.0, PixelFormats.Pbgra32);
            //bm.Render(ellipse);
            //bm.Freeze();
            //ImageBrush ib = new ImageBrush(bm);
            ellipse.CacheMode = new BitmapCache();
            BitmapCacheBrush ib = new BitmapCacheBrush(ellipse);
            DiffuseMaterial  dm = new DiffuseMaterial(ib);

            component_model.Material = dm;
            particle_positions       = new Point3DCollection();
            triangle_indices         = new Int32Collection();
            tex_coords = new PointCollection();
            ((MeshGeometry3D)component_model.Geometry).Positions          = particle_positions;
            ((MeshGeometry3D)component_model.Geometry).TriangleIndices    = triangle_indices;
            ((MeshGeometry3D)component_model.Geometry).TextureCoordinates = tex_coords;
        }
Beispiel #3
0
        private Ellipse CubesSphere(GameField gameField)
        {
            var center     = gameField.Cube.Center;
            var centerAndD = new Point3D(center.X + 1, center.Y, center.Z);
            var elc        = _transform3DTool.TransformPointTo2D(center);
            var els        = _transform3DTool.TransformPointTo2D(centerAndD);
            var d          = Math.Sqrt(Math.Pow(elc.X - els.X, 2) + Math.Pow(elc.Y - els.Y, 2)) * 0.7;

            var fill = new RadialGradientBrush
            {
                GradientOrigin = new Point(0.75, 0.25),
                GradientStops  = new GradientStopCollection
                {
                    new GradientStop(Colors.White, 0),
                    new GradientStop(
                        gameField.PlayerColor.Color == Colors.White
                        ? Colors.LightGray
                        : gameField.PlayerColor.Color,
                        0.8)
                }
            };

            fill.Freeze();
            var e = new Ellipse
            {
                Width   = d,
                Height  = d,
                Fill    = fill,
                Opacity = gameField.Layer == HighlightedLayer ? 1 : 0.7
            };

            Canvas.SetTop(e, elc.Y - d / 2);
            Canvas.SetLeft(e, elc.X - d / 2);
            return(e);
        }
        private static Brush[] CreateBrushes(Color c, CornerRadius cornerRadius)
        {
            Brush[] brushArray = new Brush[9];
            brushArray[4] = (Brush) new SolidColorBrush(c);
            brushArray[4].Freeze();
            GradientStopCollection stops = SystemDropShadowChrome.CreateStops(c, 0.0);
            LinearGradientBrush    linearGradientBrush1 = new LinearGradientBrush(stops, new Point(0.0, 1.0), new Point(0.0, 0.0));

            linearGradientBrush1.Freeze();
            brushArray[1] = (Brush)linearGradientBrush1;
            LinearGradientBrush linearGradientBrush2 = new LinearGradientBrush(stops, new Point(1.0, 0.0), new Point(0.0, 0.0));

            linearGradientBrush2.Freeze();
            brushArray[3] = (Brush)linearGradientBrush2;
            LinearGradientBrush linearGradientBrush3 = new LinearGradientBrush(stops, new Point(0.0, 0.0), new Point(1.0, 0.0));

            linearGradientBrush3.Freeze();
            brushArray[5] = (Brush)linearGradientBrush3;
            LinearGradientBrush linearGradientBrush4 = new LinearGradientBrush(stops, new Point(0.0, 0.0), new Point(0.0, 1.0));

            linearGradientBrush4.Freeze();
            brushArray[7] = (Brush)linearGradientBrush4;
            GradientStopCollection gradientStopCollection1 = cornerRadius.TopLeft != 0.0 ? SystemDropShadowChrome.CreateStops(c, cornerRadius.TopLeft) : stops;
            RadialGradientBrush    radialGradientBrush1    = new RadialGradientBrush(gradientStopCollection1);

            radialGradientBrush1.RadiusX        = 1.0;
            radialGradientBrush1.RadiusY        = 1.0;
            radialGradientBrush1.Center         = new Point(1.0, 1.0);
            radialGradientBrush1.GradientOrigin = new Point(1.0, 1.0);
            radialGradientBrush1.Freeze();
            brushArray[0] = (Brush)radialGradientBrush1;
            GradientStopCollection gradientStopCollection2 = cornerRadius.TopRight != 0.0 ? (cornerRadius.TopRight != cornerRadius.TopLeft ? SystemDropShadowChrome.CreateStops(c, cornerRadius.TopRight) : gradientStopCollection1) : stops;
            RadialGradientBrush    radialGradientBrush2    = new RadialGradientBrush(gradientStopCollection2);

            radialGradientBrush2.RadiusX        = 1.0;
            radialGradientBrush2.RadiusY        = 1.0;
            radialGradientBrush2.Center         = new Point(0.0, 1.0);
            radialGradientBrush2.GradientOrigin = new Point(0.0, 1.0);
            radialGradientBrush2.Freeze();
            brushArray[2] = (Brush)radialGradientBrush2;
            GradientStopCollection gradientStopCollection3 = cornerRadius.BottomLeft != 0.0 ? (cornerRadius.BottomLeft != cornerRadius.TopLeft ? (cornerRadius.BottomLeft != cornerRadius.TopRight ? SystemDropShadowChrome.CreateStops(c, cornerRadius.BottomLeft) : gradientStopCollection2) : gradientStopCollection1) : stops;
            RadialGradientBrush    radialGradientBrush3    = new RadialGradientBrush(gradientStopCollection3);

            radialGradientBrush3.RadiusX        = 1.0;
            radialGradientBrush3.RadiusY        = 1.0;
            radialGradientBrush3.Center         = new Point(1.0, 0.0);
            radialGradientBrush3.GradientOrigin = new Point(1.0, 0.0);
            radialGradientBrush3.Freeze();
            brushArray[6] = (Brush)radialGradientBrush3;
            RadialGradientBrush radialGradientBrush4 = new RadialGradientBrush(cornerRadius.BottomRight != 0.0 ? (cornerRadius.BottomRight != cornerRadius.TopLeft ? (cornerRadius.BottomRight != cornerRadius.TopRight ? (cornerRadius.BottomRight != cornerRadius.BottomLeft ? SystemDropShadowChrome.CreateStops(c, cornerRadius.BottomRight) : gradientStopCollection3) : gradientStopCollection2) : gradientStopCollection1) : stops);

            radialGradientBrush4.RadiusX        = 1.0;
            radialGradientBrush4.RadiusY        = 1.0;
            radialGradientBrush4.Center         = new Point(0.0, 0.0);
            radialGradientBrush4.GradientOrigin = new Point(0.0, 0.0);
            radialGradientBrush4.Freeze();
            brushArray[8] = (Brush)radialGradientBrush4;
            return(brushArray);
        }
Beispiel #5
0
        private static void DrawBackground(Color background, Color backgroundUpDown, Color border)
        {
            switch (FProp.Default.FRarity_Design)
            {
            case "Flat":
                Point         dStart    = new Point(3, 440);
                LineSegment[] dSegments = new[]
                {
                    new LineSegment(new Point(512, 380), true),
                    new LineSegment(new Point(512, 380 + 132), true),
                    new LineSegment(new Point(3, 380 + 132), true),
                    new LineSegment(new Point(3, 440), true)
                };
                PathFigure   dFigure = new PathFigure(dStart, dSegments, true);
                PathGeometry dGeo    = new PathGeometry(new[] { dFigure });

                Point         uStart    = new Point(3, 3);
                LineSegment[] uSegments = new[]
                {
                    new LineSegment(new Point(3, 33), true),
                    new LineSegment(new Point(335, 3), true)
                };
                PathFigure   uFigure = new PathFigure(uStart, uSegments, true);
                PathGeometry uGeo    = new PathGeometry(new[] { uFigure });


                //background + border
                IconCreator.ICDrawingContext.DrawRectangle(new SolidColorBrush(border), null, new Rect(0, 0, 515, 515));
                IconCreator.ICDrawingContext.DrawRectangle(new SolidColorBrush(background), null, new Rect(3, 3, 509, 509));
                //up & down
                IconCreator.ICDrawingContext.DrawGeometry(new SolidColorBrush(Color.FromArgb(125, backgroundUpDown.R, backgroundUpDown.G, backgroundUpDown.B)), null, uGeo);
                IconCreator.ICDrawingContext.DrawGeometry(new SolidColorBrush(Color.FromArgb(125, backgroundUpDown.R, backgroundUpDown.G, backgroundUpDown.B)), null, dGeo);
                break;

            case "Default":
            case "Minimalist":
                RadialGradientBrush radialGradient = new RadialGradientBrush();
                radialGradient.GradientOrigin = new Point(0.5, 0.5);
                radialGradient.Center         = new Point(0.5, 0.5);

                radialGradient.RadiusX = 0.5;
                radialGradient.RadiusY = 0.5;

                radialGradient.GradientStops.Add(new GradientStop(background, 0.0));
                radialGradient.GradientStops.Add(new GradientStop(backgroundUpDown, 1.5));

                // Freeze the brush (make it unmodifiable) for performance benefits.
                radialGradient.Freeze();

                //background + border
                IconCreator.ICDrawingContext.DrawRectangle(new SolidColorBrush(border), null, new Rect(0, 0, 515, 515));
                IconCreator.ICDrawingContext.DrawRectangle(radialGradient, null, new Rect(3, 3, 509, 509));
                break;

            default:
                break;
            }
        }
        private RadialGradientBrush CreateFrozenBrush(GradientStopCollection stops, double radX, double radY, Point center, Point origin)
        {
            var brush = new RadialGradientBrush(stops)
            {
                RadiusX        = radX,
                RadiusY        = radY,
                Center         = center,
                GradientOrigin = origin
            };

            brush.Freeze();

            return(brush);
        }
Beispiel #7
0
        static KlopCell2()
        {
            AvailableBrush = new SolidColorBrush(Colors.Gray)
            {
                Opacity = 0.3
            };
            HoverBrush.Opacity            = 0.5;
            HoverUnavailableBrush.Opacity = 0.2;

            AvailableBrush.Freeze();
            BorderPen.Freeze();
            HoverBrush.Freeze();
            HoverUnavailableBrush.Freeze();
            DeadBrush.Freeze();
        }
Beispiel #8
0
        // Helper
        private RadialGradientBrush DonutBrush(Color customColor)
        {
            RadialGradientBrush brush = new RadialGradientBrush {
                Center         = new Point(13, 13),
                GradientOrigin = new Point(13, 13),
                MappingMode    = BrushMappingMode.Absolute,
                RadiusX        = 13,
                RadiusY        = 13
            };

            // Add the colors to make a donut
            brush.GradientStops.Add(new GradientStop(Colors.Transparent, 0.4));
            brush.GradientStops.Add(new GradientStop(customColor, 0.4));
            brush.Freeze();
            return(brush);
        }
        private RadialGradientBrush GenerateRadialColorShape()
        {
            RadialGradientBrush selectedStackPanel = new RadialGradientBrush();

            selectedStackPanel.GradientOrigin = new Point(0.5, 0.5);
            selectedStackPanel.Center         = new Point(0.5, 0.5);
            selectedStackPanel.RadiusX        = 0.5;
            selectedStackPanel.RadiusY        = 0.5;

            selectedStackPanel.GradientStops.Add(new GradientStop(Colors.LightCoral, 0.0));
            selectedStackPanel.GradientStops.Add(new GradientStop(Color.FromRgb(255, 255, 231), 0.4));
            selectedStackPanel.GradientStops.Add(new GradientStop(Colors.LightCoral, 0.7));

            selectedStackPanel.Freeze();

            return(selectedStackPanel);
        }
Beispiel #10
0
        public RadialGradientBrushSnippet()
        {
            Title      = "RadialGradientBrush Example";
            Background = Brushes.White;
            Margin     = new Thickness(20);

            //
            // Create a RadialGradientBrush with four gradient stops.
            //
            RadialGradientBrush radialGradient = new RadialGradientBrush();

            // Set the GradientOrigin to the center of the area being painted.
            radialGradient.GradientOrigin = new Point(0.5, 0.5);

            // Set the gradient center to the center of the area being painted.
            radialGradient.Center = new Point(0.5, 0.5);

            // Set the radius of the gradient circle so that it extends to
            // the edges of the area being painted.
            radialGradient.RadiusX = 0.5;
            radialGradient.RadiusY = 0.5;

            // Create four gradient stops.
            radialGradient.GradientStops.Add(new GradientStop(Colors.Yellow, 0.0));
            radialGradient.GradientStops.Add(new GradientStop(Colors.Red, 0.25));
            radialGradient.GradientStops.Add(new GradientStop(Colors.Blue, 0.75));
            radialGradient.GradientStops.Add(new GradientStop(Colors.LimeGreen, 1.0));

            // Freeze the brush (make it unmodifiable) for performance benefits.
            radialGradient.Freeze();

            // Create a rectangle and paint it with the
            // RadialGradientBrush.
            Rectangle aRectangle = new Rectangle();

            aRectangle.Width  = 200;
            aRectangle.Height = 100;
            aRectangle.Fill   = radialGradient;

            StackPanel mainPanel = new StackPanel();

            mainPanel.Children.Add(aRectangle);
            Content = mainPanel;
        }
Beispiel #11
0
        private Brush GetForegroundBrush()
        {
            if (!IsMouseOver)
            {
                return(new SolidColorBrush(BackgroundColor));
            }
            else
            {
                RadialGradientBrush brush    = new RadialGradientBrush(Colors.White, BackgroundColor);
                Point absoluteGradientOrigin = Mouse.GetPosition(this);
                Point relativeGradientOrigin = new Point(
                    absoluteGradientOrigin.X / base.ActualWidth, absoluteGradientOrigin.Y / base.ActualHeight);

                brush.GradientOrigin = relativeGradientOrigin;
                brush.Center         = relativeGradientOrigin;
                brush.Freeze();
                return(brush);
            }
        }
Beispiel #12
0
        private Brush CreateBrush(double centerX, double centerY, double radiusX, double radiusY)
        {
            if (!base.Antialiased)
            {
                return(SolidColorBrushCache.Get((ColorRgba128Float)Colors.White));
            }
            GradientStopCollection gradientStopCollection = new GradientStopCollection(0x20);

            for (int i = 0; i < 0x20; i++)
            {
                double num2;
                switch (i)
                {
                case 0:
                    num2 = 0.0;
                    break;

                case 0x1f:
                    num2 = 1.0;
                    break;

                default:
                    num2 = ((double)i) / 31.0;
                    break;
                }
                double       gradientStopAlpha = this.GetGradientStopAlpha(num2);
                GradientStop item = new GradientStop(new ColorRgba128Float((ColorRgba128Float)Colors.White, (float)gradientStopAlpha), num2);
                gradientStopCollection.Add(item);
            }
            gradientStopCollection.Freeze();
            RadialGradientBrush brush = new RadialGradientBrush(gradientStopCollection)
            {
                ColorInterpolationMode = ColorInterpolationMode.ScRgbLinearInterpolation,
                GradientOrigin         = PointDouble.Zero,
                RadiusX = radiusX,
                RadiusY = radiusY,
                Center  = new PointDouble(centerX, centerY)
            };

            brush.Freeze();
            return(brush);
        }
Beispiel #13
0
        /// <summary>
        /// Displays a point on the screen in the specified location, with the specified colour.
        /// </summary>
        /// <param name="id">Id of the point.</param>
        /// <param name="p">Position of the point in screen coordinates.</param>
        /// <param name="brushColor">The brush to use for the elipse.</param>
        void DisplayPoint(int id, PointF p, System.Windows.Media.Color brushColor)
        {
            Ellipse e = null;

            if (points.ContainsKey(id))
            {
                e = points[id] as Ellipse;
                e.RenderTransform = new TranslateTransform(p.X - 13, p.Y - 13);
            }

            if (e == null)
            {
                e = new Ellipse();

                RadialGradientBrush radialGradient = new RadialGradientBrush();
                radialGradient.GradientOrigin = new System.Windows.Point(0.5, 0.5);
                radialGradient.Center         = new System.Windows.Point(0.5, 0.5);
                radialGradient.RadiusX        = 0.5;
                radialGradient.RadiusY        = 0.5;

                System.Windows.Media.Color shadow = Colors.Black;
                shadow.A = 30;
                radialGradient.GradientStops.Add(new GradientStop(shadow, 0.9));
                brushColor.A = 60;
                radialGradient.GradientStops.Add(new GradientStop(brushColor, 0.8));
                brushColor.A = 150;
                radialGradient.GradientStops.Add(new GradientStop(brushColor, 0.1));

                radialGradient.Freeze();

                e.Height = 26.0;
                e.Width  = 26.0;
                e.Fill   = radialGradient;

                int eZ = this.framework.MaxZIndex + 100;
                e.IsHitTestVisible = false;
                e.RenderTransform  = new TranslateTransform(p.X - 13, p.Y - 13);
                canvas1.Children.Add(e);
                Panel.SetZIndex(e, eZ);
                points.Add(id, e);
            }
        }
Beispiel #14
0
        private void InitializeGradients()
        {
            blueRadialGradient.GradientOrigin = new Point(0.5, 0.5);
            blueRadialGradient.Center         = new Point(0.5, 0.5);
            blueRadialGradient.RadiusX        = 0.5;
            blueRadialGradient.RadiusY        = 0.5;
            blueRadialGradient.GradientStops.Add(new GradientStop(Color.FromRgb(200, 30, 30), 1));
            blueRadialGradient.GradientStops.Add(new GradientStop(Color.FromRgb(200, 60, 60), 0.8));
            blueRadialGradient.GradientStops.Add(new GradientStop(Color.FromRgb(200, 110, 110), 0.0));
            blueRadialGradient.Freeze();

            redRadialGradient.GradientOrigin = new Point(0.5, 0.5);
            redRadialGradient.Center         = new Point(0.5, 0.5);
            redRadialGradient.RadiusX        = 0.5;
            redRadialGradient.RadiusY        = 0.5;
            redRadialGradient.GradientStops.Add(new GradientStop(Color.FromRgb(20, 20, 220), 1));
            redRadialGradient.GradientStops.Add(new GradientStop(Color.FromRgb(40, 40, 200), 0.7));
            redRadialGradient.GradientStops.Add(new GradientStop(Color.FromRgb(80, 80, 180), 0.0));
            redRadialGradient.Freeze();
        }
Beispiel #15
0
        private void InitializeRadBrush()
        {
            // Set the GradientOrigin to the center of the area being painted.
            HoverStateBrush.GradientOrigin = new Point(0.5, 0.5);

            // Set the gradient center to the center of the area being painted.
            HoverStateBrush.Center = new Point(0.5, 0.5);

            // Set the radius of the gradient circle so that it extends to
            // the edges of the area being painted.
            HoverStateBrush.RadiusX = 0.65;
            HoverStateBrush.RadiusY = 0.85;

            // Create four gradient stops.
            HoverStateBrush.GradientStops.Add(new GradientStop(Color.FromRgb(0x29, 0xB0, 0xC4), 0.0));
            HoverStateBrush.GradientStops.Add(new GradientStop(Color.FromRgb(0x31, 0xDB, 0xF5), 1.0));

            // Freeze the brush (make it unmodifiable) for performance benefits.
            HoverStateBrush.Freeze();
        }
Beispiel #16
0
        public override void Dibujarse()
        {
            // Crear figura
            Ellipse elipsePlaneta = new Ellipse();

            elipsePlaneta.Name       = Nombre;
            elipsePlaneta.Width      = Dimenciones.Ancho;
            elipsePlaneta.Height     = Dimenciones.Largo;
            elipsePlaneta.Visibility = Visibility.Visible;

            // Generar el relleno del elipse
            RadialGradientBrush radialGradient = new RadialGradientBrush();

            radialGradient.GradientOrigin = new Point(0.5, 0.5);

            // Set the gradient center to the center of the area being painted.
            radialGradient.Center = new Point(0.5, 0.5);

            // Set the radius of the gradient circle so that it extends to
            // the edges of the area being painted.
            radialGradient.RadiusX = 0.5;
            radialGradient.RadiusY = 0.5;

            // Create four gradient stops.
            radialGradient.GradientStops.Add(new GradientStop(ColorCentral, 0.1));
            radialGradient.GradientStops.Add(new GradientStop(ColorBorde, 1));

            // Freeze the brush (make it unmodifiable) for performance benefits.
            radialGradient.Freeze();

            elipsePlaneta.Fill = radialGradient;

            // Asignar el elipse a la variable del elemento dibujable
            elementoDibujable = elipsePlaneta;

            // Cargar en canvas
            Canvas.Children.Add(elipsePlaneta);
            Canvas.SetLeft(elipsePlaneta, this.Posicion.PosicionX);
            Canvas.SetTop(elipsePlaneta, this.Posicion.PosicionY);
            Canvas.SetZIndex(elipsePlaneta, 0);
        }
        public UGRadialGradientBrush(IUGContext context, Vector2 center, float radius, IEnumerable <UGGradientStop> gradientStops, UGEdgeBehavior edgeBehavior)
        {
            var count = gradientStops.Count();

            if (count < 2)
            {
                throw new ArgumentException(nameof(gradientStops));
            }

            var wpfStops  = gradientStops.ToWPFGradientStopCollection(count);
            var native    = new RadialGradientBrush(wpfStops);
            var wpfCenter = center.ToWPFPoint();

            native.Center         = wpfCenter;
            native.GradientOrigin = wpfCenter;
            native.RadiusX        = radius;
            native.RadiusY        = radius;
            native.SpreadMethod   = edgeBehavior.ToWPFSpreadMethod();
            native.Freeze();
            _native = native;
        }
Beispiel #18
0
        private Brush GetForegroundBrush()
        {
            if (!IsMouseOver)
            {
                return(new SolidColorBrush(BackgroundColor));
            }

            var absoluteGradientOrigin = Mouse.GetPosition(this);
            var relativeGradientOrigin = new Point(
                absoluteGradientOrigin.X / ActualWidth, absoluteGradientOrigin.Y / ActualHeight);

            var brush = new RadialGradientBrush(Colors.White, BackgroundColor)
            {
                GradientOrigin = relativeGradientOrigin,
                RadiusX        = 0.2,
                Center         = relativeGradientOrigin
            };

            brush.Freeze();

            return(brush);
        }
Beispiel #19
0
        // *** Private static methods ***
        private static void CreateBrushes()
        {
            // Get the colors for the shadow
            Color shadowColor      = Color.FromArgb(128, 0, 0, 0);
            Color transparentColor = Color.FromArgb(16, 0, 0, 0);
            // Create a GradientStopCollection from these
            GradientStopCollection gradient = new GradientStopCollection(2);

            gradient.Add(new GradientStop(shadowColor, 0.5));
            gradient.Add(new GradientStop(transparentColor, 1.0));
            gradient.Freeze();
            // Create the background brush
            backgroundBrush = new SolidColorBrush(shadowColor);
            backgroundBrush.Freeze();
            // Create the LinearGradientBrushes
            rightBrush  = new LinearGradientBrush(gradient, new Point(0.0, 0.0), new Point(1.0, 0.0)); rightBrush.Freeze();
            bottomBrush = new LinearGradientBrush(gradient, new Point(0.0, 0.0), new Point(0.0, 1.0)); bottomBrush.Freeze();
            // Create the RadialGradientBrushes
            bottomRightBrush = new RadialGradientBrush(gradient);
            bottomRightBrush.GradientOrigin = new Point(0.0, 0.0);
            bottomRightBrush.Center         = new Point(0.0, 0.0);
            bottomRightBrush.RadiusX        = 1.0;
            bottomRightBrush.RadiusY        = 1.0;
            bottomRightBrush.Freeze();

            topRightBrush = new RadialGradientBrush(gradient);
            topRightBrush.GradientOrigin = new Point(0.0, 1.0);
            topRightBrush.Center         = new Point(0.0, 1.0);
            topRightBrush.RadiusX        = 1.0;
            topRightBrush.RadiusY        = 1.0;
            topRightBrush.Freeze();

            bottomLeftBrush = new RadialGradientBrush(gradient);
            bottomLeftBrush.GradientOrigin = new Point(1.0, 0.0);
            bottomLeftBrush.Center         = new Point(1.0, 0.0);
            bottomLeftBrush.RadiusX        = 1.0;
            bottomLeftBrush.RadiusY        = 1.0;
            bottomLeftBrush.Freeze();
        }
Beispiel #20
0
        private DrawingVisual GetFaceDrawingVisual()
        {
            RadialGradientBrush radialGradientBrush = new RadialGradientBrush(Colors.Yellow, Colors.Orange);

            radialGradientBrush.RadiusX = 0.8;
            radialGradientBrush.RadiusY = 0.8;
            radialGradientBrush.Freeze();
            Pen outerPen = new Pen(Brushes.Black, 5.25);

            outerPen.Freeze();
            DrawingVisual  drawingVisual  = new DrawingVisual();
            DrawingContext drawingContext = drawingVisual.RenderOpen();

            drawingContext.DrawEllipse(radialGradientBrush, outerPen, new Point(75, 75), 72.375, 72.375);
            drawingContext.DrawEllipse(Brushes.Black, null, new Point(44.25, 49.5), 10.125, 12.75);
            drawingContext.DrawEllipse(Brushes.Black, null, new Point(105.75, 49.5), 10.125, 12.75);
            ArcSegment arcSegment = new ArcSegment(new Point(115.5, 93.75), new Size(61.5, 61.5), 0, false, SweepDirection.Counterclockwise, true);

            PathFigure pathFigure = new PathFigure(new Point(34.5, 93.75), new List <PathSegment>()
            {
                arcSegment
            }, false);
            PathGeometry pathGeometry = new PathGeometry(new List <PathFigure>()
            {
                pathFigure
            });

            pathGeometry.Freeze();
            Pen smilePen = new Pen(Brushes.Black, 10.5);

            smilePen.StartLineCap = PenLineCap.Round;
            smilePen.EndLineCap   = PenLineCap.Round;
            smilePen.Freeze();
            drawingContext.DrawGeometry(null, smilePen, pathGeometry);
            drawingContext.Close();

            return(drawingVisual);
        }
        private DrawingVisual GetFaceDrawingVisual()
        {
            RadialGradientBrush radialGradientBrush = new RadialGradientBrush(Colors.Yellow, Colors.Orange);

            radialGradientBrush.RadiusX = 0.8;
            radialGradientBrush.RadiusY = 0.8;
            radialGradientBrush.Freeze();
            Pen outerPen = new Pen(Brushes.Black, 5.25);

            outerPen.Freeze();
            DrawingVisual  drawingVisual  = new DrawingVisual();
            DrawingContext drawingContext = drawingVisual.RenderOpen();

            drawingContext.DrawEllipse(radialGradientBrush, outerPen, new Point(ActualWidth / 2, ActualHeight / 2), (ActualWidth - outerPen.Thickness) / 2, (ActualHeight - outerPen.Thickness) / 2);
            drawingContext.DrawEllipse(Brushes.Black, null, new Point(ActualWidth / 3.3898305084745761, ActualHeight / 3.0303030303030303), ActualWidth / 14.814814814814815, ActualHeight / 11.764705882352942);
            drawingContext.DrawEllipse(Brushes.Black, null, new Point(ActualWidth / 1.4184397163120568, ActualHeight / 3.0303030303030303), ActualWidth / 14.814814814814815, ActualHeight / 11.764705882352942);
            ArcSegment arcSegment = new ArcSegment(new Point(ActualWidth / 1.2987012987012987, ActualHeight / 1.6), new Size(ActualWidth / 2.4390243902439024, ActualHeight / 2.4390243902439024), 0, false, SweepDirection.Counterclockwise, true);
            PathFigure pathFigure = new PathFigure(new Point(ActualWidth / 4.3478260869565215, ActualHeight / 1.6), new List <PathSegment>()
            {
                arcSegment
            }, false);
            PathGeometry pathGeometry = new PathGeometry(new List <PathFigure>()
            {
                pathFigure
            });

            pathGeometry.Freeze();
            Pen smilePen = new Pen(Brushes.Black, 10.5);

            smilePen.StartLineCap = PenLineCap.Round;
            smilePen.EndLineCap   = PenLineCap.Round;
            smilePen.Freeze();
            drawingContext.DrawGeometry(null, smilePen, pathGeometry);
            drawingContext.Close();
            return(drawingVisual);
        }
Beispiel #22
0
            public static void VCell(Vec location)
            {
                Vec   index     = chunkpos + location;
                Color cellcolor = BColors.BCList[Globe.GetChunk(index).BiomeID];

                Point cellcenter = new Point(Globe.GetChunk(index).BiomeCenter[0], Globe.GetChunk(index).BiomeCenter[1]);

                Biomes[(int)location[0] + 1, (int)location[1] + 1] = Globe.GetChunk(index).BiomeID;

                RadialGradientBrush cellbrush = new RadialGradientBrush()
                {
                    GradientOrigin = new Point(0.5, 0.5),
                    Center         = new Point(0.5, 0.5),
                    RadiusX        = 0.5,
                    RadiusY        = 0.5
                };

                cellbrush.GradientStops.Add(new GradientStop(cellcolor, 0.0));
                cellbrush.GradientStops.Add(new GradientStop(Color.Multiply(cellcolor, (float)0.75), 1.0));

                cellbrush.Freeze();

                Polygon cell = new Polygon()
                {
                    Fill = cellbrush
                };

                Cells[(int)location[0] + 1, (int)location[1] + 1] = cell;

                // voronoi from triangulation algorithm

                Vec[] t = new Vec[4];
                Vec   p;
                Vec   q;

                q = new Vec()
                {
                    -1, 0
                };
                p    = Globe.GetChunk(index + q).BiomeCenter;
                t[0] = (Vec)(new Polar(p[0], p[1] / 64)) + origin + (q * 200) + (location * 200);
                q    = new Vec()
                {
                    -1, -1
                };
                p    = Globe.GetChunk(index + q).BiomeCenter;
                t[1] = (Vec)(new Polar(p[0], p[1] / 64)) + origin + (q * 200) + (location * 200);
                q    = new Vec()
                {
                    0, -1
                };
                p    = Globe.GetChunk(index + q).BiomeCenter;
                t[2] = (Vec)(new Polar(p[0], p[1] / 64)) + origin + (q * 200) + (location * 200);
                q    = new Vec()
                {
                    0, 0
                };
                p    = Globe.GetChunk(index + q).BiomeCenter;
                t[3] = (Vec)(new Polar(p[0], p[1] / 64)) + origin + (q * 200) + (location * 200);

                if (!Consts.IsInCirc(t))
                {
                    Vec v1 = Consts.Center(t[0], t[1], t[3]);
                    Vec v2 = Consts.Center(t[1], t[2], t[3]);

                    Point p1 = new Point(v1[0], v1[1]);
                    Point p2 = new Point(v2[0], v2[1]);

                    cell.Points.Add(p1);
                    cell.Points.Add(p2);
                }
                else
                {
                    Vec v1 = Consts.Center(t[0], t[2], t[3]);

                    Point p1 = new Point(v1[0], v1[1]);

                    cell.Points.Add(p1);
                }

                q = new Vec()
                {
                    0, -1
                };
                p    = Globe.GetChunk(index + q).BiomeCenter;
                t[0] = (Vec)(new Polar(p[0], p[1] / 64)) + origin + (q * 200) + (location * 200);
                q    = new Vec()
                {
                    1, -1
                };
                p    = Globe.GetChunk(index + q).BiomeCenter;
                t[1] = (Vec)(new Polar(p[0], p[1] / 64)) + origin + (q * 200) + (location * 200);
                q    = new Vec()
                {
                    1, 0
                };
                p    = Globe.GetChunk(index + q).BiomeCenter;
                t[2] = (Vec)(new Polar(p[0], p[1] / 64)) + origin + (q * 200) + (location * 200);
                q    = new Vec()
                {
                    0, 0
                };
                p    = Globe.GetChunk(index + q).BiomeCenter;
                t[3] = (Vec)(new Polar(p[0], p[1] / 64)) + origin + (q * 200) + (location * 200);

                if (!Consts.IsInCirc(t))
                {
                    Vec v1 = Consts.Center(t[0], t[1], t[3]);
                    Vec v2 = Consts.Center(t[1], t[2], t[3]);

                    Point p1 = new Point(v1[0], v1[1]);
                    Point p2 = new Point(v2[0], v2[1]);

                    cell.Points.Add(p1);
                    cell.Points.Add(p2);
                }
                else
                {
                    Vec v1 = Consts.Center(t[0], t[2], t[3]);

                    Point p1 = new Point(v1[0], v1[1]);

                    cell.Points.Add(p1);
                }

                q = new Vec()
                {
                    1, 0
                };
                p    = Globe.GetChunk(index + q).BiomeCenter;
                t[0] = (Vec)(new Polar(p[0], p[1] / 64)) + origin + (q * 200) + (location * 200);
                q    = new Vec()
                {
                    1, 1
                };
                p    = Globe.GetChunk(index + q).BiomeCenter;
                t[1] = (Vec)(new Polar(p[0], p[1] / 64)) + origin + (q * 200) + (location * 200);
                q    = new Vec()
                {
                    0, 1
                };
                p    = Globe.GetChunk(index + q).BiomeCenter;
                t[2] = (Vec)(new Polar(p[0], p[1] / 64)) + origin + (q * 200) + (location * 200);
                q    = new Vec()
                {
                    0, 0
                };
                p    = Globe.GetChunk(index + q).BiomeCenter;
                t[3] = (Vec)(new Polar(p[0], p[1] / 64)) + origin + (q * 200) + (location * 200);

                if (!Consts.IsInCirc(t))
                {
                    Vec v1 = Consts.Center(t[0], t[1], t[3]);
                    Vec v2 = Consts.Center(t[1], t[2], t[3]);

                    Point p1 = new Point(v1[0], v1[1]);
                    Point p2 = new Point(v2[0], v2[1]);

                    cell.Points.Add(p1);
                    cell.Points.Add(p2);
                }
                else
                {
                    Vec v1 = Consts.Center(t[0], t[2], t[3]);

                    Point p1 = new Point(v1[0], v1[1]);

                    cell.Points.Add(p1);
                }

                q = new Vec()
                {
                    0, 1
                };
                p    = Globe.GetChunk(index + q).BiomeCenter;
                t[0] = (Vec)(new Polar(p[0], p[1] / 64)) + origin + (q * 200) + (location * 200);
                q    = new Vec()
                {
                    -1, 1
                };
                p    = Globe.GetChunk(index + q).BiomeCenter;
                t[1] = (Vec)(new Polar(p[0], p[1] / 64)) + origin + (q * 200) + (location * 200);
                q    = new Vec()
                {
                    -1, 0
                };
                p    = Globe.GetChunk(index + q).BiomeCenter;
                t[2] = (Vec)(new Polar(p[0], p[1] / 64)) + origin + (q * 200) + (location * 200);
                q    = new Vec()
                {
                    0, 0
                };
                p    = Globe.GetChunk(index + q).BiomeCenter;
                t[3] = (Vec)(new Polar(p[0], p[1] / 64)) + origin + (q * 200) + (location * 200);

                if (!Consts.IsInCirc(t))
                {
                    Vec v1 = Consts.Center(t[0], t[1], t[3]);
                    Vec v2 = Consts.Center(t[1], t[2], t[3]);

                    Point p1 = new Point(v1[0], v1[1]);
                    Point p2 = new Point(v2[0], v2[1]);

                    cell.Points.Add(p1);
                    cell.Points.Add(p2);
                }
                else
                {
                    Vec v1 = Consts.Center(t[0], t[2], t[3]);

                    Point p1 = new Point(v1[0], v1[1]);

                    cell.Points.Add(p1);
                }

                Cells[(int)location[0] + 1, (int)location[1] + 1] = cell;
                MainWindow.App.map.Children.Add(cell);

                Bases.Draw(index, location);
            }
Beispiel #23
0
        private static Brush[] CreateBrushes(System.Windows.Media.Color c, System.Windows.CornerRadius cornerRadius)
        {
            GradientStopCollection stops2;
            GradientStopCollection stops3;
            GradientStopCollection stops4;
            GradientStopCollection stops5;

            Brush[] brushArray = new Brush[9];
            brushArray[4] = new SolidColorBrush(c);
            brushArray[4].Freeze();
            GradientStopCollection gradientStopCollection = CreateStops(c, 0.0);
            LinearGradientBrush    brush = new LinearGradientBrush(gradientStopCollection, new Point(0.0, 1.0), new Point(0.0, 0.0));

            brush.Freeze();
            brushArray[1] = brush;
            LinearGradientBrush brush2 = new LinearGradientBrush(gradientStopCollection, new Point(1.0, 0.0), new Point(0.0, 0.0));

            brush2.Freeze();
            brushArray[3] = brush2;
            LinearGradientBrush brush3 = new LinearGradientBrush(gradientStopCollection, new Point(0.0, 0.0), new Point(1.0, 0.0));

            brush3.Freeze();
            brushArray[5] = brush3;
            LinearGradientBrush brush4 = new LinearGradientBrush(gradientStopCollection, new Point(0.0, 0.0), new Point(0.0, 1.0));

            brush4.Freeze();
            brushArray[7] = brush4;
            if (cornerRadius.TopLeft == 0.0)
            {
                stops2 = gradientStopCollection;
            }
            else
            {
                stops2 = CreateStops(c, cornerRadius.TopLeft);
            }
            RadialGradientBrush brush5 = new RadialGradientBrush(stops2)
            {
                RadiusX        = 1.0,
                RadiusY        = 1.0,
                Center         = new Point(1.0, 1.0),
                GradientOrigin = new Point(1.0, 1.0)
            };

            brush5.Freeze();
            brushArray[0] = brush5;
            if (cornerRadius.TopRight == 0.0)
            {
                stops3 = gradientStopCollection;
            }
            else if (cornerRadius.TopRight == cornerRadius.TopLeft)
            {
                stops3 = stops2;
            }
            else
            {
                stops3 = CreateStops(c, cornerRadius.TopRight);
            }
            RadialGradientBrush brush6 = new RadialGradientBrush(stops3)
            {
                RadiusX        = 1.0,
                RadiusY        = 1.0,
                Center         = new Point(0.0, 1.0),
                GradientOrigin = new Point(0.0, 1.0)
            };

            brush6.Freeze();
            brushArray[2] = brush6;
            if (cornerRadius.BottomLeft == 0.0)
            {
                stops4 = gradientStopCollection;
            }
            else if (cornerRadius.BottomLeft == cornerRadius.TopLeft)
            {
                stops4 = stops2;
            }
            else if (cornerRadius.BottomLeft == cornerRadius.TopRight)
            {
                stops4 = stops3;
            }
            else
            {
                stops4 = CreateStops(c, cornerRadius.BottomLeft);
            }
            RadialGradientBrush brush7 = new RadialGradientBrush(stops4)
            {
                RadiusX        = 1.0,
                RadiusY        = 1.0,
                Center         = new Point(1.0, 0.0),
                GradientOrigin = new Point(1.0, 0.0)
            };

            brush7.Freeze();
            brushArray[6] = brush7;
            if (cornerRadius.BottomRight == 0.0)
            {
                stops5 = gradientStopCollection;
            }
            else if (cornerRadius.BottomRight == cornerRadius.TopLeft)
            {
                stops5 = stops2;
            }
            else if (cornerRadius.BottomRight == cornerRadius.TopRight)
            {
                stops5 = stops3;
            }
            else if (cornerRadius.BottomRight == cornerRadius.BottomLeft)
            {
                stops5 = stops4;
            }
            else
            {
                stops5 = CreateStops(c, cornerRadius.BottomRight);
            }
            RadialGradientBrush brush8 = new RadialGradientBrush(stops5)
            {
                RadiusX        = 1.0,
                RadiusY        = 1.0,
                Center         = new Point(0.0, 0.0),
                GradientOrigin = new Point(0.0, 0.0)
            };

            brush8.Freeze();
            brushArray[8] = brush8;
            return(brushArray);
        }
Beispiel #24
0
        private static void DrawCube()
        {
            if (Battle3DViewPort == null)
            {
                Battle3DViewPort = Application.Current.FindResource("Battle3DViewPort") as HelixViewport3D;
            }

            // Battle3DViewPort = new HelixViewport3D();

            //var view = new HelixViewport3D();


            int roomSize = 20;
            var lights   = new DefaultLights();

            LinearGradientBrush horGradBrushBlue = new LinearGradientBrush();

            horGradBrushBlue.StartPoint = new Point(0, 0.5);
            horGradBrushBlue.EndPoint   = new Point(1, 0.5);
            horGradBrushBlue.GradientStops.Add(new GradientStop(Colors.RoyalBlue, 0.0));
            horGradBrushBlue.GradientStops.Add(new GradientStop(Colors.Blue, 0.4));

            LinearGradientBrush horGradBrushGreen = new LinearGradientBrush();

            horGradBrushGreen.StartPoint = new Point(0, 0.5);
            horGradBrushGreen.EndPoint   = new Point(1, 0.5);
            horGradBrushGreen.GradientStops.Add(new GradientStop(Colors.Green, 0.5));
            horGradBrushGreen.GradientStops.Add(new GradientStop(Colors.ForestGreen, 1.0));

            RadialGradientBrush radGradBrush = new RadialGradientBrush();

            radGradBrush.GradientOrigin = new Point(0.75, 0.75);
            radGradBrush.Center         = new Point(0.5, 0.5);
            radGradBrush.RadiusX        = 0.5;
            radGradBrush.RadiusY        = 0.5;
            radGradBrush.GradientStops.Add(new GradientStop(Colors.RoyalBlue, 0.0));
            radGradBrush.GradientStops.Add(new GradientStop(Colors.Blue, 0.4));

            radGradBrush.Freeze();
            horGradBrushBlue.Freeze();

            Rectangle myRectangle = new Rectangle();

            myRectangle.Width  = 200;
            myRectangle.Height = 100;
            myRectangle.Fill   = radGradBrush;

            CubeVisual3D cube = new CubeVisual3D();

            int x = 0;
            int y = 0;
            int z = 0;

            for (x = 0; x < roomSize; x++)
            {
                for (y = 0; y < roomSize; y++)
                {
                    for (z = 0; z < roomSize; z++)
                    {
                        if (z == 0)
                        {
                            cube = new CubeVisual3D();

                            cube.SideLength = 1;
                            cube.Center     = new Point3D(x, y, z);
                            cube.Fill       = horGradBrushGreen;



                            Battle3DViewPort.Children.Add(cube);
                        }
                        else if (z == 1 && x >= 5 && y >= 5)
                        {
                            cube = new CubeVisual3D();

                            cube.SideLength = 1;
                            cube.Center     = new Point3D(x, y, z);
                            cube.Fill       = horGradBrushGreen;

                            Battle3DViewPort.Children.Add(cube);
                        }
                        else if (z >= 2 && z <= 10 && x > 10 && y > 10 && x < roomSize - 5 && y < roomSize - 5)
                        {
                            cube = new CubeVisual3D();

                            cube.SideLength = 1;
                            cube.Center     = new Point3D(x, y, z);
                            cube.Fill       = horGradBrushBlue;

                            Battle3DViewPort.Children.Add(cube);
                        }
                    }
                }
            }

            GridLinesVisual3D grid2 = new GridLinesVisual3D();

            grid2.Center        = new Point3D(12, 12, 1.52);
            grid2.Length        = 15;
            grid2.Width         = 15;
            grid2.MajorDistance = 5;
            grid2.MinorDistance = 1;
            grid2.Thickness     = .02;
            grid2.Fill          = Brushes.Black;


            Battle3DViewPort.Children.Add(grid2);

            GridLinesVisual3D grid = new GridLinesVisual3D();

            grid.Center        = new Point3D(9.5, 9.5, .52);
            grid.Length        = 20;
            grid.Width         = 20;
            grid.MajorDistance = 5;
            grid.MinorDistance = 1;
            grid.Thickness     = .02;
            grid.Fill          = Brushes.Black;


            Battle3DViewPort.Children.Add(grid);

            foreach (KeyValuePair <Guid, SphereVisual3D> sphere in Players.UnitSpheres)
            {
                Battle3DViewPort.Children.Add(sphere.Value);
            }
            //foreach(SphereVisual3D sphere in Players.UnitSpheres)
            //{

            //}
            //    Players.UnitSpheres.Add(Guid.NewGuid(), new SphereVisual3D());


            //Players.UnitSpheres.Last().Value.Center = new Point3D(5, 5, 3);
            //Players.UnitSpheres.Last().Value.Fill = Brushes.DarkOrange;
            //Players.UnitSpheres.Last().Value.Radius = 0.5;
            //Battle3DViewPort.Children.Add(Players.UnitSpheres.Last().Value);

            //UnitModel.Content = Display3d("CuteDarkVador.STL");

            //var transGroup = new Transform3DGroup();
            //transGroup.Children.Add(new ScaleTransform3D(new Vector3D(.01, .01, .01)));
            //transGroup.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), 90)));
            //transGroup.Children.Add(new TranslateTransform3D(new Vector3D(5, 10, 2)));

            //UnitModel.Transform = transGroup;


            Battle3DViewPort.ZoomExtents();

            //view.Children.Add(cube);
            //BattleScreenCanvas.Children.Add(BattleViewPort);
        }
Beispiel #25
0
        void addall()
        {
            Date.Content = items.date;

            foreach (Item item in items.items)
            {
                try {
                    foreach (string wantitem in wantitems)
                    {
                        if (wantitem == item.item.name)
                        {
                            isInshop = true;
                            matchinshop.Add(wantitem);
                        }
                    }
                } catch (Exception) { }
                BitmapImage bmpitemimage = new BitmapImage();
                bmpitemimage.BeginInit();
                bmpitemimage.UriSource = new Uri(item.item.image);
                bmpitemimage.EndInit();

                Image itemimage = new Image();
                itemimage.Source = bmpitemimage;
                itemimage.Width  = 160;
                itemimage.Height = 160;

                Label itemname = new Label();
                itemname.Content    = item.item.name;
                itemname.Foreground = Brushes.White;
                itemname.FontSize   = 15;

                Border itemframe = new Border();
                itemframe.BorderThickness = new Thickness(5, 5, 5, 5);
                var converter = new System.Windows.Media.BrushConverter();
                if (item.item.rarity == "common")
                {
                    itemframe.BorderBrush = (Brush)converter.ConvertFromString("#bebebe");
                }
                else if (item.item.rarity == "uncommon")
                {
                    itemframe.BorderBrush = (Brush)converter.ConvertFromString("#8fee3b");
                }
                else if (item.item.rarity == "epic")
                {
                    itemframe.BorderBrush = (Brush)converter.ConvertFromString("#b04eec");
                }
                else if (item.item.rarity == "rare")
                {
                    itemframe.BorderBrush = (Brush)converter.ConvertFromString("#3ad6ff");
                }
                else if (item.item.rarity == "legendary")
                {
                    itemframe.BorderBrush = (Brush)converter.ConvertFromString("#e38748");
                }
                itemframe.Margin = new Thickness(5, 5, 0, 0);

                RadialGradientBrush itemtransition = new RadialGradientBrush();
                if (item.item.rarity == "common")
                {
                    itemtransition.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#bebebe"), 0));
                    itemtransition.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#848282"), 1));
                }
                else if (item.item.rarity == "uncommon")
                {
                    itemtransition.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#69bb1e"), 0));
                    itemtransition.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#227622"), 1));
                }
                else if (item.item.rarity == "epic")
                {
                    itemtransition.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#c359ff"), 0));
                    itemtransition.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#701fe5"), 1));
                }
                else if (item.item.rarity == "rare")
                {
                    itemtransition.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#2cc1ff"), 0));
                    itemtransition.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#215dc2"), 1));
                }
                else if (item.item.rarity == "legendary")
                {
                    itemtransition.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#ea8d23"), 0));
                    itemtransition.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#c04d1f"), 1));
                }
                itemtransition.Freeze();

                StackPanel itemgroup = new StackPanel();
                itemgroup.Orientation = Orientation.Vertical;
                itemgroup.Width       = 160;
                itemgroup.Height      = 160;
                itemgroup.Background  = itemtransition;
                itemgroup.Children.Add(itemname);
                itemgroup.Children.Add(itemimage);

                itemframe.Child = itemgroup;

                ShopContent.Children.Add(itemframe);
            }
            //MessageBox.Show(items.vbucks.ToString());
            //MessageBox.Show(items.items[0].item.image.ToString());
            doPopup();
        }
Beispiel #26
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Method draws a ellipse with specified parameters.
        /// </summary>
        /// <param name="canvas">canvas object to draw on</param>
        /// <param name="x">x-coordinate value</param>
        /// <param name="y">y-coordinate value</param>
        /// <param name="radius">radius of the elliptical object</param>
        private static void drawMyEllipse(Canvas canvas, double x1, double y1, double radius)
        {
            // RNG.
            Random random = new Random();

            // Constraints.
            double strokeThicknessMin = 1.0;
            double strokeThicknessMax = 1.2;

            double ellipseModifierMin = 1.0;
            double ellipseModifierMax = 1.5;

            // Generate random numbers.
            double randomStrokeThickness   = random.NextDouble() * (strokeThicknessMax - strokeThicknessMin) + strokeThicknessMin;
            double randomEllipseDimensions = random.NextDouble() * (ellipseModifierMax - ellipseModifierMin) + ellipseModifierMin;
            int    randomAlpha             = random.Next(200, 250);
            int    randomRed   = random.Next(200, 220);
            int    randomGreen = random.Next(245, 255);
            int    randomBlue  = random.Next(250, 255);

            // Create a RadialGradientBrush with four gradient stops.
            RadialGradientBrush radialGradientBrush = new RadialGradientBrush();

            // Set the GradientOrigin to the center of the area being painted.
            radialGradientBrush.GradientOrigin = new System.Windows.Point(0.5, 0.5);

            // Set the gradient center to the center of the area being painted.
            radialGradientBrush.Center = new System.Windows.Point(0.5, 0.5);

            // Set the radius of the gradient circle so that it extends to
            // the edges of the area being painted.
            radialGradientBrush.RadiusX = 0.5;
            radialGradientBrush.RadiusY = 0.5;

            // Create four gradient stops.
            radialGradientBrush.GradientStops.Add(new GradientStop(Colors.GreenYellow, 0.0));
            radialGradientBrush.GradientStops.Add(new GradientStop(Colors.Green, 0.25));
            radialGradientBrush.GradientStops.Add(new GradientStop(Colors.ForestGreen, 0.75));
            radialGradientBrush.GradientStops.Add(new GradientStop(Colors.DarkSeaGreen, 1.0));

            // Freeze the brush (make it unmodifiable) for performance benefits.
            radialGradientBrush.Freeze();

            // Create a SolidColorBrush with a single color.
            SolidColorBrush mySolidColorBrush = new SolidColorBrush();

            mySolidColorBrush.Color = System.Windows.Media.Color.FromArgb(Convert.ToByte(randomAlpha), Convert.ToByte(randomRed), Convert.ToByte(randomGreen), Convert.ToByte(randomBlue));

            // Settings for the ellipse.
            Ellipse myEllipse = new Ellipse();

            myEllipse.Fill            = radialGradientBrush;
            myEllipse.StrokeThickness = randomStrokeThickness;
            myEllipse.Stroke          = mySolidColorBrush;

            myEllipse.HorizontalAlignment = HorizontalAlignment.Center;
            myEllipse.VerticalAlignment   = VerticalAlignment.Center;

            myEllipse.Width  = randomEllipseDimensions * radius;
            myEllipse.Height = randomEllipseDimensions * radius;
            myEllipse.SetCenter(x1, y1);

            // Draw to canvas.
            canvas.Children.Add(myEllipse);
        }
        // Creates an array of brushes needed to render this
        private static Brush[] CreateBrushes(Color c, CornerRadius cornerRadius)
        {
            Brush[] brushes = new Brush[9];

            // Create center brush
            brushes[Center] = new SolidColorBrush(c);
            brushes[Center].Freeze();



            // Sides
            GradientStopCollection sideStops = CreateStops(c, 0);
            LinearGradientBrush    top       = new LinearGradientBrush(sideStops, new Point(0, 1), new Point(0, 0));

            top.Freeze();
            brushes[Top] = top;

            LinearGradientBrush left = new LinearGradientBrush(sideStops, new Point(1, 0), new Point(0, 0));

            left.Freeze();
            brushes[Left] = left;

            LinearGradientBrush right = new LinearGradientBrush(sideStops, new Point(0, 0), new Point(1, 0));

            right.Freeze();
            brushes[Right] = right;

            LinearGradientBrush bottom = new LinearGradientBrush(sideStops, new Point(0, 0), new Point(0, 1));

            bottom.Freeze();
            brushes[Bottom] = bottom;

            // Corners

            // Use side stops if the corner radius is 0
            GradientStopCollection topLeftStops;

            if (cornerRadius.TopLeft == 0)
            {
                topLeftStops = sideStops;
            }
            else
            {
                topLeftStops = CreateStops(c, cornerRadius.TopLeft);
            }

            RadialGradientBrush topLeft = new RadialGradientBrush(topLeftStops);

            topLeft.RadiusX        = 1;
            topLeft.RadiusY        = 1;
            topLeft.Center         = new Point(1, 1);
            topLeft.GradientOrigin = new Point(1, 1);
            topLeft.Freeze();
            brushes[TopLeft] = topLeft;

            // Reuse previous stops if corner radius is the same as side or top left
            GradientStopCollection topRightStops;

            if (cornerRadius.TopRight == 0)
            {
                topRightStops = sideStops;
            }
            else if (cornerRadius.TopRight == cornerRadius.TopLeft)
            {
                topRightStops = topLeftStops;
            }
            else
            {
                topRightStops = CreateStops(c, cornerRadius.TopRight);
            }

            RadialGradientBrush topRight = new RadialGradientBrush(topRightStops);

            topRight.RadiusX        = 1;
            topRight.RadiusY        = 1;
            topRight.Center         = new Point(0, 1);
            topRight.GradientOrigin = new Point(0, 1);
            topRight.Freeze();
            brushes[TopRight] = topRight;

            // Reuse previous stops if corner radius is the same as any of the previous radii
            GradientStopCollection bottomLeftStops;

            if (cornerRadius.BottomLeft == 0)
            {
                bottomLeftStops = sideStops;
            }
            else if (cornerRadius.BottomLeft == cornerRadius.TopLeft)
            {
                bottomLeftStops = topLeftStops;
            }
            else if (cornerRadius.BottomLeft == cornerRadius.TopRight)
            {
                bottomLeftStops = topRightStops;
            }
            else
            {
                bottomLeftStops = CreateStops(c, cornerRadius.BottomLeft);
            }

            RadialGradientBrush bottomLeft = new RadialGradientBrush(bottomLeftStops);

            bottomLeft.RadiusX        = 1;
            bottomLeft.RadiusY        = 1;
            bottomLeft.Center         = new Point(1, 0);
            bottomLeft.GradientOrigin = new Point(1, 0);
            bottomLeft.Freeze();
            brushes[BottomLeft] = bottomLeft;

            // Reuse previous stops if corner radius is the same as any of the previous radii
            GradientStopCollection bottomRightStops;

            if (cornerRadius.BottomRight == 0)
            {
                bottomRightStops = sideStops;
            }
            else if (cornerRadius.BottomRight == cornerRadius.TopLeft)
            {
                bottomRightStops = topLeftStops;
            }
            else if (cornerRadius.BottomRight == cornerRadius.TopRight)
            {
                bottomRightStops = topRightStops;
            }
            else if (cornerRadius.BottomRight == cornerRadius.BottomLeft)
            {
                bottomRightStops = bottomLeftStops;
            }
            else
            {
                bottomRightStops = CreateStops(c, cornerRadius.BottomRight);
            }

            RadialGradientBrush bottomRight = new RadialGradientBrush(bottomRightStops);

            bottomRight.RadiusX        = 1;
            bottomRight.RadiusY        = 1;
            bottomRight.Center         = new Point(0, 0);
            bottomRight.GradientOrigin = new Point(0, 0);
            bottomRight.Freeze();
            brushes[BottomRight] = bottomRight;

            return(brushes);
        }
Beispiel #28
0
        private void DrawRadialBorder(
            DrawingContext drawingContext,
            double left,
            double top,
            double width,
            double height,
            Corners corner)
        {
            if ((width <= 0) || (height <= 0))
            {
                return;
            }

            var bounds           = new Rect(left, top, width, height);
            var offsetPercentage = 0.0;

            switch (corner)
            {
            case Corners.TopLeft:
                offsetPercentage = CornerRadius.TopLeft /
                                   (CornerRadius.TopLeft + BorderThickness.Top);
                break;

            case Corners.TopRight:
                offsetPercentage = CornerRadius.TopRight /
                                   (CornerRadius.TopRight + BorderThickness.Top);
                break;

            case Corners.BottomRight:
                offsetPercentage = CornerRadius.BottomRight /
                                   (CornerRadius.BottomRight + BorderThickness.Bottom);
                break;

            case Corners.BottomLeft:
                offsetPercentage = CornerRadius.BottomLeft /
                                   (CornerRadius.BottomLeft + BorderThickness.Bottom);
                break;
            }

            var brush = new RadialGradientBrush(CreateStops(offsetPercentage));

            switch (corner)
            {
            case Corners.TopLeft:
                brush.Center = new Point(1.0, 1.0);
                break;

            case Corners.TopRight:
                brush.Center = new Point(0.0, 1.0);
                break;

            case Corners.BottomRight:
                brush.Center = new Point(0.0, 0.0);
                break;

            case Corners.BottomLeft:
                brush.Center = new Point(1.0, 0.0);
                break;
            }

            brush.GradientOrigin = brush.Center;
            brush.RadiusX        = 1.0;
            brush.RadiusY        = 1.0;
            brush.Freeze();

            drawingContext.DrawRectangle(brush, null, bounds);
        }
Beispiel #29
0
        private void DrawHeatMap()
        {
            ClearRenderTargetBitmap(_heatMap, Brushes.Black);
            if (_sensorsToUse.Count == 0)
            {
                Common.ShowMessageBox("Can't render", "You haven't selected any sensors to render the heatmap from",
                                      false, true);
                return;
            }

            var width  = _heatMap.Width;
            var height = _heatMap.Height;

            var depths = _sensorsToUse.Select(x => x.Elevation).Distinct().OrderBy(x => x).ToArray();

            MinDepth = depths.Min();
            MaxDepth = depths.Max();


            if (!SpecifyRadiusEnabled)
            {
                Radius = (float)height / (depths.Count() - 1) / 2;
            }
            Debug.Print("Radius: {0}", Radius);

            var depthRange = MaxDepth - MinDepth;

            var heightMultiplier = height / (depths.Count() - 1);

            Debug.Print("Depth Min {0} Max {1} Range {2} Multiplier {3}", MinDepth, MaxDepth, depthRange, heightMultiplier);

            var timeStamps = _sensorsToUse.SelectMany(x => x.CurrentState.Values).Select(x => x.Key).ToArray();

            if (!SpecifyMinTimestampEnabled)
            {
                MinTimestamp = timeStamps.Min();
            }
            if (!SpecifyMaxTimestampEnabled)
            {
                MaxTimestamp = timeStamps.Max();
            }

            //No longer need timestamps
            timeStamps = null;

            var timeRange = MaxTimestamp - MinTimestamp;

            var widthMultiplier = width / timeRange.TotalMinutes;

            Debug.Print("Time Min {0} Max {1} Range {2} Multiplier {3}", MinTimestamp, MaxTimestamp, timeRange, widthMultiplier);

            if (!SpecifySamplingRateEnabled)
            {
                SamplingRate = (int)(1 / widthMultiplier) * 2;
            }

            var values = _sensorsToUse.SelectMany(x => x.CurrentState.Values).Select(x => x.Value).ToArray();

            if (!SpecifyMinValueEnabled)
            {
                MinValue = values.Min();
            }
            if (!SpecifyMaxValueEnabled)
            {
                MaxValue = values.Max();
            }

            values = null;

            var valuesRange = MaxValue - MinValue;

            var valuesMultiplier = 255 / valuesRange;

            Debug.Print("Values Min {0} Max {1} Range {2} Multiplier {3}", MinValue, MaxValue, valuesRange, valuesMultiplier);
            _depths = new List <DepthYValue>();
            foreach (var sensor in _sensorsToUse)
            {
                var y = (Array.IndexOf(depths, sensor.Elevation) * heightMultiplier);
                _depths.Add(new DepthYValue(sensor.Elevation, y));
                foreach (var timeStamp in sensor.CurrentState.Values.OrderBy(x => x.Key).Where((x, index) => index % SamplingRate == 0))
                {
                    var intensity           = (byte)((timeStamp.Value - MinValue) * valuesMultiplier);
                    var radialGradientBrush = new RadialGradientBrush();
                    radialGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(intensity, 255, 255, 255), 0.0));
                    radialGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0, 255, 255, 255), 1));
                    radialGradientBrush.Freeze();

                    var x = ((timeStamp.Key - MinTimestamp).TotalMinutes * widthMultiplier) - Radius;

                    //Debug.Print("Point Timestamp {0} Value {1} Depth {2} Intensity {3} x {4} y {5}", timeStamp.Key, timeStamp.Value, sensor.Depth, intensity, x, y - Radius);

                    var drawingVisual = new DrawingVisual();
                    using (var context = drawingVisual.RenderOpen())
                    {
                        context.DrawRectangle(radialGradientBrush, null, new Rect(x, y - Radius, Radius * 2, Radius * 2));
                    }
                    _heatMap.Render(drawingVisual);
                }
            }
        }