Пример #1
0
        private async void Load()
        {
            var picker = new Windows.Storage.Pickers.FileOpenPicker();

            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add(".gif");
            picker.FileTypeFilter.Add(".isf");

            Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();


            if (file != null)
            {
                // Application now has read/write access to the picked file
                // this.textBlock.Text = "Picked photo: " + file.Name;

                IInputStream stream = await file.OpenSequentialReadAsync();

                await inkCanvas.InkPresenter.StrokeContainer.LoadAsync(stream);

                //var a = inkCanvas.InkPresenter.StrokeContainer.GetStrokes().ElementAt(0).GetInkPoints().ElementAt(0);
            }
            else
            {
                //this.textBlock.Text = "Operation cancelled.";
            }
        }
        async void OnLoad(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            if (Windows.UI.ViewManagement.ApplicationView.Value != Windows.UI.ViewManagement.ApplicationViewState.Snapped || Windows.UI.ViewManagement.ApplicationView.TryUnsnap())
            {
                var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
                openPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                openPicker.FileTypeFilter.Add(".gif");
                Windows.Storage.StorageFile file = await openPicker.PickSingleFileAsync();

                if (null != file)
                {
                    using (var stream = await file.OpenSequentialReadAsync())
                    {
                        await inkManager.LoadAsync(stream);
                    }

                    renderer.Clear();
                    renderer.AddInk(inkManager.GetStrokes());

                    // There is no selection - disable movement
                    AnchorSelection();

                    rootPage.NotifyUser(inkManager.GetStrokes().Count + " strokes loaded!", SDKTemplate.NotifyType.StatusMessage);
                }
            }
            else
            {
                rootPage.NotifyUser("Cannot unsnap the application. File picker cannot be used in snapped mode.", SDKTemplate.NotifyType.ErrorMessage);
            }
        }
Пример #3
0
        /// <summary>
        /// Gets a <see cref="Windows.Storage.StorageFile"/> as a byte array.
        /// </summary>
        /// <param name="file">The file to read.</param>
        /// <returns><paramref name="file"/> as a byte array.</returns>
        public static async Task <byte[]> FileToBytes(Windows.Storage.StorageFile file)
        {
            using (var inputStream = await file.OpenSequentialReadAsync())
            {
                var readStream = inputStream.AsStreamForRead();
                var byteArray  = new byte[readStream.Length];
                await readStream.ReadAsync(byteArray, 0, byteArray.Length);

                return(byteArray);
            }
        }
Пример #4
0
        private async System.Threading.Tasks.Task ins_img_ClickAsync()
        {
            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");

            Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();

            if (file != null)
            {
                using (IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
                {
                    BitmapImage bitmapImage = new BitmapImage();

                    await bitmapImage.SetSourceAsync(fileStream);

                    image2.Source = bitmapImage;
                }

                using (var inputStream = await file.OpenSequentialReadAsync())
                {
                    var readStream = inputStream.AsStreamForRead();

                    var byteArray = new byte[readStream.Length];
                    await readStream.ReadAsync(byteArray, 0, byteArray.Length);

                    byte_img_test = byteArray;
                }
            }
            else
            {
            }
        }
        async void OnLoad(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            var openPicker = new Windows.Storage.Pickers.FileOpenPicker();

            openPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
            openPicker.FileTypeFilter.Add(".gif");
            Windows.Storage.StorageFile file = await openPicker.PickSingleFileAsync();

            if (null != file)
            {
                using (var stream = await file.OpenSequentialReadAsync())
                {
                    await inkManager.LoadAsync(stream);
                }

                renderer.Clear();
                renderer.AddInk(inkManager.GetStrokes());

                // There is no selection - disable movement
                AnchorSelection();

                rootPage.NotifyUser(inkManager.GetStrokes().Count + " strokes loaded!", SDKTemplate.NotifyType.StatusMessage);
            }
        }