Beispiel #1
0
 private void _showSourceButton_Click(object sender, EventArgs e)
 {
     if (UriUtil.IsHttpUri(_sourceTextBox.Text) || UriUtil.IsFileUri(_sourceTextBox.Text))
     {
         Process.Start(_sourceTextBox.Text);
     }
 }
        private IProducer <CloseableReference <IPooledByteBuffer> > GetBasicEncodedImageSequence(
            ImageRequest imageRequest)
        {
            Preconditions.CheckNotNull(imageRequest);

            Uri uri = imageRequest.SourceUri;

            Preconditions.CheckNotNull(uri, "Uri is null.");
            if (UriUtil.IsNetworkUri(uri))
            {
                lock (_gate)
                {
                    if (_encodedImageProducerSequence == null)
                    {
                        _encodedImageProducerSequence = new RemoveImageTransformMetaDataProducer(
                            GetBackgroundNetworkFetchToEncodedMemorySequence());
                    }
                }

                return(_encodedImageProducerSequence);
            }
            else if (UriUtil.IsAppDataUri(uri))
            {
                return(GetEncodedLocalImageFileFetchSequence());
            }
            else if (UriUtil.IsAppPackageUri(uri))
            {
                return(GetEncodedLocalAssetFetchSequence());
            }
            else if (UriUtil.IsAppResourceUri(uri))
            {
                return(GetEncodedLocalResourceFetchSequence());
            }
            else if (UriUtil.IsDataUri(uri))
            {
                return(GetEncodedDataFetchSequence());
            }
            else if (UriUtil.IsFileUri(uri))
            {
                return(GetEncodedLocalImageFileFetchSequence());
            }
            else if (UriUtil.IsFutureAccessListUri(uri))
            {
                return(GetEncodedFutureAccessListFetchSequence());
            }
            else
            {
                string uriString = uri.ToString();
                if (uriString.Length > 30)
                {
                    uriString = uriString.Substring(0, 30) + "...";
                }

                throw new Exception("Unsupported uri scheme! Uri is: " + uriString);
            }
        }
        private IProducer <CloseableReference <CloseableImage> > GetBasicDecodedImageSequence(
            ImageRequest imageRequest)
        {
            Preconditions.CheckNotNull(imageRequest);

            Uri uri = imageRequest.SourceUri;

            Preconditions.CheckNotNull(uri, "Uri is null.");
            if (UriUtil.IsNetworkUri(uri))
            {
                return(GetNetworkFetchSequence());
            }
            else if (UriUtil.IsAppDataUri(uri))
            {
                if (MediaUtils.IsVideo(MediaUtils.ExtractMime(uri.ToString())))
                {
                    return(GetLocalVideoFileFetchSequence());
                }
                else
                {
                    return(GetLocalImageFileFetchSequence());
                }
            }
            else if (UriUtil.IsAppPackageUri(uri))
            {
                return(GetLocalAssetFetchSequence());
            }
            else if (UriUtil.IsAppResourceUri(uri))
            {
                return(GetLocalResourceFetchSequence());
            }
            else if (UriUtil.IsDataUri(uri))
            {
                return(GetDataFetchSequence());
            }
            else if (UriUtil.IsFileUri(uri))
            {
                return(GetLocalImageFileFetchSequence());
            }
            else if (UriUtil.IsFutureAccessListUri(uri))
            {
                return(GetFutureAccessListFetchSequence());
            }
            else
            {
                string uriString = uri.ToString();
                if (uriString.Length > 30)
                {
                    uriString = uriString.Substring(0, 30) + "...";
                }

                throw new Exception("Unsupported uri scheme! Uri is: " + uriString);
            }
        }
Beispiel #4
0
 // ------------------------------
 // private
 // ------------------------------
 private void UpdateOkButtonEnabled()
 {
     if (StringUtil.IsNullOrWhitespace(_titleTextTextBox.Text))
     {
         _okButton.Enabled = false;
     }
     else if (_linkTargetListBox.SelectedIndex == 0)
     {
         _okButton.Enabled = _memoListView.MemoListBox.SelectedItems.Count > 0;
     }
     else if (_linkTargetListBox.SelectedIndex == 1)
     {
         _okButton.Enabled = UriUtil.IsHttpUri(_addressTextBox.Text) || UriUtil.IsFileUri(_addressTextBox.Text);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Gets the encoded image.
        /// </summary>
        protected override Task <EncodedImage> GetEncodedImage(ImageRequest imageRequest)
        {
            if (UriUtil.IsFileUri(imageRequest.SourceUri))
            {
                FileInfo file = new FileInfo(imageRequest.SourceUri.LocalPath);
                return(Task.FromResult(GetEncodedImage(file.OpenRead(), (int)(file.Length))));
            }
            else
            {
                Task <StorageFile> uriToFilePathTask = StorageFile.GetFileFromApplicationUriAsync(
                    imageRequest.SourceUri).AsTask();

                return(uriToFilePathTask.ContinueWith(
                           (filePathTask) =>
                {
                    FileInfo file = new FileInfo(filePathTask.Result.Path);
                    return GetEncodedImage(file.OpenRead(), (int)(file.Length));
                }));
            }
        }
Beispiel #6
0
 private void UpdateSourceTextBox()
 {
     _sourceTextBox.Text       = _memo.Source;
     _showSourceButton.Enabled = UriUtil.IsHttpUri(_sourceTextBox.Text) || UriUtil.IsFileUri(_sourceTextBox.Text);
 }