资源简介
飞行器在空中的姿态,不同于它在地理坐标系中的坐标值。本代码形象的演示了什么是姿态角,其中的代码和图片资源也有一定的复用价值。对于想要根据3D模型上各个顶点坐标来计算姿态角的朋友,也有一定参考价值。
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
namespace HUD
{
public class BorderTextLabel : System.Windows.Controls.Label
{
private static void Redraw(Dependencyobject d DependencyPropertyChangedEventArgs e)
{
((BorderTextLabel)d).InvalidateVisual();
}
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty value); }
}
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(“Text“ typeof(string) typeof(BorderTextLabel) new frameworkPropertymetadata(string.EmptyRedraw));
public Brush Stroke
{
get { return (Brush)GetValue(StrokeProperty); }
set { SetValue(StrokeProperty value); }
}
public static readonly DependencyProperty StrokeProperty = DependencyProperty.Register(“Stroke“ typeof(Brush) typeof(BorderTextLabel) new frameworkPropertymetadata(Brushes.Black Redraw));
public double StrokeThickness
{
get { return (double)GetValue(StrokeThicknessProperty); }
set { SetValue(StrokeThicknessProperty value); }
}
public static readonly DependencyProperty StrokeThicknessProperty = DependencyProperty.Register(“StrokeThickness“ typeof(double) typeof(BorderTextLabel) new frameworkPropertymetadata((double)1 Redraw));
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
FormattedText formattedText = new FormattedText(this.Text CultureInfo.CurrentCulture FlowDirection new Typeface(FontFamily Fontstyle FontWeight FontStretch) FontSize this.Foreground);
if (double.IsNaN(this.Width))
this.Width = formattedText.Width;
if (double.IsNaN(this.Height))
this.Height = formattedText.Height;
Point startp = new Point(0 0);
if (this.HorizontalContentAlignment == HorizontalAlignment.Right) startp.X = this.Width - formattedText.Width;
if (this.HorizontalContentAlignment == HorizontalAlignment.Center) startp.X = (this.Width - formattedText.Width) / 2;
if (this.VerticalContentAlignment == VerticalAlignment.Bottom) startp.X = this.Height - formattedText.Height;
if (this.VerticalContentAlignment == VerticalAlignment.Center) startp.X = (this.Height - formattedText.Height) / 2;
var textgeometry = formattedText.BuildGeometry(startp);
drawingContext.DrawGeometry(this.Foreground new Pen(Stroke StrokeThickness) textgeometry);
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-08-01 07:31 HUD-master\
目录 0 2017-08-01 07:31 HUD-master\HUD\
文件 2885 2017-08-01 07:31 HUD-master\HUD\BorderTextLabel.cs
文件 4050 2017-08-01 07:31 HUD-master\HUD\HUD.csproj
文件 1458 2017-08-01 07:31 HUD-master\HUD\HUD.sln
文件 4458 2017-08-01 07:31 HUD-master\HUD\HUDControl.xaml
文件 31006 2017-08-01 07:31 HUD-master\HUD\HUDControl.xaml.cs
目录 0 2017-08-01 07:31 HUD-master\HUD\Properties\
文件 2226 2017-08-01 07:31 HUD-master\HUD\Properties\AssemblyInfo.cs
文件 2778 2017-08-01 07:31 HUD-master\HUD\Properties\Resources.Designer.cs
文件 5612 2017-08-01 07:31 HUD-master\HUD\Properties\Resources.resx
文件 1114 2017-08-01 07:31 HUD-master\HUD\Properties\Settings.Designer.cs
文件 201 2017-08-01 07:31 HUD-master\HUD\Properties\Settings.settings
目录 0 2017-08-01 07:31 HUD-master\HUDSample\
文件 187 2017-08-01 07:31 HUD-master\HUDSample\App.config
文件 372 2017-08-01 07:31 HUD-master\HUDSample\App.xaml
文件 336 2017-08-01 07:31 HUD-master\HUDSample\App.xaml.cs
文件 4658 2017-08-01 07:31 HUD-master\HUDSample\HUDSample.csproj
文件 2286 2017-08-01 07:31 HUD-master\HUDSample\MainWindow.xaml
文件 575 2017-08-01 07:31 HUD-master\HUDSample\MainWindow.xaml.cs
目录 0 2017-08-01 07:31 HUD-master\HUDSample\Properties\
文件 2271 2017-08-01 07:31 HUD-master\HUDSample\Properties\AssemblyInfo.cs
文件 2831 2017-08-01 07:31 HUD-master\HUDSample\Properties\Resources.Designer.cs
文件 5612 2017-08-01 07:31 HUD-master\HUDSample\Properties\Resources.resx
文件 1096 2017-08-01 07:31 HUD-master\HUDSample\Properties\Settings.Designer.cs
文件 201 2017-08-01 07:31 HUD-master\HUDSample\Properties\Settings.settings
文件 1082 2017-08-01 07:31 HUD-master\LICENSE
文件 169 2017-08-01 07:31 HUD-master\README.md
文件 270962 2017-08-01 07:31 HUD-master\hud.png
- 上一篇:Task使用
- 下一篇:C# Cad2006二次开发之图形扩展属性读写(附源码)
相关资源
- 环形小车 接放货 模拟演示
- C# SHAP7与西门子PLC通讯及模拟
- 自动发送弹幕(定时模拟操作键盘)
- C#十字路口红绿灯模拟
- C#按键模拟 鼠标模拟 c#按键精灵
- c# 回合制 类似梦幻西游 网络游戏 模
- 电梯模拟系统
- C# post模拟提交接收图片存到服务器上
- 本学期UML作业—C#(.net)自动贩卖机
- 模拟ATM取款机源码(C#版)完整版
- 模拟话费充值消费系统
- 银行模拟系统(ASP.NET+SQL+2000)
- C#读取ABPLC驱动程序和ABPLC模拟器
- ADB操作控制手机C#代码
- GPS仿真软件 gps模拟器 NMEA0183仿真软件
- 银行模拟系统
- c#版的模拟文件系统
- WPF 数据可视化 大屏展示 实现地图仿
- SPHYSICS流体力学仿真模拟程序的动态链
- 快手安卓脚本雷电模拟器3.28 c#雷电多
- 三维水淹模拟系统C#实现
- Unity3D《farm business》农场模拟经营游戏
- C#模拟驾照考试,功能很简单,可做学
- 多态描述飞行器.zip
- 磁盘调度模拟---C#窗口化
- 数学模拟钉板实验c#源码
- C# winform ATM-自动取款机模拟软件设计
- 用遗传算法/模拟退火算法 求解旅行商
- 测量程序设计,坐标正反算,方位角
- C#写的放大镜程序模拟真实放大镜的效
评论
共有 条评论