Пример #1
0
        public static async Task <Boolean> DeleteFiles(String _tripName, List <TripSummary> _listSummary, Boolean _save)
        {
            if (_listSummary == null)
            {
                _listSummary = await TripSummary.Load();
            }

            try
            {
                foreach (TripSummary _summary in _listSummary)
                {
                    if (_summary.Id.Equals(_tripName))
                    {
                        _listSummary.Remove(_summary);
                        break;
                    }
                }

                if (_save)
                {
                    await TripSummary.Save(_listSummary);
                }

                StorageFile fileDelete = await ApplicationData.Current.LocalFolder.GetFileAsync(_tripName + ".trip");

                await fileDelete.DeleteAsync(StorageDeleteOption.PermanentDelete);

                StorageFolder folderDelete = await ApplicationData.Current.LocalFolder.GetFolderAsync(_tripName);

                await folderDelete.DeleteAsync(StorageDeleteOption.PermanentDelete);

                return(true);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                return(false);
            }
        }
Пример #2
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);
            }
        }