Exemplo n.º 1
0
 protected override void OnElementChanged(ElementChangedEventArgs <View> e)
 {
     base.OnElementChanged(e);
     if (e.OldElement == null)
     {
         MyMapRenderer myMapRenderer = (MyMapRenderer)Element;
         if (myMapRenderer.StaticColor.Equals(Color.FromHex("#212626")))
         {
             myMapRenderer.MapStyle = MapStyle.FromJson("[{\"featureType\": \"all\",\"elementType\": \"labels.text\",\"stylers\": [{\"color\": \"#a1f7ff\"}]},{\"featureType\": \"all\",\"elementType\": \"labels.text.fill\",\"stylers\": [{\"color\": \"#ffffff\"}]},{\"featureType\": \"all\",\"elementType\": \"labels.text.stroke\",\"stylers\": [{\"color\": \"#000000\"},{\"lightness\": 13}]},{\"featureType\": \"administrative\",\"elementType\": \"geometry.fill\",\"stylers\": [{\"color\": \"#000000\"}]},{\"featureType\": \"administrative\",\"elementType\": \"geometry.stroke\",\"stylers\": [{\"color\": \"#144b53\"},{\"lightness\": 14},{\"weight\": 1.4}]},{\"featureType\": \"administrative\",\"elementType\": \"labels.text\",\"stylers\": [{\"visibility\": \"simplified\"},{\"color\": \"#a1f7ff\"}]},{\"featureType\": \"administrative.province\",\"elementType\": \"labels.text\",\"stylers\": [{\"visibility\": \"simplified\"},{\"color\": \"#a1f7ff\"}]},{\"featureType\": \"administrative.locality\",\"elementType\": \"labels.text\",\"stylers\": [{\"visibility\": \"simplified\"},{\"color\": \"#a1f7ff\"}]},{\"featureType\": \"administrative.neighborhood\",\"elementType\": \"labels.text\",\"stylers\": [{\"visibility\": \"simplified\"},{\"color\": \"#a1f7ff\"}]},{\"featureType\": \"landscape\",\"elementType\": \"all\",\"stylers\": [{\"color\": \"#08304b\"}]},{\"featureType\": \"poi\",\"elementType\": \"geometry\",\"stylers\": [{\"color\": \"#0c4152\"},{\"lightness\": 5}]},{\"featureType\": \"poi.attraction\",\"elementType\": \"labels\",\"stylers\": [{\"invert_lightness\": true}]},{\"featureType\": \"poi.attraction\",\"elementType\": \"labels.text\",\"stylers\": [{\"visibility\": \"simplified\"},{\"color\": \"#a1f7ff\"}]},{\"featureType\": \"poi.park\",\"elementType\": \"labels\",\"stylers\": [{\"visibility\": \"on\"},{\"invert_lightness\": true}]},{\"featureType\": \"poi.park\",\"elementType\": \"labels.text\",\"stylers\": [{\"visibility\": \"simplified\"},{\"color\": \"#a1f7ff\"}]},{\"featureType\": \"road\",\"elementType\": \"labels.text\",\"stylers\": [{\"color\": \"#a1f7ff\"}]},{\"featureType\": \"road.highway\",\"elementType\": \"geometry.fill\",\"stylers\": [{\"color\": \"#000000\"}]},{\"featureType\": \"road.highway\",\"elementType\": \"geometry.stroke\",\"stylers\": [{\"color\": \"#0b434f\"},{\"lightness\": 25}]},{\"featureType\": \"road.highway\",\"elementType\": \"labels\",\"stylers\": [{\"lightness\": \"0\"},{\"saturation\": \"0\"},{\"invert_lightness\": true},{\"visibility\": \"simplified\"},{\"hue\": \"#00e9ff\"}]},{\"featureType\": \"road.highway\",\"elementType\": \"labels.text\",\"stylers\": [{\"visibility\": \"simplified\"},{\"color\": \"#a1f7ff\"}]},{\"featureType\": \"road.highway.controlled_access\",\"elementType\": \"labels.text\",\"stylers\": [{\"color\": \"#a1f7ff\"}]},{\"featureType\": \"road.arterial\",\"elementType\": \"geometry.fill\",\"stylers\": [{\"color\": \"#000000\"}]},{\"featureType\": \"road.arterial\",\"elementType\": \"geometry.stroke\",\"stylers\": [{\"color\": \"#0b3d51\"},{\"lightness\": 16}]},{\"featureType\": \"road.arterial\",\"elementType\": \"labels\",\"stylers\": [{\"invert_lightness\": true}]},{\"featureType\": \"road.local\",\"elementType\": \"geometry\",\"stylers\": [{\"color\": \"#000000\"}]},{\"featureType\": \"road.local\",\"elementType\": \"labels\",\"stylers\": [{\"visibility\": \"simplified\"},{\"invert_lightness\": true}]},{\"featureType\": \"transit\",\"elementType\": \"all\",\"stylers\": [{\"color\": \"#146474\"}]},{\"featureType\": \"water\",\"elementType\": \"all\",\"stylers\": [{\"color\": \"#021019\"}]}]");
         }
         else
         {
             myMapRenderer.MapStyle = MapStyle.FromJson("[{\"featureType\": \"administrative.country\",\"elementType\": \"geometry\",\"stylers\": [{\"visibility\": \"simplified\"},{\"hue\": \"#ff0000\"}]}]");
         }
     }
 }
Exemplo n.º 2
0
        private void Render(Chunk c)
        {
            int x  = (int)c.Position.X;
            int z  = (int)c.Position.Z;
            int HS = (int)Map.ChunkScale.X;

            if (x < Minimum.X || z < Minimum.Y || x < Maximum.X || z < Maximum.Y)
            {
                // Find how much bigger it needs to be
                int XShift;
                int YShift;
                if (x < Minimum.X || z < Minimum.Y)
                {
                    XShift = x - Minimum.X;
                    YShift = z - Minimum.Y;
                }
                else
                {
                    XShift = x - Maximum.X;
                    YShift = z - Maximum.Y;
                }
                XShift *= HS;
                YShift *= HS;
                // Resize Image
                Image    img = new Bitmap(Img.Size.Width + (XShift & 0xf), Img.Size.Height + (YShift & 0xf));
                Graphics g   = Graphics.FromImage(img);
                g.DrawImage(Img, new Point(Minimum.X + XShift, Minimum.Y + YShift));

                if (XShift < 0)
                {
                    Minimum.X += XShift;
                }
                else
                {
                    Maximum.X += XShift;
                }
                if (YShift < 0)
                {
                    Minimum.Y += YShift;
                }
                else
                {
                    Maximum.Y += YShift;
                }
                g.Dispose();
            }
            int    L = Minimum.X;
            int    T = Minimum.Y;
            Bitmap cimg;

            if (MyMapRenderer.RenderChunk(c, out cimg))
            {
                Point    Origin = new Point(((int)c.Position.X - L) * HS, ((int)c.Position.Y - T) * HS);
                Graphics g      = Graphics.FromImage(Img);
                g.DrawImage(cimg, Origin);
                if (ShowEntities)
                {
                    foreach (KeyValuePair <Guid, Entity> k in c.Entities)
                    {
                        Entity ent = k.Value;
                        g.DrawImage(ent.Image, new PointF((float)(ent.Pos.X - (ent.Image.Size.Width / 2d)), (float)(ent.Pos.Y - (ent.Image.Size.Height / 2d))));
                    }
                }
                if (ShowChunkBoundaries)
                {
                    DrawCross(ref g, 0, 0, Color.White);
                    DrawText(ref g, 1, 1, Color.White, "Chunk " + c.Position.ToString());
                }
            }
        }