【发布时间】:2014-05-04 19:15:15
【问题描述】:
美好的一天。我用 DShow.Net/DirectX.Capture 控制我的 USB 网络摄像头。它找到并初始化所有连接的设备,但它显示设备名称以拥有带有数字 (1.2.3 ...) 的按钮。我想显示设备的全名。我的代码示例:
if (filters.VideoInputDevices != null)
{
for (var i = 0; i < filters.VideoInputDevices.Count; i++)
{
var device = filters.VideoInputDevices[i];
var btn = new Button();
btn.Text = i.ToString();
btn.ForeColor = Color.White;
btn.BackColor = Color.DarkSlateBlue;
btn.Width = 50;
btn.Click += (obj, evt) =>
{
var thisButton = (Button)obj;
if (int.Parse(thisButton.Text) != deviceName)
{
if (capture != null)
{
capture.Dispose();
capture.Stop();
capture.PreviewWindow = null;
}
deviceName = int.Parse(thisButton.Text);
preview(deviceName);
}
};
flowLayoutPanel1.Controls.Add(btn);
}
}
【问题讨论】:
-
我不熟悉你所说的库。如果您能指出我的文档,我可能会为您提供更多帮助。但是你的问题在于
btn.Text = i.ToString();。你需要把它写成btn.Text = device.Name;之类的东西。同样,文档将帮助您确定需要使用什么。
标签: c# directx webcam directshow