====== Map Suite Wpf Desktop Edition InteractiveOverlays Samples ====== {{section>upgrade_map_suite_to_10.0}}
==== Canceling TrackOverlay ====
{{:no_screenshot.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_CancelingTrackOverlay_CS_100330.zip|View Source]] {{filehistory:DesktopEditionSample_CancelingTrackOverlay_CS_100330.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Services \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
This project shows how to implement aborting a trackshape with Esc key as you could do it in MapSuite 2.x. \\ As with Dynamic Info on TrackShape project, it shows how TrackOverlay can be extended to add some custom functionalities. \\ You will see how to handle some events of the map such as KeyDown and how to manipulate TrackOverlay.
----
==== Custom Track Line ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample Custom Track Line.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_CustomTrackLine_CS_100210.zip|View Source]] {{filehistory:DesktopEditionSample_CustomTrackLine_CS_100210.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Web \ Silverlight \ Services \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
In today’s project, we are going to see how to extend the TrackInteractiveOverlay in the Desktop edition to have the desired behavior when tracking a line. In this case, we show how to override the MouseDownCore function to have the line being tracked at left mouse click and have the last vertex added deleted at right mouse click.
----
==== Custom Track Polygon ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample Custom Track Polygon.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_CustomTrackPolygon_CS_100413.zip|View Source]] {{filehistory:DesktopEditionSample_CustomTrackPolygon_CS_100413.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Web \ Silverlight \ Services \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
In the project “Custom Track Line”, we saw how to extend the TrackInteractiveOverlay to have the behavior of deleting the last added vertex when right click on a track line. In today’s project, we show how to implement this same behavior for tracking polygon.
----
==== Drag Select Vertices As Group ====
{{wpfedition:codesamples:Map Suite Desktop Edition Sample Drag Select Vertices As Group.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_DragSelectVerticesAsGroup_CS_101111.zip|View Source]] {{filehistory:DesktopEditionSample_DragSelectVerticesAsGroup_CS_101111.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
With EditInteractiveOverlay, we know how to drag a feature such as polygon as a whole. We also know how to drag an individual vertex by setting the appropriate properties. Here we go a little further and we show how to create an inherited class from EditInteractiveOverlay to implement the logic for selecting vertices and dragging them as a group. See how the protected methods MouseDownCore, MouseUpCore, MouseClickCore and MouseMoveCore were overridden for that purpose. This is a Desktop app that also applies to Wpf.
----
==== Dragged Point Style ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample Dragged Point Style.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_DraggedPointStyle_CS_091208.zip|View Source]] {{filehistory:DesktopEditionSample_DraggedPointStyle_CS_091208.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Web \ Silverlight \ Services \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
In the Discussion Forum Post “Snapping help needed”, we show the solution to have a dragged vertex snapping to a vertex of another layer. You can see that by default the control point being dragged turns yellow. In this project, we focus our attention on how to have control on the style of the control points. You will see how to override the DrawCore function of EditInteractiveOverlay. This is a project for the Desktop edition.
----
==== Dragged Point Style Advanced ====
{{wpfedition:codesamples:Map Suite Desktop Edition Sample Dragged Point Style Advanced.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_DraggedPointStyleAdvanced_CS_101015.zip|View Source]] {{filehistory:DesktopEditionSample_DraggedPointStyleAdvanced_CS_101015.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
This project is another example of how extendible EditInteractiveOverlay is for the editing needs of the user. You can see how to change the styles of the vertex being dragged based on the Shift key and have the vertex snap to any feature. Thanks to the protected override functions such as KeyDownCore, KeyUpCore, MouseUpCore and DrawCore, these functionalities can be easily implemented by inheriting from EditInteractiveOverlay.
----
==== Dragged PointStyle with Label ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample Dragged Point Style With Label.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_DraggedPointStyleWithLabel_CS_100120.zip|View Source]] {{filehistory:DesktopEditionSample_DraggedPointStyleWithLabel_CS_100120.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
In our series of projects dedicated to EditInteractiveOverlay, today you will see how easy it is to add some labeling to your dragged control point showing dynamic information. Here we show how to display the distance from the dragged control point to the closest point of a reference shape. Also, to augment the experience of the user, the closest point of the reference shape is also shown varying as the control point is dragged around. \\ \\ In the GIS field, enterprises have different needs on how they edit there data and on how smooth the editing should be allowing the maximum control and precision to the technician editing the data. This example on how to use the EditInteractiveOverlay demonstrates how powerful and flexible editing is with Map Suite map control.
----
==== Dragging Icon ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample Dragging Icon.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_DraggingIcon_CS_100302.zip|View Source]] {{filehistory:DesktopEditionSample_DraggingIcon_CS_100302.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
In today’s sample, we show how to drag icons representing vehicle on the map. This is a handy feature if you want to give your users the ability to drag and drop some non stationary features such as vehicles. You can see that to accomplish this functionality, you can use EditInteractiveOverlay as it already has all the necessary logic for dragging purposes. Look at the code to see how to set up that overlay to have the expected behavior.
----
==== Dragging Icon Advanced ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample Dragging Icon Advanced.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_DraggingIconAdvanced_CS_100610.zip|View Source]] {{filehistory:DesktopEditionSample_DraggingIconAdvanced_CS_100610.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
This project is a more complete version of a previous project “Dragging Icon”. In addition to showing how to use EditInteractiveOverlay for dragging and dropping features represented by an icon, we also show how to add new features on the map by left double clicking on the map. You will also see how to remove a feature by right double clicking on its icon.
----
==== Dragging Vertex ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample Dragging Vertex.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_DraggingVertex_CS_100827.zip|View Source]] {{filehistory:DesktopEditionSample_DraggingVertex_CS_100827.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
The purpose of today’s project is not so much as show a new technology as to show an improvement in an existing one. We are already familiar with EditInteractiveOverlay with projects such as “Dragged PointStyle with Label”, “Snap To Layer” and “Snapping to Vertex”. But those projects showed EditInteractiveOverlay on small shapes. Using EditIntercticeOverlay on complex shapes became not very responsive. We improved that and now you can drag, resize, rotate and drag individual vertex of a complex polygon made of thousand of vertices with good responsiveness as you can see in this example. \\ \\ To run this Desktop project, you will need the version 4.0.66.0 or later of the development daily build for MapSuiteCore and DesktopEdition dlls. And do not forget to add a reference to WindowsBase.dll.\\ \\ This improvement is currently only in the development branch, it will be added to the production branch at the next major release in November.
----
==== Dynamic Info On TrackShapes ====
{{wpfedition:codesamples:Map_Suite_Wpf_Desktop_Edition_Sample_Dynamic_Info_On_TrackShapes.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_DynamicInfoOnTrackShapes_CS_090805.zip|View Source]] {{filehistory:DesktopEditionSample_DynamicInfoOnTrackShapes_CS_090805.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Web \ Silverlight \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
This project is for the Desktop version and it shows how to handle TrackOverlay to obtain dynamic information about the shape being tracked.\\ \\ In this example, you will see displayed in a groupbox, properties such as perimeter and area as the shape is being tracked.\\ \\ In this project, you will learn how to handle events such as TrackStarted, MouseMoved and TrackEnded of TrackOverlay for that purpose.\\ \\ Getting dynamic info of a shape being tracked can be handy in situation where before committing to get the completed shape, you want to know more about the shape. For example, if you are tracking a search zone, you get dynamically info about its area.\\ \\ This project will be followed by other related projects. One will show how to create one’s own inherited TrackOverlay for having the possibility to abort tracking by pressing a key. Another project will show how to display dynamic info inside the shape itself instead of using a separate control.
----
==== Editing Rectangles ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample Editing Rectangles.png?300x180}}
[[[Source_Code_DesktopEditionSample_EditingRectangles_CS_100204.zip|View Source]] {{filehistory:DesktopEditionSample_EditingRectangles_CS_100204.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
This sample shows how to extend the EditInteractiveOverlay rectangles as shapes rather than polygon shapes by setting special column values. For features (Well Known Text and Binary), the concept of a rectangle is not supported and typically rectangles are handled as polygons. This feature allows users to modify the rectangle but requires that the modification keep a rectangular form. The rectangle doesn't need to be straight as long as all of the corner angles are at 90 degrees relative to each other. \\ To activate the feature, you need to assign the value of the column called "Edit" to "rectangle". The resize function will keep the ratio of width and height of the rectangle, otherwise it will use the original method. \\ For more information you can see the discussion forum post below: \\ http://gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/21/aft/5822/afv/topic/Default.aspx
----
==== EditOverlay Styles ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample EditOverlay Styles.jpg?300x180}}
[[[Source_Code_WebEditionSample_EditOverlayStyles_CS_100910.zip|View Source]] {{filehistory:WebEditionSample_EditOverlayStyles_CS_100910.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Web \ Silverlight \ Services \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
In today’s Web project, we learn how to control the styles of the EditOverlay for both the default style and the editing style. In order to accomplish this, we write some javascript code. Look at the code in the “script” tag to see how we can control the fill color, the opacity, the border width etc of the features in the EditOverlay.
----
==== Connecting Two Shapes With Arraw Line Samples ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample Connecting Two Shapes.jpg?300x180}}
[[[Source_Code_WpfDesktopEditionSample_ConnectingTwoShape_CS_130620.zip|View Source]] {{filehistory:ConnectingTwoShapesWithArrawLine_CS_141212.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Services \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
In this sample, two polygons are connected by a arrowline, and if the polygons are moved the connecting arrowline will be moved automatically as well.
----
==== Preset Vertex To Tracked Polygon ====
{{wpfedition:codesamples:Map Suite Desktop Edition Sample Preset Vertex To Tracked Polygon.jpg?300x180}}
[[[Source_Code_DesktopEditionSample PresetVertexToTrackedPolygon CS 110405.zip|View Source]] {{filehistory:DesktopEditionSample PresetVertexToTrackedPolygon CS 110405.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
This Desktop sample shows how to extend TrackInteractiveOverlay to give the ability to add a preset vertex to a track polygon while tracking. This can be handy in the situations where you need to add a vertex outside the current extent of the map or when you need to add a vertex with precise X and Y values. In the custom PresetVertexTrackInteractiveOverlay, you can see how the protected function GetTrackingShapeCore was overridden to implement this tracking behavior of the polygon.
----
==== Select and Drag(wpf) ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample Select And Drag.jpg?300x180}}
[[[Source_Code_WpfDesktopEditionSample_SelectAndDrag_CS_100908.zip|View Source]] {{filehistory:WpfDesktopEditionSample_SelectAndDrag_CS_100908.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
In this Wpf project, we show how to select a feature from a shapefile based on a column value using the GetFeaturesByColumnValue. We also show to setup the EditOverlay to give the user the ability to drag the selected feature. In this project, you can also see how to get the world coordinates at the mouse move event. Notice that the code for doing this is quite different in Wpf compared to the winforms edition.
----
==== Select Vertices ====
{{wpfedition:codesamples:Map Suite Desktop Edition Sample Select Vertices.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_SelectVertices_CS_101104.zip|View Source]] {{filehistory:DesktopEditionSample_SelectVertices_CS_101104.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
The purpose of this sample is to help you, the developer understand some intricacies of inheriting from EditInteractiveOverlay when implementing your own editing logic. Here we show how to keep control points drawing as selected even after the dragging operation is finished. For this purpose, we need to override three protected functions, OnControlPointSelected, MouseUpCore and DrawCore. Please, read carefully the comments to understand the inner workings of EditInteractiveOverlay.
----
==== Select with Track Shape ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample Select With TrackShape.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_SelectWithTrackShape_CS_100315.zip|View Source]] {{filehistory:DesktopEditionSample_SelectWithTrackShape_CS_100315.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Web \ Silverlight \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
In today’s Desktop project, we combine the skills we learned in the samples “Spatial Query A Feature Layer” and “Track And Edit Shapes”. You can see how we use the event TrackEnded to get the RectangleShape from the tracked shape of TrackOverlay to do the spatial query. In this example, we use a Rectangle but you could also very easily use another shape such as Polygon, Circle, etc.
----
==== Snap To Layer ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample Snap To Layer.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_SnapToLayer_CS_091209.zip|View Source]] {{filehistory:DesktopEditionSample_SnapToLayer_CS_091209.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
This project shows how you can apply snapping to an EditInteractiveOverlay. There are many aspects to snapping. Previously, we showed a project with the mouse pointer snapping to the closest vertex of an editable polygon. Today, we show the technique to drag a control point and have it snap to the closest vertex of a layer if within tolerance. The tolerance can be set in world (meter, feet etc) or screen (pixels) coordinates. Notice that we are also using the technique showed in the previous project “Dragged Point Style”.
----
==== Snapping to Layer2 ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample SnapToLayer2.jpg?300x180}}
[[[Source_Code_WpfDesktopEditionSample SnapToLayer2 CS 110413.zip|View Source]] {{filehistory:WpfDesktopEditionSample SnapToLayer2 CS 110413.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
The purpose of this Wpf project is to address some limitations of the class SnapToLayerEditInteractiveOverlay found in a previous sample Snap To Layer. \\ This class allowed the snapping of the mouse pointer to the closest vertex of a polygon if it is within a set tolerance. While this worked great for simple polygons, there was a performance limitation with complex polygons made of many vertices. This Wpf sample addresses this limitation and allows responsive dragging and snapping of vertex regardless of the size of polygon to snap to.
----
==== Snapping to Vertex ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample Snapping to Vertex.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_SnappingToVertex_CS_091127.zip|View Source]] {{filehistory:DesktopEditionSample_SnappingToVertex_CS_091127.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
This project is the first one of a series that will be dedicated to snapping using InteractiveOverlay. In this project, we show how to snap the mouse pointer to the closest vertex of an editable polygon if it is within a set tolerance. The tolerance is shown as a circle around the vertices. This technique can also be applied to snapping vertices within the same shape, between different shapes or even based on a layer. Those different types of snapping will be the subject of future projects related to snapping using InteractiveOverlay.
----
==== Track Zoom In Without Shift ====
{{:no_screenshot.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_TrackZoomInWithoutShift_CS_091028.zip|View Source]] {{filehistory:DesktopEditionSample_TrackZoomInWithoutShift_CS_091028.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
This project is for DesktopEdition users. In Map Suite 2.x, different modes of the map are offered to the developer to choose what kind of behavior the map has at a mouse action. In Map Suite 3.x, we went away from modes to have a more flexible model using InteracticeOverlay. By default, track zoom in is done by clicking and dragging the mouse on the map while holding the Shift key. This is very convenient but what if you want to offer the users the same experience as with 2.x, where the same mouse action has different behavior such as TrackZoomIn and Pan through the use of modes.\\ \\ In this project, we show how to build your own InteractiveOverlay to emulate in Map Suite 3.x the mode behavior 2.x has.
----
==== Tracked Shapes to File ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edtion Sample Tracked Shapes To File.jpg?300x180}}
[[[Source_Code_WpfDesktopEditionSample TrackedShapesToFile CS 101126.zip|View Source]] {{filehistory:WpfDesktopEditionSample TrackedShapesToFile CS 101126.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
In this Wpf sample, we show how to persist the tracked shapes by saving the WKT (Well Known Text) to a file using the TrackEnded event. Also, you can see how to retrieve the WKT from files to create the features for the TrackShapeLayer of the TrackOverlay when loading the map. You will need the MapSuiteCore.dll and WpfDesktopEdition.dll references for this sample.
----
==== Tracked Shapes to WKT ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample Tracked Shapes to WKT.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_TrackedShapesToWKT_CS_100513.zip|View Source]] {{filehistory:DesktopEditionSample_TrackedShapesToWKT_CS_100513.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Web \ Silverlight \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
In today’s project, we show how to save a tracked shape to WKT (Well Known Text). You will notice that we make the distinction between the shape being tracked and the finished tracked shape thanks to two different events of TrackOverlay, TrackEnding and TrackEnded.
----
==== TrackOverlay with ESC(New) ====
{{:no_screenshot.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_TrackOverlayWithEsc_CS_090811.zip|View Source]] {{filehistory:DesktopEditionSample_TrackOverlayWithEsc_CS_090811.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
This project is meant to respond to a limitation with aborting tracking a shape in the project TrackOverlay with Esc. Now we can abort the tracked shape from the first vertex being added. Notice how we used a new class CustomTrackInteractiveOverlay inheriting from TrackInteractiveOverlay for this purpose.
----
==== Vertex Tolerance ====
{{wpfedition:codesamples:Map Suite Wpf Desktop Edition Sample Vertex Tolerance.jpg?300x180}}
[[[Source_Code_DesktopEditionSample_VertexTolerance_CS_091210.zip|View Source]] {{filehistory:DesktopEditionSample_VertexTolerance_CS_091210.zip|C# Download}}
[[Map Suite Samples Applies To|Applies To: Desktop \ Web \ Silverlight \ Services \ Wpf]] \\ [[Map Suite Samples Alternate Languages | Need it in another language?]]
Basically, this project shows the opposite of yesterday’s project “Snap To Layer”. Instead of having the dragged control point snapping to a vertex if within a tolerance, we show how to not allow a control point get within a set tolerance. This technique can be handy to implement if you have a requirement to have vertices of a shape being no less than a certain distance between each others. To implement that technique, again we use the power and flexibility of the EditInteractiveOverlay of the Desktop edition.