コード例 #1
0
        private async void HyperlinkButton_Click(object sender, RoutedEventArgs e)
        {
            var picker = new Windows.Storage.Pickers.FileOpenPicker();

            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".png");
            StorageFile file = await picker.PickSingleFileAsync();

            if (file != null)
            {
                try
                {
                    string uri = file.Path;

                    base64img = "data:" + file.ContentType + ";base64,";
                    // var tempfile = await RescaleImage(file, 128, 128);
                    base64img += Convert.ToBase64String(await filetobytes(file));
                    BitmapImage img = new BitmapImage();
                    UserIconRect.Opacity = 0;
                    using (var fileStream = await file.OpenStreamForReadAsync())
                    {
                        await img.SetSourceAsync(fileStream.AsRandomAccessStream());
                    }

                    UserIcon.ImageSource = img;
                    UserIconRect.Fade(1, 300).Start();
                    deleteImage.Content    = "Cancel icon modification";
                    deleteImage.Visibility = Visibility.Visible;
                }
                catch { }
            }
        }
コード例 #2
0
 private void GuildIcon_ImageOpened(object sender, RoutedEventArgs e)
 {
     UserIconRect.Opacity = 0;
     UserIconRect.Fade(1, 300).Start();
 }