mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-05 07:28:29 -04:00
8bebf0c394
Convert to IActivate, IDeactivate scheme, thanks andrew add support for rfcomm* interfaces on linux fix guage off screen draw mono issue. remove use of BackStageViewContentPanel andrews spacer changes - not using dues to screen space issue change configpanel constructor to load xml directly remove IMavlink Interface fix hsi off screen draw issue on mono modify hud to use sprite fonts, instead of drawing via GDI+ modify progress reporter to use a 10hz timer to update screen, using invoke/begininvoke fails on mono at 50hz (over 100ms per call). fix targetalt and target airspeed jumping issue. lots of cleanup on tab switching, ie stoping timers/other 3dr radio status led update update ardurover car icon speedup georef image screen. tested on over 1000 images.
123 lines
3.1 KiB
C#
123 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace ArdupilotMega.Controls
|
|
{
|
|
/// <summary>
|
|
/// profiling showed that the built in Label function was using alot of call time.
|
|
/// </summary>
|
|
public partial class MyLabel : Control //: Label
|
|
{
|
|
string label = "";
|
|
int noofchars = 0;
|
|
bool autosize = false;
|
|
|
|
[System.ComponentModel.Browsable(true)]
|
|
public bool resize { get { return autosize; } set { autosize = value; } }
|
|
|
|
public MyLabel()
|
|
{
|
|
}
|
|
|
|
public override string Text
|
|
{
|
|
get
|
|
{
|
|
return label;
|
|
}
|
|
set
|
|
{
|
|
|
|
if (value == null)
|
|
return;
|
|
|
|
if (label == value)
|
|
return;
|
|
|
|
label = value;
|
|
|
|
if (noofchars != label.Length && resize)
|
|
{
|
|
noofchars = label.Length;
|
|
Size textSize = TextRenderer.MeasureText(value, this.Font);
|
|
this.Width = textSize.Width;
|
|
}
|
|
|
|
if (this.Visible && ThisReallyVisible())
|
|
this.Invalidate();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// this is to fix a mono off screen drawing issue
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool ThisReallyVisible()
|
|
{
|
|
if (Parent != null)
|
|
return this.Bounds.IntersectsWith(Parent.ClientRectangle);
|
|
|
|
return true;
|
|
}
|
|
|
|
public override void Refresh()
|
|
{
|
|
base.Refresh();
|
|
}
|
|
|
|
protected override void OnParentBindingContextChanged(EventArgs e)
|
|
{
|
|
base.OnParentBindingContextChanged(e);
|
|
}
|
|
|
|
protected override void OnVisibleChanged(EventArgs e)
|
|
{
|
|
base.OnVisibleChanged(e);
|
|
}
|
|
|
|
|
|
SolidBrush s = new SolidBrush(Color.White);
|
|
SolidBrush b = new SolidBrush(Color.Black);
|
|
|
|
StringFormat stringFormat = new StringFormat();
|
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
{
|
|
|
|
// TextRenderer.DrawText(e.Graphics, label, this.Font, new Point(0, 0), ForeColor);
|
|
|
|
stringFormat.Alignment = StringAlignment.Near;
|
|
stringFormat.LineAlignment = StringAlignment.Center;
|
|
|
|
s = new SolidBrush(ForeColor);
|
|
|
|
e.Graphics.DrawString(label, this.Font, s, new PointF(0, this.Height / 2.0f), stringFormat);
|
|
|
|
}
|
|
|
|
protected override void OnPaintBackground(PaintEventArgs pevent)
|
|
{
|
|
b = new SolidBrush(BackColor);
|
|
|
|
pevent.Graphics.FillRectangle(b, this.ClientRectangle);
|
|
|
|
base.OnPaintBackground(pevent);
|
|
}
|
|
|
|
protected override void WndProc(ref Message m) // seems to crash here on linux... so try ignore it
|
|
{
|
|
try
|
|
{
|
|
base.WndProc(ref m);
|
|
}
|
|
catch { }
|
|
}
|
|
}
|
|
}
|