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是差不多的,然而这个包和那个包之间的那些转换都是些什么鬼呀!!!但是四天的学习和操作下来,我觉得安卓 ...
随机推荐
- ServiceStack.Redis.RedisNativeClient的方法“get_Db”没有实现
Redis 4.0.0.0版本已经开始收费 Redis 4.0.5.0 已经完成收费 今日在更换Redis版本时 出现了ServiceStack.Redis.RedisNativeClient的方法“ ...
- Android进阶笔记19:onInterceptTouchEvent、onTouchEvent与onTouch
1.onTouch方法:onTouch方法是View的 OnTouchListener借口中定义的方法,处理View及其子类被touch是的事件处理.当一个View绑定了OnTouchLister后, ...
- 【Android 界面效果22】Android的Tab与TabHost
Tab与TabHost 这就是Tab,而盛放Tab的容器就是TabHost 如何实现?? 每一个Tab还对应了一个布局,这个就有点好玩了.一个Activity,对应了多个功能布局. ①新建一个Tab项 ...
- [转]Displaying standard DataTables in MVC
本文转自:http://stackoverflow.com/questions/2243898/displaying-standard-datatables-in-mvc Controller act ...
- Python中的字符串处理
Python转义字符 在需要在字符中使用特殊字符时,python用反斜杠(\)转义字符.如下表: 转义字符 描述 \(在行尾时) 续行符 \\ 反斜杠符号 \' 单引号 \" 双引号 \a ...
- Linux勉強
block 與 inode 的總量: 未使用與已使用的 inode / block 數量: block 與 inode 的大小 (block 為 1, 2, 4K,inode 為 128 by ...
- Sublime_Tip_01
//JerryWeb //20150601 //WebTool | Sublime ======= Sublime_Tip_01======= 接触了Sublime后,才真正开始爱上了coding # ...
- 阿里巴巴的分布式应用框架-dubbo负载均衡策略--- 一致哈希算法
dubbo是阿里巴巴公司开发的一个开源分布式应用框架,基于服务的发布者和订阅者,服务者启动服务向注册中心发布自己的服务:消费者(订阅者)启动服务器向注册中心订阅所需要的服务.注册中心将订阅的服务注册列 ...
- MVC中的 程序集添加-----程序包管理器控制台
Install-Package Microsoft.AspNet.WebApi.Owin -Version Install-Package Microsoft.Owin.Host.SystemWeb ...
- PHP和CS的引用传值
PHP的引用传值 function change_value($num){ $num+=2; } $age = 3; change_value(&$age); echo $age; CS的引用 ...