Exemplo n.º 1
0
        public IHardwareProxy LoadFromHardwareId(string hardwareId)
        {
            if (string.IsNullOrEmpty(hardwareId))
            {
                return(null);
            }
            string[] parts = hardwareId.Split("|".ToCharArray());
            if (parts.Length < 2)
            {
                return(null);
            }

            Guid   id     = new Guid(parts[0]);
            string resstr = parts[1];

            CameraChoice cams    = new CameraChoice();
            IMoniker     moniker = null;

            foreach (var camera_device in cams.Devices)
            {
                if (camera_device.Mon != null)
                {
                    Guid camid;
                    camera_device.Mon.GetClassID(out camid);
                    if (camid == id)
                    {
                        moniker = camera_device.Mon;
                        break;
                    }
                }
            }
            if (moniker == null)
            {
                return(null);
            }
            ResolutionList resolutions = Camera.GetResolutionList(moniker);

            if (resolutions == null)
            {
                return(null);
            }

            for (int index = 0; index < resolutions.Count; index++)
            {
                if (resstr == resolutions[index].ToString())
                {
                    CameraProxy proxy = new CameraProxy();
                    proxy.SetCamera(moniker, resolutions[index]);
                    return(proxy);
                }
            }
            return(null);
        }
Exemplo n.º 2
0
		public IHardwareProxy LoadFromHardwareId(string hardwareId)
		{
			if(string.IsNullOrEmpty(hardwareId))
				return null;
			string[] parts = hardwareId.Split("|".ToCharArray());
			if (parts.Length < 2)
				return null;

			Guid id = new Guid(parts[0]);
			string resstr = parts[1];

			CameraChoice cams = new CameraChoice();
			IMoniker moniker= null;
			foreach (var camera_device in cams.Devices)
			{
				if(camera_device.Mon!=null)
				{
					Guid camid;
					camera_device.Mon.GetClassID(out camid);
					if(camid == id)
					{
						moniker = camera_device.Mon;
						break;
					}
				}
			}
			if (moniker == null)
				return null;
			ResolutionList resolutions = Camera.GetResolutionList(moniker);
			if (resolutions == null)
				return null;

			for (int index = 0; index < resolutions.Count; index++)
			{
				if (resstr == resolutions[index].ToString())
				{
					CameraProxy proxy  = new CameraProxy();
					proxy.SetCamera(moniker, resolutions[index]);
					return proxy;
				}
			}
			return null;
		}