// Get entries for Device Menue
        private void PopulateDeviceMenu()
        {
            devices.Clear();
            devices_iuid.Clear();

            RS.ImplDesc desc = new RS.ImplDesc();
            desc.group    = RS.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = RS.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;

            deviceMenu.DropDownItems.Clear();

            for (int i = 0; ; i++)
            {
                RS.ImplDesc desc1 = manager.Session.QueryImpl(desc, i);
                if (desc1 == null)
                {
                    break;
                }
                RS.Capture capture;
                if (manager.Session.CreateImpl <RS.Capture>(desc1, out capture) < RS.Status.STATUS_NO_ERROR)
                {
                    continue;
                }
                for (int j = 0; ; j++)
                {
                    RS.DeviceInfo dinfo;
                    if (capture.QueryDeviceInfo(j, out dinfo) < RS.Status.STATUS_NO_ERROR)
                    {
                        break;
                    }

                    ToolStripMenuItem sm1 = new ToolStripMenuItem(dinfo.name, null, new EventHandler(Device_Item_Click));
                    devices[sm1]      = dinfo;
                    devices_iuid[sm1] = desc1.iuid;
                    deviceMenu.DropDownItems.Add(sm1);
                }
                capture.Dispose();
            }
            if (deviceMenu.DropDownItems.Count > 0)
            {
                (deviceMenu.DropDownItems[0] as ToolStripMenuItem).Checked = true;
            }
            else
            {
                buttonStart.Enabled = false;
                radioDepth.Visible  = false;
                radioIR.Visible     = false;
                for (int s = 0; s < RS.Capture.STREAM_LIMIT; s++)
                {
                    if (streamMenue[s] != null)
                    {
                        streamMenue[s].Visible = false;
                    }
                }
            }
        }
예제 #2
0
        private void PopulateDevice()
        {
            devices.Clear();
            devices_iuid.Clear();

            RS.ImplDesc desc = new RS.ImplDesc();
            desc.group    = RS.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = RS.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
            cb_Devices.Items.Clear();

            for (int i = 0; ; i++)
            {
                RS.ImplDesc desc1 = session.QueryImpl(desc, i);
                if (desc1 == null)
                {
                    break;
                }
                RS.Capture capture;
                if (session.CreateImpl <RS.Capture>(desc1, out capture) < RS.Status.STATUS_NO_ERROR)
                {
                    continue;
                }
                for (int j = 0; ; j++)
                {
                    RS.DeviceInfo dinfo;
                    if (capture.QueryDeviceInfo(j, out dinfo) < RS.Status.STATUS_NO_ERROR)
                    {
                        break;
                    }

                    string deviceName = dinfo.name;
                    devices[deviceName]      = dinfo;
                    devices_iuid[deviceName] = desc1.iuid;
                    cb_Devices.Items.Add(deviceName);
                }
                capture.Dispose();
            }
        }
예제 #3
0
        // Get entries for color Streams
        private void PopulateColorDepthMenus(ToolStripMenuItem device_item)
        {
            RS.ImplDesc desc = new RS.ImplDesc();
            desc.group          = RS.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup       = RS.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
            desc.iuid           = devices_iuid[device_item];
            current_device_iuid = desc.iuid;
            desc.cuids[0]       = RS.Capture.CUID;

            profiles.Clear();
            foreach (ToolStripMenuItem menu in streamMenue)
            {
                if (menu != null)
                {
                    menu.DropDownItems.Clear();
                }
            }

            RS.Capture    capture;
            RS.DeviceInfo dinfo2 = GetCheckedDevice();
            if (manager.Session.CreateImpl <RS.Capture>(desc, out capture) >= RS.Status.STATUS_NO_ERROR)
            {
                RS.Device device = capture.CreateDevice(dinfo2.didx);
                if (device != null)
                {
                    RS.StreamProfileSet streamProfileSet = new RS.StreamProfileSet();

                    for (int s = 0; s < RS.Capture.STREAM_LIMIT; s++)
                    {
                        RS.StreamType streamType = RS.Capture.StreamTypeFromIndex(s);
                        if (((int)dinfo2.streams & (int)streamType) != 0 && streamMenue[s] != null)
                        {
                            streamMenue[s].Visible   = true;
                            streamButtons[s].Visible = true;
                            int num = device.QueryStreamProfileSetNum(streamType);
                            for (int p = 0; p < num; p++)
                            {
                                if (device.QueryStreamProfileSet(streamType, p, out streamProfileSet) < RS.Status.STATUS_NO_ERROR)
                                {
                                    break;
                                }
                                RS.StreamProfile  streamProfile = streamProfileSet[streamType];
                                ToolStripMenuItem sm1           = new ToolStripMenuItem(ProfileToString(streamProfile), null, new EventHandler(Stream_Item_Click));
                                profiles[sm1] = streamProfile;
                                streamMenue[s].DropDownItems.Add(sm1);
                            }
                        }
                        else if (((int)dinfo2.streams & (int)streamType) == 0 && streamMenue[s] != null)
                        {
                            streamMenue[s].Visible   = false;
                            streamButtons[s].Visible = false;
                        }
                    }

                    device.Dispose();
                }
                capture.Dispose();
            }
            for (int i = 0; i < RS.Capture.STREAM_LIMIT; i++)
            {
                ToolStripMenuItem menu = streamMenue[i];
                if (menu != null)
                {
                    streamString[i]           = new ToolStripMenuItem("None", null, new EventHandler(Stream_Item_Click));
                    profiles[streamString[i]] = new RS.StreamProfile();
                    menu.DropDownItems.Add(streamString[i]);
                    if (menu == colorMenu)
                    {
                        (menu.DropDownItems[0] as ToolStripMenuItem).Checked = true;
                    }
                    else
                    {
                        streamString[i].Checked = true;
                    }
                }
            }

            CheckSelection();
        }