public async Task <List <ZipItem> > List()
    {
        List <ZipItem> results = null;
        StorageFile    file    = await _access.GetFileAsync(_token);

        if (file != null)
        {
            using (Stream stream = await file.OpenStreamForReadAsync())
            {
                using (ZipArchive archive = new ZipArchive(stream, ZipArchiveMode.Read))
                {
                    results = new List <ZipItem>();
                    foreach (ZipArchiveEntry entry in archive.Entries)
                    {
                        if (entry.Name != string.Empty)
                        {
                            results.Add(new ZipItem()
                            {
                                Name            = entry.Name,
                                CompressedBytes = $"Compressed Size {entry.CompressedLength}",
                                ActualBytes     = $"Actual Size {entry.Length}"
                            });
                        }
                    }
                }
            }
        }
        return(results);
    }
Пример #2
0
        /// <summary>
        /// Reads the file token and image transform variables from the persisted state and
        /// restores the UI.
        /// </summary>
        private async void RestoreDataFromPersistedState()
        {
            try
            {
                rootPage.NotifyUser("Loading image file from persisted state...", NotifyType.StatusMessage);

                m_fileToken              = (string)m_localSettings["scenario2FileToken"];
                m_displayWidthNonScaled  = (uint)m_localSettings["scenario2Width"];
                m_displayHeightNonScaled = (uint)m_localSettings["scenario2Height"];
                m_scaleFactor            = (double)m_localSettings["scenario2Scale"];

                PhotoOrientation desiredOrientation =
                    Helpers.ConvertToPhotoOrientation((ushort)m_localSettings["scenario2UserRotation"]);

                m_exifOrientation =
                    Helpers.ConvertToPhotoOrientation((ushort)m_localSettings["scenario2ExifOrientation"]);

                m_disableExifOrientation = (bool)m_localSettings["scenario2DisableExif"];

                // Display the image in the UI.
                StorageFile file = await m_futureAccess.GetFileAsync(m_fileToken);

                BitmapImage src = new BitmapImage();

                using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read))
                {
                    await src.SetSourceAsync(stream);
                }
                PreviewImage.Source = src;
                AutomationProperties.SetName(PreviewImage, file.Name);

                // Display the image dimensions and transformation state in the UI.
                ExifOrientationTextblock.Text = Helpers.GetOrientationString(m_exifOrientation);
                ScaleSlider.Value             = m_scaleFactor * 100;
                UpdateImageDimensionsUI();

                // Restore the image tag's rotation transform.
                while (desiredOrientation != m_userRotation)
                {
                    RotateRight_Click(null, null);
                }

                RotateRightButton.IsEnabled = true;
                RotateLeftButton.IsEnabled  = true;
                SaveButton.IsEnabled        = true;
                CloseButton.IsEnabled       = true;
                SaveAsButton.IsEnabled      = true;
                ScaleSlider.IsEnabled       = true;
                rootPage.NotifyUser("Loaded image file from persisted state: " + file.Name, NotifyType.StatusMessage);
            }
            catch (Exception err)
            {
                rootPage.NotifyUser("Error: " + err.Message, NotifyType.ErrorMessage);
                ResetSessionState();
                ResetPersistedState();
            }
        }
Пример #3
0
        protected override async void LoadState(object param, Dictionary <string, object> pageState)
        {
            base.LoadState(param, pageState);
            int           id   = (int)param;
            VideoDataItem item = VideoDataSource.GetItem(id);

            if (item != null)
            {
                OpenFile(item.File);
            }
            else if (pageState["fileToken"] != null)
            {
                StorageItemAccessList future = StorageApplicationPermissions.FutureAccessList;
                StorageFile           file   = await future.GetFileAsync(pageState["fileToken"] as string);

                future.Clear();
                OpenFile(file);
            }
            if (pageState != null)
            {
                MediaPlayerState state = pageState["MediaState"] as MediaPlayerState;
                if (state != null)
                {
                    MediaPlayer.RestorePlayerState(state);
                }
            }
        }
Пример #4
0
        /// <summary>
        ///     Updates the amount of transferred bytes we store for a transfer that was recorded previously with RecordTransfer().
        /// </summary>
        /// <param name="friendNumber">Friend number of the transfer to update.</param>
        /// <param name="fileNumber">File number of the transfer to update.</param>
        /// <param name="transferredBytes">New amount of transferred bytes.</param>
        /// <returns></returns>
        public async Task UpdateTransfer(int friendNumber, int fileNumber, long transferredBytes)
        {
            var entry = FindEntry(friendNumber, fileNumber);

            if (entry.Token == null)
            {
                return;
            }

            var file = await _futureAccesList.GetFileAsync(entry.Token);

            var metadata = DeserializeMetadata(entry.Metadata);

            metadata.TransferredBytes = transferredBytes;

            _futureAccesList.AddOrReplace(entry.Token, file, SerializeMetadata(metadata));
        }
Пример #5
0
        public async Task <StorageFile> GetAsync(string path)
        {
            if (!_future.Entries.Any(x => x.Metadata.Equals(path)))
            {
                return(null);
            }
            var token = _future.Entries.First(x => x.Metadata.Equals(path)).Token;

            return(await _future.GetFileAsync(token));
        }
Пример #6
0
        public async Task <IFile> GetKeyFileAsync(IFile dbFile)
        {
            var token = GetKeyToken(dbFile.IdFromPath());

            if (_accessList.ContainsItem(token))
            {
                var key = await _accessList.GetFileAsync(token);

                if (!key.IsAvailable)
                {
                    _accessList.Remove(token);
                    return(null);
                }

                return(key.AsFile());
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// Reads the file token and property text from the persisted state, and calls
        /// DisplayImageUIAsync().
        /// </summary>
        private async void RestoreDataFromPersistedState()
        {
            try
            {
                m_fileToken = m_localSettings["scenario1FileToken"].ToString();
                StorageFile file = await m_futureAccess.GetFileAsync(m_fileToken);

                m_imageProperties = await file.Properties.GetImagePropertiesAsync();

                Dictionary <string, string> propertyText = new Dictionary <string, string>();
                propertyText.Add("Title", m_localSettings["scenario1Title"].ToString());
                propertyText.Add("Keywords", m_localSettings["scenario1Keywords"].ToString());
                propertyText.Add("DateTaken", m_localSettings["scenario1DateTaken"].ToString());
                propertyText.Add("Make", m_localSettings["scenario1Make"].ToString());
                propertyText.Add("Model", m_localSettings["scenario1Model"].ToString());
                propertyText.Add("Orientation", m_localSettings["scenario1Orientation"].ToString());
                propertyText.Add("LatDeg", m_localSettings["scenario1LatDeg"].ToString());
                propertyText.Add("LatMin", m_localSettings["scenario1LatMin"].ToString());
                propertyText.Add("LatSec", m_localSettings["scenario1LatSec"].ToString());
                propertyText.Add("LatRef", m_localSettings["scenario1LatRef"].ToString());
                propertyText.Add("LongDeg", m_localSettings["scenario1LongDeg"].ToString());
                propertyText.Add("LongMin", m_localSettings["scenario1LongMin"].ToString());
                propertyText.Add("LongSec", m_localSettings["scenario1LongSec"].ToString());
                propertyText.Add("LongRef", m_localSettings["scenario1LongRef"].ToString());
                propertyText.Add("Exposure", m_localSettings["scenario1Exposure"].ToString());
                propertyText.Add("FNumber", m_localSettings["scenario1FNumber"].ToString());

                await DisplayImageUIAsync(file, propertyText);

                rootPage.NotifyUser(
                    "Loaded file from persisted state: " + file.Name,
                    NotifyType.StatusMessage
                    );

                CloseButton.IsEnabled = true;
                ApplyButton.IsEnabled = true;
            }
            catch (Exception err)
            {
                rootPage.NotifyUser("Error: " + err.Message, NotifyType.ErrorMessage);
                ResetSessionState();
                ResetPersistedState();
            }
        }
Пример #8
0
 /// <summary>
 /// Retrieves the database file.
 /// </summary>
 /// <param name="id">The database ID.</param>
 /// <returns>The database file.</returns>
 public async Task <IStorageFile> RetrieveAsync(string id)
 {
     return(await _accessList.GetFileAsync(id));
 }