<UserControl x:Class="SilverlightTest.PolygonTest"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:Custom.Controls;assembly=Custom.Controls"
mc:Ignorable="d"
d:DesignHeight="" d:DesignWidth=""> <Canvas x:Name="LayoutRoot" Width="" Height="">
<Canvas.Background>
<ImageBrush ImageSource="/SilverlightTest;component/Images/map.png" Stretch="None" />
</Canvas.Background> <Rectangle Margin="" Stroke="Black" Width="" Height="" />
<InkPresenter x:Name="MyIP" Width="" Height="" Margin="" MouseLeftButtonDown="MyIP_MouseLeftButtonDown"
LostMouseCapture="MyIP_LostMouseCapture" MouseMove="MyIP_MouseMove" Background="Transparent" Opacity="">
</InkPresenter>
<!--<Polygon MouseEnter="OnMouseEnter" MouseLeave="OnMouseLeave" Fill="#FF000000" Opacity="0.5" Visibility="Visible" StrokeThickness="" Stroke="#FF222935"
Points="219,122 221,124 221,128 221,132 221,135 221,138 221,141 221,145 221,148 221,151 221,154
, , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , , , , , , , ,
, , , , , ," />-->
<!-- ,, -->
</Canvas>
</UserControl>
using System.Windows;
using System.Windows.Controls;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes; namespace SilverlightTest
{
public partial class PolygonTest : UserControl
{
Stroke NewStroke; public PolygonTest()
{
InitializeComponent();
SetBoundary();
} private void OnMouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
{
Polygon pl = sender as Polygon;
if (pl == null) return;
SetProperty(pl, , );
} private void OnMouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
{
Polygon pl = sender as Polygon;
if (pl == null) return;
SetProperty(pl, 0.5, );
} private void SetProperty(Polygon pl, double opacity, double thickness)
{
pl.Opacity = opacity;
pl.StrokeThickness = thickness;
} private void SetBoundary()
{
RectangleGeometry MyRectangleGeometry = new RectangleGeometry();
MyRectangleGeometry.Rect = new Rect(, , MyIP.ActualWidth, MyIP.ActualHeight);
MyIP.Clip = MyRectangleGeometry;
} private void MyIP_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
MyIP.CaptureMouse();
StylusPointCollection MyStylusPointCollection = new StylusPointCollection();
MyStylusPointCollection.Add(e.StylusDevice.GetStylusPoints(MyIP));
NewStroke = new Stroke(MyStylusPointCollection);
MyIP.Strokes.Add(NewStroke);
} private void MyIP_LostMouseCapture(object sender, System.Windows.Input.MouseEventArgs e)
{
string str = string.Empty;
int index = ;
foreach (var item in NewStroke.StylusPoints)
{
if (index % == )
str += item.X.ToString() + "," + item.Y.ToString() + " ";
index++;
}
str = str.Trim();
MessageBox.Show(str);
NewStroke = null;
} private void MyIP_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
if (NewStroke != null)
NewStroke.StylusPoints.Add(e.StylusDevice.GetStylusPoints(MyIP));
}
}
}

silverlight 画图InkPresenter的更多相关文章

  1. silverlight visifire控件图表制作——silverlight 后台方法画图

    1.调用wcf 获取信息 private void svc_GetSingleChartDataCompleted(object sender, GetSingleChartDataCompleted ...

  2. [Cocos2d-x For WP8]DrawPrimitives画图

    在Silverlight框架的WP8应用程序里面,我们画几何图形的时候会通过Line等等的类在用C#代码或者在XAML上画图,那么在Cocos2d-x For WP8里面我们一样也可以实现这样的功能. ...

  3. Silverlight形状、画笔、变换、图像处理、几何图形

    1.形状(Ellipse.Line.Path.Polygon.Polyline 和 Rectangle) <UserControl x:Class="SharpStudy.MainPa ...

  4. silverlight visifire控件图表制作——silverlight 后台方法ControlChart.xaml.cs

    一.构造方法ControlChart 1.前台页面控件赋值 //时间下拉框赋值,下拉框赋选定值                for (int ii = DateTime.Today.Year; ii ...

  5. Silverlight 之 浅析

    一.silverlight定义及作用 silverlight用XAML来做前端界面,用.NET或者JS作为程序脚本支持,在浏览器内外运行的应用.可以认为和FLASH 和ADOBE AIR有很大的功能重 ...

  6. 一步一步学Silverlight 2系列(26):基本图形

    概述 Silverlight 2 Beta 1版本发布了,无论从Runtime还是Tools都给我们带来了很多的惊喜,如支持框架语言Visual Basic, Visual C#, IronRuby, ...

  7. [置顶] Silverlight之控件应用总结(一)(3)

    [置顶] Silverlight之控件应用总结(一)(3) 分类: 技术2012-04-02 20:35 2442人阅读 评论(1) 收藏 举报 silverlightradiobuttondatat ...

  8. Ubuntu 16.10 安装KolourPaint 4画图工具

    KolourPaint 4画图工具简单实用,可以绘画.视频处理和图标编辑: • 绘画:绘制图表和“手绘” • 视频处理:编辑截图和照片;应用特效 • 图标编辑:绘画剪贴和标识透明化 1.在Ubuntu ...

  9. Android开发之画图的实现

    Android开发之画图的实现    四天前上完安卓的第一节课,真的是一脸懵逼,尽管熊哥说和java是差不多的,然而这个包和那个包之间的那些转换都是些什么鬼呀!!!但是四天的学习和操作下来,我觉得安卓 ...

随机推荐

  1. CSS 之 控制图片与文字对齐

    文字旁边搭配图片时,发现图片比文字靠上,原来默认的情况是图片顶对齐而文字底对齐,通过设置css属性可以使得图片与文字对齐. 设置各对象的vertical-align属性,属性说明: baseline- ...

  2. jQuery的如何捕捉回车键,改变事件标签

    我希望有一个jQuery的解决方案,我必须接近,有什么需要做的? $('html').bind('keypress', function(e) { if(e.keyCode == 13) { retu ...

  3. solrj:org.apache.solr.common.util.NamedList.java

    package org.apache.solr.common.util; import java.io.Serializable; import java.util.ArrayList; import ...

  4. UVa OJ 10300

    Problem A Ecological Premium Input: standard input Output: standard output Time Limit: 1 second Memo ...

  5. WebStorm配置(2016/11/18更新)

    目录: 1.主题设置 2.模板设置 3.代码段设置 4.快捷键设置 5.显示行号+自动换行 6.配置github 7.常用快捷键 8.软件下载(破解版及汉化包) 1.主题设置 1)ctrl+alt+s ...

  6. DataContractJsonSerializer和JavaScriptSerializer内部实现差异

    定义一个下面这样的类,此类有Serializable属性,并且有一个属性的定义没有使用自动属性来实现. [Serializable] public class Users { public int U ...

  7. 《Cortex-M0权威指南》之体系结构---栈空间操作

    转载请注明来源:cuixiaolei的技术博客 栈空间作为一种存储器使用机制,是"先入先出"的结构,在系统空间中用作临时数据的存储.栈空间操作的关键之一为栈指针寄存器,每次执行栈操 ...

  8. C++: byte 和 int 的相互转化

    原文链接:http://blog.csdn.net/puttytree/article/details/7825709 NumberUtil.h // // NumberUtil.h // MinaC ...

  9. javaweb学习总结二十六(response对象的用法二 下载文件)

    一:浏览器打开服务器上的文件 1:读取服务器上面的资源,如果在web层,可以直接使用servletContext,如果在非web层 可以使用类加载器读取文件 2:向浏览器写数据,实际上是把数据封装到r ...

  10. 剑指Offer05 用栈模拟队列

    添加了模板类应用 /************************************************************************* > File Name: ...