さんぽ

さんぽ

Mar 20, 2007
XML
カテゴリ: 副業
カメラの画像を表示できるようになったので、次はカメラの選択ができるようにしました。


カメラ選択

このカメラの選択には,いろいろてこずりました。号泣
1.カメラの一覧を表示する。
2.選択したカメラを設定する。

1は簡単にできると思っていたのですが、ボタンの配列をどのように宣言したらよいのかまったくわかりませんでした。いろいろwebで調べて以下のような形になりました。

private void Form1_Load(object sender, EventArgs e)
{
//get device list

DsDevice device = null;



dropDown = new ToolStripDropDown();

// Set the drop-down on the ToolStripDropDownButton.
DeviceList.DropDown = dropDown;

// Set the drop-down direction.
DeviceList.DropDownDirection = ToolStripDropDownDirection.Left;

// Do not show a drop-down arrow.
DeviceList.ShowDropDownArrow = false;

// Declare three buttons, set their foreground color and text,
// and add the buttons to the drop-down.
if (!DsDev.GetDevicesOfCat(FilterCategory.VideoInputDevice, out captureDevices))


MessageBox.Show("ビデオキャプチャ可能なデバイスが見つかりません.");
return;
}
DsDevice devtemp = null;

deviceL = new ToolStripButton[captureDevices.Count];

{
devtemp = captureDevices[i] as DsDevice;
deviceL[i] = new ToolStripButton();
deviceL[i].ForeColor = Color.Black;
deviceL[i].Text = System.Convert.ToSingle(i) +"." + devtemp.Name;

deviceL[i].Click += new EventHandler(setDeviceLabel);
devtemp = null;
}

dropDown.Items.AddRange(deviceL);

toolStrip1.Items.Add(DeviceList);

}


2は選択したカメラの数字(int)どのように渡したらよいのかわかりませんでした。そこで下記のように、Labelのはじめにカメラの数字を追加しましたが、そのあと文字列からどのようにして、数字を取り出せばよいのかで苦労しました。なぜか直接Label.Textを直接int型に変更することができません。

if (this.DeviceLabel.Text== "カメラを選択してください。")
{

MessageBox.Show("カメラを選択してください。");
return;
}
int camnum = System.Convert.ToInt32( System.Convert.ToString(DeviceLabel.Text[0]));

device = captureDevices[camnum] as DsDevice;








お気に入りの記事を「いいね!」で応援しよう

Last updated  Mar 20, 2007 10:50:36 PM
コメント(2) | コメントを書く


【毎日開催】
15記事にいいね!で1ポイント
10秒滞在
いいね! -- / --
おめでとうございます!
ミッションを達成しました。
※「ポイントを獲得する」ボタンを押すと広告が表示されます。
x
X

PR

Profile

がっちゃん0508

がっちゃん0508

Keyword Search

▼キーワード検索

Favorite Blog

まだ登録されていません

Comments

excel 2010 新機能 マクロは便利です!@ excel 2010 新機能 vbaは便利です! vbaをマスターする簡単な方法は、マクロを…
どぴゅ@ みんなホントにオナ鑑だけなの? 相互オナって約束だったけど、いざとなる…
お猿@ やっちまったなぁ! <small> <a href="http://feti.findeath…
チリチリ@ 次は庭で全裸予定w <small> <a href="http://kuri.backblac…
通な俺@ 愛 液ごちそうたまでしたw <small> <a href="http://hiru.kamerock…

Freepage List


© Rakuten Group, Inc.
X
Mobilize your Site
スマートフォン版を閲覧 | PC版を閲覧
Share by: