在绘图画布东西 [英] Drawing things on a Canvas

查看:119
本文介绍了在绘图画布东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么会借鉴C#中的画布Windows Phone的东西吗?

好吧,让我更加清楚一点。

假设用户点击他的手指下来386,43在画布上。 (画布是768×480)

我想我的应用程序能够通过在画布上放置一个红点在386,43回应。

我的没有与之前任何帆布经验。

如果这是太复杂的一个问题(它可能是)要回答,的给我链接到其他用帆布和绘制网站文章。

How would I draw something on a Canvas in C# for Windows Phone?

Okay, let me be a little more clear.

Say the user taps his finger down at 386,43 on the canvas. (the canvas is 768 by 480)

I would like my application to be able to respond by placing a red dot at 386,43 on the canvas.

I have no prior experience with Canvas whatsoever.

If this is too complex to be answered in one question (which it probably is), please give me links to other websites with Canvas and Drawing articles.

推荐答案

有这样做的各种方式。根据红点的性质,你可以把一个用户控件。对于一个基本的圈子,你可以简单地处理你的画布在ManipulationStarted 事件。

There are various ways of doing this. Depending on the nature of the red dot, you could make it a UserControl. For a basic circle, you can simply handle your canvas' ManipulationStarted event.

private void myCanvas_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
{

            Ellipse el = new Ellipse();
            el.Width = 10;
            el.Height = 10;
            el.Fill = new SolidColorBrush(Colors.Red);
            Canvas.SetLeft(el, e.ManipulationOrigin.X);
            Canvas.SetTop(el, e.ManipulationOrigin.Y);
            myCanvas.Children.Add(el);
}

这篇关于在绘图画布东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆