private async Task SaveConf() { if (_importInProgress) { return; } if (TripRef.Sample) { Toast.DisplayTwoLines(_res.GetString("SampleMode"), _res.GetString("NoSampleModification"), "Icons/toastImageAndText.png"); return; } _changeInProgress = false; StartImport(); // modification of summary from ViewHome only if (PageRef is ViewHome) { TripSummaryRef.FolderTopName = TripName.Text; TripSummaryRef.LocationMain = TripName.Text; TripSummaryRef.LocationFromTo = TripLocation.Text; TripSummaryRef.SyncDropbox.Requested = (bool)ChkDropbox.IsChecked; TripSummaryRef.SyncDropbox.Compression = SynchroManager.IntToCompr(ComboDropbox.SelectedIndex); TripSummaryRef.SyncUsb.Requested = (bool)ChkUsb.IsChecked; TripSummaryRef.SyncUsb.Compression = SynchroManager.IntToCompr(ComboUsb.SelectedIndex); // save summary await(PageRef as ViewHome).SaveSummary(); } TripRef.Summary.FolderTopName = TripName.Text; // modification of Trip foreach (AlbumConfUserControl _albumConf in listAlbums) { if (_albumConf.AlbumRef.DisplayName != _albumConf.NameTopRef.Text) { // was changed bu user _albumConf.AlbumRef.DisplayName = _albumConf.NameTopRef.Text; _albumConf.AlbumRef.Summary.StrLocation = _albumConf.NameTopRef.Text; _albumConf.AlbumRef.Summary.StrLocationShort = _albumConf.NameTopRef.Text; } _albumConf.AlbumRef.DateArrival = _albumConf.DateTopRef.Date.Date; _albumConf.AlbumRef.PositionPresent = (Boolean)_albumConf.CheckBoxRef.IsChecked; } await TripRef.Update(true, false, null, null, null, this); }
public static async Task <Boolean> Merge(TripDescUserControl _tripDescSrc, TripDescUserControl _tripDescDest, Page _parent) { ResourceLoader _res = ResourceLoader.GetForCurrentView(); if (_tripDescDest.TripSummary.Sample || _tripDescSrc.TripSummary.Sample) { Toast.DisplaySingleLine(_res.GetString("MergeSamples")); return(false); } // no previous import date exists, ask and import everything Boolean _requestMerge = false; MessageDialog messageDialog; messageDialog = new MessageDialog(_res.GetString("MergeTrips")); messageDialog.Commands.Add(new UICommand(_res.GetString("No"), (command) => { })); messageDialog.Commands.Add(new UICommand(_res.GetString("Yes"), (command) => { _requestMerge = true; })); messageDialog.CancelCommandIndex = 0; messageDialog.DefaultCommandIndex = 1; await messageDialog.ShowAsync(); if (!_requestMerge) { return(false); } if (_parent is ViewHome) { (_parent as ViewHome).ProgressUpdate(_res.GetString("Merging"), 0); } Trip _tripSrc = await Trip.Load(_tripDescSrc); Trip _tripDest = await Trip.Load(_tripDescDest); try { StorageFolder _folderSrc = await ApplicationData.Current.LocalFolder.GetFolderAsync(_tripDescSrc.TripSummary.PathThumb); StorageFolder _folderDest = await ApplicationData.Current.LocalFolder.GetFolderAsync(_tripDescDest.TripSummary.PathThumb); var _items = await _folderSrc.GetItemsAsync(); int _count = 0; foreach (object _file in _items) { if (_file is StorageFile) { await(_file as StorageFile).MoveAsync(_folderDest, (_file as StorageFile).Name, NameCollisionOption.ReplaceExisting); } if (_parent is ViewHome) { (_parent as ViewHome).ProgressUpdate(_res.GetString("MovePicture") + " " + (_file as StorageFile).Name, 100 * _count++ / _items.Count); } } } catch (Exception e) { Debug.WriteLine(e.Message); return(false); } List <String> _listPicNames = new List <string>(); foreach (String _str in _tripSrc.Summary.PicturesThumb) { _listPicNames.Add(_str); } foreach (String _str in _tripDest.Summary.PicturesThumb) { _listPicNames.Add(_str); } _tripDest.Summary.PicturesThumb = GetRandomList(_listPicNames); _tripDest.Merge(_tripSrc, _tripDescDest.TripSummary.PathThumb); await _tripDest.Update(true, true, null, null, null, _parent); // try delete top folder if empty try { StorageFolder folderDelete = await StorageFolder.GetFolderFromPathAsync(_tripSrc.GetPath()); IReadOnlyList <IStorageItem> _files = await folderDelete.GetItemsAsync(); if (_files.Count == 0) { await folderDelete.DeleteAsync(); } } catch (Exception e) { Debug.WriteLine(e.Message); return(false); } return(true); }