Exemple #1
0
        protected override void DrawCore(IEnumerable <Feature> features, GeoCanvas canvas, System.Collections.ObjectModel.Collection <SimpleCandidate> labelsInThisLayer, System.Collections.ObjectModel.Collection <SimpleCandidate> labelsInAllLayers)
        {
            LineShape     drawingLineShape;
            PointShape    linePoint;
            LineBaseShape lineShape;
            LineStyle     lineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.Black, 1f, false);
            LineShape     tangentLineShape;
            ScreenPointF  screenPointF;
            double        angle, decDistance = 0;

            foreach (Feature feature in features)
            {
                drawingLineShape = (LineShape)feature.GetShape();

                while (!(decDistance > drawingLineShape.GetLength(GeographyUnit.Meter, DistanceUnit.Kilometer)))
                {
                    linePoint = drawingLineShape.GetPointOnALine(StartingPoint.FirstPoint, decDistance, GeographyUnit.Meter, DistanceUnit.Kilometer);

                    tangentLineShape = GetTangentForLinePosition(drawingLineShape, decDistance);
                    angle            = GetAngleFromTwoVertices(tangentLineShape.Vertices[0], tangentLineShape.Vertices[1]);

                    angle += 90.0;
                    if (angle >= 360.0)
                    {
                        angle = angle - 180;
                    }

                    screenPointF = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, linePoint, (float)canvas.Width, (float)canvas.Height);

                    canvas.DrawText("    " + decDistance.ToString(), new GeoFont("Arial", 12, DrawingFontStyles.Bold),
                                    new GeoSolidBrush(GeoColor.StandardColors.Black), new GeoPen(GeoColor.StandardColors.White),
                                    new ScreenPointF[] { screenPointF }, DrawingLevel.LabelLevel, 0f, 0f, Convert.ToSingle(angle));

                    double dblTranslateAngle = GetOrthogonalFromVertex(tangentLineShape.Vertices[0], tangentLineShape.Vertices[1], Side.Right);

                    double worldDist = ExtentHelper.GetWorldDistanceBetweenTwoScreenPoints
                                           (canvas.CurrentWorldExtent, 0, 0, 5, 0, canvas.Width, canvas.Height, GeographyUnit.Meter, DistanceUnit.Meter);

                    PointShape pointShape2 = (PointShape)BaseShape.TranslateByDegree
                                                 (linePoint, worldDist, dblTranslateAngle, GeographyUnit.Meter, DistanceUnit.Meter);

                    lineShape = new ThinkGeo.MapSuite.Core.LineShape(new ThinkGeo.MapSuite.Core.Vertex[] {
                        new ThinkGeo.MapSuite.Core.Vertex(linePoint),
                        new ThinkGeo.MapSuite.Core.Vertex(pointShape2)
                    });

                    lineStyle.Draw(new BaseShape[] { lineShape }, canvas, labelsInThisLayer, labelsInAllLayers);
                    decDistance += 0.1;
                }
                lineStyle.Draw(features, canvas, labelsInThisLayer, labelsInAllLayers);
            }
        }
Exemple #2
0
        private static void DrawNormalStyle(this Style style, PlatformGeoCanvas canvas, DrawingRectangleF drawingRectangleF)
        {
            if (style is LineStyle)
            {
                LineStyle lineStyle = (LineStyle)style;

                if (lineStyle.CenterPen.Width <= 2 && lineStyle.InnerPen.Width <= 2 && lineStyle.OuterPen.Width <= 2)
                {
                    lineStyle = (LineStyle)lineStyle.CloneDeep();

                    lineStyle.CenterPen.Width += 1;
                    lineStyle.InnerPen.Width  += 1;
                    lineStyle.OuterPen.Width  += 1;

                    LineShape line = GenerateStraightHorizontalLineShape(canvas.CurrentWorldExtent);
                    line.Rotate(line.GetCenterPoint(), 270);
                    lineStyle.Draw(new BaseShape[] { line }, canvas, new Collection <SimpleCandidate>(), new Collection <SimpleCandidate>());
                }
                else
                {
                    lineStyle.DrawSample(canvas, drawingRectangleF);
                }
            }
            else if (style is FontPointStyle)
            {
                var fontStyle = (FontPointStyle)style;
                var tmpsize   = fontStyle.CharacterFont.Size;
                if (tmpsize > 26)
                {
                    fontStyle.CharacterFont = new GeoFont(fontStyle.CharacterFont.FontName, 26, fontStyle.CharacterFont.Style);
                }
                fontStyle.DrawSample(canvas, drawingRectangleF);
                if (tmpsize > 26)
                {
                    fontStyle.CharacterFont = new GeoFont(fontStyle.CharacterFont.FontName, tmpsize, fontStyle.CharacterFont.Style);
                }
            }
            else if (style is PointStyle)
            {
                var pointStyle    = (PointStyle)style;
                var tmpSymbolSize = pointStyle.SymbolSize;
                if (tmpSymbolSize > 22)
                {
                    pointStyle.SymbolSize = 22;
                }
                pointStyle.DrawSample(canvas, drawingRectangleF);
                if (tmpSymbolSize > 22)
                {
                    pointStyle.SymbolSize = tmpSymbolSize;
                }
            }
            else if (style != null)
            {
                style.DrawSample(canvas, drawingRectangleF);
            }
        }
Exemple #3
0
 static public void GUILine(Rect position, Color color, float height = 2f)
 {
     if (Event.current.type == EventType.Repaint)
     {
         Color orgColor = GUI.color;
         GUI.color = orgColor * color;
         LineStyle.Draw(position, false, false, false, false);
         GUI.color = orgColor;
     }
 }
Exemple #4
0
        protected override void DrawCore(IEnumerable <Feature> features, GeoCanvas canvas, Collection <SimpleCandidate> labelsInThisLayer, Collection <SimpleCandidate> labelsInAllLayers)
        {
            PointStyle pointStyle = new PointStyle(geoImage);

            foreach (Feature feature in features)
            {
                MultilineShape lineShape = (MultilineShape)feature.GetShape();
                lineStyle.Draw(new BaseShape[] { lineShape }, canvas, labelsInThisLayer, labelsInAllLayers);

                List <Vertex> allVertices = lineShape.Lines.SelectMany(l => l.Vertices).ToList();

                double totalDistance = 0;
                for (int i = 0; i < allVertices.Count - 1; i++)
                {
                    PointShape pointShape1 = new PointShape(allVertices[i]);
                    PointShape pointShape2 = new PointShape(allVertices[i + 1]);

                    LineShape tempLineShape = new LineShape();
                    tempLineShape.Vertices.Add(allVertices[i]);
                    tempLineShape.Vertices.Add(allVertices[i + 1]);

                    double angle = GetAngleFromTwoVertices(allVertices[i], allVertices[i + 1]);
                    // Left side
                    if (imageDirection == ImageDirection.Left)
                    {
                        if (angle >= 270)
                        {
                            angle -= 180;
                        }
                    }
                    // Right side
                    else
                    {
                        if (angle <= 90)
                        {
                            angle += 180;
                        }
                    }
                    pointStyle.RotationAngle = (float)angle;

                    float  screenDistance  = ExtentHelper.GetScreenDistanceBetweenTwoWorldPoints(canvas.CurrentWorldExtent, pointShape1, pointShape2, canvas.Width, canvas.Height);
                    double currentDistance = Math.Round(pointShape1.GetDistanceTo(pointShape2, canvas.MapUnit, DistanceUnit.Meter), 2);
                    double worldInterval   = (currentDistance * imageSpacing) / screenDistance;
                    while (totalDistance <= currentDistance)
                    {
                        PointShape tempPointShape = tempLineShape.GetPointOnALine(StartingPoint.FirstPoint, totalDistance, canvas.MapUnit, DistanceUnit.Meter);
                        pointStyle.Draw(new BaseShape[] { tempPointShape }, canvas, labelsInThisLayer, labelsInAllLayers);
                        totalDistance = totalDistance + worldInterval;
                    }

                    totalDistance = totalDistance - currentDistance;
                }
            }
        }
Exemple #5
0
    static public void GUILine(Color color, float height = 2f)
    {
        Rect position = GUILayoutUtility.GetRect(0f, float.MaxValue, height, height, LineStyle);

        if (Event.current.type == EventType.Repaint)
        {
            Color orgColor = GUI.color;
            GUI.color = orgColor * color;
            LineStyle.Draw(position, false, false, false, false);
            GUI.color = orgColor;
        }
    }
Exemple #6
0
        void DrawLine(Rect lineRect, int row, int controlID)
        {
            var line = Line(row);

            DrawAdornments(line, lineRect);

            List <int> tabSizes;
            string     baseTextFormatted = Whitespace.FormatBaseText(line.Text, out tabSizes);
            string     renderText        = Whitespace.FormatRichText(line.RichText, tabSizes);

            LineStyle.Draw(lineRect, MissingEngineAPI.GUIContent_Temp(renderText), controlID);

            if (ShowCursor && row == CaretRow)
            {
                int graphicalCaretPos = Whitespace.ConvertToGraphicalCaretColumn(CaretColumn, line, tabSizes);
                LineStyle.DrawCursor(lineRect, MissingEngineAPI.GUIContent_Temp(baseTextFormatted), controlID, graphicalCaretPos);
            }
        }
Exemple #7
0
        internal virtual void DrawItem(AdvancedDropdownItem item, string name, Texture2D icon, bool enabled, bool drawArrow, bool selected, bool hasSearch)
        {
            GUIContent content = new GUIContent(name, icon);
            Texture    imgTemp = content.image;

            //we need to pretend we have an icon to calculate proper width in case
            if (content.image == null)
            {
                content.image = Texture2D.whiteTexture;
            }
            Rect rect = GUILayoutUtility.GetRect(content, LineStyle, GUILayout.ExpandWidth(true));

            content.image = imgTemp;

            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            Texture imageTemp = content.image;

            if (content.image == null)
            {
                LineStyle.Draw(rect, GUIContent.none, false, false, selected, selected);
                rect.x     += IconSize.x + 1;
                rect.width -= IconSize.x + 1;
            }

            EditorGUI.BeginDisabledGroup(!enabled);
            LineStyle.Draw(rect, content, false, false, selected, selected);
            content.image = imageTemp;
            if (drawArrow)
            {
                float size      = LineStyle.lineHeight;
                Rect  arrowRect = new Rect(rect.x + rect.width - size, rect.y, size, size);
                LineStyle.Draw(arrowRect, Styles.arrowRightContent, false, false, false, false);
            }

            EditorGUI.EndDisabledGroup();
        }
        protected override void DrawCore(IEnumerable <Feature> features, GeoCanvas canvas, Collection <SimpleCandidate> labelsInThisLayer, Collection <SimpleCandidate> labelsInAllLayers)
        {
            PointStyle[] pointStyles = geoImages.Select(geoImage => { return(new PointStyle(geoImage)
                {
                    DrawingLevel = DrawingLevel.LevelThree
                }); }).ToArray();
            foreach (Feature feature in features)
            {
                LineShape lineShape = (LineShape)feature.GetShape();
                lineStyle.Draw(new BaseShape[] { lineShape }, canvas, labelsInThisLayer, labelsInAllLayers);

                int    index     = 0;
                double totalDist = 0;
                for (int i = 0; i < lineShape.Vertices.Count - 1; i++)
                {
                    PointShape pointShape1 = new PointShape(lineShape.Vertices[i]);
                    PointShape pointShape2 = new PointShape(lineShape.Vertices[i + 1]);

                    LineShape tempLineShape = new LineShape();
                    tempLineShape.Vertices.Add(lineShape.Vertices[i]);
                    tempLineShape.Vertices.Add(lineShape.Vertices[i + 1]);

                    double angle = GetAngleFromTwoVertices(lineShape.Vertices[i], lineShape.Vertices[i + 1]);

                    //Left side
                    if (side == SymbolSide.Left)
                    {
                        if (angle >= 270)
                        {
                            angle = angle - 180;
                        }
                    }
                    //Right side
                    else
                    {
                        if (angle <= 90)
                        {
                            angle = angle + 180;
                        }
                    }
                    //pointStyle.RotationAngle = (float)angle;
                    foreach (var pointStyle in pointStyles)
                    {
                        pointStyle.RotationAngle = (float)angle;
                    }
                    float screenDist = ExtentHelper.GetScreenDistanceBetweenTwoWorldPoints(canvas.CurrentWorldExtent, pointShape1,
                                                                                           pointShape2, canvas.Width, canvas.Height);
                    double currentDist   = Math.Round(pointShape1.GetDistanceTo(pointShape2, canvas.MapUnit, DistanceUnit.Meter), 2);
                    double worldInterval = (currentDist * spacing) / screenDist;

                    while (totalDist <= currentDist)
                    {
                        PointStyle pointStyle     = pointStyles[index % pointStyles.Length];
                        PointShape tempPointShape = tempLineShape.GetPointOnALine(StartingPoint.FirstPoint, totalDist, canvas.MapUnit, DistanceUnit.Meter);
                        pointStyle.Draw(new BaseShape[] { tempPointShape }, canvas, labelsInThisLayer, labelsInAllLayers);
                        totalDist = totalDist + worldInterval;
                        index++;
                    }

                    totalDist = totalDist - currentDist;
                }
            }
        }
Exemple #9
0
 public virtual void Draw(Form form, Color color)
 {
     this.graphics = form.CreateGraphics();
     this.pen      = implementor.Draw(color);
 }