資源簡介
使用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個文件信息
- 上一篇:C#動態添加數據到折線圖
- 下一篇:winform自繪波形,鼠標滾輪滾動縮放波形尺寸
評論
共有 條評論