• 大小: 475KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-02
  • 语言: C#
  • 标签: winform  飞行仪表  

资源简介

使用C#编写winform的仿真飞行仪表盘,可实现俯仰角,滚动角,航向角的可视化监测

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Dashboard
{
    public partial class Form1 : Form
    {


        public Image imgtmp;
        public Image imgori;
        public Bitmap bitmp;
        public Bitmap bm;
        public bool IsSure = false;

        double DbPitchAngle = new double(); //俯仰角度[-9090]
        double DbRowAngle = new double();   //滚转角度[-180180]
        double DbYawAngle = new double();    //航向角度[-4545]
        public Form1()
        {
            InitializeComponent();
        }
        //重绘旋转后的仪表盘图片 
        public void Overlap(Bitmap btm int x int y int w int h)
        {
            Bitmap image = new Bitmap(btm);
            Bitmap hi = new Bitmap(bm);
            Graphics g = Graphics.FromImage(hi);
            g.DrawImage(image new Rectangle(x y w h));
            bm = hi;
        }



        //-------------------磁罗盘显示函数-------------------//
        //入口参数:
        //航向角 dir_angle 范围0~360 度 
        private void Compass_Disp(double dir_angle)
        {
            string file = System.IO.Path.Combine(Environment.CurrentDirectory @“point.jpg“);
            bitmp = new Bitmap(file);
            Bitmap pointImage = new Bitmap(250 250);
            System.Drawing.Graphics gPoint = System.Drawing.Graphics.FromImage(pointImage);
            gPoint.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bilinear;
            gPoint.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            //计算偏移量
            Rectangle rectPoint = new Rectangle(0 0 250 250);
            gPoint.TranslateTransform(125 125);
            //g.RotateTransform(360 - row_angle);
            gPoint.RotateTransform((float)dir_angle);
            //恢复图像在水平和垂直方向的平移 
            gPoint.TranslateTransform(-125 -125);
            gPoint.DrawImage(bitmp rectPoint);
            //重至绘图的所有变换  
            gPoint.ResetTransform();
            gPoint.Dispose();
            //保存旋转后的图片
            bm = pointImage;
            Overlap(pointImage 0 0 250 250);
            CompointBox.Image = bm;

            // 刻度盘截圆
            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
            gp.FillMode = 0;
            gp.AddEllipse(new Rectangle(0 0 350 350));
            ComshellBox.Region = new Region(gp);
            //表盘截圆
            System.Drawing.Drawing2D.GraphicsPath gp1 = new System.Drawing.Drawing2D.GraphicsPath();
            gp1.FillMode = 0;
            gp1.AddEllipse(new Rectangle(0 0 250 250));
            CompointBox.Region = new Region(gp1);
            gp1.Dispose();
            gp.Dispose();
            gPoint.Dispose();
            bitmp.Dispose();
            //Graphics gp1 = CompointBox.CreateGraphics();
            //gp

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      36801  2018-08-25 16:49  仪表盘\Dashboard\Dashboard\11.jpg

     文件      36801  2018-08-25 16:49  仪表盘\Dashboard\Dashboard\bin\Debug\11.jpg

     文件      24939  2018-08-24 20:49  仪表盘\Dashboard\Dashboard\bin\Debug\compass.jpg

     文件      89600  2018-12-26 11:43  仪表盘\Dashboard\Dashboard\bin\Debug\Dashboard.exe

     文件      28160  2018-12-26 11:43  仪表盘\Dashboard\Dashboard\bin\Debug\Dashboard.pdb

     文件      11600  2018-12-26 11:43  仪表盘\Dashboard\Dashboard\bin\Debug\Dashboard.vshost.exe

     文件        490  2012-06-06 02:06  仪表盘\Dashboard\Dashboard\bin\Debug\Dashboard.vshost.exe.manifest

     文件      13901  2018-08-24 20:50  仪表盘\Dashboard\Dashboard\bin\Debug\point.jpg

     文件      24939  2018-08-24 20:49  仪表盘\Dashboard\Dashboard\compass.jpg

     文件       3908  2018-12-26 11:29  仪表盘\Dashboard\Dashboard\Dashboard.csproj

     文件       9711  2018-12-26 11:44  仪表盘\Dashboard\Dashboard\Form1.cs

     文件       5138  2018-12-26 11:44  仪表盘\Dashboard\Dashboard\Form1.Designer.cs

     文件       6011  2018-12-26 11:44  仪表盘\Dashboard\Dashboard\Form1.resx

     文件        526  2018-12-26 11:43  仪表盘\Dashboard\Dashboard\obj\x86\Debug\Dashboard.csproj.FileListAbsolute.txt

     文件       1061  2018-12-26 11:41  仪表盘\Dashboard\Dashboard\obj\x86\Debug\Dashboard.csproj.GenerateResource.Cache

     文件      89600  2018-12-26 11:43  仪表盘\Dashboard\Dashboard\obj\x86\Debug\Dashboard.exe

     文件        180  2018-12-26 11:41  仪表盘\Dashboard\Dashboard\obj\x86\Debug\Dashboard.Form1.resources

     文件      28160  2018-12-26 11:43  仪表盘\Dashboard\Dashboard\obj\x86\Debug\Dashboard.pdb

     文件      76481  2018-12-26 11:42  仪表盘\Dashboard\Dashboard\obj\x86\Debug\Dashboard.Properties.Resources.resources

     文件       2867  2018-12-26 11:06  仪表盘\Dashboard\Dashboard\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6460  2018-12-26 11:43  仪表盘\Dashboard\Dashboard\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       5120  2018-12-26 11:12  仪表盘\Dashboard\Dashboard\obj\x86\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件      13901  2018-08-24 20:50  仪表盘\Dashboard\Dashboard\point.jpg

     文件        490  2018-12-26 11:06  仪表盘\Dashboard\Dashboard\Program.cs

     文件      36801  2018-08-25 16:49  仪表盘\Dashboard\Dashboard\Properties\11.jpg

     文件       1350  2018-12-26 11:06  仪表盘\Dashboard\Dashboard\Properties\AssemblyInfo.cs

     文件      24939  2018-08-24 20:49  仪表盘\Dashboard\Dashboard\Properties\compass.jpg

     文件      13901  2018-08-24 20:50  仪表盘\Dashboard\Dashboard\Properties\point.jpg

     文件       3961  2018-12-26 11:12  仪表盘\Dashboard\Dashboard\Properties\Resources.Designer.cs

     文件       6645  2018-12-26 11:12  仪表盘\Dashboard\Dashboard\Properties\Resources.resx

............此处省略17个文件信息

评论

共有 条评论