示例#1
0
        private void PopulateProfiles(RS.DeviceInfo dinfo)
        {
            RS.SenseManager pp     = RS.SenseManager.CreateInstance();
            RS.Device       device = pp.CaptureManager.Device;
            if (device == null)
            {
                pp.Dispose();
            }
            RS.StreamProfileSet profile = new RS.StreamProfileSet();

            for (int s = 0; s < RS.Capture.STREAM_LIMIT; s++)
            {
                RS.StreamType st = RS.Capture.StreamTypeFromIndex(s);
                if (((int)dinfo.streams & (int)st) != 0)
                {
                    int num = device.QueryStreamProfileSetNum(st);
                    for (int p = 0; p < num; p++)
                    {
                        if (device.QueryStreamProfileSet(st, p, out profile) < RS.Status.STATUS_NO_ERROR)
                        {
                            break;
                        }
                        RS.StreamProfile sprofile = profile[st];
                        string           profNime = ProfileToString(sprofile);
                        profiles[profile] = sprofile;
                        cb_Profile.Items.Add(profNime);
                    }
                }
                else if (((int)dinfo.streams & (int)st) == 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();
        }