private int DoImport(ImportBackend imp)
    {
        if (collection == null)
        {
            return(0);
        }

        this.importer = imp;
        AllowFinish   = false;

        total = importer.Prepare();

        if (total > 0)
        {
            UpdateProgressBar(1, total);
        }

        collection.Clear();
        collection.Capacity = total;

        while (total > 0 && this.Step())
        {
            System.DateTime start_time = System.DateTime.Now;
            System.TimeSpan span       = start_time - start_time;

            while (Application.EventsPending() && span.TotalMilliseconds < 100)
            {
                span = System.DateTime.Now - start_time;
                Application.RunIteration();
            }
        }

        return(total);
    }
Ejemplo n.º 2
0
    public bool Start()
    {
        if (Dialog != null)
        {
            Dialog.Sensitive = true;
        }

        if (import_path == null)
        {
            return(false);
        }

        string [] pathimport = { ImportPath };
        //this.Dialog.Destroy();

        if (copy_check != null)
        {
            copy = copy_check.Active;
        }

        bool recurse = true;

        if (recurse_check != null)
        {
            recurse = recurse_check.Active;
        }

        bool detect_duplicates = false;

        if (duplicate_check != null)
        {
            detect_duplicates = duplicate_check.Active;
        }

//		importer = new FileImportBackend (store, pathimport, copy, recurse, null);
        importer    = new FileImportBackend(store, pathimport, copy, recurse, detect_duplicates, null, Dialog);
        AllowFinish = false;

        total = importer.Prepare();

        if (total > 0)
        {
            UpdateProgressBar(1, total);
        }

        collection.Clear();
        collection.Capacity = total;

        if (total > 0)
        {
            step.Start();
        }

        return(false);
    }
    public void Finish()
    {
        if (idle_start.IsPending || step.IsPending)
        {
            AllowFinish = false;
            return;
        }

        if (importer != null)
        {
            importer.Finish();
        }

        importer = null;
    }
    public void Cancel()
    {
        idle_start.Stop();
        step.Stop();
        if (importer != null)
        {
            importer.Cancel();
            importer = null;
        }

        if (collection == null || collection.Count == 0)
        {
            return;
        }

        Photo [] photos = new Photo [collection.Count];
        for (int i = 0; i < collection.Count; i++)
        {
            photos [i] = (Photo)collection [i];
        }

        store.Remove(photos);
    }
	public bool Start ()
	{
		if (Dialog != null)
			Dialog.Sensitive = true;

		if (import_path == null)
			return false;

		string [] pathimport =  {ImportPath};
		//this.Dialog.Destroy();
		
		if (copy_check != null)
			copy = copy_check.Active;
		
		bool recurse = true;
		if (recurse_check != null)
			recurse = recurse_check.Active;
		
//		importer = new FileImportBackend (store, pathimport, copy, recurse, null);
		importer = new FileImportBackend (store, pathimport, copy, recurse, null, Dialog);
		AllowFinish = false;
		
		total = importer.Prepare ();
		
		if (total > 0)
			UpdateProgressBar (1, total);
		
		collection.Clear ();
		collection.Capacity = total;

		if (total > 0)
			step.Start ();
	       
		return false;
	}
	public void Cancel ()
	{
		idle_start.Stop ();
		step.Stop ();
		if (importer != null) {
			importer.Cancel ();
			importer = null;
		}
		
		if (collection == null || collection.Count == 0)
			return;
		
		Photo [] photos = new Photo [collection.Count];
		for (int i = 0; i < collection.Count; i++)
			photos [i] = (Photo) collection [i];

		store.Remove (photos);
	}
	public void Finish ()
	{
		if (idle_start.IsPending || step.IsPending) {
			AllowFinish = false;
			return;
		}
		
		if (importer != null)
			importer.Finish ();
		
		importer = null;
	}
	private int DoImport (ImportBackend imp)
	{
		if (collection == null)
			return 0;

		this.importer = imp;
		AllowFinish = false;
		
		total = importer.Prepare ();

		if (total > 0)
			UpdateProgressBar (1, total);
		
		collection.Clear ();
		collection.Capacity = total;

		while (total > 0 && this.Step ()) {
			System.DateTime start_time = System.DateTime.Now;
			System.TimeSpan span = start_time - start_time;

			while (Application.EventsPending () && span.TotalMilliseconds < 100) {
				span = System.DateTime.Now - start_time;
				Application.RunIteration ();
			}
		}

		return total;
	}