c# 在 web eye 网络摄像头控件上添加透明标签
c# Add transparent label on web eye web cam control
我一直在研究钢铁侠 HUD。我正在使用 WebEye 访问网络摄像头...现在我必须在网络摄像头控件上添加标签,但标签不透明
我已经尝试了所有控件,但无法使用透明功能..
这是我的代码
foreach (WebCameraId camera in webCameraControl1.GetVideoCaptureDevices())
{
comboBox1.Items.Add(new ComboBoxItem(camera));
}
if (comboBox1.Items.Count > 0)
{
comboBox1.SelectedItem = comboBox1.Items[0];
}
ComboBoxItem i = (ComboBoxItem)comboBox1.SelectedItem;
try
{
webCameraControl1.StartCapture(i.Id);
}
finally
{
//Do something if u want to
}
请帮忙!!
实际上,创建透明标签对视频没有帮助。如果你的 webCameraControl
不是密封的 class,你可以继承它直接在它的表面添加文本,就像我对这个图片框所做的那样:
public partial class LabledPictureBox : PictureBox
{
public LabledPictureBox()
{
InitializeComponent();
}
#region properties
// I needed to override these properties to make them Browsable....
[Browsable(true)]
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
}
}
[Browsable(true)]
public override Font Font
{
get
{
return base.Font;
}
set
{
base.Font = value;
}
}
[Browsable(true)]
public override Color ForeColor
{
get
{
return base.ForeColor;
}
set
{
base.ForeColor = value;
}
}
#endregion properties
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
// This is actually the only code line that's needed to add the text to the picture box
TextRenderer.DrawText(pe.Graphics, this.Text, this.Font, pe.ClipRectangle, this.ForeColor);
}
}
这里最重要的是 base.OnPaint
之后的那一行 - 该行实际上将文本直接绘制在已绘制控件的表面上。
我一直在研究钢铁侠 HUD。我正在使用 WebEye 访问网络摄像头...现在我必须在网络摄像头控件上添加标签,但标签不透明 我已经尝试了所有控件,但无法使用透明功能..
这是我的代码
foreach (WebCameraId camera in webCameraControl1.GetVideoCaptureDevices())
{
comboBox1.Items.Add(new ComboBoxItem(camera));
}
if (comboBox1.Items.Count > 0)
{
comboBox1.SelectedItem = comboBox1.Items[0];
}
ComboBoxItem i = (ComboBoxItem)comboBox1.SelectedItem;
try
{
webCameraControl1.StartCapture(i.Id);
}
finally
{
//Do something if u want to
}
请帮忙!!
实际上,创建透明标签对视频没有帮助。如果你的 webCameraControl
不是密封的 class,你可以继承它直接在它的表面添加文本,就像我对这个图片框所做的那样:
public partial class LabledPictureBox : PictureBox
{
public LabledPictureBox()
{
InitializeComponent();
}
#region properties
// I needed to override these properties to make them Browsable....
[Browsable(true)]
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
}
}
[Browsable(true)]
public override Font Font
{
get
{
return base.Font;
}
set
{
base.Font = value;
}
}
[Browsable(true)]
public override Color ForeColor
{
get
{
return base.ForeColor;
}
set
{
base.ForeColor = value;
}
}
#endregion properties
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
// This is actually the only code line that's needed to add the text to the picture box
TextRenderer.DrawText(pe.Graphics, this.Text, this.Font, pe.ClipRectangle, this.ForeColor);
}
}
这里最重要的是 base.OnPaint
之后的那一行 - 该行实际上将文本直接绘制在已绘制控件的表面上。