Windows Phone的简单外观半规 [英] Simple looking semi gauge for Windows Phone

查看:61
本文介绍了Windows Phone的简单外观半规的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的开发人员,

我一直在CodeProject.com上查找半规控件.
但是,我注意到的是,到目前为止,实际上每个仪表盘控制都比我要求的要先进.

因此,我想知道创建一个简单的量规控件是否花费大量时间,如下所示:
http://imageshack.us/photo/my-images/252/gauge.png/ [ ^ ]

我希望你们中已经有一个这样显示的控件.
请注意,该对象将在Windows Phone中使用.

顺祝商祺,
拉斯


----------------
此控件已用于现代战争精英"(CoD统计信息)之类的东西.

最大值基于所玩游戏的100%.
蓝色条(显示百分比)是获胜回合的数量.

没有其他必要的特殊行为,但是会很好,因为人们每天只能刷新两次API.

---

对象的另一种行为可能是它的计算像totalrounds/wonrounds一样,将显示1.6或类似值,其中50%=偶数.

Dear developers,

I''ve been looking on CodeProject.com for semi-gauge controls.
However, what i noticed is that so far actually every gauge control is more advanced then i require.

Therefore, I''m wondering if it takes a lot of time to create a simple gauge control shown as the following:
http://imageshack.us/photo/my-images/252/gauge.png/[^]

I hope one of you already have a control which is being displayed like this.
Please note that this object will be used within Windows Phone.

Yours Sincerely,
Lars


----------------
This control is being used for something like Modern Warfare Elite (CoD stats).

The max value is based on the games played which is 100%.
The blue bar (displaying the percentage) is the amount of won rounds.

There are no other special behaviours neccesary but would be nice, since people can only refresh their API twice a day.

---

another behaviour of the object could be that it''s calculate like totalrounds / wonrounds which would display 1.6 or something, where one is 50% = even.

推荐答案

似乎应该完全是微不足道的,它只有两条路径,每条路径包括两条直线和两条弧线.我实际上没有在WPF中完成此操作,因为我主要在WinForms中工作,但是假设您可以绘制自定义控件,那无非是(伪代码的半编码方式)

This seems like it should be utterly trivial, it''s just two paths each of which includes two lines and two arcs. I haven''t actually done it in WPF, since I mostly work in WinForms, but assuming you can paint a custom control it is nothing more than (half way to pseudocode)

protected override void OnPaint(Graphics g){
 float cx = Width / 2, r = cx * 0.95f, cy = Height - 10, rinner = r * 0.6f;
 GraphicsPath unfilledGuage = new GraphicsPath();
 unfilledGuage.AddArc(cx - r, cy - r, r * 2, r * 2, -180, 180);
 unfilledGuage.AddArc(cx - rinner, cy - rinner, rinner * 2, rinner * 2, 0, -180);
 unfilledGuage.CloseFigure();
 g.FillPath(unfilledBrush, unfilledGuage);

 float angle = 180 * (Value / Max);

 GraphicsPath filledGuage = new GraphicsPath();
 filledGuage.AddArc(cx - r, cy - r, r * 2, r * 2, -180, angle);
 filledGuage.AddArc(cx - rinner, cy - rinner, rinner * 2, rinner * 2, -(180 - angle), -angle);
 filledGuage.CloseFigure();
 g.FillPath(filledBrush, filledGuage);
}


这篇关于Windows Phone的简单外观半规的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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