Exemple #1
0
        public async void Import(StorageFolder _rootFolder, Boolean _reorganize, Page _parentLoc,
                                 Trip.Callback _callbackEnd)
        {
            _parent    = _parentLoc;
            Reorganize = _reorganize;

            ProgressUpdate(_res.GetString("SearchPictures"), 0);

            // create picture list
            List <Picture> _picList = await CreatePicList(_rootFolder);

            if (_picList.Count == 0)
            {
                ProgressFinished(_res.GetString("NoPicture"));
                return;
            }

            ProgressUpdate(_res.GetString("ImportStart"), 0);

            // update picture list locations
            _picList = await UpdatePicListLocation(_picList);

            // create albums
            Albums = CreateAlbums(_picList);

            // update albums data
            await Update(true, true, null, null, _callbackEnd, _parentLoc);
        }
Exemple #2
0
        public async Task Update(Boolean _reorganizeAlt, Boolean _downloadAlt, Trip.Callback _callbackPosition, Trip.Callback _callbackItinerary,
                                 Trip.Callback _callbackEnd, Page _parentLoc)
        {
            int _count = 1;

            _parent = _parentLoc;
            try
            {
                if (_downloadAlt)
                {
                    // set albums positions and download
                    foreach (Album _album in Albums)
                    {
                        await _album.UpdatePosition();

                        ProgressUpdate(_res.GetString("DownloadPosition") + " " + _count + " " + _res.GetString("Of") + " " + Albums.Count + "...",
                                       100 * _count / Albums.Count);
                        _count++;
                    }

                    if (_callbackPosition != null)
                    {
                        _callbackPosition();
                    }
                }

                // merge albums
                for (int _idx = Albums.Count - 2; _idx >= 0; _idx--)
                {
                    if (Albums[_idx].Merge(Albums[_idx + 1], false))
                    {
                        Albums.RemoveAt(_idx + 1);
                    }
                }

                // merge force
                if ((_albumMergeForceDest != null) && (_albumMergeForceSrc != null) && (_albumMergeForceDest.Merge(_albumMergeForceSrc, true)))
                {
                    foreach (Album _albumDelete in Albums)
                    {
                        if (_albumDelete.Id == _albumMergeForceSrc.Id)
                        {
                            Albums.Remove(_albumDelete);
                            _albumMergeForceDest = null;
                            _albumMergeForceSrc  = null;
                            break;
                        }
                    }
                }

                if (_downloadAlt)
                {
                    // create itineraries
                    ItinerariesCreate();

                    // create itineraries
                    await ItinerariesDownload();

                    if (_callbackItinerary != null)
                    {
                        _callbackItinerary();
                    }
                }

                // reorganize folders
                _count = 1;
                if (Reorganize && _reorganizeAlt)
                {
                    foreach (Album _album in Albums)
                    {
                        await _album.ReorganizeAlbums(GetPath());

                        ProgressUpdate(_res.GetString("Reorganize") + " " + _count + " " + _res.GetString("Of") + " " + Albums.Count + "...",
                                       100 * _count / Albums.Count);
                        _count++;
                    }
                }

                if (_downloadAlt)
                {
                    // update trip infos
                    UpdateData();
                }

                // rename top folders and sub-paths
                if (Reorganize && _reorganizeAlt)
                {
                    if (Summary.SyncDropbox.InProgress)
                    {
                        Summary.SyncDropbox.PreviousName = GetPath();
                    }
                    await RenameTopFolder();
                }

                // CreateThumbnails
                await CreateThumbnails();

                // Force resynchronize
                Summary.SyncDropbox.Finished = false;

                // save to file
                await Serialization.SerializeToXmlFile <Trip>(Id + ".trip", this);

                ProgressFinished("");

                if (_callbackEnd != null)
                {
                    _callbackEnd();
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }