Drag-and-drop behavior in Deepearth (DragBehavior)

Source: Internet
Author: User

In Deepearth, the drag-and-drop behavior of maps is used to standardize the operation model of user's selection, movement and plotting when manipulating maps. The Deepearth is encapsulated in an enumeration structure inside the map control, and the source code is as follows:

/// <summary>
/// 地图拖放行为
/// </summary>
public enum DragBehavior
{
     /// <summary>
     /// 鼠标成手型图标点在地图上拖放,地图的呈现随同鼠标的拖动进行移动并定位于鼠标释放的位置。
     /// </summary>
     Pan,
     /// <summary>
     ///在地图上通过选择绘制出一个选框图形,当鼠标释放选择的时候将地图放大级别显示。
     /// </summary>
     Select,
     /// <summary>
     /// 在地图上绘制图形。
     /// </summary>
     Draw
}

The drag-and-drop behavior in Deepearth is defined as the drag-and-drop behavior of the mouse, and when the user operates the map on the map, the mouse hands-like icon points on the map to drag and drop the map, when the mouse release drag and positioning the map in the mouse release drag map location. The default drag-and-drop behavior is defined in the source code as follows:

//地图拖放行为
private DragBehavior _DragMode = DragBehavior.Pan;

The above is a simple description of the drag-and-drop behavior of the map, let's look at how to use the map in the development of drag-and-drop behavior, we can put a button on the interface to do an experiment, by clicking the button to achieve the function of switching map drag and drop behavior:

/// <summary>
/// 改变地图的拖放行为
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnDragBehavior_Click(object sender, RoutedEventArgs e)
{
     //判断当前地图的拖放模式--实现两种模式之间切换
     switch (mapInstance.DragMode)
     {
         case Map.DragBehavior.Pan:
             mapInstance.DragMode = Map.DragBehavior.Select;
             ToolTipService.SetToolTip(btnDragBehavior, "切换到选择放大模式");
             btnDragBehavior.Content = "选择";
             break;
         case Map.DragBehavior.Select:
             mapInstance.DragMode = Map.DragBehavior.Pan;
             ToolTipService.SetToolTip(btnDragBehavior, "切换到拖放平移模式");
             btnDragBehavior.Content = "拖放";
             break;
     }
}

The above code block thinking is very clear, through the current map of the drag-and-drop behavior to determine, alternately set the map drag-and-drop behavior, after compiling the program to run the effect as shown in the following figure:

It's not very nice to put it in the middle of the map, so we can move the toggle trigger function of the drag-and-drop mode to the function navigation menu by pressing the method described in the previous "explore Deepearth's built-in controls," so that the overall look is quite different.

Here changed the layout of the next interface, the original directly applicable button to display text to change the way to apply the picture, through different drag-and-drop behavior to operate the map, the switch implementation of this function is very convenient, simple, but very applicable. We can expand the map of the drag-and-drop to achieve a lot of functions, such as mapping on the map, select points, box selection and other complex operations, this article is not to introduce, in the follow-up related articles in detail how to achieve these functions.

Article Source: http://beniao.cnblogs.com/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.