本文整理汇总了C#中Device.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Device.Start方法的具体用法?C# Device.Start怎么用?C# Device.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Device
的用法示例。
在下文中一共展示了Device.Start方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainForm
public MainForm()
{
Text = "Freenect2.Net test";
Size = new Size(1100, 900);
var imageSize = new Size(500, 400);
var colorBox = new PictureBox();
colorBox.Size = imageSize;
colorBox.Location = new Point(0, 0);
colorBox.SizeMode = PictureBoxSizeMode.StretchImage;
Controls.Add(colorBox);
var depthBox = new PictureBox();
depthBox.Size = imageSize;
depthBox.Location = new Point(0, imageSize.Height);
depthBox.SizeMode = PictureBoxSizeMode.StretchImage;
Controls.Add(depthBox);
device = new Device(0);
device.FrameReceived += (color, depth) => {
var colorImage = Utility.ColorFrameTo32bppRgb(color, device.FrameSize);
var depthImage = Utility.DepthFrameTo8bppGrayscale(depth, device.FrameSize, device.MaxDepth);
// This is called from another thread, so we can't access control directly. Also can't use
// Invoke, because it is blocking and can cause deadlock when device is disposed.
// StartInvoke works best.
BeginInvoke(new Action(() => {
colorBox.Image = colorImage;
depthBox.Image = depthImage;
}));
};
device.Start();
FormClosed += (sender, args) => {
device.Stop();
device.Dispose();
};
}
示例2: InitializeOmnis
public bool InitializeOmnis(string LeftOmniName, string RightOmniName)
{
bool success = false;
if (HasOmnis)
{
try
{
LeftOmni = new Device(LeftOmniName);
RightOmni = new Device(RightOmniName);
LeftOmni.Start();
RightOmni.Start();
SetOmniForce(new OmniPosition());
LeftOmni.SetpointEnabled = true;
RightOmni.SetpointEnabled = true;
success = true;
}
catch (Exception ex)
{
Main.ShowError(ex.Message, ex.ToString());
}
}
return success;
}
示例3: ButtonCaptureClick
private void ButtonCaptureClick(object sender, RoutedEventArgs e)
{
if (!_isRunning)
{
DeviceItem selectedItem = comboBoxDevice.SelectionBoxItem as DeviceItem;
if (selectedItem == null)
{
_activeDevice = null;
return;
}
_isRunning = true;
_activeDevice = selectedItem.Device;
_activeDevice.PacketCaptured += ActiveDevicePacketCaptured;
_activeDevice.Open(true, 20);
_activeDevice.Start();
buttonCapture.Content = "Stop";
}
else
{
if (_activeDevice == null)
return;
if (!_activeDevice.IsOpen)
return;
try
{
_activeDevice.Stop();
_activeDevice.Close();
}
catch
{}
buttonCapture.Content = "Capture";
_isRunning = false;
}
}
示例4: ButtonScanClick
private void ButtonScanClick(object sender, RoutedEventArgs e)
{
if (_isRunning)
{
_activeDevice.Stop();
_activeDevice.Close();
Host.StopDnsResolver();
buttonScan.Content = "Scan";
_isRunning = false;
return;
}
_foundAddresses.Clear();
_hosts.Clear();
DeviceItem selectedItem = comboBoxDevice.SelectionBoxItem as DeviceItem;
if (selectedItem == null)
{
_activeDevice = null;
return;
}
if (_activeDevice != null && _activeDevice.IsOpen)
{
_activeDevice.Stop();
_activeDevice.Close();
_hosts.Clear();
}
_activeDevice = selectedItem.Device;
_activeDevice.Filter = "arp";
_activeDevice.PacketCaptured += ActiveDevicePacketCaptured;
_activeDevice.Open(true, 20);
_activeDevice.Start();
buttonScan.Content = "Stop";
Host.StartDnsResolver();
_isRunning = true;
Address deviceAddress = _activeDevice.Addresses.First(a => a.IpAddress.AddressFamily == AddressFamily.InterNetwork);
foreach (IPAddress ipAddress in deviceAddress.IpAddress.GetPossibleIpAddresses(deviceAddress.NetMask))
_activeDevice.Send(ArpPacket.CreateArpRequest(_activeDevice.MacAddress, deviceAddress.IpAddress, ipAddress));
}