博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
WP7 开发(六) WP7控件开发(三)-绘图控件 地图控件
阅读量:5267 次
发布时间:2019-06-14

本文共 2682 字,大约阅读时间需要 8 分钟。

   -InkPresenter:产生手写效果

    示例代码:

        Stroke newStroke;

        private void inkPresenter1_LostMouseCapture(object sender, MouseEventArgs e)

        {

            newStroke = null;//失去焦点时销毁上一次的Stroke

        }

 

        private void inkPresenter1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)

        {

            inkPresenter1.CaptureMouse();//开始捕获鼠标移动路径

            StylusPointCollection spc = new StylusPointCollection();

            spc.Add(e.StylusDevice.GetStylusPoints(inkPresenter1));

            newStroke = new Stroke();

            this.inkPresenter1.Strokes.Add(newStroke);

        }

 

        private void inkPresenter1_MouseMove(object sender, MouseEventArgs e)

        {

            if (newStroke != null)

            {

                //记录鼠标在inkPresenter1上的移动的点

                newStroke.StylusPoints.Add(e.StylusDevice.GetStylusPoints(inkPresenter1));

            }

        }

   -Path:通过Markup Syntax来绘制一系列的线条,通过Geometries来绘制形状

    示例:

     <Path Height="428" HorizontalAlignment="Left"

     Margin="12,127,0,0" Name="path1" Stroke="Red" StrokeThickness="10" VerticalAlignment="Top"       Width="456" Fill="Green">

      <Path.Data>

          <EllipseGeometry Center="200,200"  RadiusX="100" RadiusY="30"/>

      </Path.Data>

    </Path>

   -Ellipse:绘制圆形或椭圆形

   -Rectangle:绘制矩形

   -Line:绘制两点间的连线

   -Polygon:绘制封闭多边形

   -Polyline:绘制封闭、开发多边形

   -Glyphs:绘制字母、符号、字符等,主要用来显示Unicode字符,需要加载字体库从网上字体库,对于  使用不多的情况使用,否则会消耗系统的资源

   -Map控件:在使用时,首先要申请授权验证密钥 显示模式设置有Road、Arial

          -显示缩放按钮:ZoomBarVisibility属性

          -显示比例尺:ScaleVisibility属性 

          -加标记:用到Pushpin类

     //为地图加标记

            Pushpin pin = new Pushpin();

            pin.Location = new GeoCoordinate(30.3441333,120.342155132);

            pin.Width = 200;

            pin.Height = 200;

            pin.Content = "济南";

            pin.Background = new SolidColorBrush(Colors.Red);

            mymap.Children.Add(pin);

          -绘制多变型区域:用到MapPolygon类 实例化 设置Locations属性即可

     //在地图上绘制多边形

            MapPolygon polygon = new MapPolygon();

            polygon.Fill = new SolidColorBrush(Colors.Red);

            polygon.Stroke = new SolidColorBrush(Colors.Yellow);

            polygon.StrokeThickness = 5;

            polygon.Opacity = 0.7;

            polygon.Locations = new LocationCollection()

            {

                new GeoCoordinate(30,120),

                new GeoCoordinate(30,130),

                new GeoCoordinate(30,160),

                new GeoCoordinate(30,140)

            };

            mymap.Children.Add(polygon);

   -绘制多边线:用到MapPolyline 实例化 设置Stroke属性和Locatatoins

     //在地图上绘制多边线

            MapPolyline polyline = new MapPolyline();

            polyline.Stroke = new SolidColorBrush(Colors.Red);

            polyline.StrokeThickness = 5;

            polyline.Opacity = 0.5;

            polyline.Locations = new LocationCollection()

            {

                new GeoCoordinate(30.3424242,120.3432444),

                new GeoCoordinate(30.3424242,120.3432444)

            };

            mymap.Children.Add(polyline);

          -在地图上添加图片

      //在地图上添加图片

            Image image = new Image();

            image.Width = 100;

            image.Height = 100;

            image.Source = new BitmapImage(new Uri("Images/Pic1.jpg",UriKind.Relative));

            MapLayer imagelayer = new MapLayer();

            imagelayer.AddChild(image,new GeoCoordinate(30,120),PositionOrigin.BottomLeft);

            mymap.Children.Add(imagelayer);

转载于:https://www.cnblogs.com/xingfuzzhd/archive/2011/11/14/2248391.html

你可能感兴趣的文章
[Kaggle] Sentiment Analysis on Movie Reviews
查看>>
价值观
查看>>
mongodb命令----批量更改文档字段名
查看>>
MacOS copy图标shell脚本
查看>>
国外常见互联网盈利创新模式
查看>>
Oracle-05
查看>>
linux grep 搜索查找
查看>>
Not enough free disk space on disk '/boot'(转载)
查看>>
android 签名
查看>>
android:scaleType属性
查看>>
mysql-5.7 innodb 的并行任务调度详解
查看>>
shell脚本
查看>>
Upload Image to .NET Core 2.1 API
查看>>
Js时间处理
查看>>
Java项目xml相关配置
查看>>
三维变换概述
查看>>
vue route 跳转
查看>>
【雷电】源代码分析(二)-- 进入游戏攻击
查看>>
Entityframework:“System.Data.Entity.Internal.AppConfig”的类型初始值设定项引发异常。...
查看>>
Linux中防火墙centos
查看>>