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是差不多的,然而这个包和那个包之间的那些转换都是些什么鬼呀!!!但是四天的学习和操作下来,我觉得安卓 ...
随机推荐
- javascript函数中的实例对象、类对象、局部变量(局部函数)
定义 function Person(national,age) { this.age = age; //实例对象,每个示例不同 Person.national = national; //类对象,所 ...
- js和jquery的DOM事件大全
- ls与dir的区别
1.ls具有上色的效果,dir没有. 2.ls是unix/linux系列的命令,dir是dos/windows系列的命令.
- Unix系统安装MySQL-python出现UnicodeDecodeError错误解决方法
今天装MySQL-python时候出现了这个错误: error: command ---------------------------------------- Cleaning up... Com ...
- oralce之存储过程
一:--循环向表emp中插入数据 declare maxnumber ; v_count number; begin v_count :; ..maxnumber LOOP v_count :; in ...
- HDU 1598 find the most comfortable road (MST)
find the most comfortable road Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- [freemarker篇]04.简单介绍-基本数据类型
好几天没有更新博客了,最近一顿乱七八糟的忙!今天简单更新第四章,这里只能说是简单介绍,因为权威的还是需要看Freemarker的官方中文手册! 好几天没有更新博客了,最近一顿乱七八糟的忙!今天简单更新 ...
- 【转载】MQTT学习笔记——MQTT协议体验 Mosquitto安装和使用
http://blog.csdn.net/xukai871105/article/details/39252653 0 前言 MQTT是IBM开发的一个即时通讯协议.MQTT是面向M2M和物联 ...
- SignalR 简介
SignalR 简介 由帕特里克 · 弗莱彻|2013 年 2 月 27 日 英文原文地址:http://www.asp.net/signalr/overview/getting-started/in ...
- IntentFilterDemo
intent-filter示例: <activity android:name=".CustomActivity" android:label="@string/t ...