質問編集履歴

2

ソースコード編集

2015/12/09 02:18

投稿

TAKAYASU
TAKAYASU

スコア146

test CHANGED
File without changes
test CHANGED
@@ -24,45 +24,43 @@
24
24
 
25
25
  {
26
26
 
27
+
28
+
27
29
  InitializeComponent();
30
+
31
+
28
32
 
29
33
  }
30
34
 
31
- private void GuiThread(Action action)
35
+
32
36
 
33
- {
34
-
35
- Dispatcher.BeginInvoke(action);
37
+ private void GuiThread(Action action){
36
38
 
37
39
 
38
40
 
39
-
40
-
41
- if(action.Equals(AddressFamily.InterNetwork))
41
+ Dispatcher.BeginInvoke(action);
42
-
43
- {
44
-
45
-
46
-
47
- }
48
42
 
49
43
  }
50
44
 
51
45
 
52
46
 
53
- void GetUsbCameras()
47
+ void GetUsbCameras(){
54
48
 
55
- {
49
+
56
50
 
57
51
  var usbList = WebCamera.GetDevices();
58
52
 
59
- foreach(var device in usbList)
60
53
 
61
- {
62
54
 
55
+ foreach(var device in usbList){
56
+
57
+
58
+
63
- GuiThread(() => DiscoveredDeviceList.Items.Add("[USB]Name:" + device.Name));
59
+ GuiThread(() => DiscoveredDeviceList.Items.Add("[USB]Name:" + device.Name));
64
60
 
65
61
  }
62
+
63
+
66
64
 
67
65
  }
68
66
 
@@ -72,7 +70,11 @@
72
70
 
73
71
  {
74
72
 
73
+
74
+
75
75
  IPCameraFactory.DeviceDiscovered += IPCameraFactory_DeviceDisCoverd;
76
+
77
+
76
78
 
77
79
  IPCameraFactory.DiscoverDevices();
78
80
 
@@ -84,15 +86,23 @@
84
86
 
85
87
  DiscoveryEventArgs Devices;
86
88
 
89
+
90
+
87
91
  void IPCameraFactory_DeviceDisCoverd(object sender,DiscoveryEventArgs e)
88
92
 
89
93
  {
94
+
95
+
90
96
 
91
97
  GuiThread(() => DiscoveredDeviceList.Items.Add("[IPCamera]Host:" + e.Device.Uri +
92
98
 
93
99
  "Port:" + e.Device.Port));
94
100
 
101
+
102
+
95
103
  Devices = e;
104
+
105
+
96
106
 
97
107
  }
98
108
 
@@ -102,7 +112,11 @@
102
112
 
103
113
  {
104
114
 
115
+
116
+
105
117
  DiscoveredDeviceList.Items.Clear();
118
+
119
+
106
120
 
107
121
  IPCameraFactory.DeviceDiscovered -= IPCameraFactory_DeviceDisCoverd;
108
122
 
@@ -110,7 +124,11 @@
110
124
 
111
125
  GetUsbCameras();
112
126
 
127
+
128
+
113
129
  GetIpCameras();
130
+
131
+
114
132
 
115
133
  }
116
134
 

1

ソースコード追記

2015/12/09 02:18

投稿

TAKAYASU
TAKAYASU

スコア146

test CHANGED
File without changes
test CHANGED
@@ -11,3 +11,109 @@
11
11
 
12
12
 
13
13
  m(_ _)m
14
+
15
+
16
+
17
+ 追記:
18
+
19
+ ソースコード一部を載せます
20
+
21
+
22
+
23
+ public MainWindow()
24
+
25
+ {
26
+
27
+ InitializeComponent();
28
+
29
+ }
30
+
31
+ private void GuiThread(Action action)
32
+
33
+ {
34
+
35
+ Dispatcher.BeginInvoke(action);
36
+
37
+
38
+
39
+
40
+
41
+ if(action.Equals(AddressFamily.InterNetwork))
42
+
43
+ {
44
+
45
+
46
+
47
+ }
48
+
49
+ }
50
+
51
+
52
+
53
+ void GetUsbCameras()
54
+
55
+ {
56
+
57
+ var usbList = WebCamera.GetDevices();
58
+
59
+ foreach(var device in usbList)
60
+
61
+ {
62
+
63
+ GuiThread(() => DiscoveredDeviceList.Items.Add("[USB]Name:" + device.Name));
64
+
65
+ }
66
+
67
+ }
68
+
69
+
70
+
71
+ void GetIpCameras()
72
+
73
+ {
74
+
75
+ IPCameraFactory.DeviceDiscovered += IPCameraFactory_DeviceDisCoverd;
76
+
77
+ IPCameraFactory.DiscoverDevices();
78
+
79
+
80
+
81
+ }
82
+
83
+
84
+
85
+ DiscoveryEventArgs Devices;
86
+
87
+ void IPCameraFactory_DeviceDisCoverd(object sender,DiscoveryEventArgs e)
88
+
89
+ {
90
+
91
+ GuiThread(() => DiscoveredDeviceList.Items.Add("[IPCamera]Host:" + e.Device.Uri +
92
+
93
+ "Port:" + e.Device.Port));
94
+
95
+ Devices = e;
96
+
97
+ }
98
+
99
+
100
+
101
+ private void DiscoverButton(object sender,RoutedEventArgs e)
102
+
103
+ {
104
+
105
+ DiscoveredDeviceList.Items.Clear();
106
+
107
+ IPCameraFactory.DeviceDiscovered -= IPCameraFactory_DeviceDisCoverd;
108
+
109
+
110
+
111
+ GetUsbCameras();
112
+
113
+ GetIpCameras();
114
+
115
+ }
116
+
117
+
118
+
119
+ xamlでDiscoverButtonという名前のボタンを作ってます。