• 大小: 0.28M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2024-04-29
  • 语言: C#
  • 标签: 方位角  飞行器  模拟  

资源简介

飞行器在空中的姿态,不同于它在地理坐标系中的坐标值。本代码形象的演示了什么是姿态角,其中的代码和图片资源也有一定的复用价值。对于想要根据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

评论

共有 条评论