2012-07-25 10:44:24 -03:00
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
public partial class QuickView : UserControl
|
|
|
|
|
{
|
|
|
|
|
[System.ComponentModel.Browsable(true)]
|
2012-08-30 09:51:29 -03:00
|
|
|
|
public string desc { get { return labelWithPseudoOpacity1.Text; } set { if (labelWithPseudoOpacity1.Text == value) return; labelWithPseudoOpacity1.Text = value; } }
|
2012-07-25 10:44:24 -03:00
|
|
|
|
[System.ComponentModel.Browsable(true)]
|
2012-09-19 20:37:36 -03:00
|
|
|
|
public double number { get { return double.Parse(labelWithPseudoOpacity2.Text); }
|
|
|
|
|
set {
|
|
|
|
|
string ans = (value).ToString("0.00");
|
|
|
|
|
if (labelWithPseudoOpacity2.Text == ans)
|
|
|
|
|
return;
|
|
|
|
|
labelWithPseudoOpacity2.Text = ans;
|
|
|
|
|
GetFontSize();
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-25 10:44:24 -03:00
|
|
|
|
[System.ComponentModel.Browsable(true)]
|
2012-08-30 09:51:29 -03:00
|
|
|
|
public Color numberColor { get { return labelWithPseudoOpacity2.ForeColor; } set { if (labelWithPseudoOpacity2.ForeColor == value) return; labelWithPseudoOpacity2.ForeColor = value; } }
|
2012-07-25 10:44:24 -03:00
|
|
|
|
|
|
|
|
|
public QuickView()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
labelWithPseudoOpacity1.DoubleClick += new EventHandler(labelWithPseudoOpacity1_DoubleClick);
|
|
|
|
|
labelWithPseudoOpacity2.DoubleClick += new EventHandler(labelWithPseudoOpacity2_DoubleClick);
|
2012-09-19 20:37:36 -03:00
|
|
|
|
|
|
|
|
|
labelWithPseudoOpacity2.DoubleBuffered = true;
|
2012-07-25 10:44:24 -03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void labelWithPseudoOpacity2_DoubleClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.OnDoubleClick(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void labelWithPseudoOpacity1_DoubleClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.OnDoubleClick(e);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-06 11:22:57 -03:00
|
|
|
|
public override void Refresh()
|
|
|
|
|
{
|
|
|
|
|
if (this.Visible)
|
|
|
|
|
base.Refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnInvalidated(InvalidateEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.Visible)
|
|
|
|
|
base.OnInvalidated(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.Visible)
|
|
|
|
|
base.OnPaint(e);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-19 20:37:36 -03:00
|
|
|
|
void GetFontSize()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Size extent = TextRenderer.MeasureText(labelWithPseudoOpacity2.Text, this.Font);
|
|
|
|
|
|
2012-10-30 20:02:29 -03:00
|
|
|
|
float hRatio = (labelWithPseudoOpacity2.Height) / (float)(extent.Height);
|
2012-09-19 20:37:36 -03:00
|
|
|
|
float wRatio = this.Width / (float)extent.Width;
|
|
|
|
|
float ratio = (hRatio < wRatio) ? hRatio : wRatio;
|
|
|
|
|
|
|
|
|
|
float newSize = this.Font.Size * ratio;
|
|
|
|
|
|
|
|
|
|
if (newSize < 8)
|
|
|
|
|
newSize = 8;
|
|
|
|
|
|
|
|
|
|
//return newSize;
|
|
|
|
|
|
|
|
|
|
labelWithPseudoOpacity2.Font = new Font(labelWithPseudoOpacity2.Font.FontFamily, newSize - 2, labelWithPseudoOpacity2.Font.Style);
|
|
|
|
|
|
|
|
|
|
extent = TextRenderer.MeasureText(labelWithPseudoOpacity2.Text, labelWithPseudoOpacity2.Font);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-30 09:51:29 -03:00
|
|
|
|
protected override void OnResize(EventArgs e)
|
|
|
|
|
{
|
2012-09-19 20:37:36 -03:00
|
|
|
|
this.ResizeRedraw = true;
|
|
|
|
|
|
|
|
|
|
GetFontSize();
|
2012-08-30 09:51:29 -03:00
|
|
|
|
|
|
|
|
|
base.OnResize(e);
|
|
|
|
|
}
|
2012-07-25 10:44:24 -03:00
|
|
|
|
}
|
|
|
|
|
}
|