Ejemplo 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();
            cams.UpdateDeviceList();
			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;
			RotateFlipType rotation = RotateFlipType.RotateNoneFlipNone;
			if (parts.Length >= 3)
				rotation = (RotateFlipType)Enum.Parse(typeof(RotateFlipType),parts[2],true);

			for (int index = 0; index < resolutions.Count; index++)
			{
				if (resstr == resolutions[index].ToString())
				{
					NetCameraProxy proxy = new NetCameraProxy();
					proxy.SetCamera(moniker, resolutions[index]);
					proxy.Rotation = rotation;
					return proxy;
				}
			}
			return null;
		}
Ejemplo 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();

            cams.UpdateDeviceList();
            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);
            }
            RotateFlipType rotation = RotateFlipType.RotateNoneFlipNone;

            if (parts.Length >= 3)
            {
                rotation = (RotateFlipType)Enum.Parse(typeof(RotateFlipType), parts[2], true);
            }

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