Esempio n. 1
0
        public override void DrawMapText()
        {
            foreach (var textInfo in _textInfos)
            {
                MapText mapText = textInfo._mapText;
                if (_font != null)
                {
                    // Font font = (Font) _font.GetNativeFont();
                    Font       font       = (Font)mapText.Font.GetNativeFont();
                    SolidBrush solidBrush = new SolidBrush(Color.FromArgb((int)(textInfo._mapText.GetForeColor() | 0xFF000000)));
                    //SharedGraphics2D.Graphics.SmoothingMode = SmoothingMode.HighQuality;
                    //SharedGraphics2D.Graphics.CompositingQuality = CompositingQuality.HighQuality;
                    //SharedGraphics2D.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias;


                    if (textInfo._graphicsPath == null)
                    {
                        SharedGraphics2D.Graphics.DrawString(mapText.TextString, font, solidBrush, (float)mapText.Bounds.X,
                                                             (float)mapText.Bounds.Y);
                    }
                    else
                    {
                        double angle       = GetAngle(textInfo._graphicsPath.PathPoints[0], textInfo._graphicsPath.PathPoints[textInfo._graphicsPath.PathPoints.Length - 1]);
                        float  rotateAngle = GetRotateAngle(angle);
                        SharedGraphics2D.Graphics.DrawString(textInfo._mapText.TextString, font, Color.FromArgb((int)(textInfo._mapText.GetForeColor() | 0xFF000000)),
                                                             new SolidBrush(
                                                                 Color.FromArgb((int)(textInfo._mapText.GetForeColor() | 0xFF000000))),
                                                             TextPathAlign.Center,
                                                             TextPathPosition.CenterPath, 100, rotateAngle,
                                                             textInfo._graphicsPath);
                    }
                }
            }
        }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * draw a text.
         * @param mapText a map text object.
         */

        private void DrawText(MapText mapText)
        {
            {
                _fontColor = mapText.ForeColor;
                DrawString(_font, mapText.TextString,
                           (int)mapText.Point.X,
                           (int)mapText.Point.Y);
            }
        }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * draw the map text.
         */
        public override void DrawMapText()
        {
            for (int i = 0; i < _mapNameHolder.Count; i++)
            {
                MapText mapText = (MapText)_mapNameHolder[i];
                if (_font != null)
                {
                    DrawText(mapText);
                }
            }
        }
Esempio n. 4
0
        public MapTextBuilder Text(string text)
        {
            var txt = new MapText
            {
                Font              = this.font,
                Outline           = this.haveShadow,
                TextColor         = this.textColor,
                OutlineColor      = this.shadowColor,
                Position          = new PositionDefinition(this.nextPosition.X, this.nextPosition.Y),
                PositionAlignment = this.alignment,
                Text              = text
            };

            this.mapItems.Add(txt);
            this.nextPosition.X           += txt.Size.X;
            this.didBreakOnLastTextAlready = false;
            return(this);
        }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Add a map text to the drawing list.
         * @param mapText
         */

        private void AddMapName(MapText mapText)
        {
            GeoLatLngBounds mapTextBounds = mapText.Bounds;

            for (int i = 0; i < _mapNameHolder.Count; i++)
            {
                GeoLatLngBounds storedMapTextBounds =
                    ((MapText)_mapNameHolder[i]).Bounds;
                if (storedMapTextBounds.Intersects(mapTextBounds))
                {
                    return;
                }
            }
            if (_mapSize.Contains(mapTextBounds))
            {
                _mapNameHolder.Add(mapText);
            }
        }
Esempio n. 6
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * get a map text object at given index.
         */
        private MapText GetMapText(RecordIndex recordIndex)
        {
            MapText mapText = new MapText();

            mapText.Angle        = recordIndex.Param1;
            mapText.ForeColor    = recordIndex.Param2;
            mapText.BackColor    = recordIndex.Param3;
            mapText.Bounds.X     = recordIndex.MinX / DOUBLE_PRECISION;
            mapText.Bounds.Y     = recordIndex.MinY / DOUBLE_PRECISION;
            mapText.Bounds.Width =
                (recordIndex.MaxX - recordIndex.MinX) / DOUBLE_PRECISION;
            mapText.Bounds.Height =
                (recordIndex.MaxY - recordIndex.MinY) / DOUBLE_PRECISION;
            mapText.Justification = DataReader.ReadInt(_reader);
            mapText.Spacing       = DataReader.ReadInt(_reader);
            mapText.LineType      = DataReader.ReadInt(_reader);
            mapText.TextString    = DataReader.ReadString(_reader);
            return(mapText);
        }
Esempio n. 7
0
        /// <summary>
        /// Insert linebreaks to make text fit provided width
        /// </summary>
        /// <param name="text"></param>
        /// <param name="breakWidth"></param>
        /// <returns></returns>
        public MapTextBuilder Text(string text, int breakWidth)
        {
            var testItem = new MapText
            {
                Font              = this.font,
                Outline           = this.haveShadow,
                TextColor         = this.textColor,
                OutlineColor      = this.shadowColor,
                Position          = new PositionDefinition(this.nextPosition.X, this.nextPosition.Y),
                PositionAlignment = this.alignment,
                Text              = text
            };

            var words            = testItem.Text.Split(" ".ToArray(), StringSplitOptions.None);
            var lastAcceptedText = words[0];

            for (int i = 1; i < words.Length; i++)
            {
                testItem.Text = lastAcceptedText + " " + words[i];
                if (testItem.Size.X + this.nextPosition.X > breakWidth)
                {
                    if (!String.IsNullOrEmpty(lastAcceptedText))
                    {
                        if (this.nextPosition.X != 0)
                        {
                            this.Text(lastAcceptedText).Break();
                            lastAcceptedText = "";
                            continue;
                        }
                        testItem.Text = lastAcceptedText + "\n" + words[i];
                    }
                }
                lastAcceptedText = testItem.Text;
            }
            this.Text(lastAcceptedText);
            return(this);
        }
Esempio n. 8
0
        public IEnumerable <MapOverlay> GetCustomOverlay()
        {
            MapOverlay overlay = new MapOverlay();

            foreach (PmvNetCharacterInfo character in this.characters.Values.ToArray())
            {
                var texture = new MapTexture()
                {
                    Texture           = API.Content.Textures.CharacterLocator,
                    KeyColor          = this.locatorColor,
                    Position          = new PositionDefinition(character.Zone, character.X, character.Z),
                    PositionAlignment = MapItemAlignment.Center,
                };

                var txt = new MapText
                {
                    Position          = new PositionDefinition(),
                    PositionAlignment = MapItemAlignment.Center,
                    Text         = character.Name,
                    TextColor    = texture.KeyColor,
                    OutlineColor = Color.Black,
                    Outline      = true,
                    Font         = API.Content.Fonts.GetFont(this.CharacterLocatorFont)
                };

                var mpt = new MapTextureText(texture, txt, 1)
                {
                    PositionAlignment = MapItemAlignment.Bottom | MapItemAlignment.Center,
                };

                overlay.MapItems.Add(mpt);
            }
            yield return(overlay);

            yield break;
        }
Esempio n. 9
0
 // Clears and draws a letter in a cell in the given bitmap.
 public Rectangle DrawCell(Point ptCell, MapText mapText)
 {
     Rectangle r = RectFromCell(ptCell);
      using (Graphics g = Graphics.FromImage(_bmpFore))
      {
     Rectangle r1 = new Rectangle(r.Location, r.Size + new Size(1, 1));
     g.FillRectangle(new SolidBrush(windowColor()), r1);
     drawChar(g, mapText.GetCell(ptCell),mapText.GetColor(ptCell), r);
      }
      return r;
 }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * draw a map object.
         * @param mapObject the map object to be drawing.
         * @param drawBoundary the drawing boundry.
         * @param zoomLevel the current zoomLevel.
         */
        public override void DrawMapObject(MapObject mapObject, GeoLatLngBounds drawBoundary,
                int zoomLevel)
        {
            GeoLatLng drawPt = new GeoLatLng();
            _sutherlandHodgman = new SutherlandHodgman(drawBoundary);
            _mapZoomLevel = zoomLevel;
            _mapCenterPt.X = drawBoundary.GetCenterX();
            _mapCenterPt.Y = drawBoundary.GetCenterY();
            bool pointFound = false;
            Point[] plinePoints=null;
            switch (mapObject.GetMapObjectType())
            {
                case MapObject.NONE:
                    break;
                case MapObject.POINT:
                    {
                        MapPoint mapPoint = (MapPoint)mapObject;
                        DrawPoint(mapPoint);
                        drawPt.X = mapPoint.Point.X;
                        drawPt.Y = mapPoint.Point.Y;
                        pointFound = true;
                    }
                    break;
                case MapObject.MULTIPOINT:
                    {
                        MapMultiPoint mapMultiPoint = (MapMultiPoint)mapObject;
                        for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                        {
                            MapPoint mapPoint = new MapPoint
                            {
                                SymbolType = mapMultiPoint.SymbolType,
                                Point = new GeoLatLng(mapMultiPoint.Points[i])
                            };
                            DrawPoint(mapPoint);
                        }
                        for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                        {
                            if (drawBoundary.Contains(mapMultiPoint.Points[i]))
                            {
                                drawPt.X = mapMultiPoint.Points[i].X;
                                drawPt.Y = mapMultiPoint.Points[i].Y;
                                pointFound = true;
                                break;
                            }
                        }

                    }
                    break;
                case MapObject.PLINE:
                    {
                        MapPline mapPline = (MapPline)mapObject;
                        plinePoints=DrawPline(mapPline.PenStyle, mapPline.Pline);
                        for (int i = 0; i < mapPline.Pline.GetVertexCount(); i++)
                        {
                            if (drawBoundary.Contains(mapPline.Pline.GetVertex(i)))
                            {
                                drawPt.X = mapPline.Pline.GetVertex(i).X;
                                drawPt.Y = mapPline.Pline.GetVertex(i).Y;
                                pointFound = true;
                                break;
                            }
                        }
                    }
                    break;
                case MapObject.MULTIPLINE:
                    {
                        MapMultiPline mapMultiPline = (MapMultiPline)mapObject;
                        for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                        {
                            DrawPline(mapMultiPline.PenStyle,
                                    mapMultiPline.Plines[i]);
                            for (int j = 0; j < mapMultiPline.Plines[i].GetVertexCount(); j++)
                            {
                                if (drawBoundary.Contains(mapMultiPline.Plines[i].GetVertex(j)))
                                {
                                    drawPt.X = mapMultiPline.Plines[i].GetVertex(j).X;
                                    drawPt.Y = mapMultiPline.Plines[i].GetVertex(j).Y;
                                    pointFound = true;
                                    break;
                                }
                            }
                        }
                    }
                    break;
                case MapObject.REGION:
                    {
                        MapRegion mapRegion = (MapRegion)mapObject;
                        DrawRegion(mapRegion.PenStyle, mapRegion.BrushStyle,
                                mapRegion.Region);
                        drawPt.X = mapRegion.CenterPt.X;
                        drawPt.Y = mapRegion.CenterPt.Y;
                        pointFound = true;
                    }
                    break;
                case MapObject.MULTIREGION:
                    {
                        MapMultiRegion mapMultiRegion = (MapMultiRegion)mapObject;
                        for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                        {
                            DrawRegion(mapMultiRegion.PenStyle,
                                    mapMultiRegion.BrushStyle,
                                    mapMultiRegion.Regions[i]);

                        }
                        drawPt.X = mapMultiRegion.CenterPt.X;
                        drawPt.Y = mapMultiRegion.CenterPt.Y;
                        pointFound = true;
                    }
                    break;
                case MapObject.COLLECTION:
                    {
                        MapCollection mapCollection = (MapCollection)mapObject;
                        if (mapCollection.MultiRegion != null)
                        {
                            MapMultiRegion mapMultiRegion = mapCollection.MultiRegion;
                            for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                            {
                                DrawRegion(mapMultiRegion.PenStyle,
                                        mapMultiRegion.BrushStyle,
                                        mapMultiRegion.Regions[i]);
                            }
                        }
                        if (mapCollection.MultiPline != null)
                        {
                            MapMultiPline mapMultiPline = mapCollection.MultiPline;
                            for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                            {
                                DrawPline(mapMultiPline.PenStyle,
                                        mapMultiPline.Plines[i]);
                            }
                        }
                        if (mapCollection.MultiPoint != null)
                        {
                            MapMultiPoint mapMultiPoint = mapCollection.MultiPoint;
                            for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                            {
                                MapPoint mapPoint = new MapPoint
                                {
                                    SymbolType = mapMultiPoint.SymbolType,
                                    Point = new GeoLatLng(mapMultiPoint.Points[i])
                                };
                                DrawPoint(mapPoint);
                            }
                        }
                        pointFound = true;
                        drawPt.X = mapCollection.Bounds.X + mapCollection.Bounds.Width / 2;
                        drawPt.Y = mapCollection.Bounds.Y + mapCollection.Bounds.Height / 2;

                    }
                    break;
                case MapObject.TEXT:
                    {
                        MapText mapText = (MapText)mapObject;
                        drawPt.X = mapText.Point.X;
                        drawPt.Y = mapText.Point.Y;
                        pointFound = true;
                    }
                    break;
            }
            if (!(mapObject.Name.ToLower().Equals("unknown") || mapObject.Name.Length==0) && pointFound)
            {
                MapText mapName = new MapText { Font = _font };
                mapName.SetForeColor(_fontColor);
                mapName.TextString = mapObject.Name;
                GeoPoint screenPt = FromLatLngToMapPixel(drawPt);
                mapName.Point.X = screenPt.X;
                mapName.Point.Y = screenPt.Y;
                mapName.Bounds.X = mapName.Point.X;
                mapName.Bounds.Y = mapName.Point.Y;
                Font font = null;
                if (_font != null)
                {

                    font = (Font)_font.GetNativeFont();
                    SizeF sizeF = SharedGraphics2D.Graphics.MeasureString(mapName.TextString, font);
                    mapName.Bounds.Height = sizeF.Height;
                    mapName.Bounds.Width = sizeF.Width;

                }
                TextPosInfo textPosInfo = new TextPosInfo();
                textPosInfo._mapText = mapName;
                if(mapObject.GetMapObjectType()==MapObject.PLINE)
                {
                    if(plinePoints!=null)
                    {
                        GraphicsPath graphicsPath = new GraphicsPath();
                        graphicsPath.AddLines(plinePoints);
                        RectangleF []rectangleF;
                        double angle = GetAngle(plinePoints[0], plinePoints[plinePoints.Length - 1]);
                        if (angle < 180)
                        {
                            graphicsPath.Reverse();
                        }
                        angle = GetAngle(plinePoints[0], plinePoints[plinePoints.Length - 1]);

                        float rotateAngle = GetRotateAngle(angle);
                        rectangleF = SharedGraphics2D.Graphics.MeasureString(mapName.TextString, font,
                                                                                new SolidBrush(
                                                                                    Color.FromArgb(_fontColor)),
                                                                                TextPathAlign.Center,
                                                                                TextPathPosition.CenterPath, 100, rotateAngle,
                                                                                graphicsPath);

                        textPosInfo._graphicsPath = graphicsPath;
                        textPosInfo._rectangles = rectangleF;

                        if (rectangleF.Length == mapName.TextString.Length)
                        {

                            //RectangleF[] rectangleFs = new RectangleF[rectangleF.Length];
                            //Array.Copy(rectangleF, rectangleFs, rectangleF.Length);
                            //for (int i = 0; i < rectangleFs.Length;i++ )
                            //{
                            //    for(int j=0;j<rectangleF.Length;j++)
                            //    {
                            //        if(i!=j)
                            //        {
                            //            if(rectangleFs[i].IntersectsWith(rectangleF[j]))
                            //            {
                            //                return;
                            //            }
                            //        }
                            //    }
                            //}

                           AddMapName(textPosInfo);
                        }

                    }
                }else
                {
                    textPosInfo._graphicsPath = null;
                    textPosInfo._rectangles = new[]{new RectangleF((float)textPosInfo._mapText.Bounds.X, (float)textPosInfo._mapText.Bounds.Y,
                                                           (float)textPosInfo._mapText.Bounds.Width,
                                                           (float)textPosInfo._mapText.Bounds.Height)};
                    AddMapName(textPosInfo);
                }

            }
        }
Esempio n. 11
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * draw a map object.
         * @param mapObject the map object to be drawing.
         * @param drawBoundary the drawing boundry.
         * @param zoomLevel the current zoomLevel.
         */
        public override void DrawMapObject(MapObject mapObject, GeoLatLngBounds drawBoundary,
                                           int zoomLevel)
        {
            GeoLatLng drawPt = new GeoLatLng();

            _sutherlandHodgman = new SutherlandHodgman(drawBoundary);
            _mapZoomLevel      = zoomLevel;
            _mapCenterPt.X     = drawBoundary.GetCenterX();
            _mapCenterPt.Y     = drawBoundary.GetCenterY();
            bool pointFound = false;

            switch (mapObject.GetMapObjectType())
            {
            case MapObject.NONE:
                break;

            case MapObject.POINT:
            {
                MapPoint mapPoint = (MapPoint)mapObject;
                DrawPoint(mapPoint);
                drawPt.X   = mapPoint.Point.X;
                drawPt.Y   = mapPoint.Point.Y;
                pointFound = true;
            }
            break;

            case MapObject.MULTIPOINT:
            {
                MapMultiPoint mapMultiPoint = (MapMultiPoint)mapObject;
                for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                {
                    MapPoint mapPoint = new MapPoint
                    {
                        SymbolType = mapMultiPoint.SymbolType,
                        Point      = new GeoLatLng(mapMultiPoint.Points[i])
                    };
                    DrawPoint(mapPoint);
                }
                for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                {
                    if (drawBoundary.Contains(mapMultiPoint.Points[i]))
                    {
                        drawPt.X   = mapMultiPoint.Points[i].X;
                        drawPt.Y   = mapMultiPoint.Points[i].Y;
                        pointFound = true;
                        break;
                    }
                }
            }
            break;

            case MapObject.PLINE:
            {
                MapPline mapPline = (MapPline)mapObject;
                DrawPline(mapPline.PenStyle, mapPline.Pline);
                for (int i = 0; i < mapPline.Pline.GetVertexCount(); i++)
                {
                    if (drawBoundary.Contains(mapPline.Pline.GetVertex(i)))
                    {
                        drawPt.X   = mapPline.Pline.GetVertex(i).X;
                        drawPt.Y   = mapPline.Pline.GetVertex(i).Y;
                        pointFound = true;
                        break;
                    }
                }
            }
            break;

            case MapObject.MULTIPLINE:
            {
                MapMultiPline mapMultiPline = (MapMultiPline)mapObject;
                for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                {
                    DrawPline(mapMultiPline.PenStyle,
                              mapMultiPline.Plines[i]);
                    for (int j = 0; j < mapMultiPline.Plines[i].GetVertexCount(); j++)
                    {
                        if (drawBoundary.Contains(mapMultiPline.Plines[i].GetVertex(j)))
                        {
                            drawPt.X   = mapMultiPline.Plines[i].GetVertex(j).X;
                            drawPt.Y   = mapMultiPline.Plines[i].GetVertex(j).Y;
                            pointFound = true;
                            break;
                        }
                    }
                }
            }
            break;

            case MapObject.REGION:
            {
                MapRegion mapRegion = (MapRegion)mapObject;
                DrawRegion(mapRegion.PenStyle, mapRegion.BrushStyle,
                           mapRegion.Region);
                drawPt.X   = mapRegion.CenterPt.X;
                drawPt.Y   = mapRegion.CenterPt.Y;
                pointFound = true;
            }
            break;

            case MapObject.MULTIREGION:
            {
                MapMultiRegion mapMultiRegion = (MapMultiRegion)mapObject;
                for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                {
                    DrawRegion(mapMultiRegion.PenStyle,
                               mapMultiRegion.BrushStyle,
                               mapMultiRegion.Regions[i]);
                }
                drawPt.X   = mapMultiRegion.CenterPt.X;
                drawPt.Y   = mapMultiRegion.CenterPt.Y;
                pointFound = true;
            }
            break;

            case MapObject.COLLECTION:
            {
                MapCollection mapCollection = (MapCollection)mapObject;
                if (mapCollection.MultiRegion != null)
                {
                    MapMultiRegion mapMultiRegion = mapCollection.MultiRegion;
                    for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                    {
                        DrawRegion(mapMultiRegion.PenStyle,
                                   mapMultiRegion.BrushStyle,
                                   mapMultiRegion.Regions[i]);
                    }
                }
                if (mapCollection.MultiPline != null)
                {
                    MapMultiPline mapMultiPline = mapCollection.MultiPline;
                    for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                    {
                        DrawPline(mapMultiPline.PenStyle,
                                  mapMultiPline.Plines[i]);
                    }
                }
                if (mapCollection.MultiPoint != null)
                {
                    MapMultiPoint mapMultiPoint = mapCollection.MultiPoint;
                    for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                    {
                        MapPoint mapPoint = new MapPoint
                        {
                            SymbolType = mapMultiPoint.SymbolType,
                            Point      = new GeoLatLng(mapMultiPoint.Points[i])
                        };
                        DrawPoint(mapPoint);
                    }
                }
                pointFound = true;
                drawPt.X   = mapCollection.Bounds.X + mapCollection.Bounds.Width / 2;
                drawPt.Y   = mapCollection.Bounds.Y + mapCollection.Bounds.Height / 2;
            }
            break;

            case MapObject.TEXT:
            {
                MapText mapText = (MapText)mapObject;
                drawPt.X   = mapText.Point.X;
                drawPt.Y   = mapText.Point.Y;
                pointFound = true;
            }
            break;
            }
            if (!mapObject.Name.ToLower().Equals("unknown") && pointFound)
            {
                MapText mapName = new MapText {
                    Font = _font
                };
                mapName.SetForeColor(_fontColor);
                mapName.TextString = mapObject.Name;
                GeoPoint screenPt = FromLatLngToMapPixel(drawPt);
                mapName.Point.X  = screenPt.X;
                mapName.Point.Y  = screenPt.Y;
                mapName.Bounds.X = mapName.Point.X;
                mapName.Bounds.Y = mapName.Point.Y;
                if (_font != null)
                {
                    mapName.Bounds.Height = IMAGE_PATERN_WIDTH;
                    mapName.Bounds.Width  = _font.CharsWidth(mapObject.Name.ToCharArray(), 0,
                                                             mapObject.Name.ToCharArray().Length);
                }
                AddMapName(mapName);
            }
        }
Esempio n. 12
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * draw a map object.
         * @param mapObject the map object to be drawing.
         * @param drawBoundary the drawing boundry.
         * @param zoomLevel the current zoomLevel.
         */
        public override void DrawMapObject(MapObject mapObject, GeoLatLngBounds drawBoundary,
                                           int zoomLevel)
        {
            GeoLatLng drawPt = new GeoLatLng();

            _sutherlandHodgman = new SutherlandHodgman(drawBoundary);
            _mapZoomLevel      = zoomLevel;
            _mapCenterPt.X     = drawBoundary.GetCenterX();
            _mapCenterPt.Y     = drawBoundary.GetCenterY();
            bool pointFound = false;

            Point[] plinePoints = null;
            switch (mapObject.GetMapObjectType())
            {
            case MapObject.NONE:
                break;

            case MapObject.POINT:
            {
                MapPoint mapPoint = (MapPoint)mapObject;
                DrawPoint(mapPoint);
                drawPt.X   = mapPoint.Point.X;
                drawPt.Y   = mapPoint.Point.Y;
                pointFound = true;
            }
            break;

            case MapObject.MULTIPOINT:
            {
                MapMultiPoint mapMultiPoint = (MapMultiPoint)mapObject;
                for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                {
                    MapPoint mapPoint = new MapPoint
                    {
                        SymbolType = mapMultiPoint.SymbolType,
                        Point      = new GeoLatLng(mapMultiPoint.Points[i])
                    };
                    DrawPoint(mapPoint);
                }
                for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                {
                    if (drawBoundary.Contains(mapMultiPoint.Points[i]))
                    {
                        drawPt.X   = mapMultiPoint.Points[i].X;
                        drawPt.Y   = mapMultiPoint.Points[i].Y;
                        pointFound = true;
                        break;
                    }
                }
            }
            break;

            case MapObject.PLINE:
            {
                MapPline mapPline = (MapPline)mapObject;
                plinePoints = DrawPline(mapPline.PenStyle, mapPline.Pline);
                for (int i = 0; i < mapPline.Pline.GetVertexCount(); i++)
                {
                    if (drawBoundary.Contains(mapPline.Pline.GetVertex(i)))
                    {
                        drawPt.X   = mapPline.Pline.GetVertex(i).X;
                        drawPt.Y   = mapPline.Pline.GetVertex(i).Y;
                        pointFound = true;
                        break;
                    }
                }
            }
            break;

            case MapObject.MULTIPLINE:
            {
                MapMultiPline mapMultiPline = (MapMultiPline)mapObject;
                for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                {
                    DrawPline(mapMultiPline.PenStyle,
                              mapMultiPline.Plines[i]);
                    for (int j = 0; j < mapMultiPline.Plines[i].GetVertexCount(); j++)
                    {
                        if (drawBoundary.Contains(mapMultiPline.Plines[i].GetVertex(j)))
                        {
                            drawPt.X   = mapMultiPline.Plines[i].GetVertex(j).X;
                            drawPt.Y   = mapMultiPline.Plines[i].GetVertex(j).Y;
                            pointFound = true;
                            break;
                        }
                    }
                }
            }
            break;

            case MapObject.REGION:
            {
                MapRegion mapRegion = (MapRegion)mapObject;
                DrawRegion(mapRegion.PenStyle, mapRegion.BrushStyle,
                           mapRegion.Region);
                drawPt.X   = mapRegion.CenterPt.X;
                drawPt.Y   = mapRegion.CenterPt.Y;
                pointFound = true;
            }
            break;

            case MapObject.MULTIREGION:
            {
                MapMultiRegion mapMultiRegion = (MapMultiRegion)mapObject;
                for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                {
                    DrawRegion(mapMultiRegion.PenStyle,
                               mapMultiRegion.BrushStyle,
                               mapMultiRegion.Regions[i]);
                }
                drawPt.X   = mapMultiRegion.CenterPt.X;
                drawPt.Y   = mapMultiRegion.CenterPt.Y;
                pointFound = true;
            }
            break;

            case MapObject.COLLECTION:
            {
                MapCollection mapCollection = (MapCollection)mapObject;
                if (mapCollection.MultiRegion != null)
                {
                    MapMultiRegion mapMultiRegion = mapCollection.MultiRegion;
                    for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                    {
                        DrawRegion(mapMultiRegion.PenStyle,
                                   mapMultiRegion.BrushStyle,
                                   mapMultiRegion.Regions[i]);
                    }
                }
                if (mapCollection.MultiPline != null)
                {
                    MapMultiPline mapMultiPline = mapCollection.MultiPline;
                    for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                    {
                        DrawPline(mapMultiPline.PenStyle,
                                  mapMultiPline.Plines[i]);
                    }
                }
                if (mapCollection.MultiPoint != null)
                {
                    MapMultiPoint mapMultiPoint = mapCollection.MultiPoint;
                    for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                    {
                        MapPoint mapPoint = new MapPoint
                        {
                            SymbolType = mapMultiPoint.SymbolType,
                            Point      = new GeoLatLng(mapMultiPoint.Points[i])
                        };
                        DrawPoint(mapPoint);
                    }
                }
                pointFound = true;
                drawPt.X   = mapCollection.Bounds.X + mapCollection.Bounds.Width / 2;
                drawPt.Y   = mapCollection.Bounds.Y + mapCollection.Bounds.Height / 2;
            }
            break;

            case MapObject.TEXT:
            {
                MapText mapText = (MapText)mapObject;
                drawPt.X   = mapText.Point.X;
                drawPt.Y   = mapText.Point.Y;
                pointFound = true;
            }
            break;
            }
            if (!(mapObject.Name.ToLower().Equals("unknown") || mapObject.Name.Length == 0) && pointFound)
            {
                MapText mapName = new MapText {
                    Font = _font
                };
                mapName.SetForeColor(_fontColor);
                mapName.TextString = mapObject.Name;
                GeoPoint screenPt = FromLatLngToMapPixel(drawPt);
                mapName.Point.X  = screenPt.X;
                mapName.Point.Y  = screenPt.Y;
                mapName.Bounds.X = mapName.Point.X;
                mapName.Bounds.Y = mapName.Point.Y;
                Font font = null;
                if (_font != null)
                {
                    font = (Font)_font.GetNativeFont();
                    SizeF sizeF = SharedGraphics2D.Graphics.MeasureString(mapName.TextString, font);
                    mapName.Bounds.Height = sizeF.Height;
                    mapName.Bounds.Width  = sizeF.Width;
                }
                TextPosInfo textPosInfo = new TextPosInfo();
                textPosInfo._mapText = mapName;
                if (mapObject.GetMapObjectType() == MapObject.PLINE)
                {
                    if (plinePoints != null)
                    {
                        GraphicsPath graphicsPath = new GraphicsPath();
                        graphicsPath.AddLines(plinePoints);
                        RectangleF [] rectangleF;
                        double        angle = GetAngle(plinePoints[0], plinePoints[plinePoints.Length - 1]);
                        if (angle < 180)
                        {
                            graphicsPath.Reverse();
                        }
                        angle = GetAngle(plinePoints[0], plinePoints[plinePoints.Length - 1]);

                        float rotateAngle = GetRotateAngle(angle);
                        rectangleF = SharedGraphics2D.Graphics.MeasureString(mapName.TextString, font,
                                                                             new SolidBrush(
                                                                                 Color.FromArgb(_fontColor)),
                                                                             TextPathAlign.Center,
                                                                             TextPathPosition.CenterPath, 100, rotateAngle,
                                                                             graphicsPath);

                        textPosInfo._graphicsPath = graphicsPath;
                        textPosInfo._rectangles   = rectangleF;



                        if (rectangleF.Length == mapName.TextString.Length)
                        {
                            //RectangleF[] rectangleFs = new RectangleF[rectangleF.Length];
                            //Array.Copy(rectangleF, rectangleFs, rectangleF.Length);
                            //for (int i = 0; i < rectangleFs.Length;i++ )
                            //{
                            //    for(int j=0;j<rectangleF.Length;j++)
                            //    {
                            //        if(i!=j)
                            //        {
                            //            if(rectangleFs[i].IntersectsWith(rectangleF[j]))
                            //            {
                            //                return;
                            //            }
                            //        }
                            //    }
                            //}


                            AddMapName(textPosInfo);
                        }
                    }
                }
                else
                {
                    textPosInfo._graphicsPath = null;
                    textPosInfo._rectangles   = new[] { new RectangleF((float)textPosInfo._mapText.Bounds.X, (float)textPosInfo._mapText.Bounds.Y,
                                                                       (float)textPosInfo._mapText.Bounds.Width,
                                                                       (float)textPosInfo._mapText.Bounds.Height) };
                    AddMapName(textPosInfo);
                }
            }
        }
Esempio n. 13
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 21JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * get a map text object at given index.
  */
 private MapText GetMapText(RecordIndex recordIndex)
 {
     MapText mapText = new MapText();
     mapText.Angle = recordIndex.Param1;
     mapText.ForeColor = recordIndex.Param2;
     mapText.BackColor = recordIndex.Param3;
     mapText.Bounds.X = recordIndex.MinX / DOUBLE_PRECISION;
     mapText.Bounds.Y = recordIndex.MinY / DOUBLE_PRECISION;
     mapText.Bounds.Width =
             (recordIndex.MaxX - recordIndex.MinX) / DOUBLE_PRECISION;
     mapText.Bounds.Height =
             (recordIndex.MaxY - recordIndex.MinY) / DOUBLE_PRECISION;
     mapText.Justification = DataReader.ReadInt(_reader);
     mapText.Spacing = DataReader.ReadInt(_reader);
     mapText.LineType = DataReader.ReadInt(_reader);
     mapText.TextString = DataReader.ReadString(_reader);
     return mapText;
 }
Esempio n. 14
0
 ToolStripMenuItem MakeColorItem( MapText.RL_Color id )
 {
     var tsmi = new ToolStripMenuItem();
      tsmi.BackColor = MapText.PaletteByID[id].cr;
      tsmi.Tag = id;
      tsmi.AutoSize = tbarColorMenuBase.AutoSize;
      tsmi.Padding = tbarColorMenuBase.Padding;
      tsmi.Text = tbarColorMenuBase.Text;
      tsmi.Size = tbarColorMenuBase.Size;
      return tsmi;
 }
Esempio n. 15
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 21JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Add a map text to the drawing list.
  * @param mapText
  */
 private void AddMapName(MapText mapText)
 {
     GeoLatLngBounds mapTextBounds = mapText.Bounds;
     for (int i = 0; i < _mapNameHolder.Count; i++)
     {
         GeoLatLngBounds storedMapTextBounds =
                 ((MapText)_mapNameHolder[i]).Bounds;
         if (storedMapTextBounds.Intersects(mapTextBounds))
         {
             return;
         }
     }
     if (_mapSize.Contains(mapTextBounds))
     {
         _mapNameHolder.Add(mapText);
     }
 }
Esempio n. 16
0
        private IMapItem[] GetCharacterLocators()
        {
            var mapTextureTexts = new List <IMapItem>();

            if (API.State.PlayerInfo.Count == 0)
            {
                return(new MapTexture[0]);
            }

            var characters = API.State.PlayerInfo.Values.ToArray();

            IMapItem activeTex = null;

            foreach (var character in characters)
            {
                var  activeCharacter = API.AoHook.GetActiveCharacter();
                bool isActive        = character.Identity == activeCharacter;
                if (character == null || character.Zone == null || character.Position == null || character.Name == null)
                {
                    continue;
                }
                if (!character.IsHooked && !this.DrawOfflineCharacters)
                {
                    // We ain't tracking offline characters.
                    continue;
                }

                var charColor = Color.Yellow;
                if (this.HighlightActiveCharacter && !isActive)
                {
                    charColor = new Color(255, 255, 156);
                }

                var texture = new MapTexture()
                {
                    Texture           = API.Content.Textures.CharacterLocator,
                    KeyColor          = charColor,
                    Position          = new PositionDefinition(character.Zone.ID, character.Position.X, character.Position.Z),
                    PositionAlignment = MapItemAlignment.Center,
                };

                if (!character.IsHooked)
                {
                    texture.KeyColor = Color.Gray;
                }

                var charRealPos = texture.Position.GetPosition();

                var txt = new MapText
                {
                    Position          = new PositionDefinition(),
                    PositionAlignment = MapItemAlignment.Center,
                    Text         = character.Name,
                    TextColor    = charColor,
                    OutlineColor = Color.Black,
                    Outline      = true,
                    Font         = API.Content.Fonts.GetFont(this.CharacterLocatorFont)
                };

                if (this.DrawCharacterDimension)
                {
                    txt.Text += " (" + character.Dimension.ToString().Substring(0, 1) + ")";
                }

                if (!character.IsHooked)
                {
                    txt.TextColor    = Color.LightGray;
                    txt.OutlineColor = Color.Gray;
                }
                var mpt = new MapTextureText(texture, txt, 1)
                {
                    PositionAlignment = MapItemAlignment.Bottom | MapItemAlignment.Center,
                };

                if (!isActive)
                {
                    mapTextureTexts.Add(mpt);
                }
                else
                {
                    activeTex = mpt;
                }
            }

            if (activeTex != null)
            {
                mapTextureTexts.Add(activeTex);
            }
            return(mapTextureTexts.ToArray());
        }
        private MapOverlay GenerateRecentAttackInfo(Dimension dimension)
        {
            if (!this.ShowRecentAttacks)
            {
                return(null);
            }
            var overlay = new GuiTableOverlay
            {
                HeaderVisible = false,
                Position      = new Point(5, 5),
                ColumnSpacing = 15,
                RowSpacing    = 0,
            };

            // Get tower data.
            var qb = new UriQueryBuilder();
            {
                dynamic q = qb;
                q.d          = (int)dimension;
                q.output     = "xml";
                q.limit      = 5;
                q.sortorder  = "desc";
                q.chopmethod = "last";
                q.starttime  = Demoder.Common.Misc.Unixtime(DateTime.Now.Subtract(new TimeSpan(6, 0, 0)));
            }

            var towerData = API.XmlCache.Get <TowerAttacks>().Request(
                Common.CacheFlags.Default,
                qb.ToUri(new Uri(twHistorySearch)),
                dimension.ToString());

            if (towerData == null)
            {
                overlay.MapItems.Add(new MapText
                {
                    Position          = new PositionDefinition(5, 5),
                    PositionAlignment = MapItemAlignment.Top | MapItemAlignment.Left,
                    TextColor         = Color.White,
                    OutlineColor      = Color.Black,
                    Outline           = true,
                    Font = API.Content.Fonts.GetFont(this.RecentAttacksFont),
                    Text = "Error fetching recent attacks for " + dimension.ToString()
                });
                if (dimension == Common.AO.Dimension.Unknown)
                {
                    (overlay.MapItems.Last() as MapText).Text = "Please track a character, or select dimension in plugin configuration.";
                }
                return(overlay);
            }
            if (towerData.Attacks.Count == 0)
            {
                overlay.MapItems.Add(new MapText
                {
                    Position          = new PositionDefinition(5, 5),
                    PositionAlignment = MapItemAlignment.Top | MapItemAlignment.Left,
                    TextColor         = Color.White,
                    OutlineColor      = Color.Black,
                    Outline           = true,
                    Font = API.Content.Fonts.GetFont(this.RecentAttacksFont),
                    Text = "No recent attacks on " + dimension.ToString()
                });
                return(overlay);
            }

            // Define headers.
            var headerTexts = new string[] {
                "Time",
                "Zone",
                "#",
                "Nick",
                "Org"
            };

            for (int i = 0; i < 5; i++)
            {
                overlay.Headers[i] = new GuiTableHeader
                {
                    AutoSize  = true,
                    Alignment = MapItemAlignment.Left | MapItemAlignment.Top,
                    Content   = new MapText
                    {
                        Font              = API.Content.Fonts.GetFont(this.RecentAttacksFont),
                        Text              = headerTexts[i],
                        TextColor         = Color.White,
                        Outline           = true,
                        OutlineColor      = Color.Black,
                        PositionAlignment = MapItemAlignment.Center | MapItemAlignment.Top
                    }
                };
            }

            overlay.Title = new MapText
            {
                Position          = new PositionDefinition(5, 5),
                PositionAlignment = MapItemAlignment.Top | MapItemAlignment.Left,
                TextColor         = Color.White,
                OutlineColor      = Color.Black,
                Outline           = true,
                Font = API.Content.Fonts.GetFont(this.RecentAttacksFont),
                Text = "Recent tower attacks on " + dimension.ToString()
            };

            int row  = 0;
            var font = API.Content.Fonts.GetFont(this.RecentAttacksFont);

            foreach (var attack in towerData.Attacks)
            {
                // time
                overlay[row, 0] = new MapText
                {
                    Text         = attack.Time.ToShortTimeString(),
                    Font         = font,
                    TextColor    = Color.White,
                    OutlineColor = Color.Black,
                    Outline      = true,
                };

                // Attacked site ZONE
                overlay[row, 1] = new MapText
                {
                    Text         = attack.ZoneShortName,
                    Font         = font,
                    TextColor    = this.GetFactionColor(attack.DefenderFaction),
                    OutlineColor = Color.Black,
                    Outline      = true,
                };

                // Attacked site ID
                overlay[row, 2] = new MapText
                {
                    Text         = String.Format("x{0}", attack.SiteID),
                    Font         = font,
                    TextColor    = this.GetFactionColor(attack.DefenderFaction),
                    OutlineColor = Color.Black,
                    Outline      = true,
                };


                // Attacker nickname
                overlay[row, 3] = new MapText
                {
                    Text         = attack.AttackerNickName,
                    Font         = font,
                    TextColor    = this.GetFactionColor(attack.AttackerFaction),
                    OutlineColor = Color.Black,
                    Outline      = true,
                };

                // Attacker org
                overlay[row, 4] = new MapText
                {
                    Font         = font,
                    TextColor    = this.GetFactionColor(attack.AttackerFaction),
                    OutlineColor = Color.Black,
                    Outline      = true,
                };

                if (!String.IsNullOrWhiteSpace(attack.AttackerGuildName))
                {
                    (overlay[row, 4] as MapText).Text = attack.AttackerGuildName;
                }
                else
                {
                    (overlay[row, 4] as MapText).Text = "-";
                }

                row++;
            }
            return(overlay.ToGuiOverlay());
        }
        private MapOverlay GenerateTowerFieldInfo(Dimension dimension)
        {
            var overlay = new MapOverlay
            {
                Name = "LcaInfo",
            };

            // Get tower data.
            var qb = new UriQueryBuilder();
            {
                dynamic q = qb;
                q.d        = (int)dimension;
                q.output   = "xml";
                q.limit    = 300;
                q.minlevel = this.LcaMinLevel;
                q.maxlevel = this.LcaMaxLevel;
            }

            var towerData = API.XmlCache.Get <TowerSites>().Request(
                Demoder.Common.CacheFlags.Default,
                qb.ToUri(new Uri(twTowerDistribution)),
                dimension.ToString(),
                this.LcaMinLevel.ToString(),
                this.LcaMaxLevel.ToString());

            if (towerData == null)
            {
                return(null);
            }
            foreach (var site in towerData.Sites)
            {
                var tex = new MapTexture
                {
                    Position          = new PositionDefinition(site.ZoneID, site.CenterX, site.CenterY),
                    Texture           = new TextureDefinition(TextureType.Content, "TowerTexture"),
                    Size              = new Vector2(8, 8),
                    PositionAlignment = MapItemAlignment.Center | MapItemAlignment.Bottom,
                };

                // Set texture color
                switch (site.Faction)
                {
                case Common.AO.Faction.Neutral:
                    //tex.KeyColor = Color.White;
                    tex.KeyColor = Color.LightGray;
                    break;

                case Common.AO.Faction.Clan:
                    tex.KeyColor = Color.Orange;
                    break;

                case Common.AO.Faction.Omni:
                    tex.KeyColor = Color.SkyBlue;
                    break;

                default:
                    tex.KeyColor = Color.Purple;
                    break;
                }

                MapText text = null;
                if (this.ShowNames)
                {
                    text = new MapText
                    {
                        Font    = API.Content.Fonts.GetFont(this.LcaOwnerFont),
                        Outline = true,
                        Text    = site.Guild
                    };

                    // Set text color
                    switch (site.Faction)
                    {
                    case Common.AO.Faction.Neutral:
                        text.TextColor    = Color.LightGray;
                        text.OutlineColor = Color.Black;
                        break;

                    case Common.AO.Faction.Clan:
                        text.TextColor    = Color.Orange;
                        text.OutlineColor = Color.Black;
                        break;

                    case Common.AO.Faction.Omni:
                        text.TextColor    = Color.SkyBlue;
                        text.OutlineColor = Color.Black;
                        break;

                    default:
                        tex.KeyColor = Color.Purple;
                        break;
                    }
                }



                overlay.MapItems.Add(new MapTextureText(tex, text)
                {
                    PositionAlignment = MapItemAlignment.Bottom
                });
            }
            return(overlay);
        }
Esempio n. 19
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * draw a map object.
         * @param mapObject the map object to be drawing.
         * @param drawBoundary the drawing boundry.
         * @param zoomLevel the current zoomLevel.
         */
        public override void DrawMapObject(MapObject mapObject, GeoLatLngBounds drawBoundary,
                int zoomLevel)
        {
            GeoLatLng drawPt = new GeoLatLng();
            _sutherlandHodgman = new SutherlandHodgman(drawBoundary);
            _mapZoomLevel = zoomLevel;
            _mapCenterPt.X = drawBoundary.GetCenterX();
            _mapCenterPt.Y = drawBoundary.GetCenterY();
            bool pointFound = false;
            switch (mapObject.GetMapObjectType())
            {
                case MapObject.NONE:
                    break;
                case MapObject.POINT:
                    {
                        MapPoint mapPoint = (MapPoint)mapObject;
                        DrawPoint(mapPoint);
                        drawPt.X = mapPoint.Point.X;
                        drawPt.Y = mapPoint.Point.Y;
                        pointFound = true;
                    }
                    break;
                case MapObject.MULTIPOINT:
                    {
                        MapMultiPoint mapMultiPoint = (MapMultiPoint)mapObject;
                        for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                        {
                            MapPoint mapPoint = new MapPoint
                                                    {
                                                        SymbolType = mapMultiPoint.SymbolType,
                                                        Point = new GeoLatLng(mapMultiPoint.Points[i])
                                                    };
                            DrawPoint(mapPoint);
                        }
                        for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                        {
                            if (drawBoundary.Contains(mapMultiPoint.Points[i]))
                            {
                                drawPt.X = mapMultiPoint.Points[i].X;
                                drawPt.Y = mapMultiPoint.Points[i].Y;
                                pointFound = true;
                                break;
                            }
                        }

                    }
                    break;
                case MapObject.PLINE:
                    {
                        MapPline mapPline = (MapPline)mapObject;
                        DrawPline(mapPline.PenStyle, mapPline.Pline);
                        for (int i = 0; i < mapPline.Pline.GetVertexCount(); i++)
                        {
                            if (drawBoundary.Contains(mapPline.Pline.GetVertex(i)))
                            {
                                drawPt.X = mapPline.Pline.GetVertex(i).X;
                                drawPt.Y = mapPline.Pline.GetVertex(i).Y;
                                pointFound = true;
                                break;
                            }
                        }
                    }
                    break;
                case MapObject.MULTIPLINE:
                    {
                        MapMultiPline mapMultiPline = (MapMultiPline)mapObject;
                        for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                        {
                            DrawPline(mapMultiPline.PenStyle,
                                    mapMultiPline.Plines[i]);
                            for (int j = 0; j < mapMultiPline.Plines[i].GetVertexCount(); j++)
                            {
                                if (drawBoundary.Contains(mapMultiPline.Plines[i].GetVertex(j)))
                                {
                                    drawPt.X = mapMultiPline.Plines[i].GetVertex(j).X;
                                    drawPt.Y = mapMultiPline.Plines[i].GetVertex(j).Y;
                                    pointFound = true;
                                    break;
                                }
                            }
                        }
                    }
                    break;
                case MapObject.REGION:
                    {
                        MapRegion mapRegion = (MapRegion)mapObject;
                        DrawRegion(mapRegion.PenStyle, mapRegion.BrushStyle,
                                mapRegion.Region);
                        drawPt.X = mapRegion.CenterPt.X;
                        drawPt.Y = mapRegion.CenterPt.Y;
                        pointFound = true;
                    }
                    break;
                case MapObject.MULTIREGION:
                    {
                        MapMultiRegion mapMultiRegion = (MapMultiRegion)mapObject;
                        for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                        {
                            DrawRegion(mapMultiRegion.PenStyle,
                                    mapMultiRegion.BrushStyle,
                                    mapMultiRegion.Regions[i]);

                        }
                        drawPt.X = mapMultiRegion.CenterPt.X;
                        drawPt.Y = mapMultiRegion.CenterPt.Y;
                        pointFound = true;
                    }
                    break;
                case MapObject.COLLECTION:
                    {
                        MapCollection mapCollection = (MapCollection)mapObject;
                        if (mapCollection.MultiRegion != null)
                        {
                            MapMultiRegion mapMultiRegion = mapCollection.MultiRegion;
                            for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                            {
                                DrawRegion(mapMultiRegion.PenStyle,
                                        mapMultiRegion.BrushStyle,
                                        mapMultiRegion.Regions[i]);
                            }
                        }
                        if (mapCollection.MultiPline != null)
                        {
                            MapMultiPline mapMultiPline = mapCollection.MultiPline;
                            for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                            {
                                DrawPline(mapMultiPline.PenStyle,
                                        mapMultiPline.Plines[i]);
                            }
                        }
                        if (mapCollection.MultiPoint != null)
                        {
                            MapMultiPoint mapMultiPoint = mapCollection.MultiPoint;
                            for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                            {
                                MapPoint mapPoint = new MapPoint
                                                        {
                                                            SymbolType = mapMultiPoint.SymbolType,
                                                            Point = new GeoLatLng(mapMultiPoint.Points[i])
                                                        };
                                DrawPoint(mapPoint);
                            }
                        }
                        pointFound = true;
                        drawPt.X = mapCollection.Bounds.X + mapCollection.Bounds.Width / 2;
                        drawPt.Y = mapCollection.Bounds.Y + mapCollection.Bounds.Height / 2;

                    }
                    break;
                case MapObject.TEXT:
                    {
                        MapText mapText = (MapText)mapObject;
                        drawPt.X = mapText.Point.X;
                        drawPt.Y = mapText.Point.Y;
                        pointFound = true;
                    }
                    break;
            }
            if (!mapObject.Name.ToLower().Equals("unknown") && pointFound)
            {
                MapText mapName = new MapText {Font = _font};
                mapName.SetForeColor(_fontColor);
                mapName.TextString = mapObject.Name;
                GeoPoint screenPt = FromLatLngToMapPixel(drawPt);
                mapName.Point.X = screenPt.X;
                mapName.Point.Y = screenPt.Y;
                mapName.Bounds.X = mapName.Point.X;
                mapName.Bounds.Y = mapName.Point.Y;
                if (_font != null)
                {
                    mapName.Bounds.Height = IMAGE_PATERN_WIDTH;
                    mapName.Bounds.Width = _font.CharsWidth(mapObject.Name.ToCharArray(), 0,
                            mapObject.Name.ToCharArray().Length);

                }
                AddMapName(mapName);

            }
        }
Esempio n. 20
0
        // Clears and draws the entire map from the data in the given MapTxt object.
        public void DrawMap( MapText mapText )
        {
            using (var g = Graphics.FromImage(_bmpFore)) {

            Color cr = windowColor();
            g.Clear(cr);

            // Draw grid lines
            Pen pen = new Pen(CR_GRID);

            Point pt1 = new Point(0, 0);
            Point pt2 = new Point(0, 0);

            pt1.Y = 0; pt2.Y = _sizeGrid.Height * _sizeCell.Height;
            int i; for (i = 0; i <= _sizeGrid.Width; i++) {
               pt1.X = pt2.X = i * _sizeCell.Width;
               g.DrawLine(pen, pt1, pt2);
            }

            pt1.X = 0; pt2.X = _sizeGrid.Width * _sizeCell.Width;
            for (i = 0; i <= _sizeGrid.Height; i++) {
               pt1.Y = pt2.Y = i * _sizeCell.Height;
               g.DrawLine(pen, pt1, pt2);
            }

            // Draw Chars
            for (int x = 0; x < _sizeGrid.Width; x++) {
               for (int y = 0; y < _sizeGrid.Height; y++) {
                  drawChar(g, mapText.GetCell(x, y), mapText.GetColor(x, y), new Point(x, y));
               }
            }
             }
        }
Esempio n. 21
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 21JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * draw a text.
  * @param mapText a map text object.
  */
 private void DrawText(MapText mapText)
 {
     {
         _fontColor = mapText.ForeColor;
         DrawString(_font, mapText.TextString,
                 (int)mapText.Point.X,
                 (int)mapText.Point.Y);
     }
 }
Esempio n. 22
0
        // ----------------------------------------------------------------------
        // Form Events
        // ----------------------------------------------------------------------
        public Form1()
        {
            _bInitDone = false;

             // Load saved settings.
             Size sizeGrid = Properties.Settings.Default.GridSize;
             Size sizeCell = Properties.Settings.Default.CellSize;

             // Init our drawing objects based on the saved cell and grid sizes.
             MapTxt = new MapText( sizeGrid );
             PadBmp = new DrawPad( sizeGrid );
             MapBmp = new MapBitmap(sizeGrid, sizeCell);

             // Whack the beehive.
             InitializeComponent();

             _KSH = new KeyState( this, CH_WALL );

             InitDrawModesTable();
             InitColorToolbar();

             // Resize the app to fit the client area to the current grid and cell sizes.
             Size += new Size((MapBmp.Size.Width - picMap.Size.Width)
                        , (MapBmp.Size.Height - picMap.Size.Height));

             picMap.Image = MapBmp.Bitmap;
             RefreshMap();

             UpdateCaption() ;

             sbarMsg.Text = "Hello Dungeon Maker!";
             //sbarKey.Text = _chKeyDown.ToString(); // NO_KEYCACHED;
             sbarSel.Text = NO_SELECTION;

             _bInitDone = true;
        }