예제 #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);
        }