PickSingleFileAsync() public method

public PickSingleFileAsync ( ) : IAsyncOperation
return IAsyncOperation
        private async void ButtonFilePick_Click(object sender, RoutedEventArgs e)
        {
            var picker = new FileOpenPicker();
            picker.ViewMode = PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".png");

            StorageFile file = await picker.PickSingleFileAsync();


            if (file != null)
            {

                ImageProperties imgProp = await file.Properties.GetImagePropertiesAsync();
                var savedPictureStream = await file.OpenAsync(FileAccessMode.Read);

                //set image properties and show the taken photo
                bitmap = new WriteableBitmap((int)imgProp.Width, (int)imgProp.Height);
                await bitmap.SetSourceAsync(savedPictureStream);
                BBQImage.Source = bitmap;
                BBQImage.Visibility = Visibility.Visible;

                (this.DataContext as BBQRecipeViewModel).imageSource = file.Path;
            }
        }
Beispiel #2
0
        private async void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            Windows.Storage.Pickers.FileOpenPicker filepicker = new Windows.Storage.Pickers.FileOpenPicker();
            filepicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
            filepicker.FileTypeFilter.Add(".jpg");
            filepicker.FileTypeFilter.Add(".png");
            filepicker.FileTypeFilter.Add(".bmp");
            filepicker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            Windows.Storage.StorageFile imageFile = await filepicker.PickSingleFileAsync();

            if (imageFile != null)
            {
                Windows.UI.Xaml.Media.Imaging.BitmapImage   bitmap = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
                Windows.Storage.Streams.IRandomAccessStream stream = await imageFile.OpenAsync(Windows.Storage.FileAccessMode.Read);

                Image newImage = new Image();
                bitmap.SetSource(stream);
                newImage.Source = bitmap;
                //newImage.Height = 250;
                newImage.Stretch          = Stretch.UniformToFill;
                newImage.ManipulationMode = ManipulationModes.All;

                this.MyCanvas.Children.Add(newImage);
            }
        }
        private async void PlayMediaSource()
        {
            //<SnippetPlayMediaSource>
            //Create a new picker
            var filePicker = new Windows.Storage.Pickers.FileOpenPicker();

            //Add filetype filters.  In this case wmv and mp4.
            filePicker.FileTypeFilter.Add(".wmv");
            filePicker.FileTypeFilter.Add(".mp4");
            filePicker.FileTypeFilter.Add(".mkv");

            //Set picker start location to the video library
            filePicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;

            //Retrieve file from picker
            StorageFile file = await filePicker.PickSingleFileAsync();

            if (file != null)
            {
                _mediaSource        = MediaSource.CreateFromStorageFile(file);
                _mediaPlayer        = new MediaPlayer();
                _mediaPlayer.Source = _mediaSource;
                mediaPlayerElement.SetMediaPlayer(_mediaPlayer);
            }
            //</SnippetPlayMediaSource>

            //<SnippetPlay>
            _mediaPlayer.Play();
            //</SnippetPlay>

            //<SnippetAutoPlay>
            _mediaPlayer.AutoPlay = true;
            //</SnippetAutoPlay>
        }
        private async void Add_image(object sender, RoutedEventArgs e)
        {
            FileOpenPicker fp = new FileOpenPicker();

            // Adding filters for the file type to access.
            fp.FileTypeFilter.Add(".jpeg");
            fp.FileTypeFilter.Add(".png");
            fp.FileTypeFilter.Add(".bmp");
            fp.FileTypeFilter.Add(".jpg");

            // Using PickSingleFileAsync() will return a storage file which can be saved into an object of storage file class.

            StorageFile sf = await fp.PickSingleFileAsync();

            // Adding bitmap image object to store the stream provided by the object of StorageFile defined above.
            BitmapImage bmp = new BitmapImage();

            // Reading file as a stream and saving it in an object of IRandomAccess.
            IRandomAccessStream stream = await sf.OpenAsync(FileAccessMode.Read);

            // Adding stream as source of the bitmap image object defined above
            bmp.SetSource(stream);

            // Adding bmp as the source of the image in the XAML file of the document.
            image.Source = bmp;
        }
        private async void ExecuteSelectPictureCommand()
        {
            try
            {
                Busy = true;

                
                FileOpenPicker openPicker = new FileOpenPicker();
                openPicker.ViewMode = PickerViewMode.Thumbnail;
                openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                openPicker.FileTypeFilter.Add(".jpg");
                openPicker.FileTypeFilter.Add(".jpeg");
                openPicker.FileTypeFilter.Add(".png");

                StorageFile file = await openPicker.PickSingleFileAsync();

                if (file != null)
                {
                    // Copy the file into local folder
                    await file.CopyAsync(ApplicationData.Current.LocalFolder, file.Name, NameCollisionOption.ReplaceExisting);
                    // Save in the ToDoItem
                    TodoItem.ImageUri = new Uri("ms-appdata:///local/" + file.Name);
                }
            }
            finally { Busy = false; }
        }
Beispiel #6
0
        //Loading in a previously saved Note
        private async void btnLoad_Click(object sender, RoutedEventArgs e)
        {
            // Let users choose their ink file using a file picker.
            // Initialize the picker.
            Windows.Storage.Pickers.FileOpenPicker openPicker =
                new Windows.Storage.Pickers.FileOpenPicker();
            openPicker.SuggestedStartLocation =
                Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            openPicker.FileTypeFilter.Add(".gif");
            // Show the file picker.
            Windows.Storage.StorageFile file = await openPicker.PickSingleFileAsync();

            // User selects a file and picker returns a reference to the selected file.
            if (file != null)
            {
                // Open a file stream for reading.
                IRandomAccessStream stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

                // Read from file.
                using (var inputStream = stream.GetInputStreamAt(0))
                {
                    await inkCanvas.InkPresenter.StrokeContainer.LoadAsync(inputStream);
                }
                stream.Dispose();
            }
            // User selects Cancel and picker returns null.
            else
            {
                // Operation cancelled.
            }
        }
        private async void LoadImageUsingSetSource_Click(object sender, RoutedEventArgs e)
        {
            // This method loads an image into the WriteableBitmap using the SetSource method

            FileOpenPicker picker = new FileOpenPicker();
            picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add(".png");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".bmp");

            StorageFile file = await picker.PickSingleFileAsync();

            // Ensure a file was selected
            if (file != null)
            {
                // Set the source of the WriteableBitmap to the image stream
                using (IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
                {
                    try
                    {
                        await Scenario4WriteableBitmap.SetSourceAsync(fileStream);
                    }
                    catch (TaskCanceledException)
                    {
                        // The async action to set the WriteableBitmap's source may be canceled if the user clicks the button repeatedly
                    }
                }
            }
        }
        private async void BtPickVideoClick(object sender, RoutedEventArgs e)
        {
            App app = Application.Current as App;

            if (app == null)
                return;
            FileOpenPicker openPicker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.VideosLibrary
            };
            openPicker.FileTypeFilter.Add(".avi");
            openPicker.FileTypeFilter.Add(".mp4");

            StorageFile file = await openPicker.PickSingleFileAsync();
            if (file != null)
            {
                var client = new VideosServiceClient(app.EsbUsername, app.EsbPassword, app.EsbAccessKey);
                Video video = new Video { Title = file.DisplayName, Tags = file.DisplayName, Synopse = file.DisplayName };
                this.tblock_PostVideoResult.Text = await client.CreateVideoAsync(file, video);
            }
            else
            {
                this.tblock_PostVideoResult.Text = "Error reading file";
            }

        }
Beispiel #9
0
        public async void Execute(object parameter)
        {
            try
            {
                App.OpenFilePickerReason = OpenFilePickerReason.OnOpeningVideo;
                var picker = new FileOpenPicker
                {
                    ViewMode = PickerViewMode.List,
                    SuggestedStartLocation = PickerLocationId.VideosLibrary
                };
                foreach (var ext in _allowedExtensions)
                    picker.FileTypeFilter.Add(ext);


#if WINDOWS_APP
                StorageFile file = null;
                file = await picker.PickSingleFileAsync();
                if (file != null)
                {
                    LogHelper.Log("Opening file: " + file.Path);
                    await Locator.MediaPlaybackViewModel.OpenFile(file);
                }
                else
                {
                    LogHelper.Log("Cancelled");
                }
                App.OpenFilePickerReason = OpenFilePickerReason.Null;
#else
            picker.PickSingleFileAndContinue();
#endif
            }
            catch { }
        }
        public async override void Execute(object parameter)
        {
            var album = parameter as AlbumItem;

            if (album == null)
            {
                var args = parameter as ItemClickEventArgs;
                if(args != null)
                album = args.ClickedItem as AlbumItem;
            }

            var openPicker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.PicturesLibrary
            };
            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.FileTypeFilter.Add(".jpeg");
            openPicker.FileTypeFilter.Add(".png");
            openPicker.FileTypeFilter.Add(".gif");
            // Windows Phone launches the picker, then freezes the app. We need
            // to pick it up again on OnActivated.
#if WINDOWS_PHONE_APP
            App.OpenFilePickerReason = OpenFilePickerReason.OnPickingAlbumArt;
            App.SelectedAlbumItem = album;
            openPicker.PickSingleFileAndContinue();
#else
            var file = await openPicker.PickSingleFileAsync();
            if (file == null) return;
            var byteArray = await ConvertImage.ConvertImagetoByte(file);
            await App.MusicMetaService.SaveAlbumImageAsync(album, byteArray);
            await Locator.MusicLibraryVM._albumDatabase.Update(album);
#endif
        }
Beispiel #11
0
        /// <summary>
        /// MakeParameterForOffLine : Make Parameter For Reports on Device
        /// </summary>
        /// <returns>Parameter String</returns>
        public static async Task<string> MakeParameterForOffLine()
        {
            string strOzdPath = string.Empty;
            string strFinalPath = string.Empty;

            try
            {
                FileOpenPicker foPicker = new FileOpenPicker();

                foPicker.ViewMode = PickerViewMode.List;
                foPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                foPicker.FileTypeFilter.Add(".ozd");

                StorageFile sfiFile = await foPicker.PickSingleFileAsync();
                StorageFolder sfoFolder = ApplicationData.Current.LocalFolder;
                
                if (sfiFile != null)
                {
                    // await sfiFile.CopyAsync(sfoFolder, sfiFile.Name, NameCollisionOption.ReplaceExisting);
                    await sfiFile.CopyAsync(sfoFolder, "insert.ozd", NameCollisionOption.ReplaceExisting);

                    //strOzdPath = ApplicationData.Current.LocalFolder.Path + "\\" + sfiFile.Name;
                    strOzdPath = ApplicationData.Current.LocalFolder.Path + "\\insert.ozd";
                    StorageFile sfoTmpFile = await StorageFile.GetFileFromPathAsync(strOzdPath);
                    strFinalPath = "connection.openfile=" + strOzdPath;
                }                
            }
            catch (Exception ex)
            {
                strFinalPath = "";
            }

            return strFinalPath;
        }
        private async void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            StorageFile file;
            var item = sender as MenuFlyoutItem;
            if (item.Tag.ToString() == "photo")
            {
                FileOpenPicker openPicker = new FileOpenPicker();
                openPicker.ViewMode = PickerViewMode.Thumbnail;
                openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                openPicker.FileTypeFilter.Add(".jpg");
                openPicker.FileTypeFilter.Add(".jpeg");
                openPicker.FileTypeFilter.Add(".png");

                file = await openPicker.PickSingleFileAsync();
            }
            else
            {
                CameraCaptureUI captureUI = new CameraCaptureUI();
                captureUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg;
                captureUI.PhotoSettings.CroppedSizeInPixels = new Size(200, 200);

                file = await captureUI.CaptureFileAsync(CameraCaptureUIMode.Photo);
            }
            if (file != null)
            {
                // Application now has read/write access to the picked file
                var img = await UtilityHelper.LoadImage(file);
                imgSource.Source = img;
                fileStream = await file.OpenStreamForWriteAsync();
            }
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {

            bar.IsIndeterminate = true;
            bar.Visibility = Visibility.Visible;
           


            var picker = new FileOpenPicker();
            picker.FileTypeFilter.Add(".jpeg");

            picker.FileTypeFilter.Add(".jpg");
            picker.SuggestedStartLocation = PickerLocationId.Desktop;
            picker.ViewMode = PickerViewMode.List;
            StorageFile file = await picker.PickSingleFileAsync();
            IRandomAccessStream stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

          

            Helper obj = new Helper();
            CloudBlobContainer blobContainer = await obj.GetCloudBobContainer();
            CloudBlockBlob blob = blobContainer.GetBlockBlobReference(Guid.NewGuid().ToString() + ".jpg");


            await blob.UploadFromStreamAsync(stream);
            bar.IsIndeterminate = false;
            bar.Visibility = Visibility.Collapsed;
            MessageDialog msd = new MessageDialog("The image uploaded succesfully");
            await msd.ShowAsync();


        }
Beispiel #14
0
		public static async Task<StorageFile> PickOpenFileAsync(string[] extensions)
		{
			StorageFile file = null;
			try
			{
				Task<StorageFile> fileTask = null;
				await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, delegate
				{
					var openPicker = new FileOpenPicker
					{
						ViewMode = PickerViewMode.List,
						SuggestedStartLocation = PickerLocationId.DocumentsLibrary
					};

					foreach (var ext in extensions)
					{
						openPicker.FileTypeFilter.Add(ext);
					}
					fileTask = openPicker.PickSingleFileAsync().AsTask();
				});

				file = await fileTask;
			}
			catch (Exception ex)
			{
				await Logger.AddAsync(ex.ToString(), Logger.FileErrorLogFilename);
			}
			finally
			{
				SetLastPickedOpenFile(file);
				SetLastPickedOpenFileMRU(file);
			}
			return file;
		}
        /// <summary>
        /// Handles the pick file button click event to load a video.
        /// </summary>
        private async void pickFileButton_Click(object sender, RoutedEventArgs e)
        {
            // Clear previous returned file name, if it exists, between iterations of this scenario 
            rootPage.NotifyUser("", NotifyType.StatusMessage);

            // Create and open the file picker
            FileOpenPicker openPicker = new FileOpenPicker();
            openPicker.ViewMode = PickerViewMode.Thumbnail;
            openPicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;
            openPicker.FileTypeFilter.Add(".mp4");
            openPicker.FileTypeFilter.Add(".mkv");
            openPicker.FileTypeFilter.Add(".avi");

            StorageFile file = await openPicker.PickSingleFileAsync();
            if (file != null)
            {
                rootPage.NotifyUser("Picked video: " + file.Name, NotifyType.StatusMessage);
                this.mediaElement.SetPlaybackSource(MediaSource.CreateFromStorageFile(file));
                this.mediaElement.Play();
            }
            else
            {
                rootPage.NotifyUser("Operation cancelled.", NotifyType.ErrorMessage);
            }
        }
        private async void SelectPictureButton_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker openPicker = new FileOpenPicker();  //允许用户打开和选择文件的UI
            openPicker.ViewMode = PickerViewMode.Thumbnail;
            openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.FileTypeFilter.Add(".jpeg");
            openPicker.FileTypeFilter.Add(".png");

            StorageFile file = await openPicker.PickSingleFileAsync();  //storageFile:提供有关文件及其内容以及操作的方式
            if (file != null)
            {
                path = file.Path;
                using (IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
                {
                    // Set the image source to the selected bitmap 
                    BitmapImage bitmapImage = new BitmapImage();
                    bitmapImage.DecodePixelWidth = 600; //match the target Image.Width, not shown
                    await bitmapImage.SetSourceAsync(fileStream);
                    img.Source = bitmapImage;
                }
            }
            else
            {
                var i = new MessageDialog("error with picture").ShowAsync();
            }
        }
        public async Task<string> GetPictureFromGalleryAsync()
		{
            FileOpenPicker openPicker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.PicturesLibrary
            };
            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.FileTypeFilter.Add(".jpeg");
            openPicker.FileTypeFilter.Add(".bmp");
            openPicker.FileTypeFilter.Add(".png");

            StorageFile file = await openPicker.PickSingleFileAsync();
            if (file != null)
            {
                var stream = await file.OpenAsync(FileAccessMode.Read);
                BitmapImage image = new BitmapImage();
                image.SetSource(stream);

                var path = Path.Combine(StorageService.ImagePath);
                _url = String.Format("Image_{0}.{1}", Guid.NewGuid(), file.FileType);
                var folder = await StorageFolder.GetFolderFromPathAsync(path);

                //TODO rajouter le code pour le redimensionnement de l'image

                await file.CopyAsync(folder, _url);
                return string.Format("{0}\\{1}", path, _url);
            }

            return "";
		}
      private async void BackgroundButton_Click(object sender, RoutedEventArgs e)
      {
        // Clear previous returned file name, if it exists, between iterations of this scenario
        OutputTextBlock.Text = "";

        FileOpenPicker openPicker = new FileOpenPicker();
        openPicker.ViewMode = PickerViewMode.Thumbnail;
        openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
        openPicker.FileTypeFilter.Add(".jpg");
        openPicker.FileTypeFilter.Add(".jpeg");
        openPicker.FileTypeFilter.Add(".png");
        StorageFile file = await openPicker.PickSingleFileAsync();
        if (file != null)
        {
          // Application now has read/write access to the picked file
          OutputTextBlock.Text = "Picked photo: " + file.Name;

          BitmapImage img = new BitmapImage();
          img = await ImageHelpers.LoadImage( file );
          MyPicture.Source = img;

        }
        else
        {
          OutputTextBlock.Text = "Operation cancelled.";
        }
      }
Beispiel #19
0
        private async void GetThumbnailButton_Click(object sender, RoutedEventArgs e)
        {
            rootPage.ResetOutput(ThumbnailImage, OutputTextBlock);

            // Pick a document
            FileOpenPicker openPicker = new FileOpenPicker();
            foreach (string extension in FileExtensions.Document)
            {
                openPicker.FileTypeFilter.Add(extension);
            }

            StorageFile file = await openPicker.PickSingleFileAsync();
            if (file != null)
            {
                const ThumbnailMode thumbnailMode = ThumbnailMode.DocumentsView;
                const uint size = 100;
                using (StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(thumbnailMode, size))
                {
                    if (thumbnail != null)
                    {
                        MainPage.DisplayResult(ThumbnailImage, OutputTextBlock, thumbnailMode.ToString(), size, file, thumbnail, false);
                    }
                    else
                    {
                        rootPage.NotifyUser(Errors.NoIcon, NotifyType.StatusMessage);
                    }
                }
            }
            else
            {
                rootPage.NotifyUser(Errors.Cancel, NotifyType.StatusMessage);
            }

        }
 /// <summary>
 /// Opens a Adobe Color Swatch file, and reads its content.
 /// </summary>
 private async void Open_Executed()
 {
     var openPicker = new FileOpenPicker();
     openPicker.SuggestedStartLocation = PickerLocationId.Desktop;
     openPicker.FileTypeFilter.Add(".aco");
     StorageFile file = await openPicker.PickSingleFileAsync();
     if (null != file)
     {
         try
         {
             // User picked a file. 
             var stream = await file.OpenStreamForReadAsync();
             var reader = new AcoConverter();
             var swatchColors = reader.ReadPhotoShopSwatchFile(stream);
             Palette.Clear();
             foreach (var color in swatchColors)
             {
                 var pc = new NamedColor(color.Red, color.Green, color.Blue, color.Name);
                 Palette.Add(pc);
             }
         }
         catch (Exception ex)
         {
             Log.Error(ex.Message);
             Toast.ShowError("Oops, something went wrong.");
         }
     }
     else
     {
         // User cancelled.
         Toast.ShowWarning("Operation cancelled.");
     }
 }
        private async void BrowseButton_Click(object sender, RoutedEventArgs e)
        {

            //Upload picture 
            FileOpenPicker openPicker = new FileOpenPicker();
            openPicker.ViewMode = PickerViewMode.Thumbnail;
            openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.FileTypeFilter.Add(".jpeg");
            openPicker.FileTypeFilter.Add(".png");

            StorageFile file = await openPicker.PickSingleFileAsync();
            var bitmapImage = new BitmapImage();

            var stream = await file.OpenAsync(FileAccessMode.Read);
            bitmapImage.SetSource(stream);
           
            if (file != null)
            {
                FacePhoto.Source = bitmapImage;                
                scale = FacePhoto.Width / bitmapImage.PixelWidth;
            }
            else
            {
                Debug.WriteLine("Operation cancelled.");
            }

            // Remove any existing rectangles from previous events 
            FacesCanvas.Children.Clear();

            //DetectFaces
            var s = await file.OpenAsync(FileAccessMode.Read);
            List<MyFaceModel> faces = await DetectFaces(s.AsStream());
            DrawFaces(faces);
        }
        private async void seleccionarImagen(object sender, RoutedEventArgs e)
        {
            FileOpenPicker picker = new FileOpenPicker();
            picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add(".png");
            file = await picker.PickSingleFileAsync();

            BitmapImage image = new BitmapImage();
            try
            {
                using (var stream = await file.OpenAsync(FileAccessMode.Read))
                {
                    await image.SetSourceAsync(stream);
                }
                ImageBrush brush = new ImageBrush();
                brush.Stretch = Stretch.UniformToFill;
                brush.ImageSource = image;
                imagen.Fill = brush;
            }
            catch (Exception exception)
            {

            }
            
        }
        private async void SetImageButton_Click(object sender, RoutedEventArgs e)
        {

            FileOpenPicker imagePicker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.PicturesLibrary,
                FileTypeFilter = { ".jpg", ".jpeg", ".png", ".bmp" }
            };

            StorageFile imageFile = await imagePicker.PickSingleFileAsync();
            if (imageFile != null)
            {
                // SetAccountPictureAsync() accepts 3 storageFile objects for setting the small image, large image, and video.
                // More than one type can be set in the same call, but a small image must be accompanied by a large image and/or video.
                // If only a large image is passed, the small image will be autogenerated.
                // If only a video is passed, the large image and small will be autogenerated.
                // Videos must be convertable to mp4, <=5MB, and height and width >= 448 pixels.

                // Setting the Account Picture will fail if user disallows it in PC Settings.
                SetAccountPictureResult result = await UserInformation.SetAccountPicturesAsync(null, imageFile, null);
                if (result == SetAccountPictureResult.Success)
                {
                    rootPage.NotifyUser("Account picture was successfully changed.", NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("Account picture could not be changed.", NotifyType.StatusMessage);
                    AccountPictureImage.Visibility = Visibility.Collapsed;
                }
            }
        }
        public async System.Threading.Tasks.Task LoadKML(System.Collections.Generic.List<Windows.Devices.Geolocation.BasicGeoposition> mapdata)
        {
            Windows.Data.Xml.Dom.XmlLoadSettings loadSettings = new Windows.Data.Xml.Dom.XmlLoadSettings();
            loadSettings.ElementContentWhiteSpace = false;
            Windows.Data.Xml.Dom.XmlDocument kml = new Windows.Data.Xml.Dom.XmlDocument();
            FileOpenPicker openPicker = new FileOpenPicker();
            openPicker.ViewMode = PickerViewMode.List;
            openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            openPicker.FileTypeFilter.Add(".kml");
            Windows.Storage.IStorageFile file = await openPicker.PickSingleFileAsync();
            if (file != null)
            {
                string[] stringSeparators = new string[] { ",17" };
                kml = await Windows.Data.Xml.Dom.XmlDocument.LoadFromFileAsync(file);
                var element = kml.GetElementsByTagName("coordinates").Item(0);
                string ats  = element.FirstChild.GetXml();

                string[] atsa = ats.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
                int size = atsa.Length-1;
                for (int i = 0; i < size; i++)
                {
                    string[] coord = atsa[i].Split(',');
                    double longi = Convert.ToDouble(coord[0]);
                    double lati = Convert.ToDouble(coord[1]);
                    mapdata.Add(new Windows.Devices.Geolocation.BasicGeoposition() { Latitude = lati, Longitude = longi });
                }
            }
        }
Beispiel #25
0
		public async static Task<SimpleCollada> Load_File()
        {
            try
            {
				SimpleCollada col_scenes = null;
				XmlSerializer sr = new XmlSerializer(typeof(SimpleCollada));
                FileOpenPicker openPicker = new FileOpenPicker();
                openPicker.ViewMode = PickerViewMode.Thumbnail;
                openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                openPicker.FileTypeFilter.Add(".xml");
                openPicker.FileTypeFilter.Add(".dae");
                StorageFile file = await openPicker.PickSingleFileAsync();
                if (file != null)
                {
                    var stream = await file.OpenStreamForReadAsync();
                    col_scenes = (SimpleCollada)(sr.Deserialize(stream));
                }
               
				return col_scenes;
            }
            catch (Exception ex)
            {
                //Console.WriteLine(ex.ToString());
                //Console.ReadLine();
				return null;
            }			
		}
Beispiel #26
0
        public async void UploadtoParse()
        {

            ParseClient.Initialize("oVFGM355Btjc1oETUvhz7AjvNbVJZXFD523abVig", "4FpFCQyO7YVmo2kMgrlymgDsshAvTnGAtQcy9NHl");

            var filePicker = new FileOpenPicker();
            filePicker.FileTypeFilter.Add(".png");
            var pickedfile = await filePicker.PickSingleFileAsync();
            using (var randomStream = (await pickedfile.OpenReadAsync()))
            {
                using (var stream = randomStream.AsStream())
                {
                    //byte[] data = System.Text.Encoding.UTF8.GetBytes("Working at Parse is great!");
                    ParseFile file = new ParseFile("resume1.png", stream);

                    await file.SaveAsync();

                    var jobApplication = new ParseObject("JobApplication");
                    jobApplication["applicantName"] = "jambor";
                    jobApplication["applicantResumeFile"] = file;
                    await jobApplication.SaveAsync();

                }
            }

          

        }
Beispiel #27
0
        private async void openFileButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var pi = new FileOpenPicker();
                pi.SuggestedStartLocation = PickerLocationId.Downloads;
                pi.FileTypeFilter.Add(".dll");
                //{
                //    //SettingsIdentifier = "PE Viewer",
                //    SuggestedStartLocation = PickerLocationId.Downloads,
                //    ViewMode = PickerViewMode.List
                //};
                ////pi.FileTypeFilter.Add("DLL and EXE files|*.dll;*.exe");
                ////pi.FileTypeFilter.Add("All files|*.*");

                var fi = await pi.PickSingleFileAsync();

                var fiStream = await fi.OpenAsync(Windows.Storage.FileAccessMode.Read);
                var stream = fiStream.OpenRead();

                var buf = await ReadAll(stream);

                var bufStream = new MemoryStream(buf);

                var pe = new PEFile();
                pe.ReadFrom(new BinaryStreamReader(bufStream, new byte[32]));

                LayoutRoot.Children.Add(new PEFileView { DataContext = pe });
            }
            catch (Exception error)
            {
                openFileButton.Content = error;
            }
        }
Beispiel #28
0
        public static async Task<SaveAllSpecies> Import()
        {
            FileOpenPicker importPicker = new FileOpenPicker();
            importPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            importPicker.FileTypeFilter.Add(".xml");
            importPicker.CommitButtonText = "Import";
            StorageFile file = await importPicker.PickSingleFileAsync();
            if (null != file)
            {
                using (var stream = await file.OpenAsync(FileAccessMode.Read))
                {
                    using (Stream inputStream = stream.AsStreamForRead())
                    {
                        SaveAllSpecies data;
                        XmlSerializer serializer = new XmlSerializer(typeof(SaveAllSpecies));
                        using (XmlReader xmlReader = XmlReader.Create(inputStream))
                        {
                            data = (SaveAllSpecies)serializer.Deserialize(xmlReader);
                        }
                        await inputStream.FlushAsync();
                        return data;
                    }                    
                }
            }
            else
            {
                //nothing
            }

            return null;
        }
        public async void OnOpenDotnet()
        {
            try
            {
                var picker = new FileOpenPicker()
                {
                    SuggestedStartLocation = PickerLocationId.DocumentsLibrary
                };
                picker.FileTypeFilter.Add(".txt");

                StorageFile file = await picker.PickSingleFileAsync();
                if (file != null)
                {
                    IRandomAccessStreamWithContentType wrtStream = await file.OpenReadAsync();
                    Stream stream = wrtStream.AsStreamForRead();
                    using (var reader = new StreamReader(stream))
                    {
                        text1.Text = await reader.ReadToEndAsync();
                    }
                }
            }
            catch (Exception ex)
            {
                var dlg = new MessageDialog(ex.Message, "Error");
                await dlg.ShowAsync();
            }
        }
        /// <summary>
        /// Open the image selection standard dialog
        /// </summary>
        /// <param name="sender">event sender</param>
        /// <param name="e">event argument</param>
        private async void OpenPicture_Click(object sender, RoutedEventArgs e)
        {
            if (!this.showInProgress)
            {
                this.showInProgress = true;

                try
                {
                    var picker = new FileOpenPicker();

                    picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                    picker.ViewMode = PickerViewMode.Thumbnail;
                    picker.FileTypeFilter.Add(".jpg");
                    picker.FileTypeFilter.Add(".jpeg");

                    var file = await picker.PickSingleFileAsync();
                    if (file != null)
                    {
                        // open captured file and set the image source on the control
                        this.ocrData.PhotoStream = await file.OpenAsync(FileAccessMode.Read);
                    }
                }
                finally
                {
                    this.showInProgress = false;
                }
            }
        }
Beispiel #31
0
        public async static Task<PhotoPageArguements> GetImageFromImport(bool isNewDocument = true)
        {
            var picker = new FileOpenPicker();

            picker.ViewMode = PickerViewMode.Thumbnail;

            picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;

            picker.FileTypeFilter.Add(".jpg");

            var file = await picker.PickSingleFileAsync();

            PhotoPageArguements arguments = null;

            if (file != null)
            {
                var temporaryFolder = ApplicationData.Current.TemporaryFolder;

                await file.CopyAsync(temporaryFolder,
                    file.Name, NameCollisionOption.ReplaceExisting);

                file = await temporaryFolder.TryGetFileAsync(file.Name);

                if (file != null)
                {
                    arguments = await ImageService.GetPhotoPageArguements(file, isNewDocument);
                }
            }

            return arguments;
        }
        async void OnFileOpenButtonClick(object sender, RoutedEventArgs args) {
            FileOpenPicker picker = new FileOpenPicker();
            picker.FileTypeFilter.Add(".txt");
            StorageFile storageFile = await picker.PickSingleFileAsync();

            // If user presses Cancel, result is null
            if (storageFile == null)
                return;

            Exception exception = null;

            try {
                using (IRandomAccessStream stream = await storageFile.OpenReadAsync()) {
                    using (DataReader dataReader = new DataReader(stream)) {
                        uint length = (uint)stream.Size;
                        await dataReader.LoadAsync(length);
                        txtbox.Text = dataReader.ReadString(length);
                    }
                }
            }
            catch (Exception exc) {
                exception = exc;
            }

            if (exception != null) {
                MessageDialog msgdlg = new MessageDialog(exception.Message, "File Read Error");
                await msgdlg.ShowAsync();
            }
        }
Beispiel #33
0
 /// <summary>
 /// Compares a picked file with sample.dat
 /// </summary>
 private async void CompareFilesButton_Click(object sender, RoutedEventArgs e)
 {
     rootPage.ResetScenarioOutput(OutputTextBlock);
     StorageFile file = rootPage.sampleFile;
     if (file != null)
     {
         FileOpenPicker picker = new FileOpenPicker();
         picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
         picker.FileTypeFilter.Add("*");
         StorageFile comparand = await picker.PickSingleFileAsync();
         if (comparand != null)
         {
             if (file.IsEqual(comparand))
             {
                 OutputTextBlock.Text = "Files are equal";
             }
             else
             {
                 OutputTextBlock.Text = "Files are not equal";
             }
         }
         else
         {
             OutputTextBlock.Text = "Operation cancelled";
         }
     }
     else
     {
         rootPage.NotifyUserFileNotExist();
     }
 }
Beispiel #34
0
        private async void AppBarButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var picker = new Windows.Storage.Pickers.FileOpenPicker();
                picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
                picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                picker.FileTypeFilter.Add(".zip");
                picker.FileTypeFilter.Add(".jpeg");
                picker.FileTypeFilter.Add(".png");


                StorageFile file = await picker.PickSingleFileAsync();

                if (file != null)
                {
                    StorageFolder          picturesFolder    = ApplicationData.Current.LocalFolder;
                    List <ZipArchiveEntry> zipArchiveEntries = await ZipArchiveManager.GetFileZip(file);

                    TreeViewNode rootNode = new TreeViewNode()
                    {
                        Content = "Flavors"
                    };
                    rootNode.IsExpanded = true;
                    rootNode.Children.Add(new TreeViewNode()
                    {
                        Content = "Vanilla"
                    });
                    rootNode.Children.Add(new TreeViewNode()
                    {
                        Content = "Strawberry"
                    });
                    rootNode.Children.Add(new TreeViewNode()
                    {
                        Content = "Chocolate"
                    });



                    string s = String.Empty;
                    foreach (var d in zipArchiveEntries)
                    {
                        s += d.FullName + "\t" + d.Name + "\t" + d + "\n";
                    }

                    sampleTreeView.RootNodes.Add(rootNode);
                    MessageDialog messageDialog1 = new MessageDialog(s);
                    await messageDialog1.ShowAsync();
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageDialog messageDialog = new MessageDialog(ex.Message);
                await messageDialog.ShowAsync();
            }
        }
Beispiel #35
0
    public static async Task <StorageFile> PickFile()
    {
        var picker = new Windows.Storage.Pickers.FileOpenPicker();

        foreach (var ext in AvailableExtensionsArchive)
        {
            picker.FileTypeFilter.Add(ext);
        }
        return(await picker.PickSingleFileAsync());
    }
Beispiel #36
0
        private async void Button_Click_3(object sender, RoutedEventArgs e)
        {
            Windows.Storage.Pickers.FileOpenPicker openPicker = new Windows.Storage.Pickers.FileOpenPicker();
            openPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
            openPicker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;

            // Filter to include a sample subset of file types.
            openPicker.FileTypeFilter.Clear();
            openPicker.FileTypeFilter.Add(".bmp");
            openPicker.FileTypeFilter.Add(".png");
            openPicker.FileTypeFilter.Add(".jpeg");
            openPicker.FileTypeFilter.Add(".jpg");

            // Open the file picker.
            Windows.Storage.StorageFile file = await openPicker.PickSingleFileAsync();

            // file is null if user cancels the file picker.
            if (file != null)
            {
                // Open a stream for the selected file.
                Windows.Storage.Streams.IRandomAccessStream fileStream =
                    await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

                // Set the image source to the selected bitmap.
                Windows.UI.Xaml.Media.Imaging.BitmapImage bitmapImage =
                    new Windows.UI.Xaml.Media.Imaging.BitmapImage();

                bitmapImage.SetSource(fileStream);
                displayImage.Source = bitmapImage;

                this.DataContext = file;
            }

            try
            {
                var db     = new SQLite.SQLiteConnection(App.DBPath);
                var emptab = (db.Table <lawyer>().Where(em => em.username == txt1.Text)).Single();

                var targetFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(emptab.username + ".jpg");

                if (targetFile != null)
                {
                    //await file.MoveAndReplaceAsync(targetFile);
                    await file.CopyAndReplaceAsync(targetFile);
                }
            }
            catch (Exception ex)
            {
                var var_name = new MessageDialog("Unable to update profile picture\nPlease try after sometime.");
                var_name.Commands.Add(new UICommand("OK"));
                var_name.ShowAsync();
            }

            // await file.CopyAsync(ApplicationData.Current.LocalFolder);
        }
Beispiel #37
0
        private async Task AddCompressFileButton_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker picker = new Windows.Storage.Pickers.FileOpenPicker();

            picker.ViewMode = PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add("*");

            StorageFolder storage    = Windows.Storage.ApplicationData.Current.LocalFolder;
            StorageFile   fileReader = await picker.PickSingleFileAsync();
        }
Beispiel #38
0
        private async Task SendAFile()
        {
            if (sndr == null)
            {
                sndr = new OBEX_Sender();
            }

            FileOpenPicker picker = null;

#if IoTCore
#else
            picker = new Windows.Storage.Pickers.FileOpenPicker();
#endif
            if (picker != null)
            {
                picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
                picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                picker.FileTypeFilter.Add(".txt");

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

                if (file != null)
                {
                    PostMessage("Picked textfile:", file.Name + "\r\nReady");
                    txt = await Windows.Storage.FileIO.ReadTextAsync(file);

                    filename = file.Name;

                    var t = Task.Run(async() =>
                    {
                        await sndr.Send(txt, filename);
                    });
                    PostMessage("Picker sending", file.Name);
                }
                else
                {
                    PostMessage("PickAFile", "Operation cancelled.");
                }
            }
            else
            {
                await sndr.Send("Hello World", "Hi.txt");

                PostMessage("Sent:", "Hi.Txt");
            }
            if (sndr != null)
            {
                sndr.Dispose();
            }
        }
Beispiel #39
0
        private async void OpenVideoButton_Click(object sender, RoutedEventArgs e)
        {
            var picker = new Windows.Storage.Pickers.FileOpenPicker
            {
                ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail
            };

            picker.FileTypeFilter.Add(".mkv");
            picker.FileTypeFilter.Add(".mp4");

            StorageFile file = await picker.PickSingleFileAsync();

            OpenVideoFile(file);
        }
        private async void FileButton_Click(object sender, RoutedEventArgs e)
        {
            var picker = new Windows.Storage.Pickers.FileOpenPicker();

            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.List;
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            picker.FileTypeFilter.Add(".csv");

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

            if (file != null)
            {
                StorageFolder folder = ApplicationData.Current.TemporaryFolder;

                var copiedFile = await file.CopyAsync(folder, file.Name, NameCollisionOption.ReplaceExisting);

                var r = await DataSourceModel.ReadFileForDrawItem(copiedFile);

                if (r != null)
                {
                    if (r.ItemList.Count > 200 || r.ItemList.Count == 0)
                    {
                        ContentDialog dialog = new ContentDialog();
                        dialog.Title   = Strings.Resources.DataSetting_Dialog_Error;
                        dialog.Content = Strings.Resources.DataSetting_Dialog_Exceed;

                        dialog.PrimaryButtonText = Strings.Resources.DataSetting_Dialog_Ok;
                        await dialog.ShowAsync();
                    }
                    else
                    {
                        this.FilePathText.Text = copiedFile.Name;
                        ApplyDataSource();
                        return;
                    }
                }
                else
                {
                    ContentDialog dialog = new ContentDialog();
                    dialog.Title   = Strings.Resources.DataSetting_Dialog_Error;
                    dialog.Content = Strings.Resources.DataSetting_Dialog_FileError;

                    dialog.PrimaryButtonText = Strings.Resources.DataSetting_Dialog_Ok;
                    await dialog.ShowAsync();
                }

                SetDataModel();
            }
        }
Beispiel #41
0
        public async Task UploadAsync()
        {
            var filePicker = new Windows.Storage.Pickers.FileOpenPicker();

            filePicker.FileTypeFilter.Add("*");
            filePicker.ViewMode = PickerViewMode.List;
            filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            var fileToUpload = await filePicker.PickSingleFileAsync();

            if (fileToUpload == null)
            {
                return;
            }

            var startNotification = NotificationHelper.Factory("Upload started", string.Format("The file {0} has started uploading...", fileToUpload.Name));

            ToastNotificationManager.CreateToastNotifier().Show(startNotification);

            var uploadedFile = default(ISftpFile);

            try
            {
                uploadedFile = await this.CurrentFolder.CreateFileAsync(fileToUpload.Name, CreationCollisionOption.GenerateUniqueName);

                this.Files.Add(uploadedFile);
                var sourceProperties = await fileToUpload.GetBasicPropertiesAsync();

                using (var input = await fileToUpload.OpenStreamForReadAsync())
                {
                    var upload = uploadedFile.CopyAndReplaceAsyncWithProgress(input);
                    upload.Progress = (info, progress) =>
                    {
                        uploadedFile.Size     = progress;
                        uploadedFile.Progress = progress / (double)sourceProperties.Size;
                    };
                    await upload;
                }

                var successNotification = NotificationHelper.Factory("Upload finished", string.Format("The file {0} was uploaded successfully.", fileToUpload.Name), uploadedFile.ImagePath);
                ToastNotificationManager.CreateToastNotifier().Show(successNotification);
            }
            catch (Exception exp)
            {
                Debug.WriteLine(exp);

                var errorNotification = NotificationHelper.Factory("Upload failed", string.Format("The file {0} could not be uploaded.", fileToUpload.Name));
                ToastNotificationManager.CreateToastNotifier().Show(errorNotification);
            }
        }
    private async void AppBarButton_Click_OpenLocalFile3(object sender, RoutedEventArgs e)
    {
        var picker = new Windows.Storage.Pickers.FileOpenPicker();

        foreach (var ext in BookManager.AvailableExtensionsArchive)
        {
            picker.FileTypeFilter.Add(ext);
        }
        var file = await picker.PickSingleFileAsync();

        if (file != null)
        {
            this.Frame.Navigate(typeof(BookFixed3Viewer), file);
        }
    }
        /// <inheritdoc />
        public async Task <IStorageFile> PickSingleFileAsync()
        {
            var picker = new Windows.Storage.Pickers.FileOpenPicker {
                ViewMode = PickerViewMode.List
            };

            foreach (var fileType in this.FileTypeFilter)
            {
                picker.FileTypeFilter.Add(fileType);
            }

            var file = await picker.PickSingleFileAsync();

            return(file == null ? null : new StorageFile(null, file));
        }
        private async void BtnOpenQRImage_ClickAsync(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");

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

            if (file != null)
            {
                using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read))
                {
                    BitmapDecoder decoder;
                    try
                    {
                        // Create the decoder from the stream
                        decoder = await BitmapDecoder.CreateAsync(stream);

                        // Get the SoftwareBitmap representation of the file
                        var softwareBitmap = await decoder.GetSoftwareBitmapAsync();

                        var QRcodeResult = barcodeManager.DecodeBarcodeImage(softwareBitmap);
                        handleQRcodeFound(QRcodeResult);
                    }
                    catch (Exception ex)
                    {
                        MessageDialog msgbox = new MessageDialog("An error occurred: " + ex.Message);
                    }
                }
            }
            else
            {
                MessageDialog msgbox = new MessageDialog("No file selected.");

                // Set the command that will be invoked by default
                msgbox.DefaultCommandIndex = 0;

                // Set the command to be invoked when escape is pressed
                msgbox.CancelCommandIndex = 1;

                // Show the message dialog
                await msgbox.ShowAsync();
            }
        }
        //Click event opens file picker and allows user to select an image
        //that will be displayed as playlist image.
        private async void CoverImage_Click(object sender, RoutedEventArgs e)
        {
            var ImagePicker = new Windows.Storage.Pickers.FileOpenPicker();

            string[] ImageTypes = new string[] { ".jpg", ".bmp", ".png", ".jpeg", ".jpg" };
            foreach (string ImageType in ImageTypes)
            {
                ImagePicker.FileTypeFilter.Add(ImageType);
            }
            ImagePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            ImagePicker.ViewMode = PickerViewMode.Thumbnail;
            StorageFile file = await ImagePicker.PickSingleFileAsync();

            imagePath = file.Path;
            imageName = file.Name;
        }
        async private System.Threading.Tasks.Task SetLocalMedia()
        {
            var openPicker = new Windows.Storage.Pickers.FileOpenPicker();

            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.FileTypeFilter.Add(".jpeg");
            openPicker.FileTypeFilter.Add(".bmp");
            openPicker.FileTypeFilter.Add(".png");

            var file = await openPicker.PickSingleFileAsync();

            // mediaPlayer is a MediaElement defined in XAML
            if (file != null)
            {
            }
        }
        /// <summary>
        /// Select_Image_Click allows user to select a an image using filepicker.
        /// Filepath is supposed to start at PicturesLibrary
        /// Image selected is then sent to mediaplayer.postersource on page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Select_Image_Click(object sender, RoutedEventArgs e)
        {
            var ImagePicker = new Windows.Storage.Pickers.FileOpenPicker();

            string[] ImageTypes = new string[] { ".jpg" };            //make a collection of all Pictures you want

            //Add your ImageTypes to the ImageTypeFilter list of ImagePicker.
            foreach (string ImageType in ImageTypes)
            {
                ImagePicker.FileTypeFilter.Add(ImageType);
            }

            //Set picker start location to the Saved Picture library
            ImagePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            ImagePicker.ViewMode = PickerViewMode.Thumbnail;

            // Filter to include a sample subset of file types.
            ImagePicker.FileTypeFilter.Clear();
            ImagePicker.FileTypeFilter.Add(".bmp");
            ImagePicker.FileTypeFilter.Add(".png");
            ImagePicker.FileTypeFilter.Add(".jpeg");
            ImagePicker.FileTypeFilter.Add(".jpg");

            //Retrieve file from picker
            StorageFile file = await ImagePicker.PickSingleFileAsync();

            if (file != null)
            {
                // Open a stream for the selected file.
                // The 'using' block ensures the stream is disposed
                // after the image is loaded.
                using (Windows.Storage.Streams.IRandomAccessStream fileStream =
                           await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
                {
                    // Set the image source to the selected bitmap.
                    Windows.UI.Xaml.Media.Imaging.BitmapImage bitmapImage =
                        new Windows.UI.Xaml.Media.Imaging.BitmapImage();

                    bitmapImage.SetSource(fileStream);
                    System.Diagnostics.Debug.WriteLine("bitmap");
                    //System.Diagnostics.Debug.WriteLine(bitmapImage.UriSource.ToString());
                    System.Diagnostics.Debug.WriteLine("bitmap");
                    _mediaPlayer.PosterSource = bitmapImage;
                    System.Diagnostics.Debug.WriteLine(_mediaPlayer.PosterSource.ToString());
                }
            }
        }
Beispiel #48
0
        public async void dodajSliku(Object o)
        {
            //naci kod u primjerima sa c2
            FileOpenPicker 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)
            {
                //uploadSlika = (await Windows.Storage.FileIO.ReadBufferAsync(file)).ToArray();
            }
        }
        private async void PickFile()
        {
            var picker = new Windows.Storage.Pickers.FileOpenPicker();

            picker.ViewMode = PickerViewMode.List;
            picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; // Todo: usb, cloud
            picker.FileTypeFilter.Add(".txt");

            StorageFile file = await picker.PickSingleFileAsync();

            if (file != null)
            {
                // Save only path relative to User Pictures folder
                string fileNameStr = file.Path.Substring(file.Path.IndexOf("Pictures") + ("Pictures").Length);
                dataSettings.Text = "Pictures," + fileNameStr;
            }
        }
Beispiel #50
0
        private async void btnBrowser_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker picker = new Windows.Storage.Pickers.FileOpenPicker();

            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add(".mp4");
            picker.FileTypeFilter.Add(".avi");
            picker.FileTypeFilter.Add(".wmv");
            StorageFile file = await picker.PickSingleFileAsync();

            if (file != null)
            {
                listfile.Add(file);
                listVideo.ItemsSource = listfile;
            }
        }
Beispiel #51
0
        public async void ButtonOpen(object sender, RoutedEventArgs e)
        {
            var picker = new Windows.Storage.Pickers.FileOpenPicker();

            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            picker.FileTypeFilter.Add("*");
            Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();

            texteditor editor = new texteditor();

            editor.Editorclass.Readfile(file, ref editor1.edit);
            editors.Add(editor);
            StorageFolder tempfold = await file.GetParentAsync();

            fileviewer1.setdirectory(tempfold);
        }
        private async void Button_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");

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


            using (Windows.Storage.Streams.IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
            {
                BitmapImage bitmapImage = new BitmapImage();
                await bitmapImage.SetSourceAsync(fileStream);

                SelectedImage.Source = bitmapImage;
            }

            var schnitzelDetector =
                new SchnitzelDetector("AKIAJFHV4ILY7OS5LALQ", "cmxRYkx/cNY2iyW5fvi3Hy8o3+RK8nPJcbehfJ34");


            try
            {
                IsLoading.Visibility = Visibility.Visible;
                ResultTb.Text        = "";
                var result = await schnitzelDetector.IsSchnitzel(file.Path, file.Name);

                if (result)
                {
                    ResultTb.Text = "It's a schnitzel!!";
                }
                else
                {
                    ResultTb.Text = "Nope, it's not a schnitzel";
                }
            }
            finally
            {
                IsLoading.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #53
0
        private async void Button_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");

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


            using (Windows.Storage.Streams.IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
            {
                BitmapImage bitmapImage = new BitmapImage();
                await bitmapImage.SetSourceAsync(fileStream);

                SelectedImage.Source = bitmapImage;
            }


            var compararfaces =
                new CompareFace("accessKey", "secretkey");


            try
            {
                IsLoading.Visibility = Visibility.Visible;
                ResultTb.Text        = "";
                var result = await compararfaces.MachFaces(file.Path, file.Name, NomePessoa.Text);

                if (result)
                {
                    ResultTb.Text = "Esta pessoa está cadastrada!";
                }
                else
                {
                    ResultTb.Text = "Esta pessoa não está cadastrada";
                }
            }
            finally
            {
                IsLoading.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #54
0
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var picker = new Windows.Storage.Pickers.FileOpenPicker();

            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.VideosLibrary;
            picker.FileTypeFilter.Add(".mp4");
            secondVideoFile = await picker.PickSingleFileAsync();

            txtfilename1.Text = secondVideoFile.DisplayName;
            txtfps1.Text      = await GetFileSize(secondVideoFile);

            txtsize.Text = secondVideoFile.FileType;
            if (secondVideoFile == null)
            {
                // rootPage.NotifyUser("File picking cancelled", NotifyType.ErrorMessage);
                return;
            }
            mediaElement.SetSource(await secondVideoFile.OpenReadAsync(), secondVideoFile.ContentType);
        }
Beispiel #55
0
        private async void MediaVideo_btnopen()
        {
            FileOpenPicker picker = new Windows.Storage.Pickers.FileOpenPicker();

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

            if (file != null)
            {
                mediaVideo.MediaPlay(await file.OpenAsync(FileAccessMode.Read), file.ContentType);
            }
            DispatcherTimer timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick    += Timer_Tick;
            timer.Start();
        }
        private async void PickImage_Click(object sender, RoutedEventArgs e)
#endif
        {
            FileOpenPicker picker = new Windows.Storage.Pickers.FileOpenPicker();

            picker.ViewMode = PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".png");
            picker.FileTypeFilter.Add(".gif");
            picker.CommitButtonText = "Copy";
#if WINDOWS_PHONE_APP
            picker.PickSingleFileAndContinue();
#else
            StorageFile file = await picker.PickSingleFileAsync();
            await CopyImageToLocalFolderAsync(file);
#endif
        }
        private async void BT_UfoCsvOpen_Click(object sender, RoutedEventArgs e)
        {
            var filePicker = new Windows.Storage.Pickers.FileOpenPicker();

            // 選択可能な拡張子を追加
            filePicker.FileTypeFilter.Add(".csv");

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

            if (file == null)
            {
                return;
            }

            TB_UfoCsvPath.Text = file.Path.ToString();
            sUfoCsvFile        = await GetCsvData(file);

            sUfoCsvRowIndex = 0;
        }
        private async void OpenButton_Click(object sender, RoutedEventArgs e)
        {
            // Open a text file.
            Windows.Storage.Pickers.FileOpenPicker open =
                new Windows.Storage.Pickers.FileOpenPicker();
            open.SuggestedStartLocation =
                Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            open.FileTypeFilter.Add(".rtf");

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

            if (file != null)
            {
                Windows.Storage.Streams.IRandomAccessStream randAccStream =
                    await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

                // Load the file into the Document property of the RichEditBox.
                editor.Document.LoadFromStream(Windows.UI.Text.TextSetOptions.FormatRtf, randAccStream);
            }
        }
Beispiel #59
0
        private async void playButton_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker mediaFilePicker = new Windows.Storage.Pickers.FileOpenPicker();

            mediaFilePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.VideosLibrary;

            mediaFilePicker.FileTypeFilter.Add(".wmv");
            mediaFilePicker.FileTypeFilter.Add(".mp4");

            StorageFile file = await mediaFilePicker.PickSingleFileAsync();

            var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

            mediaControl.SetSource(stream, file.ContentType);
            mediaControl.Visibility = Windows.UI.Xaml.Visibility.Visible;
            mediaControl.Play();

            //mediaControl.Source = new Uri("http://media.ch9.ms/ch9/b5a6/9b11ab16-bcc5-41b7-b727-a593951db5a6/kona_Source.wmv", UriKind.Absolute);
            //mediaControl.Play();
        }
Beispiel #60
0
        async private System.Threading.Tasks.Task SetLocalMedia()
        {
            var openPicker = new Windows.Storage.Pickers.FileOpenPicker();

            openPicker.FileTypeFilter.Add(".wma");
            openPicker.FileTypeFilter.Add(".mp3");

            var file = await openPicker.PickSingleFileAsync();

            // mediaPlayer is a MediaPlayerElement defined in XAML
            if (file != null)
            {
                var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

                slider.Visibility       = Windows.UI.Xaml.Visibility.Visible;
                mediaCommand.Visibility = Windows.UI.Xaml.Visibility.Visible;
                mediaPlayer.SetSource(stream, file.ContentType);
                mediaPlayer.Play();
            }
        }