当前位置: 首页>>代码示例>>C#>>正文


C# Device.Start方法代码示例

本文整理汇总了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();
        };
	}
开发者ID:madadam,项目名称:freenect2.net,代码行数:40,代码来源:Main.cs

示例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;
        }
开发者ID:surgical-robots,项目名称:robot-control-app,代码行数:25,代码来源:User.cs

示例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;
            }
        }
开发者ID:borte,项目名称:Pcap-Wrapper,代码行数:44,代码来源:MainWindow.xaml.cs

示例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));
        }
开发者ID:borte,项目名称:Pcap-Wrapper,代码行数:52,代码来源:MainWindow.xaml.cs


注:本文中的Device.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。