Example #1
0
        private void gridDisp_DragStarted(object sender, DragItemsStartingEventArgs e)
        {
            TripDescUserControl _desc = e.Items[0] as TripDescUserControl;

            _itemIndexDelete = _listTripDesc.IndexOf(_desc);

            imageTrash.Source     = new BitmapImage(new Uri(this.BaseUri, "Icons/trash_empty.png"));
            imageTrash.Visibility = Visibility.Visible;
        }
Example #2
0
        private async void ImportStepEnd()
        {
            StopImport();

            _tripNumberUser++;
            _distanceCurrent = Distance;

            foreach (String _country in _tripImport.GetCountriesList())
            {
                _tripImport.Summary.AddCountry(_country);
            }

            if (_app.AppSettings.LearnInProgress("TOPIC_SAMPLE_A"))
            {
                _app.AppSettings.LearnDone("TOPIC_SAMPLE_A");
                foreach (TripDescUserControl _tripdesc in _listTripDesc)
                {
                    if (_tripdesc.DefBlockTrip.SampleId == 1)
                    {
                        await DeleteTrip(_tripdesc, false);

                        break;
                    }
                }
            }

            if (_app.AppSettings.LearnInProgress("TOPIC_SAMPLE_B"))
            {
                _app.AppSettings.LearnDone("TOPIC_SAMPLE_B");
                Toast.DisplayTwoLines(_res.GetString("FirstImport"), _res.GetString("SampleRemoved"), "Icons/toastImageAndText.png");
                foreach (TripDescUserControl _tripdesc in _listTripDesc)
                {
                    if (_tripdesc.DefBlockTrip.SampleId == 2)
                    {
                        await DeleteTrip(_tripdesc, true);

                        break;
                    }
                }
            }
            _app.AppSettings.LearnDone("TOPIC_SWIPE_ADD");

            _listSummary.Add(_tripImport.Summary);

            // save trip and summary
            await SaveSummary();

            // displayed trip description block
            TripDescUserControl blk = new TripDescUserControl(this, _app.AppSettings.GetConfig("CONFIG_MILES"), _app.AppSettings.ThemeColors);

            blk.DefBlockTrip = _tripImport.Summary;
            _listTripDesc.Insert(0, blk);

            txtDistance.Text = Gps.GetDistanceFormat(Distance, _app.AppSettings.GetConfig("CONFIG_MILES"));
            rewards();
        }
Example #3
0
        public void TripDescUserControlSelected(TripDescUserControl _tripDesc)
        {
            if (_importInProgress)
            {
                _tripDesc.SetInactive();
                return;
            }
            imageTrash.Visibility = Visibility.Collapsed;
            ringImport.IsActive   = true;

            this.Frame.Navigate(typeof(ViewMapTrip), _tripDesc);
        }
Example #4
0
        private async Task <Boolean> DeleteTrip(TripDescUserControl _tripDesc, Boolean _save)
        {
            if (_tripDesc == null)
            {
                return(false);
            }

            if (!(_tripDesc.TripSummary.Sample) && _tripDesc.TripSummary.SyncRequested())
            {
                Boolean _requestDeleteCloud = false;
                Boolean _requestCancel      = false;
                Boolean _status;

                MessageDialog messageDialog = new MessageDialog(_res.GetString("DeleteCloud"), _tripDesc.TripSummary.FolderTopName);
                messageDialog.Commands.Add(new UICommand(_res.GetString("Cancel"), (command) => { _requestCancel = true; }));
                messageDialog.Commands.Add(new UICommand(_res.GetString("No"), (command) => { }));
                messageDialog.Commands.Add(new UICommand(_res.GetString("Yes"), (command) => { _requestDeleteCloud = true; }));
                messageDialog.CancelCommandIndex  = 0;
                messageDialog.DefaultCommandIndex = 2;
                await messageDialog.ShowAsync();

                if (_requestCancel)
                {
                    return(false);
                }

                if (_requestDeleteCloud)
                {
                    _status = await _app.SynchroManager.DeleteAll(_tripDesc);

                    if (!_status)
                    {
                        messageDialog = new MessageDialog(_res.GetString("DeleteCloudFailed"));
                        messageDialog.Commands.Add(new UICommand(_res.GetString("Ok"), (command) => { }));
                        await messageDialog.ShowAsync();
                    }
                }
            }

            _listTripDesc.Remove(_tripDesc);

            Distance -= _tripDesc.TripSummary.Distance;

            if (!_tripDesc.DefBlockTrip.Sample)
            {
                _tripNumberUser--;
                await Trip.DeleteFiles(_tripDesc.TripSummary.Id, _listSummary, _save);
            }
            rewards();

            return(true);
        }
Example #5
0
        internal async Task <Boolean> DeleteAll(TripDescUserControl _tripDesc)
        {
            Boolean _status = true;

            _status &= await DeleteContent(_tripDesc.TripSummary.SyncDropbox);

            _status &= await DeleteContent(_tripDesc.TripSummary.SyncUsb);

#if STEP2
            _status &= await DeleteContent(_tripDesc.TripSummary.SyncGooglePlus);

            _status &= await DeleteContent(_tripDesc.TripSummary.SyncFacebook);
#endif
            return(_status);
        }
Example #6
0
        private async void imageTrash_Drop(object sender, DragEventArgs e)
        {
            if (_listTripDesc.Count >= _itemIndexDelete)
            {
                TripDescUserControl _tripDesc = _listTripDesc[_itemIndexDelete];
                await DeleteTrip(_listTripDesc[_itemIndexDelete], true);

                if ((_tripDesc.TripSummary.Sample) && (_tripDesc.TripSummary.SampleId == 1))
                {
                    _app.AppSettings.LearnDone("TOPIC_SAMPLE_A");
                }
                else if ((_tripDesc.TripSummary.Sample) && (_tripDesc.TripSummary.SampleId == 2))
                {
                    _app.AppSettings.LearnDone("TOPIC_SAMPLE_B");
                }
                rewards();
            }
            imageTrash.Visibility = Visibility.Collapsed;
            _app.AppSettings.LearnDone("TOPIC_DRAG_DELETE");
        }
Example #7
0
        public async Task SwitchSynchro(SynchroHandle _syncObj, TripDescUserControl _tripDesc)
        {
            _syncObj.Requested = !_syncObj.Requested;
            _syncObj.Finished  = false;

            if (_syncObj.Compression == SynchroManager.ComprLevel.Undefined)
            {
                MessageDialog messageDialog;
                messageDialog = new MessageDialog(_res.GetString("CompressionChooseLevel"),
                                                  _res.GetString("SynchroWith") + " " + _app.SynchroManager.CloudServerFromName(_syncObj.Server).DisplayName);
                messageDialog.Commands.Add(new UICommand(_res.GetString("CompressionHigh"), (command) => { _syncObj.Compression = SynchroManager.ComprLevel.High; }));
                messageDialog.Commands.Add(new UICommand(_res.GetString("CompressionMedium"), (command) => { _syncObj.Compression = SynchroManager.ComprLevel.Medium; }));
                messageDialog.Commands.Add(new UICommand(_res.GetString("CompressionNo"), (command) => { _syncObj.Compression = SynchroManager.ComprLevel.Original; }));
                messageDialog.CancelCommandIndex  = 0;
                messageDialog.DefaultCommandIndex = 2;
                await messageDialog.ShowAsync();
            }

            await SaveSummary();

            _app.SynchroManager.Update(_syncObj);
        }
Example #8
0
 public void SetUcSpecific(Image _logo, Rectangle _rectangle, TripDescUserControl _tripDescUc)
 {
     logo       = _logo;
     rectangle  = _rectangle;
     tripDescUc = _tripDescUc;
 }
Example #9
0
        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);
        }
Example #10
0
 public static async Task <Trip> Load(TripDescUserControl _tripDesc)
 {
     return(await LoadFromSummary(_tripDesc.TripSummary));
 }
Example #11
0
        private async Task loadUserTrip()
        {
            _listSummary = await TripSummary.Load();

            _tripNumberUser = _listSummary.Count;

            StorageFile _fileCountries = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///appdata/CountryDefinition.desc"));

            _listCountriesStandard = Serialization.DeserializeFromXmlFile <List <Country> >(_fileCountries.Path);

            if (_tripNumberUser == 0)
            {
                if (_app.AppSettings.LearnInProgress("TOPIC_SAMPLE_A"))
                {
                    StorageFile _fileSample = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///appdata/SampleA.desc"));

                    TripSummary _sample = Serialization.DeserializeFromXmlFile <TripSummary>(_fileSample.Path);
                    _listSummary.Add(_sample);
                }

                if (_app.AppSettings.LearnInProgress("TOPIC_SAMPLE_B"))
                {
                    StorageFile _fileSample = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///appdata/SampleB.desc"));

                    TripSummary _sample = Serialization.DeserializeFromXmlFile <TripSummary>(_fileSample.Path);
                    _listSummary.Add(_sample);
                }
            }

            if (_listSummary.Count == 0)
            {
                _appBar.Show(AppBarPage.SIDE.BOTH);
            }
            else if (_listSummary.Count > 0)
            {
                List <TripSummary> _tripSummOrd = _listSummary.OrderByDescending <TripSummary, DateTime>(o => o.DateArrival).ToList <TripSummary>();

                foreach (TripSummary _summary in _tripSummOrd)
                {
                    // displayed trip description block
                    TripDescUserControl blk = new TripDescUserControl(this, _app.AppSettings.GetConfig("CONFIG_MILES"), _app.AppSettings.ThemeColors);
                    blk.DefBlockTrip = _summary;
                    _listTripDesc.Add(blk);
                    Distance += _summary.Distance;
                }
            }
            StorageFile _imageAccount = UserInformation.GetAccountPicture(AccountPictureKind.SmallImage) as StorageFile;

#if DEBUG
            _imageAccount = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///assets/user.png"));

            _app.AppSettings.DisplayName = _res.GetString("Guest");
#endif
            IRandomAccessStream _stream = await _imageAccount.OpenReadAsync();

            BitmapImage _bmp = new BitmapImage();

            _bmp.SetSource(_stream);
            profilePicture.Source     = _bmp;
            profilePicture.Visibility = Visibility.Visible;

            profileName.Text = _app.AppSettings.DisplayName + " >";

            rewards();

            foreach (TripDescUserControl _tripDesc in _listTripDesc)
            {
                _app.SynchroManager.UpdateAll(_tripDesc.DefBlockTrip);
            }
        }