protected override void DrawCore(IEnumerable <Feature> features, GeoCanvas canvas, Collection <SimpleCandidate> labelsInThisLayer, Collection <SimpleCandidate> labelsInAllLayers) { foreach (Feature feature in features) { // Here we are going to do the calculation to see what // time it is for each feature and draw the appropriate style float offsetToGmt = Convert.ToSingle(feature.ColumnValues[timeZoneColumnName]); DateTime localTime = DateTime.UtcNow.AddHours(offsetToGmt); if (localTime.Hour >= 7 && localTime.Hour <= 19) { // Daytime daytimePointStyle.Draw(new Collection <Feature>() { feature }, canvas, labelsInThisLayer, labelsInAllLayers); } else { //Nighttime nighttimePointStyle.Draw(new Collection <Feature>() { feature }, canvas, labelsInThisLayer, labelsInAllLayers); } } }
//Overrides the DrawCore function. protected override void DrawCore(GeoCanvas canvas) { //Draws the Edit Shapes as default. Collection <SimpleCandidate> labelsInAllLayers = new Collection <SimpleCandidate>(); EditShapesLayer.Open(); EditShapesLayer.Draw(canvas, labelsInAllLayers); canvas.Flush(); //Draws the control points. ExistingControlPointsLayer.Open(); Collection <Feature> controlPoints = ExistingControlPointsLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns); //Loops thru the control points. foreach (Feature feature in controlPoints) { //Looks at the value of "state" to draw the control point as dragged or not. if (feature.ColumnValues["state"] != "selected") { Feature[] features = new Feature[1] { feature }; controlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers); } else { Feature[] features = new Feature[1] { feature }; draggedControlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers); } } }
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; } } }
protected override void DrawCore(IEnumerable <Feature> features, GeoCanvas canvas, Collection <SimpleCandidate> labelsInThisLayer, Collection <SimpleCandidate> labelsInAllLayers) { // Loop through each feature and determine how large the point should // be then adjust it's size. foreach (Feature feature in features) { float sizeData = Convert.ToSingle(feature.ColumnValues[sizeColumnName]); float symbolSize = sizeData / ratio; pointStyle.SymbolSize = symbolSize; pointStyle.Draw(new Collection <Feature>() { feature }, canvas, labelsInThisLayer, labelsInAllLayers); } }
//Overrides the DrawCore function. protected override void DrawCore(GeoCanvas canvas) { //Draws the Edit Shapes as default. Collection <SimpleCandidate> labelsInAllLayers = new Collection <SimpleCandidate>(); EditShapesLayer.Open(); EditShapesLayer.Draw(canvas, labelsInAllLayers); canvas.Flush(); //Draws the control points. ExistingControlPointsLayer.Open(); Collection <Feature> controlPoints = ExistingControlPointsLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns); //Loops thru the control points. foreach (Feature feature in controlPoints) { //Looks at the value of "state" to draw the control point as dragged or not. if (feature.ColumnValues["state"] != "selected") { Feature[] features = new Feature[1] { feature }; controlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers); } else { Feature[] features = new Feature[1] { feature }; draggedControlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers); PointShape pointShape = feature.GetShape() as PointShape; PointShape closestPointShape = referenceShape.GetClosestPointTo(pointShape, GeographyUnit.DecimalDegree); //Draws the closest point on the reference shape and the distance to it from the dragged control point. if (closestPointShape != null) { double Dist = System.Math.Round(closestPointShape.GetDistanceTo(pointShape, GeographyUnit.DecimalDegree, DistanceUnit.Meter)); ScreenPointF ScreenPointF = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, pointShape, canvas.Width, canvas.Height); canvas.DrawTextWithScreenCoordinate(System.Convert.ToString(Dist) + " m", new GeoFont("Arial", 12, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.StandardColors.Black), ScreenPointF.X + 35, ScreenPointF.Y, DrawingLevel.LabelLevel); canvas.DrawEllipse(closestPointShape, 12, 12, new GeoSolidBrush(GeoColor.StandardColors.Purple), DrawingLevel.LevelFour); } } } }
//Overrides the DrawCore function. protected override void DrawCore(GeoCanvas canvas) { if (EditShapesLayer.InternalFeatures.Count > 1) { throw new NotImplementedException("Only allow one shape to be editing."); } //Draws the Edit Shapes as default. Collection <SimpleCandidate> labelsInAllLayers = new Collection <SimpleCandidate>(); EditShapesLayer.Open(); EditShapesLayer.Draw(canvas, labelsInAllLayers); canvas.Flush(); ExistingControlPointsLayer.Open(); Collection <Feature> ExistingControlPoints = ExistingControlPointsLayer.QueryTools.GetAllFeatures(new string[1] { "IsSelected" }); ExistingControlPointsLayer.Close(); //Loops thru the control points. for (int i = ExistingControlPoints.Count - 1; i >= 0; i--) { Feature feature = ExistingControlPoints[i]; if (feature.ColumnValues.ContainsKey("IsSelected") && feature.ColumnValues["IsSelected"] == "true") { Feature[] features = new Feature[1] { feature }; selectedControlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers); } else { Feature[] features = new Feature[1] { feature }; controlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers); } } }
//Overrides the DrawCore function. protected override void DrawCore(GeoCanvas canvas) { //Draws the Edit Shapes as default. Collection <SimpleCandidate> labelsInAllLayers = new Collection <SimpleCandidate>(); EditShapesLayer.Open(); EditShapesLayer.Draw(canvas, labelsInAllLayers); canvas.Flush(); //Gets the control points and draw its features according to the value of "IsSelected" column. this.ExistingControlPointsLayer.Open(); Collection <Feature> ExistingControlPoints = this.ExistingControlPointsLayer.QueryTools.GetAllFeatures(new string[1] { "IsSelected" }); ExistingControlPointsLayer.Close(); //Loops thru the control points features and check for the value of "IsSelected" collumn. foreach (Feature feature in ExistingControlPoints) { if (feature.ColumnValues.ContainsKey("IsSelected") && feature.ColumnValues["IsSelected"] == "true") { Feature[] features = new Feature[1] { feature }; selectedControlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers); } else { Feature[] features = new Feature[1] { feature }; controlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers); } } }
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; } } }
//Overrides the DrawCore function to draw the Edit Layers, the vertices and tolerance ellipses of layer to snap to, //and the control points. protected override void DrawCore(GeoCanvas canvas) { //Sets the geography Unit used in FindNearestSnappingPoint function geographyUnit = canvas.MapUnit; currentWorldExtent = canvas.CurrentWorldExtent; mapWidth = canvas.Width; mapHeight = canvas.Height; //Draws the Edit Shapes as default. Collection <SimpleCandidate> labelsInAllLayers = new Collection <SimpleCandidate>(); EditShapesLayer.Open(); EditShapesLayer.Draw(canvas, labelsInAllLayers); canvas.Flush(); //Draw the vertices and tolerance ellipses of layer to snap to. toSnapInMemoryFeatureLayer.Open(); Collection <Feature> toSnapPoints = toSnapInMemoryFeatureLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns); toSnapInMemoryFeatureLayer.Close(); foreach (Feature feature in toSnapPoints) { PolygonShape polygonShape = (PolygonShape)feature.GetShape(); foreach (Vertex vertex in polygonShape.OuterRing.Vertices) { //Draws the vertex. PointShape pointShape = new PointShape(vertex); canvas.DrawEllipse(pointShape, 5, 5, new GeoSolidBrush(GeoColor.StandardColors.Black), DrawingLevel.LevelOne); //Draws the tolerance ellipse. if (toleranceType == ToleranceCoordinates.Screen) { ScreenPointF screenPointF = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, pointShape, canvas.Width, canvas.Height); canvas.DrawEllipse(screenPointF, tolerance * 2, tolerance * 2, new GeoPen(GeoColor.StandardColors.Black), new GeoSolidBrush(), DrawingLevel.LevelFour, 0, 0, PenBrushDrawingOrder.PenFirst); } else { EllipseShape ellipseShape = new EllipseShape(pointShape, tolerance, canvas.MapUnit, toleranceUnit); canvas.DrawArea(ellipseShape, new GeoPen(GeoColor.StandardColors.Black), DrawingLevel.LevelOne); } } } //Draws the control points. ExistingControlPointsLayer.Open(); Collection <Feature> controlPoints = ExistingControlPointsLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns); ////Loops thru the control points. foreach (Feature feature in controlPoints) { //Looks at the value of "state" to draw the control point as dragged or not. Feature[] features = new Feature[1] { feature }; controlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers); } foreach (Feature feature in SelectedControlPointLayer.InternalFeatures) { Feature[] features = new Feature[1] { feature }; draggedControlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers); } }