<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. LeetCode14 Longest Common Prefix

    题意: Write a function to find the longest common prefix string amongst an array of strings. (Easy) 这两 ...

  2. 让ConfigurationManager打开任意的配置文件

    VisualStudio的配置文件很好很强大,用来保存数据库连接字符串或键值对都非常方便,只需要通过ConfigurationManager的ConnectionStrings或AppSettings ...

  3. 根据当前IP获取当时所在信息

    现在很多系统,都要在登录时候,确定当前用户所在的位置.这里记录一个C#使用Http的方式获取当前IP所在的位置信息.主要使用的api是新浪的接口. public partial class sina ...

  4. 控制反转(IoC)

          大量使用工厂模式引起的问题:       Client 对象需要使用 Service1 的 execute( ) 方法完成特定功能,而 Service1 的实现 Service1Impe类 ...

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

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

  6. WPF全球化与本地化 (二)

    Visual Baml Visual Locbaml is a free and open-source software to simplify the task of WPF applicatio ...

  7. UISearchDisplayController隐藏navigationBar需注意

    不能调用self.navigationController.navigationBar.hidden = YES: 调用此代码的话,你隐藏了navigationBar搜索展示控制器就拿不到导航条:就会 ...

  8. hdu1251

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others)Total Submi ...

  9. 数据库知识(主要基于Oracle,Sql可参考)

    1.关于Union的知识 select 11 from dual union select 11 from dual 和 select 11 from dual union all select 11 ...

  10. 用c#写一个json的万能解析器

    CommonJsonModel .cs /// <summary> /// 万能JSON解析器 /// </summary> public class CommonJsonMo ...