Ejemplo n.º 1
0
        public async void OpenImagePicker()
        {
            NotesPage.DisablePopupLightDismiss();

            FileOpenPicker picker = new FileOpenPicker();

            picker.ViewMode = PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;

            //image
            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".png");
            picker.FileTypeFilter.Add(".gif");

#if WINDOWS_PHONE_APP
            await Task.Delay(0);

            //open
            picker.PickMultipleFilesAndContinue();
#elif WINDOWS_UWP
            var files = await picker.PickMultipleFilesAsync();

            HandleImageFromFilePicker(files);
#endif
        }
Ejemplo n.º 2
0
        private void StartMultipartUpload_Click(object sender, RoutedEventArgs e)
        {
            // By default 'serverAddressField' is disabled and URI validation is not required. When enabling the text
            // box validating the URI is required since it was received from an untrusted source (user input).
            // The URI is validated by calling Uri.TryCreate() that will return 'false' for strings that are not valid URIs.
            // Note that when enabling the text box users may provide URIs to machines on the intrAnet that require
            // the "Home or Work Networking" capability.
            Uri uri;

            if (!Uri.TryCreate(serverAddressField.Text.Trim(), UriKind.Absolute, out uri))
            {
                //NotifyUser("Invalid URI.", NotifyType.ErrorMessage);
                return;
            }

            FileOpenPicker picker = new FileOpenPicker();

            picker.FileTypeFilter.Add("*");

#if WINDOWS_PHONE_APP
            picker.ContinuationData.Add("uri", uri.OriginalString);
            picker.PickMultipleFilesAndContinue();
#else
            StartMultipleFilesUpload(picker, uri);
#endif
        }
Ejemplo n.º 3
0
        public static void SelectMultipleFiles()
        {
            try
            {
                var fileOpenPicker = new FileOpenPicker();

                fileOpenPicker.ContinuationData["Operation"] = "SelectedFiles";

                // Use wildcard filter to start FileOpenPicker in location selection screen instead of
                // photo selection screen
                fileOpenPicker.FileTypeFilter.Add("*");
                fileOpenPicker.ViewMode = PickerViewMode.Thumbnail;

                fileOpenPicker.PickMultipleFilesAndContinue();
            }
            catch (Exception e)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    new CustomMessageDialog(
                        AppMessages.SelectFileFailed_Title,
                        String.Format(AppMessages.SelectFileFailed, e.Message),
                        App.AppInformation,
                        MessageDialogButtons.Ok).ShowDialog();
                });
            }
        }
Ejemplo n.º 4
0
        private void SelectFilesButton_Clicked(object sender, RoutedEventArgs e)
        {
            FileOpenPicker folderPicker = new FileOpenPicker();

            folderPicker.SuggestedStartLocation = PickerLocationId.Downloads;
            folderPicker.FileTypeFilter.Add(DeviceFirmwareUpdateSettingPageViewModel.ZipFile);
            folderPicker.PickMultipleFilesAndContinue();
        }
        public void OpenPhoto()
        {
            IsOpen = false;

            Execute.BeginOnUIThread(TimeSpan.FromSeconds(0.25), async() =>
            {
#if WP81
                var photoPickerSettings = IoC.Get <IStateService>().GetPhotoPickerSettings();
                if (photoPickerSettings != null && photoPickerSettings.External)
                {
                    var from = _contactEnabled ? "DialogDetailsView" : "SecretDialogDetailsView";

                    ((App)Application.Current).ChooseFileInfo = new ChooseFileInfo(DateTime.Now);
                    var fileOpenPicker = new FileOpenPicker();
                    fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                    fileOpenPicker.ViewMode = PickerViewMode.Thumbnail;
                    fileOpenPicker.FileTypeFilter.Clear();
                    fileOpenPicker.FileTypeFilter.Add(".bmp");
                    fileOpenPicker.FileTypeFilter.Add(".png");
                    fileOpenPicker.FileTypeFilter.Add(".jpeg");
                    fileOpenPicker.FileTypeFilter.Add(".jpg");
                    fileOpenPicker.ContinuationData.Add("From", from);
                    fileOpenPicker.ContinuationData.Add("Type", "Image");

                    if (Environment.OSVersion.Version.Major >= 10)
                    {
                        var result = await fileOpenPicker.PickMultipleFilesAsync();
                        if (result.Count > 0)
                        {
                            Execute.BeginOnThreadPool(() =>
                            {
                                _sendPhotosAction.SafeInvoke(result);
                            });
                        }
                    }
                    else
                    {
                        fileOpenPicker.PickMultipleFilesAndContinue();
                    }
                }
                else
                {
                    OpenPhotoPicker(false, (r1, r2) => _sendPhotosAction.SafeInvoke(r1));
                }
#else
                ((App)Application.Current).ChooseFileInfo = new ChooseFileInfo(DateTime.Now);
                var task = new PhotoChooserTask {
                    ShowCamera = true
                };
                task.Completed += (o, e) => Handle(_stateService, e.ChosenPhoto, e.OriginalFileName);
                task.Show();
#endif
            });
        }
Ejemplo n.º 6
0
        //this method is ONLY used by the PickPhoto button, not for the initial photo picking under multi mode
        private void PickPhotos()
        {
            var picker = new FileOpenPicker();

            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".png");
            picker.FileTypeFilter.Add(".gif");
            picker.FileTypeFilter.Add(".bmp");
            picker.ContinuationData[Continuation_Key_Operation] = Continuation_OperationPage_PickPhotos;
            picker.PickMultipleFilesAndContinue();
        }
Ejemplo n.º 7
0
        private void picker_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker openPicker = new FileOpenPicker();

            openPicker.ViewMode = PickerViewMode.Thumbnail;
            openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.FileTypeFilter.Add(".jpeg");
            openPicker.FileTypeFilter.Add(".png");
            openPicker.ContinuationData["Operation"] = "UpdateProfilePicture";
            openPicker.PickMultipleFilesAndContinue();
        }
Ejemplo n.º 8
0
        }//capture frames with camera

        private void imagesSourceButton_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker imagesPicker = new FileOpenPicker();

            imagesPicker.ViewMode = PickerViewMode.Thumbnail;
            imagesPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            imagesPicker.FileTypeFilter.Add(".bmp");
            imagesPicker.FileTypeFilter.Add(".jpg");
            imagesPicker.FileTypeFilter.Add(".png");
            fileKindIsPhoto = true;
            imagesPicker.PickMultipleFilesAndContinue();
        }//select images
Ejemplo n.º 9
0
        private void image_Click(object sender, RoutedEventArgs e)
        {
            isPicure           = true;
            Config.pictrueType = 1;
            image.IsEnabled    = false;
            FileOpenPicker openPicker = new FileOpenPicker();

            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.FileTypeFilter.Add(".png");
            openPicker.ContinuationData["Operation"] = "ImageWeibo";
            openPicker.PickMultipleFilesAndContinue();
        }
        private void PickFilesButton_Click(object sender, RoutedEventArgs e)
        {
            // Clear any previously returned files between iterations of this scenario
            OutputTextBlock.Text = "";

            FileOpenPicker openPicker = new FileOpenPicker();

            openPicker.ViewMode = PickerViewMode.List;
            openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            openPicker.FileTypeFilter.Add("*");

            openPicker.PickMultipleFilesAndContinue();
        }
Ejemplo n.º 11
0
        private void PickPhotoBtn_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker openPicker = new FileOpenPicker();

            openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            openPicker.ViewMode = PickerViewMode.Thumbnail;

            // Filter to include a sample subset of file types
            openPicker.FileTypeFilter.Clear();
            openPicker.FileTypeFilter.Add(".jpeg");
            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.PickMultipleFilesAndContinue();
            view.Activated += ContinueFileOpen;
        }
        private void ImageBtn_Click(object sender, RoutedEventArgs e)
        {
            if (m_files.Count != 0)
            {
                m_files.Clear();
            }
            statusText.Text = "";
            FileOpenPicker openPicker = new FileOpenPicker();

            openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            openPicker.ViewMode = PickerViewMode.Thumbnail;
            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.FileTypeFilter.Add(".png");
            openPicker.FileTypeFilter.Add(".bmp");
            openPicker.PickMultipleFilesAndContinue();
        }
Ejemplo n.º 13
0
        private void OpenFile()
        {
            FileOpenPicker openPicker = new FileOpenPicker();

            openPicker.ViewMode = PickerViewMode.List;
            openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            foreach (string extension in handledExtensions)
            {
                openPicker.FileTypeFilter.Add(extension);
            }

            // Store this instance as the last caller of the continuation code
            ((App)(App.Current)).PickerCaller = this;

            // Launch file open picker and caller app is suspended and may be terminated if required
            openPicker.PickMultipleFilesAndContinue();
        }
Ejemplo n.º 14
0
        private void PickPhotos(bool single)
        {
            var picker = new FileOpenPicker();

            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".png");
            picker.FileTypeFilter.Add(".gif");
            picker.FileTypeFilter.Add(".bmp");
            if (single)
            {
                picker.ContinuationData[Continuation_Key_Operation] = Continuation_HomePage_PickPhotoSingle;
                picker.PickSingleFileAndContinue();
            }
            else
            {
                picker.ContinuationData[Continuation_Key_Operation] = Continuation_HomePage_PickPhotoMulti;
                picker.PickMultipleFilesAndContinue();
            }
        }
Ejemplo n.º 15
0
        private async void LoadMultipleFilesButtonClick(object sender, RoutedEventArgs e)
        {
            var picker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.List,
                SuggestedStartLocation = PickerLocationId.Desktop,
                FileTypeFilter         = { "*" }
            };

#if WINDOWS_PHONE_APP
            picker.PickMultipleFilesAndContinue();
#elif WINDOWS_APP
            IReadOnlyList <StorageFile> files = await picker.PickMultipleFilesAsync();

            foreach (var file in files)
            {
                DisplayFileName(file);
            }
#endif
        }
        public async void PickPhoto()
        {
#if WP81
            var photoPickerSettings = IoC.Get <IStateService>().GetPhotoPickerSettings();
            if (photoPickerSettings != null && photoPickerSettings.External)
            {
                ((App)Application.Current).ChooseFileInfo = new ChooseFileInfo(DateTime.Now);
                var fileOpenPicker = new FileOpenPicker();
                fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                fileOpenPicker.ViewMode = PickerViewMode.Thumbnail;
                fileOpenPicker.FileTypeFilter.Clear();
                fileOpenPicker.FileTypeFilter.Add(".bmp");
                fileOpenPicker.FileTypeFilter.Add(".png");
                fileOpenPicker.FileTypeFilter.Add(".jpeg");
                fileOpenPicker.FileTypeFilter.Add(".jpg");
                fileOpenPicker.ContinuationData.Add("From", IsSecretChat ? "SecretDialogDetailsView" : "DialogDetailsView");
                fileOpenPicker.ContinuationData.Add("Type", "Image");
                if (Environment.OSVersion.Version.Major >= 10)
                {
                    var result = await fileOpenPicker.PickMultipleFilesAsync();

                    if (result.Count > 0)
                    {
                        Telegram.Api.Helpers.Execute.BeginOnThreadPool(() =>
                        {
                            _sendPhotosAction.SafeInvoke(result);
                        });
                    }
                }
                else
                {
                    fileOpenPicker.PickMultipleFilesAndContinue();
                }
            }
            else
            {
                ChooseAttachmentViewModel.OpenPhotoPicker(false, (r1, r2) => _sendPhotosAction(r1));
            }
#endif
        }
Ejemplo n.º 17
0
        private void OpenFiles( OpenFileInteraction interaction )
        {
            Contract.Requires( interaction != null );

            var saveButton = interaction.DefaultCommand;
            var dialog = new FileOpenPicker();

            dialog.ContinuationData.AddRange( interaction.ContinuationData );
            dialog.FileTypeFilter.AddRange( interaction.FileTypeFilter.FixUpExtensions() );
            dialog.SuggestedStartLocation = SuggestedStartLocation;
            dialog.ViewMode = ViewMode;

            if ( !string.IsNullOrEmpty( SettingsIdentifier ) )
                dialog.SettingsIdentifier = SettingsIdentifier;

            if ( saveButton != null )
                dialog.CommitButtonText = saveButton.Name;

            if ( interaction.Multiselect )
                dialog.PickMultipleFilesAndContinue();
            else
                dialog.PickSingleFileAndContinue();
        }
        public void SelectMessage(PhotoFile file)
        {
            if (file.IsButton)
            {
#if WP81
                ((App)Application.Current).ChooseFileInfo = new ChooseFileInfo(DateTime.Now);
                var fileOpenPicker = new FileOpenPicker();
                fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                fileOpenPicker.ViewMode = PickerViewMode.Thumbnail;
                fileOpenPicker.FileTypeFilter.Clear();
                fileOpenPicker.FileTypeFilter.Add(".bmp");
                fileOpenPicker.FileTypeFilter.Add(".png");
                fileOpenPicker.FileTypeFilter.Add(".jpeg");
                fileOpenPicker.FileTypeFilter.Add(".jpg");
                fileOpenPicker.ContinuationData.Add("From", "DialogDetailsView");
                fileOpenPicker.ContinuationData.Add("Type", "Image");
                fileOpenPicker.PickMultipleFilesAndContinue();
#endif
            }
            else
            {
                CurrentItem = file;
            }
        }
        public void OpenPhoto()
        {
            IsOpen = false;

            Execute.BeginOnUIThread(TimeSpan.FromSeconds(0.25), () =>
            {
                CheckDisabledFeature(_with,
                                     Constants.FeaturePMUploadPhoto,
                                     Constants.FeatureChatUploadPhoto,
                                     Constants.FeatureBigChatUploadPhoto,
                                     () =>
                {
#if WP81
                    if (_contactEnabled)
                    {
                        ((App)Application.Current).ChooseFileInfo = new ChooseFileInfo(DateTime.Now);
                        var fileOpenPicker = new FileOpenPicker();
                        fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                        fileOpenPicker.ViewMode = PickerViewMode.Thumbnail;
                        fileOpenPicker.FileTypeFilter.Clear();
                        fileOpenPicker.FileTypeFilter.Add(".bmp");
                        fileOpenPicker.FileTypeFilter.Add(".png");
                        fileOpenPicker.FileTypeFilter.Add(".jpeg");
                        fileOpenPicker.FileTypeFilter.Add(".jpg");
                        fileOpenPicker.ContinuationData.Add("From", "DialogDetailsView");
                        fileOpenPicker.ContinuationData.Add("Type", "Image");

#if MULTIPLE_PHOTOS
                        fileOpenPicker.PickMultipleFilesAndContinue();
#else
                        fileOpenPicker.PickSingleFileAndContinue();
#endif
                        //return;
                        //((App)Application.Current).ChooseFileInfo = new ChooseFileInfo(DateTime.Now);
                        //var task = new PhotoChooserTask { ShowCamera = true };
                        //task.Completed += (o, e) =>
                        //{
                        //    if (e.TaskResult != TaskResult.OK)
                        //    {
                        //        return;
                        //    }

                        //    Handle(_stateService, e.ChosenPhoto, e.OriginalFileName);
                        //};
                        //task.Show();
                    }
                    else
                    {
                        //((App)Application.Current).ChooseFileInfo = new ChooseFileInfo(DateTime.Now);
                        //var fileOpenPicker = new FileOpenPicker();
                        //fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                        //fileOpenPicker.ViewMode = PickerViewMode.Thumbnail;
                        //fileOpenPicker.FileTypeFilter.Clear();
                        //fileOpenPicker.FileTypeFilter.Add(".bmp");
                        //fileOpenPicker.FileTypeFilter.Add(".png");
                        //fileOpenPicker.FileTypeFilter.Add(".jpeg");
                        //fileOpenPicker.FileTypeFilter.Add(".jpg");
                        //fileOpenPicker.ContinuationData.Add("From", "SecretDialogDetailsView");
                        //fileOpenPicker.ContinuationData.Add("Type", "Image");
                        //fileOpenPicker.PickSingleFileAndContinue();
                        //return;
                        ((App)Application.Current).ChooseFileInfo = new ChooseFileInfo(DateTime.Now);
                        var task = new PhotoChooserTask {
                            ShowCamera = true
                        };
                        task.Completed += (o, e) =>
                        {
                            if (e.TaskResult != TaskResult.OK)
                            {
                                return;
                            }
                            Handle(_stateService, e.ChosenPhoto, e.OriginalFileName);
                        };
                        task.Show();
                    }
#else
                    ((App)Application.Current).ChooseFileInfo = new ChooseFileInfo(DateTime.Now);
                    var task = new PhotoChooserTask {
                        ShowCamera = true
                    };
                    task.Completed += (o, e) => Handle(_stateService, e.ChosenPhoto, e.OriginalFileName);
                    task.Show();
#endif
                });
            });
        }