Пример #1
0
        static public LifeCamCamera CreateFromPrefs(CameraPrefs prefs)
        {
            LifeCamCamera newCamera = new LifeCamCamera(prefs.Name);

            if (newCamera.Source == null)
            {
                throw new Exception("Camera \"" + prefs.Name + "\" not found. Skipping.");
            }

            FieldInfo[] fields = prefs.GetType().GetFields();

            Console.WriteLine("\nApplying \"" + prefs.Name + "\" settings...\n");

            foreach (FieldInfo field in fields)
            {
                try
                {
                    newCamera.GetType().GetProperty(field.Name).SetValue(newCamera, field.GetValue(prefs), null);
                    Console.WriteLine("  => " + field.Name + ": " + field.GetValue(prefs));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    continue;
                }
            }

            return(newCamera);
        }
Пример #2
0
        static public LifeCamCamera CreateFromPrefs(CameraPrefs prefs)
        {
            LifeCamCamera newCamera = new LifeCamCamera(prefs.Name, prefs.NameContains, prefs.CameraNumber);

            if (newCamera.Source == null)
            {
                throw new Exception("\nCamera not found. Skipping.");
            }

            FieldInfo[] fields = prefs.GetType().GetFields();

            Console.WriteLine("\nApplying settings to camera " + newCamera.cameraNumberFound + "...");

            foreach (FieldInfo field in fields)
            {
                try
                {
                    newCamera.GetType().GetProperty(field.Name).SetValue(newCamera, field.GetValue(prefs), null);
                    Console.WriteLine("  => " + field.Name + ": " + field.GetValue(prefs));
                }
                catch (Exception e)
                {
                    continue;
                }
            }

            return(newCamera);
        }
Пример #3
0
 private static void applyCameraSettings(CameraPrefs[] pCameraPrefsList)
 {
     foreach (CameraPrefs cameraPrefs in pCameraPrefsList)
     {
         try
         {
             LifeCamCamera camera = LifeCamCamera.CreateFromPrefs(cameraPrefs);
         }
         catch (Exception pException)
         {
             Console.WriteLine("\n  ERROR: " + pException.Message);
             continue;
         }
     }
 }