In DeepEarth, the drag-and-drop behavior of the map is used to standardize the user's operation model such as selection, movement, and drawing when operating the map. DeepEarth encapsulates it inside the map control (Map) with an enumeration structure. The source code is as follows:
code
/// <summary>
/// Map drag and drop behavior
/// </summary>
public enum DragBehavior
{
/// <summary>
/// Drag the mouse to the hand-shaped icon point on the map. The map will be displayed as the mouse is dragged and positioned at the position where the mouse is released.
/// </summary>
Pan,
/// <summary>
///Draw a marquee graphic on the map by selecting it, and when the mouse releases the selection, the map will be displayed at a magnified level.
/// </summary>
Select,
/// <summary>
/// Draw graphics on the map.
/// </summary>
Draw
}
The drag-and-drop behavior in DeepEarth is defined as mouse drag-and-drop behavior by default. When the user operates the map on the presented map, the mouse turns into a hand-shaped icon point and drags the map on the map. When the mouse releases the drag, the map is Position the map location where the mouse is released to drag. The default drag-and-drop behavior is defined in the source code as follows:
//Map drag and drop behavior
private DragBehavior _DragMode = DragBehavior.Pan;
The drag-and-drop behavior of the map is briefly described above. Let's take a look at how to use the drag-and-drop behavior of the map in development. We can place a Button on the interface as an experiment, and switch the map drag-and-drop behavior by clicking the button. Release behavior function:
code
/// <summary>
/// Change the drag and drop behavior of the map
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnDragBehavior_Click(object sender, RoutedEventArgs e)
{
//Determine the drag-and-drop mode of the current map--to switch between the two modes
switch (mapInstance.DragMode)
{
case Map.DragBehavior.Pan:
mapInstance.DragMode = Map.DragBehavior.Select;
ToolTipService.SetToolTip(btnDragBehavior, "Switch to selection zoom mode");
btnDragBehavior.Content = "Select";
break;
case Map.DragBehavior.Select:
mapInstance.DragMode = Map.DragBehavior.Pan;
ToolTipService.SetToolTip(btnDragBehavior, "Switch to drag-and-drop panning mode");
btnDragBehavior.Content = "Drag and drop";
break;
}
}