Exemplo n.º 1
0
	public DirImageCollection (DirImageRepository repo, int idx, string name)
	{
		this.repo = repo;
		this.idx = idx;
		this.name = name;
		string [] files = Directory.GetFiles (name);

		foreach (string file in files){
			string lf = file.ToLower ();
			if (lf.EndsWith (".jpg") ||
			    lf.EndsWith (".jpeg") ||
			    lf.EndsWith (".png") ||
			    lf.EndsWith (".gif") ||
			    lf.EndsWith (".tif") ||
			    lf.EndsWith (".tiff"))
				image_count++;
		}

		images = new string [image_count];

		int i = 0;
		foreach (string file in files){
			string lf = file.ToLower ();
			if (lf.EndsWith (".jpg") ||
			    lf.EndsWith (".jpeg") ||
			    lf.EndsWith (".png") ||
			    lf.EndsWith (".gif") ||
			    lf.EndsWith (".tif") ||
			    lf.EndsWith (".tiff"))
				images [i++] = file;
		}

		metadata = new XmlDocument ();
		metafile = name + "/metadata.xml";
		if (File.Exists (metafile)){
			metadata.Load (metafile);
		} else {
			metadata.LoadXml ("<?xml version=\"1.0\"?><images></images>");
		}

		keywords = new Hashtable ();
		XmlNodeList keyword_nodes = metadata.SelectNodes ("/images/image/keywords");
		foreach (XmlNode n in keyword_nodes){
			string [] keyword_list = KeywordsFromNode (n);

			foreach (string keyword in keyword_list)
				keywords [keyword] = true;
		}
	}
Exemplo n.º 2
0
    static int Main(string [] args)
    {
        Application.Init();
//		string dbname = "mphoto";
        string dbname;
        string dirtoimport;
        string mphotodir = System.Environment.GetEnvironmentVariable("HOME") + "/.mphoto";

        dbname = "URI=file:" + mphotodir + "/" + "mphoto.db";

        IImageRepository repo;

        System.IO.DirectoryInfo dinfo = new System.IO.DirectoryInfo(mphotodir);
        dinfo.Create();

        // turn on sqlite debugging
//                int fd = open ("/tmp/sqlite.debug", 576, 420);
//                sqliteParserTrace (fdopen (fd, "rw"), ">");

        if (args.Length != 0)
        {
            repo = new DirImageRepository(args);
        }
        else
        {
            repo = new DbImageRepository(dbname);
        }

        MphotoToplevel tl = new MphotoToplevel(repo, args);

        tl.Toplevel.Show();

        try {
            Application.Run();
        } catch (TargetInvocationException e) {
            Console.WriteLine("TIE: " + e.InnerException);
        } finally {
            // yuck
            DbProvider.CloseProviders();
            Thumbnailer.KillThreads();
        }

        return(0);
    }
Exemplo n.º 3
0
    public static int Main(string[] args)
    {
//		Window topwin;
        IconList         icon_list;
        IImageCollection collection;
        IIconListAdapter adapter;

        if (args.Length == 0)
        {
            Console.WriteLine("Usage: GtkMphoto /path/to/files");
            return(0);
        }

        Application.Init();

        Window topwin = new Window("GtkMphoto");

        topwin.DefaultSize  = new Size(600, 400);
        topwin.DeleteEvent += new DeleteEventHandler(Window_Delete);

        icon_list = new IconList();
        Scrollbar vsb = new VScrollbar(icon_list.Adjustment);
        Box       box = new HBox(false, 0);

        box.PackStart(icon_list, true, true, 0);
        box.PackStart(vsb, false, true, 0);

        box.ShowAll();
        topwin.Add(box);

        IImageRepository repo = new DirImageRepository(args);

        string[] collIds  = repo.GetCollectionIDs();
        string   firstcid = collIds [0];

        collection = repo.GetCollection(firstcid);

        icon_list.Adapter = new CollectionIconListAdapter(collection);

        topwin.Show();
        Application.Run();
        return(0);
    }
Exemplo n.º 4
0
	static int Main (string [] args)
	{
		Application.Init ();
//		string dbname = "mphoto";
                string dbname;
                string dirtoimport;
                string mphotodir = System.Environment.GetEnvironmentVariable ("HOME") + "/.mphoto";

                dbname = "URI=file:" + mphotodir + "/" + "mphoto.db";

                IImageRepository repo;

                System.IO.DirectoryInfo dinfo = new System.IO.DirectoryInfo (mphotodir);
                dinfo.Create ();

                // turn on sqlite debugging
//                int fd = open ("/tmp/sqlite.debug", 576, 420);
//                sqliteParserTrace (fdopen (fd, "rw"), ">");

		if (args.Length != 0) {
                    repo = new DirImageRepository (args);
                } else {
                    repo = new DbImageRepository (dbname);
                }

                MphotoToplevel tl = new MphotoToplevel (repo, args);
                tl.Toplevel.Show ();

		try {
			Application.Run ();
		} catch (TargetInvocationException e) {
			Console.WriteLine ("TIE: " + e.InnerException);
		} finally {
                        // yuck
                        DbProvider.CloseProviders ();
                        Thumbnailer.KillThreads ();
		}
		
		return 0;
	}
Exemplo n.º 5
0
	public static int Main (string[] args) {
//		Window topwin;
		IconList icon_list;
		IImageCollection collection;
		IIconListAdapter adapter;

		if (args.Length == 0) {
			Console.WriteLine ("Usage: GtkMphoto /path/to/files");
			return 0;
		}

		Application.Init ();

		Window topwin = new Window ("GtkMphoto");
		topwin.DefaultSize = new Size (600, 400);
		topwin.DeleteEvent += new DeleteEventHandler (Window_Delete);

		icon_list = new IconList ();
		Scrollbar vsb = new VScrollbar (icon_list.Adjustment);
		Box box = new HBox (false, 0);
		box.PackStart (icon_list, true, true, 0);
		box.PackStart (vsb, false, true, 0);

		box.ShowAll ();
		topwin.Add (box);

		IImageRepository repo = new DirImageRepository (args);

		string[] collIds = repo.GetCollectionIDs();
		string firstcid = collIds [0];
		collection = repo.GetCollection (firstcid);

		icon_list.Adapter = new CollectionIconListAdapter (collection);

		topwin.Show ();
		Application.Run ();
		return 0;
	}
Exemplo n.º 6
0
    public DirImageCollection(DirImageRepository repo, int idx, string name)
    {
        this.repo = repo;
        this.idx  = idx;
        this.name = name;
        string [] files = Directory.GetFiles(name);

        foreach (string file in files)
        {
            string lf = file.ToLower();
            if (lf.EndsWith(".jpg") ||
                lf.EndsWith(".jpeg") ||
                lf.EndsWith(".png") ||
                lf.EndsWith(".gif") ||
                lf.EndsWith(".tif") ||
                lf.EndsWith(".tiff"))
            {
                image_count++;
            }
        }

        images = new string [image_count];

        int i = 0;

        foreach (string file in files)
        {
            string lf = file.ToLower();
            if (lf.EndsWith(".jpg") ||
                lf.EndsWith(".jpeg") ||
                lf.EndsWith(".png") ||
                lf.EndsWith(".gif") ||
                lf.EndsWith(".tif") ||
                lf.EndsWith(".tiff"))
            {
                images [i++] = file;
            }
        }

        metadata = new XmlDocument();
        metafile = name + "/metadata.xml";
        if (File.Exists(metafile))
        {
            metadata.Load(metafile);
        }
        else
        {
            metadata.LoadXml("<?xml version=\"1.0\"?><images></images>");
        }

        keywords = new Hashtable();
        XmlNodeList keyword_nodes = metadata.SelectNodes("/images/image/keywords");

        foreach (XmlNode n in keyword_nodes)
        {
            string [] keyword_list = KeywordsFromNode(n);

            foreach (string keyword in keyword_list)
            {
                keywords [keyword] = true;
            }
        }
    }