silverlight 画图InkPresenter
<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的更多相关文章
- silverlight visifire控件图表制作——silverlight 后台方法画图
1.调用wcf 获取信息 private void svc_GetSingleChartDataCompleted(object sender, GetSingleChartDataCompleted ...
- [Cocos2d-x For WP8]DrawPrimitives画图
在Silverlight框架的WP8应用程序里面,我们画几何图形的时候会通过Line等等的类在用C#代码或者在XAML上画图,那么在Cocos2d-x For WP8里面我们一样也可以实现这样的功能. ...
- Silverlight形状、画笔、变换、图像处理、几何图形
1.形状(Ellipse.Line.Path.Polygon.Polyline 和 Rectangle) <UserControl x:Class="SharpStudy.MainPa ...
- silverlight visifire控件图表制作——silverlight 后台方法ControlChart.xaml.cs
一.构造方法ControlChart 1.前台页面控件赋值 //时间下拉框赋值,下拉框赋选定值 for (int ii = DateTime.Today.Year; ii ...
- Silverlight 之 浅析
一.silverlight定义及作用 silverlight用XAML来做前端界面,用.NET或者JS作为程序脚本支持,在浏览器内外运行的应用.可以认为和FLASH 和ADOBE AIR有很大的功能重 ...
- 一步一步学Silverlight 2系列(26):基本图形
概述 Silverlight 2 Beta 1版本发布了,无论从Runtime还是Tools都给我们带来了很多的惊喜,如支持框架语言Visual Basic, Visual C#, IronRuby, ...
- [置顶] Silverlight之控件应用总结(一)(3)
[置顶] Silverlight之控件应用总结(一)(3) 分类: 技术2012-04-02 20:35 2442人阅读 评论(1) 收藏 举报 silverlightradiobuttondatat ...
- Ubuntu 16.10 安装KolourPaint 4画图工具
KolourPaint 4画图工具简单实用,可以绘画.视频处理和图标编辑: • 绘画:绘制图表和“手绘” • 视频处理:编辑截图和照片;应用特效 • 图标编辑:绘画剪贴和标识透明化 1.在Ubuntu ...
- Android开发之画图的实现
Android开发之画图的实现 四天前上完安卓的第一节课,真的是一脸懵逼,尽管熊哥说和java是差不多的,然而这个包和那个包之间的那些转换都是些什么鬼呀!!!但是四天的学习和操作下来,我觉得安卓 ...
随机推荐
- c++ 设计模式4 (Strategy)
3.2 Strategy (策略模式) 动机:在软件构建过程中,某些对象使用的算法可能多种多样,经常改变,如果将这些算法都编码到对象中,将会使对象变得异常复杂,而且有时候支持不使用或不常使用的算法也是 ...
- JS后退, JS返回上一页, JS返回下一页
Javascript 返回上一页: 1. history.go(-1), 返回两个页面: history.go(-2); 2. history.back(). 3. window.history.fo ...
- MySQL(26):事务的隔离级别出现问题之 幻读
1. 幻读 幻读(Phantom Read)又称为虚读,是指在一个事务内两次查询中数据条数不一致,幻读和不重复读有些类型,同样是在两次查询过程中,不同的是,幻读是由于其他事务做了插入记录的操作,导致记 ...
- 12. Android框架和工具之 StringUtils(字符串操作)
1. StringUtils介绍: StringUtils是apache commons lang库(http://commons.apache.org/proper/commons-lang/dow ...
- html 模板
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- Ios入门
storyboard 文件的认识 用来描述软件界面 默认情况下程序启动就会加载Main.storyboard 加载storyboard时,会首先创建和显示箭头所指向的控制器界面 什么是UIscroll ...
- XMLObject 简易xml格式接口数据生成和解析工具
简单的请求封装,相当于封装了Book对象,但比Book对象参数更灵活 XMLObject xml = new XMLObject("book");xml.add("aut ...
- 使用Excel批量更改或插入SQL语句
在平常中我们可以通过使用SQL批量更新或新增更新数据库数据,对于这些都是有逻辑的数据可以这样处理但是对于无逻辑的数据我们如何处理(这里的数据比较多). 我是通过Excel的方式来处理的.以下已插入为例 ...
- java 远程调试
在java 命令上加入 -Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y suspend=y 配置的端口时候要保证没有被占用
- 剑指Offer36 数字在排序数组中出现的次数
/************************************************************************* > File Name: 36_Number ...