Ejemplo n.º 1
0
        public int Run()
        {
            this.CreateDialog("camera_selection_dialog");
            int return_value = -1;


            cameraList.Selection.Mode = SelectionMode.Single;
            cameraList.AppendColumn(Catalog.GetString("Camera"), new CellRendererText(), "text", 0);
            cameraList.AppendColumn(Catalog.GetString("Port"), new CellRendererText(), "text", 1);

            ListStore tstore = new ListStore(typeof(string), typeof(string));

            for (int i = 0; i < camlist.Count(); i++)
            {
                tstore.AppendValues(camlist.GetName(i), camlist.GetValue(i));
            }

            cameraList.Model = tstore;
            ResponseType response = (ResponseType)this.Dialog.Run();

            if (response == ResponseType.Ok && cameraList.Selection.CountSelectedRows() == 1)
            {
                TreeIter  selected_camera;
                TreeModel model;

                cameraList.Selection.GetSelected(out model, out selected_camera);
                return_value = camlist.GetPosition((string)model.GetValue(selected_camera, 0),
                                                   (string)model.GetValue(selected_camera, 1));
            }

            this.Dialog.Destroy();

            return(return_value);
        }
Ejemplo n.º 2
0
        // FIXME: The actual conditions for ignoring 'usb:' ones is
        // when it is the only entry for that device. I'm not 100% how
        // to handle to of the same device when they are represented by
        // 'usb:' as opposed to the fully qualified name
        private static CameraList RemoveDuplicates(CameraList cameras)
        {
            CameraList list = new CameraList();

            try
            {
                int count = cameras.Count();
                for (int i = 0; i < count; i++)
                {
                    string name  = cameras.GetName(i);
                    string value = cameras.GetValue(i);

                    if (value == "usb:")
                    {
                        continue;
                    }

                    list.Append(name, value);
                }
            }
            catch
            {
                list.Dispose();
                throw;
            }

            return(list);
        }
Ejemplo n.º 3
0
    private void GetFileList(string dir)
    {
        if (camera_fs == null)
        {
            throw new InvalidOperationException();
        }

        //workaround for nikon dslr in ptp mode
        if (dir == "/special/")
        {
            return;
        }

        //files
        CameraList filelist = camera_fs.ListFiles(dir, context);

        for (int i = 0; i < filelist.Count(); i++)
        {
            files.Add(new GPhotoCameraFile(dir, filelist.GetName(i)));
        }

        //subdirectories
        CameraList folderlist = camera_fs.ListFolders(dir, context);

        for (int i = 0; i < folderlist.Count(); i++)
        {
            GetFileList(dir + folderlist.GetName(i) + "/");
        }
    }
Ejemplo n.º 4
0
        /// <summary>
        /// Detects all usable cameras which are connected to the system
        /// </summary>
        /// <returns>A list containing all cameras which can be connected to</returns>
        public static List <Camera> Detect()
        {
            if (Utilities.Is64Bit && Environment.OSVersion.Platform != PlatformID.Unix)
            {
                Console.WriteLine("A 64bit windows system has been detected. This is not supported");
                Console.WriteLine("due to the complexity of interoperating with libgphoto2");
                Console.WriteLine("as it exposes variable length 'long' types in it's API.");
                Console.WriteLine("The API is unlikely to change before version 3 of the library");
                Console.WriteLine("The current status of this can be found on the libgphoto2");
                Console.WriteLine("mailing list. A detailed explanation can be found in the");
                Console.WriteLine("README file for libgphoto2-sharp");
                return(new List <Camera>());
            }

            List <Camera> cameras = new List <Camera>();
            Context       c       = new Context();

            using (CameraAbilitiesList abilities = new CameraAbilitiesList())
                using (PortInfoList portInfoList = new PortInfoList())
                    using (CameraList cameraList = new CameraList())
                    {
                        // Get the list of all devices that are currently supported
                        abilities.Load(c);

                        // Get the list of all the (usb?) ports that are currently available
                        portInfoList.Load();

                        // Create the list of all the connected devices which can be used
                        abilities.Detect(portInfoList, cameraList, c);

                        // Scan through all the detected cameras and remove any duplicates
                        using (CameraList cams = RemoveDuplicates(cameraList))
                        {
                            int count = cams.Count();
                            for (int i = 0; i < count; i++)
                            {
                                CameraAbilities ability  = abilities.GetAbilities(abilities.LookupModel(cams.GetName(i)));
                                PortInfo        portInfo = portInfoList.GetInfo(portInfoList.LookupPath(cams.GetValue(i)));
                                cameras.Add(new Gphoto2.Camera(ability, portInfo, c));
                            }
                        }
                    }

            return(cameras);
        }