コード例 #1
0
ファイル: SettingsPage.xaml.cs プロジェクト: Ansou1/C-Sharp
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            if (args.Files.Count > 0)
            {
                contentType = args.Files[0].ContentType;
                Stream requestStream = await args.Files[0].OpenStreamForReadAsync();
                byteArray = null;
                using (MemoryStream ms = new MemoryStream())
                {
                    await requestStream.CopyToAsync(ms);

                    byteArray = ms.ToArray();
                }
                StorageFile storageFile = args.Files[0];
                var         stream      = await storageFile.OpenAsync(FileAccessMode.Read);

                var bitmapImage = new BitmapImage();
                await bitmapImage.SetSourceAsync(stream);

                var decodeur = await BitmapDecoder.CreateAsync(stream);

                this.UserImage.Source = bitmapImage;
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Operation cancelled.");
            }
        }
コード例 #2
0
        private async void SoruEkle_Activated(CoreApplicationView sender, Windows.ApplicationModel.Activation.IActivatedEventArgs args)
        {
#if WINDOWS_PHONE_APP
            FileOpenPickerContinuationEventArgs param = args as FileOpenPickerContinuationEventArgs;

            if (param != null)
            {
                if (param.Files.Count == 0)
                {
                    return;
                }

                view.Activated -= SoruEkle_Activated;
                if (type == 1)
                {
                    resimfile1 = param.Files[0];
                    await Resim1Degistir(resimfile1);
                }
                else
                {
                    resimfile2 = param.Files[0];
                    await Resim2Degistir(resimfile2);
                }
            }
#endif
        }
コード例 #3
0
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            if ((args.ContinuationData["Operation"] as string) == "UpdateProfilePicture" &&
                args.Files != null &&
                args.Files.Count > 0)
            {
                StorageFile file = args.Files[0];

                if (file.Name.EndsWith(""))
                {
                    IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
                    /*BitmapImage bitmapImage = new BitmapImage();

                    bitmapImage.SetSource(fileStream.AsStream());
                    ProfilePic.Source = bitmapImage;*/
                    textbox.Text = fileStream.ToString();
                    byte[] buffer = new byte[500];
                    //var read = fileStream.ReadAsync(buffer, 0, 500);
                    /*byte[] result;
                    UnicodeEncoding uniencoding = new UnicodeEncoding();
                    using (FileStream SourceStream = File.Open(file.Name, FileMode.Open))
                    {
                        result = new byte[SourceStream.Length];
                        await SourceStream.ReadAsync(result, 0, (int)SourceStream.Length);
                    }

                    
                    MessageBox.Show(result.ToString());*/
                    //System.IO.Stream inputStream = fileStream.AsStream();
                }
            }
        }
コード例 #4
0
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            try
            {
                StorageFile file = args.Files[0];       // get picked filename
                myPath = args.Files[0].Path.ToString(); // show filename
                //Debug.WriteLine(args.Files[0].Path);
                if (file != null)
                {
                    // Open a stream for the selected file.
                    IRandomAccessStream fileStream = await file.OpenReadAsync();

                    // Set the image source to the selected bitmap.
                    bitmapImage = new BitmapImage();
                    bitmapImage.SetSource(fileStream);
                    imagePreivew.Source = bitmapImage;
                }
            }
            catch
            {
                Debug.WriteLine("enable to get content from the file picker");
            }

            //second method :

            //Windows.Storage.FileProperties.StorageItemThumbnail thumb = await args.Files[0].GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.ListView, 49);
            //BitmapImage tmpbmp = new BitmapImage();
            //tmpbmp.SetSource(thumb);
            //imagePreivew.Source = tmpbmp;
        }
        // For picture
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            if ((args.ContinuationData["EntityImage"] as string) == "EntityImage" && args.Files != null && args.Files.Count > 0)
            {
                // Check if the entity has entityimage anyway.
                var imageField = fields.Where(x => x.FieldMetadata.LogicalName == "entityimage").FirstOrDefault();
                if (imageField != null)
                {
                    StorageFile file = args.Files[0];
                    IRandomAccessStreamWithContentType fileStream = await file.OpenReadAsync();

                    BitmapImage im = new BitmapImage();
                    im.SetSource(fileStream);
                    fileStream.Seek(0);
                    byte[] fileBytes = null;
                    fileBytes = new byte[fileStream.Size];
                    using (DataReader reader = new DataReader(fileStream))
                    {
                        await reader.LoadAsync((uint)fileStream.Size);

                        reader.ReadBytes(fileBytes);
                    }

                    imageField.FieldData = fileBytes;
                    ((this.CRMRecordModify.lvFields.Items.First() as Grid).Children[1] as EntityImageControl).ImageBytes = fileBytes;
                }
                return;
            }
        }
コード例 #6
0
        private async void viewActivated(CoreApplicationView sender, IActivatedEventArgs args)
        {
            FileOpenPickerContinuationEventArgs arguments = args as FileOpenPickerContinuationEventArgs;

            if (arguments != null)
            {
                if (arguments.Files.Count == 0)
                {
                    return;
                }

                view.Activated += viewActivated;
                storageFile     = arguments.Files[0];
                bool validFile = await App.GetContentFromStorageFile(storageFile);

                if (!validFile)
                {
                    var messageDialog = new MessageDialog("Das Dokument hatte entweder ein falsches Format oder enthielt Fehler. Ein Import kann erneut versucht werden und die Applikation wird geschlossen.", "Fehlerhafter Import");
                    messageDialog.Commands.Add(new UICommand("Ok"));
                    await messageDialog.ShowAsync();
                }
                else
                {
                    LocalStorage.SaveSetting("lastFileName", storageFile.Name);
                    App.importedPdfFile = storageFile;
                    Frame.Navigate(typeof(PdfView));
                }
            }
        }
コード例 #7
0
        protected override void OnActivated(IActivatedEventArgs args)
        {
            Activated();

            var continuationEventArgs = args as IContinuationActivatedEventArgs;

            if (continuationEventArgs != null)
            {
                switch (continuationEventArgs.Kind)
                {
                case ActivationKind.PickFileContinuation:
                    FileOpenPickerContinuationEventArgs arguments = continuationEventArgs as FileOpenPickerContinuationEventArgs;

                    Frame frame = (Frame)Window.Current.Content;

                    MainPage nainPage = frame.Content as MainPage;

                    if (nainPage != null)
                    {
                        nainPage.FilePicked(arguments.Files.ToList());
                    }

                    break;
                }
            }

            base.OnActivated(args);
        }
コード例 #8
0
ファイル: MainPage.xaml.cs プロジェクト: jm991/Helios
        /// <summary>
        /// Handle the returned files from file picker
        /// This method is triggered by ContinuationManager based on ActivationKind
        /// </summary>
        /// <param name="args">File open picker continuation activation argment. It cantains the list of files user selected with file open picker </param>
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            if (args.Files.Count > 0)
            {
                Debug.WriteLine("Picked video: " + args.Files[0].Name);
                MediaLoaded = true;

                m_clip = await MediaClip.CreateFromFileAsync(args.Files[0]);
                m_composition = new MediaComposition();
                m_composition.Clips.Add(m_clip);

                // Update the sliders to represent the duration in milliseconds
                // TODO: move this databinding
                TrimStart.Maximum = m_clip.OriginalDuration.TotalMilliseconds;
                TrimEnd.Maximum = m_clip.OriginalDuration.TotalMilliseconds;
                TrimEnd.Value = TrimEnd.Maximum;

                //// Set up the MediaElement for preview
                // TODO: pass in the preview streamsource and grab the screensize to determine this in addition to the aspect ratio of the video
                MediaElement.SetMediaStreamSource(m_composition.GenerateMediaStreamSource());
            }
            else
            {
                Debug.WriteLine("Operation cancelled.");
            }
        }
コード例 #9
0
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            if ((args.ContinuationData["Operation"] as string) == "ImageChat" && args.Files != null && args.Files.Count > 0)
            {
                StorageFile inFile = args.Files[0];



                MessageModel message1  = new MessageModel();
                string       imagePath = await HttpPostSignleImage.HttpPost(inFile);

                message1.type    = 2;
                message1.msg     = imagePath;
                message1.toPhone = User.uid;
                message1.myImage = Config.UserImage;
                message1.myPhone = Config.UserPhone;
                message1.myName  = Config.UserName;
                message1.myDream = Config.UserDream;
                message1.toImage = User.image;
                message1.time    = HelpMethods.GetTimeNow();
                messageList.Add(message1);

                if (myChat.Items.Count > 0)
                {
                    myChat.ScrollIntoView(myChat.Items.Last(), ScrollIntoViewAlignment.Leading);
                }

                string messageJSON = JsonConvert.SerializeObject(message1);
                SocKetHelp.socket.Emit("chat", messageJSON);
                DbService.Current.Add(message1);
            }
        }
コード例 #10
0
ファイル: App.xaml.cs プロジェクト: jc-150461/SQLIteListView
        protected async override void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            IContinuationActivatedEventArgs continuationArgs = args as IContinuationActivatedEventArgs;

            if (continuationArgs != null &&
                continuationArgs.Kind == ActivationKind.PickFileContinuation)
            {
                FileOpenPickerContinuationEventArgs pickerArgs = args as FileOpenPickerContinuationEventArgs;

                if (pickerArgs.Files.Count > 0)
                {
                    // Get the file and a Stream
                    StorageFile storageFile = pickerArgs.Files[0];
                    IRandomAccessStreamWithContentType raStream = await storageFile.OpenReadAsync();

                    Stream stream = raStream.AsStreamForRead();

                    // Set the completion of the Task
                    TaskCompletionSource.SetResult(stream);
                }
                else
                {
                    TaskCompletionSource.SetResult(null);
                }
            }
        }
コード例 #11
0
        public async void view_Activated(CoreApplicationView sender, Windows.ApplicationModel.Activation.IActivatedEventArgs args1)
        {
            FileOpenPickerContinuationEventArgs args = args1 as FileOpenPickerContinuationEventArgs;


            if (args != null)
            {
                if (args.Files.Count == 0)
                {
                    return;
                }

                view.Activated -= view_Activated;
                StorageFile storfile = args.Files[0];
                var         stream   = await storfile.OpenAsync(Windows.Storage.FileAccessMode.Read);

                var bitmapImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
                await bitmapImage.SetSourceAsync(stream);

                var decoder = await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream);

                ImageName         = storfile.Name;
                btimg.ImageSource = bitmapImage;
                image.Content     = "";
            }
        }
コード例 #12
0
ファイル: App.xaml.cs プロジェクト: SamirHafez/Nutrition
        protected async override void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            var continuationEventArgs = args as IContinuationActivatedEventArgs;

            if (continuationEventArgs != null)
            {
                switch (continuationEventArgs.Kind)
                {
                case ActivationKind.PickFileContinuation:
                    FileOpenPickerContinuationEventArgs arguments = continuationEventArgs as FileOpenPickerContinuationEventArgs;
                    StorageFile file      = arguments.Files.FirstOrDefault();
                    var         messenger = Mvx.Resolve <IMvxMessenger>();

                    using (var imgStream = await file.OpenAsync(FileAccessMode.Read))
                    {
                        var buffer = new byte[imgStream.Size];
                        await imgStream.ReadAsync(buffer.AsBuffer(), (uint)imgStream.Size, InputStreamOptions.None);

                        var properties = await file.Properties.GetImagePropertiesAsync();

                        var message = new PictureMessage(this)
                        {
                            Width   = properties.Width,
                            Height  = properties.Height,
                            Picture = buffer
                        };
                        messenger.Publish(message);
                    }
                    break;
                }
            }
        }
コード例 #13
0
 /// <summary>
 /// Implements IFileOpenPickerContinuable. This method is marked async but cannot be awaited
 /// by the caller and does not follow the "Async" naming convention.  It is intended to be
 /// called in a "fire and forget" manner.
 /// </summary>
 /// <param name="args">Contains the file(s) returned by the continuable file picker.</param>
 public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
 {
     if (args.Files.Count != 0)
     {
         await LoadFileAsync(args.Files[0]);
     }
 }
コード例 #14
0
ファイル: MainViewModel.cs プロジェクト: jm991/HeliosApp
        /// <summary>
        /// Handle the returned files from file picker
        /// This method is triggered by ContinuationManager based on ActivationKind
        /// </summary>
        /// <param name="args">File open picker continuation activation argment. It cantains the list of files user selected with file open picker </param>
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            //if (args.Files.Count > 0)
            //{
            //    await LoadFile(args.Files[0]);
            //}
            //else
            //{
            //    Debug.WriteLine("Operation cancelled.");
            //}

            IReadOnlyList <StorageFile> files = args.Files;

            if (files.Count > 0)
            {
                StringBuilder output = new StringBuilder("Picked files:\n");
                // Application now has read/write access to the picked file(s)
                foreach (StorageFile file in files)
                {
                    output.Append(file.Name + "\n");
                    await LoadFile(file);
                }
                Debug.WriteLine(output.ToString());
                MediaLoaded = true;


                // Set up the MSS for the MediaElement to bind to for preview
                // TODO: pass in the preview streamsource and grab the screensize to determine this in addition to the aspect ratio of the video
                MediaSource = m_composition.GenerateMediaStreamSource();
            }
            else
            {
                Debug.WriteLine("Operation cancelled.");
            }
        }
コード例 #15
0
        private async void SoruDetay_Activated(CoreApplicationView sender, Windows.ApplicationModel.Activation.IActivatedEventArgs args)
        {
#if WINDOWS_PHONE_APP
            FileOpenPickerContinuationEventArgs param = args as FileOpenPickerContinuationEventArgs;

            if (param != null)
            {
                if (param.Files.Count == 0)
                {
                    return;
                }
                view.Activated -= SoruDetay_Activated;
                file            = param.Files[0];
                if (file != null)
                {
                    var data = await FileHelper.ReadFile(file);

                    var result = await App.APIService.ResimGuncelle(data, file.Name);

                    if (result != null)
                    {
                        await Mesaj.MesajGoster(result.Mesaj);
                    }
                }
            }
#endif
        }
コード例 #16
0
ファイル: EditPage.xaml.cs プロジェクト: Gluco/AwfulMetro
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs fileOpenPickerContinuationEventArgs)
        {
            if (fileOpenPickerContinuationEventArgs.Files == null) return;
            var file = fileOpenPickerContinuationEventArgs.Files.First();
            if (file == null) return;
            LoadingProgressBar.Visibility = Visibility.Visible;
            IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read);
            ImgurEntity result = null;
            try
            {
                result = await UploadManager.UploadImgur(stream);
            }
            catch (Exception)
            {
                
                Debug.WriteLine("Error with Imgur *SHOCK*");
            }
            if (result == null)
            {
                var msgDlg = new MessageDialog("Something went wrong with the upload. My heart bleeds for you.");
                msgDlg.ShowAsync();
                LoadingProgressBar.Visibility = Visibility.Collapsed;
                return;
            }

            // We have got an image up on Imgur! Time to get it into the reply box!

            string imgLink = string.Format("[TIMG]{0}[/TIMG]", result.data.link);
            ReplyTextBox.Text = ReplyTextBox.Text.Insert(ReplyTextBox.Text.Length, imgLink);
            LoadingProgressBar.Visibility = Visibility.Collapsed;
        }
コード例 #17
0
        /// <summary>
        /// 选择背景图片后的一些处理
        /// </summary>
        private async void CheckOpenPickerToDoWhat()
        {
            if (PublicS.commandArgs_PickFile == null)
            {
                return;
            }
            FileOpenPickerContinuationEventArgs commandArgs_PickFile_thisone = PublicS.commandArgs_PickFile;

            PublicS.commandArgs_PickFile = null;
            if ((commandArgs_PickFile_thisone.ContinuationData["Operation"] as string) == "bjtp" &&
                commandArgs_PickFile_thisone.Files.Count > 0)
            {
                StorageFile         file       = commandArgs_PickFile_thisone.Files[0];
                IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

                IStorageFolder ISF = ApplicationData.Current.LocalFolder;
                await file.CopyAsync(ISF, "mybg.png", NameCollisionOption.ReplaceExisting);

                BitmapImage bitmapImage = new BitmapImage();
                bitmapImage.SetSource(fileStream);
                ImageBrush ib = new ImageBrush();
                ib.Stretch      = Stretch.UniformToFill;
                ib.ImageSource  = bitmapImage;
                this.Background = ib;
            }
        }
コード例 #18
0
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            if (args.Files.Count > 0)
            {
                StartProcessing();
                try
                {
                    SetProgressString(App.Localizer.GetString("Copying"));
                    string key = await ChmFile.SetupChmFileFromPhone(args.Files[0]);

                    if (key == null) // failed
                    {
                        MessageDialog msg = new MessageDialog(string.Format(App.Localizer.GetString("InvalidFile"), args.Files[0].Path));
                        await msg.ShowAsync();
                    }
                    else
                    {
                        Frame.Navigate(typeof(ReadingPage), key);
                    }
                }
                finally
                {
                    StopProcessing();
                }
            }
        }
コード例 #19
0
        private async void viewActivated(CoreApplicationView sender, IActivatedEventArgs args1)
        {
            FileOpenPickerContinuationEventArgs args = args1 as FileOpenPickerContinuationEventArgs;

            if (args != null)
            {
                if (args.Files.Count == 0)
                {
                    return;
                }

                _view.Activated -= viewActivated;
                var storageFile = args.Files[0];
                var stream      = await storageFile.OpenAsync(FileAccessMode.Read);

                stream.Seek(0);

                using (var r = new BinaryReader(stream.AsStream()))
                {
                    var bytes = r.ReadBytes((int)stream.Size);

                    await ProcessImage(bytes);
                }
                //
                //                var decoder = await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream);
                //                img.Source = bitmapImage;
            }
        }
コード例 #20
0
        private void OnViewActivated(CoreApplicationView sender, IActivatedEventArgs args1)
        {
            FileOpenPickerContinuationEventArgs args = args1 as FileOpenPickerContinuationEventArgs;

            if (args != null)
            {
                if (args.Files.Count == 0)
                {
                    return;
                }

                StorageFile file = args.Files[0];

                foreach (ReportPhoto photo in photos)
                {
                    if (file.Path.Equals(photo.FilePath))
                    {
                        return;
                    }
                }
                photos.Add(new ReportPhoto(file));
            }

            this.UpdateSendButtonAvaialbility();
            this.UpdateAddPhotoButtonAvailability();
        }
 private void OnFilePickerOpened(FileOpenPickerContinuationEventArgs e)
 {
     if (FilePickerOpened != null)
     {
         FilePickerOpened(this, e);
     }
 }
コード例 #22
0
ファイル: AudioPage.cs プロジェクト: Makzz90/VKClient_re
        protected override void HandleOnNavigatedTo(NavigationEventArgs e)
        {
            base.HandleOnNavigatedTo(e);
            if (!this._isInitialized)
            {
                if (this.CommonParameters.UserOrGroupId == 0L)
                {
                    this.CommonParameters.UserOrGroupId = AppGlobalStateManager.Current.LoggedInUserId;
                }
                this.Initialize();
                this.BuildAppBar();
                this.PerformInitialLoad();
                this.allAudio.IsInPickMode = this.CommonParameters.PickMode;
                this.UpdateAppBar();
                this._isInitialized = true;
            }
            this.ProcessInputParameters();
            CurrentMediaSource.AudioSource = this.CommonParameters.IsGroup ? StatisticsActionSource.audios_group : StatisticsActionSource.audios_user;
            FileOpenPickerContinuationEventArgs parameterForIdAndReset = ParametersRepository.GetParameterForIdAndReset("FilePicked") as FileOpenPickerContinuationEventArgs;

            if (parameterForIdAndReset == null || !((IEnumerable <StorageFile>)parameterForIdAndReset.Files).Any <StorageFile>())
            {
                return;
            }
            StorageFile file = ((IEnumerable <StorageFile>)parameterForIdAndReset.Files).First <StorageFile>();

            this.SkipNextNavigationParametersRepositoryClearing = true;
            Navigator.Current.NavigateToAddNewAudio(file);
        }
コード例 #23
0
        private async void viewActivated(CoreApplicationView sender, IActivatedEventArgs args1)
        {
            /*
             * Open camera and capture photos
             * Source: http://windowsapptutorials.com/windows-phone-8-1/media-windows-phone-8-1/using-fileopenpicker-in-windows-phone-8-1-to-choose-picture-from-picture-gallery/
             * */
            FileOpenPickerContinuationEventArgs args = args1 as FileOpenPickerContinuationEventArgs;

            if (args != null)
            {
                if (args.Files.Count == 0)
                {
                    return;
                }

                view.Activated -= viewActivated;
                storageFile     = args.Files[0];
                var stream = await storageFile.OpenAsync(Windows.Storage.FileAccessMode.Read);

                var bitmapImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
                await bitmapImage.SetSourceAsync(stream);

                var decoder = await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream);

                img.Source = bitmapImage;
            }
        }
コード例 #24
0
 public async void PickPhotosContiue(FileOpenPickerContinuationEventArgs args)
 {
     if (args.ContinuationData.ContainsKey(Continuation_Key_Operation) &&
         args.ContinuationData[Continuation_Key_Operation].ToString() == Continuation_OperationPage_PickPhotos)
     {
         CheckAndAddPhotos(args.Files);
     }
 }
コード例 #25
0
 public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
 {
     if (args.Files.Count != 0)
     {
         var file = args.Files[0];
         await uploadFile(file, selectedPeer);
     }
 }
コード例 #26
0
 public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
 {
     foreach (StorageFile pickedFile in args.Files)
     {
         await dfuSettingViewModel.SaveFile(pickedFile);
     }
     dfuSettingViewModel.ImageFileNames = dfuSettingViewModel.GetShortFileName();
 }
コード例 #27
0
 public void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
 {
     if (args.Files.Count > 0)
     {
         var pickedImage = args.Files[0];
         this.viewModel.Image = pickedImage;
     }
 }
コード例 #28
0
        async void view_Activated(CoreApplicationView sender, Windows.ApplicationModel.Activation.IActivatedEventArgs args)
        {
            string strEx = string.Empty;

            try
            {
                FileOpenPickerContinuationEventArgs result = args as FileOpenPickerContinuationEventArgs;
                if (result != null && result.Files.Any())
                {
                    m_StorageFile = result.Files.FirstOrDefault();
                    //var composition = new MediaComposition();
                    //composition.Clips.Add(await MediaClip.CreateFromFileAsync(result.Files.FirstOrDefault()));
                    //await composition.RenderToFileAsync(file);
                    var basicProperties = await result.Files.FirstOrDefault().GetBasicPropertiesAsync();

                    ImageProperties imgProp = await result.Files.FirstOrDefault().Properties.GetImagePropertiesAsync();

                    var savedPictureStream = await result.Files.FirstOrDefault().OpenAsync(FileAccessMode.Read);

                    Debug.WriteLine("Default size :  " + Calculatesize(savedPictureStream.Size));
                    var length = basicProperties.Size;
                    //string strLength = Calculatesize(length);
                    WriteableBitmap wb = new WriteableBitmap(1, 1);
                    await wb.SetSourceAsync(savedPictureStream);

                    using (var storageStream = await result.Files.FirstOrDefault().OpenAsync(FileAccessMode.Read))
                    {
                        var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, storageStream);

                        var pixelStream = wb.PixelBuffer.AsStream();
                        var pixels      = new byte[pixelStream.Length];
                        await pixelStream.ReadAsync(pixels, 0, pixels.Length);

                        encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Ignore, (uint)wb.PixelWidth, (uint)wb.PixelHeight, 48, 48, pixels);
                        await encoder.FlushAsync();
                    }
                    m_NewStorageFile = result.Files.FirstOrDefault();
                    //TSGServiceManager.uploadFile(strURL, dictHeader, result.Files.FirstOrDefault());
                    var thumb = await LoadVideoImageThumb(result.Files.FirstOrDefault());

                    //var thumb = new BitmapImage();
                    //var tt = await result.Files.FirstOrDefault().GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.MusicView, 200, ThumbnailOptions.UseCurrentScale);
                    //thumb.SetSource(tt);
                    imgUpload.Source = thumb;
                    imgTemp.Source   = wb;
                }
            }
            catch (Exception ex)
            {
                strEx = ex.ToString();
            }
            if (!string.IsNullOrEmpty(strEx))
            {
                MessageDialog msg = new MessageDialog(strEx);
                await msg.ShowAsync();
            }
        }
コード例 #29
0
        public void ContinueFileOpen(FileOpenPickerContinuationEventArgs args)
        {
            var file = args.Files.ElementAtOrDefault(0);

            if (file != null)
            {
                _jyUserFeedbackSdkManager.UploadPicture(Constants.Appkey, Constants.SecretId, file);
            }
        }
コード例 #30
0
        private void Application_ContractActivated(object sender, IActivatedEventArgs e)
        {
            var filePickerContinuationArgs = e as FileOpenPickerContinuationEventArgs;

            if (filePickerContinuationArgs != null)
            {
                this.FilePickerContinuationArgs = filePickerContinuationArgs;
            }
        }
コード例 #31
0
        internal void WinPhonePickedFile(FileOpenPickerContinuationEventArgs arguments)
        {
            var files = arguments.Files;

            foreach (var file in files)
            {
                DisplayFileName(file);
            }
        }
コード例 #32
0
        /// <summary>
        /// Handle the returned files from file picker
        /// This method is triggered by ContinuationManager based on ActivationKind
        /// </summary>
        /// <param name="args">File open picker continuation activation argment. It cantains the list of files user selected with file open picker </param>
        public void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            IReadOnlyList <StorageFile> files = args.Files;

            if (files.Count > 0)
            {
                m_files = files.ToList();
                this.Frame.Navigate(typeof(ImagesPage), m_files);
            }
        }
コード例 #33
0
 public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
 {
     foreach (StorageFile pickedFile in args.Files)
     {
         //FirmwareTypeEnum type;
         //if (Enum.TryParse(dfuSettingViewModel.SelectedDeviceFirmwareTypeName, out type))
         await dfuSettingViewModel.SaveFile(pickedFile);
     }
     dfuSettingViewModel.ImageFileNames = dfuSettingViewModel.GetShortFileName();
 }
コード例 #34
0
        public void PickFileContinuation(FileOpenPickerContinuationEventArgs args)
        {
            var file = args.Files.FirstOrDefault();
            if (file == null)
                return;

            StorageApplicationPermissions.FutureAccessList.Add(file);
            string uriString = new Uri(file.Path).AbsoluteUri;
            Images.Add(uriString);
            SelectedImage = uriString;
        }
コード例 #35
0
ファイル: MainPage.xaml.cs プロジェクト: kryz/Xamarin.Plugins
        public void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            if (args.Files.Count > 0)
            {
                var email = SamplesExtensions.BuildSampleEmail()
                    .WithAttachment(args.Files[0])
                    .Build();

                MessagingPlugin.EmailMessenger.SendSampleEmail(email);
            }
        }
 /// <summary>
 /// Handle the returned files from file picker
 /// This method is triggered by ContinuationManager based on ActivationKind
 /// </summary>
 /// <param name="args">File open picker continuation activation argment. It cantains the list of files user selected with file open picker </param>
 public void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
 {
     if (args.Files.Count > 0)
     {
         OutputTextBlock.Text = "Picked photo: " + args.Files[0].Name;
     }
     else
     {
         OutputTextBlock.Text = "Operation cancelled.";
     }
 }
コード例 #37
0
        // được gọi khi chọn được hình ảnh và chuyển lại vào page này
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            if (args.Files.Any() == true)
            {
                _imageViewModel.Path = args.Files.First().Path;
                imageView.Source     = await Util.LoadImage(args.Files.First());

                // set lại scale nhỏ nhất
                CaculateMinScale(true);
            }
        }
 /// <summary>
 /// Handle the returned files from file picker
 /// This method is triggered by ContinuationManager based on ActivationKind
 /// </summary>
 /// <param name="args">File open picker continuation activation argment. It cantains the list of files user selected with file open picker </param>
 public void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
 {
     if (args.Files.Count > 0)
     {
         OutputTextBlock.Text = "Picked photo: " + args.Files[0].Name;
     }
     else
     {
         OutputTextBlock.Text = "Operation cancelled.";
     }
 }
コード例 #39
0
        internal async void WinPhonePickedFile(FileOpenPickerContinuationEventArgs arguments)
        {
            var file = arguments.Files.FirstOrDefault();
            if (file == null)
            {
                return;
            }

            StorageApplicationPermissions.FutureAccessList.Add(file);
            await ListPermissions();
        }
コード例 #40
0
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            var file = args.Files.FirstOrDefault();
            if (file == null)
                return;

            if (!await ApplyFilterAsync(file))
                return;

            SaveButton.IsEnabled = true;
        }
コード例 #41
0
    public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
    {
      if (args.Files.Count > 0)
      {
        OutputTextBlock.Text = "Picked photo: " + args.Files[0].Name;

        BitmapImage img = new BitmapImage();
        img = await ImageHelpers.LoadImage( args.Files[0] );
        MyPicture.Source = img;

      }
    }
 /// <summary>
 /// Handle the returned files from file picker
 /// This method is triggered by ContinuationManager based on ActivationKind
 /// </summary>
 /// <param name="args">File open picker continuation activation argment. It cantains the list of files user selected with file open picker </param>
 public void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
 {
     if (args.Files.Count > 0)
     {
         StorageFile file = args.Files[0];
         fileToken = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(file);
         OutputFileButton.IsEnabled = true;
         OutputFileAsync(file);
     }
     else
     {
         rootPage.NotifyUser("Operation cancelled.", NotifyType.StatusMessage);
     }
 }
コード例 #43
0
 public void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
 {
     if ((args.ContinuationData["Operation"] as string) == "UpdateDatabase"
         && args.Files != null
         && args.Files.Count > 0)
     {
         ImportFromFile(args.Files[0]);
     }
     else if ((args.ContinuationData["Operation"] as string) == "ChooseBackgroundImage"
         && args.Files != null
         && args.Files.Count > 0)
     {
         ChooseBackgroundImage(args.Files[0]);
     }
 }
コード例 #44
0
        internal async void HandleFilePickerLaunch(FileOpenPickerContinuationEventArgs filePickerOpenArgs)
        {
            EditAlbum editAlbumDialog;

            if (filePickerOpenArgs.Files.Count > 0)
            {
                DebugHelper.Assert(new CallerInfo(), filePickerOpenArgs.Files.Count == 1);

                editAlbumDialog = new EditAlbum(Album, filePickerOpenArgs.Files[0]);
            }
            else
            {
                editAlbumDialog = new EditAlbum(Album);
            }

            await editAlbumDialog.ShowAsync();
        }
コード例 #45
0
 /// <summary>
 /// Handle the returned files from file picker
 /// This method is triggered by ContinuationManager based on ActivationKind
 /// </summary>
 /// <param name="args">File open picker continuation activation argment. It cantains the list of files user selected with file open picker </param>
 public void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
 {
     IReadOnlyList<StorageFile> files = args.Files;
     if (files.Count > 0)
     {
         StringBuilder output = new StringBuilder("Picked files:\n");
         // Application now has read/write access to the picked file(s)
         foreach (StorageFile file in files)
         {
             output.Append(file.Name + "\n");
         }
         OutputTextBlock.Text = output.ToString();
     }
     else
     {
         OutputTextBlock.Text = "Operation cancelled.";
     }
 }
コード例 #46
0
        /// <summary>
        /// Handle the returned files from file picker
        /// This method is triggered by ContinuationManager based on ActivationKind
        /// </summary>
        /// <param name="args">File open picker continuation activation argment. It cantains the list of files user selected with file open picker </param>
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            if (args.Files.Count > 0)
            {
                StorageFile file = args.Files[0];

                BitmapImage bitmapImage = new BitmapImage();
                using (IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.Read))
                {
                    bitmapImage.SetSource(fileStream);
                }
                Image.Source = bitmapImage;
            }
            else
            {
                this.Frame.GoBack();
            }
        }
コード例 #47
0
        private static void ContinuationFileOpenPicker(Page page, FileOpenPickerContinuationEventArgs e)
        {
            if (page == null) return;
            if (e == null) return;

            var operation = (string)e.ContinuationData["Operation"];

            var pickPhotoAction = page
                .FindAction<PickPhotoAction>(x => x.OperationName == operation);

            if (pickPhotoAction == null || pickPhotoAction.CallbackCommand == null) return;

            var photo = e.Files.SingleOrDefault();

            if (pickPhotoAction.CallbackCommand.CanExecute(photo))
            {
                pickPhotoAction.CallbackCommand.Execute(photo);
            }
        }
コード例 #48
0
 public void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
 {
     
  new MessageDialog("gfgr").ShowAsync();
     IReadOnlyList<StorageFile> files = args.Files;
     if (files.Count > 0)
     {
      
         foreach (StorageFile file in files)
         {
             _uri=new Uri(file.Path);
         }
         
      
     }
     else
     {
       
     }
 }
コード例 #49
0
ファイル: UserData.xaml.cs プロジェクト: x01673/dreaming
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {


            if ((args.ContinuationData["Operation"] as string) == "Image" && args.Files != null && args.Files.Count > 0)
            {
             
                StorageFile inFile = args.Files[0];
                StorageFile imageFile = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFileAsync(inFile.Name, CreationCollisionOption.ReplaceExisting);
              
                var inStream = await inFile.OpenAsync(FileAccessMode.Read);
               
                var outStream = await imageFile.OpenAsync(FileAccessMode.ReadWrite);
                outStream.Size = 0;
                BitmapDecoder decoder = await BitmapDecoder.CreateAsync(inStream);
                PixelDataProvider provider = await decoder.GetPixelDataAsync();
                byte[] data = provider.DetachPixelData();
                var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, outStream);
                encoder.SetPixelData(decoder.BitmapPixelFormat, decoder.BitmapAlphaMode,
                                                   decoder.PixelWidth, decoder.PixelHeight,
                                                   decoder.DpiX, decoder.DpiY, data
                    );

                try
                {
                    await encoder.FlushAsync();

                    ((UserDataViewModel)DataContext).ImagePath = imageFile.Path;
             

                }
                catch (Exception err)
                {
                    Debug.WriteLine(err.ToString());
                }
                finally
                {

                }
            }
        }
コード例 #50
0
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            TreeMap.Children.Clear();
            var files = args.Files;
            var sources = new List<BitmapImage>();
            foreach (var file in files)
            {
                var stream = (await file.OpenStreamForReadAsync()).AsRandomAccessStream();//await file.GetScaledImageAsThumbnailAsync(ThumbnailMode.PicturesView, 300);
                var imageSource = new BitmapImage();
                await imageSource.SetSourceAsync(stream);

                sources.Add(imageSource);

                var image = new Image();
                image.Stretch = Stretch.UniformToFill;
                image.Source = imageSource;
                TreeMap.Children.Add(image);
            }

            MosaicImage.Source = sources;
        }
コード例 #51
0
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {

            Button1.Content = "fff";
            IReadOnlyList<StorageFile> files = args.Files;
            if (files.Count > 0)
            {
                StringBuilder output = new StringBuilder("Picked files:\n");
                // Application now has read/write access to the picked file(s)
                foreach (StorageFile file in files)
                {
                    Player.SetSource((await file.OpenAsync(FileAccessMode.Read)), "");
                }


            }
            else
            {

            }
        }
コード例 #52
0
        public void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            if ((args.ContinuationData["Operation"] as string) == "CompressFile" &&
                args.Files != null &&
                args.Files.Count > 0)
            {
                StorageFile file = args.Files[0];
                string algorithmRaw = args.ContinuationData["CompressAlgorithm"] as string;

                CompressAlgorithm? Algorithm;

                if (algorithmRaw == "")
                {
                    Algorithm = null;
                }
                else
                {
                    Algorithm = (CompressAlgorithm?)Enum.Parse(typeof(CompressAlgorithm), algorithmRaw);
                }   

                CompressFile(Algorithm, file);
            }
        }
コード例 #53
0
 public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
 {
     await ViewModel.ContinueFileOpenPickerAsync(args);
 }
コード例 #54
0
 public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
 {
     if (args.Files.Count > 0)
     {
         // Only pick 1 file.
         Windows.Storage.StorageFile file = args.Files[0];
         // Next, launch the file.
         bool success = await Windows.System.Launcher.LaunchFileAsync(file);
         if (success)
         {
             rootPage.NotifyUser("File launched: " + file.Name, NotifyType.StatusMessage);
         }
         else
         {
             rootPage.NotifyUser("File launch failed.", NotifyType.ErrorMessage);
         }
     }
     else
     {
         rootPage.NotifyUser("No file was picked.", NotifyType.ErrorMessage);
     }
 }
コード例 #55
0
        public void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            



            //var fileBuf = await file.OpenReadAsync();

            //Byte[] fileBytes = null;
            //Windows.Storage.Streams.IBuffer fileBytes = null;
            /*var fileBuf = await file.OpenReadAsync();
            uint filesize = Convert.ToUInt32(fileBuf.Size);
 
            var ms = fileBuf.ReadAsync(fileBytes, filesize, Windows.Storage.Streams.InputStreamOptions.None);*/
            //var ms = new MemoryStream(orgImageBuf, 0, orgImageBuf.Length, false);
            //currentApp.CurrentImageRecog = ms;
            //currentApp.CurrentRecogResult = String.Format("Image is of {0}B", orgImageBuf.Length);
            //Frame.Navigate(typeof(WindowsApp.Views.RecogResultPage));
            //Byte[] buf = ms.ToArray();
            //currentApp.CurrentRecogResult = await App.VMHub.ProcessRequest(buf);
            /* var currentApp = (App)App.Current;
            
            
             IReadOnlyList<StorageFile> files = args.Files;
            
             if (files.Count > 0)
             {
                 //using (IRandomAccessStream fileStream = await imageFile.OpenAsync(FileAccessMode.Read))
                 /*{
                     using (IInputStream outputStream = fileStream.GetInputStreamAt(0))
                     {
                         using (DataReader dataReader = new DataReader(outputStream))
                         {
                             Byte[] imageBytes = null;
                             dataReader.ReadBytes(imageBytes);
                             dataReader.DetachStream();
                            // currentApp.CurrentRecogResult = await App.VMHub.ProcessRequest(imageBytes);
                         }
                     }
                 }
             }
             else
             {
                 return ;
             }*/

        }
コード例 #56
0
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            try
            {


                StorageFile file = args.Files[0]; // get picked filename
                myPath = args.Files[0].Path.ToString(); // show filename
                //Debug.WriteLine(args.Files[0].Path);
                if (file != null)
                {
                    // Open a stream for the selected file.
                    IRandomAccessStream fileStream = await file.OpenReadAsync();

                    // Set the image source to the selected bitmap.
                    bitmapImage = new BitmapImage();
                    bitmapImage.SetSource(fileStream);
                    imagePreivew.Source = bitmapImage;
                }
            }
            catch
            {
                Debug.WriteLine("enable to get content from the file picker");
               
                
            }

            //second method :

            //Windows.Storage.FileProperties.StorageItemThumbnail thumb = await args.Files[0].GetScaledImageAsThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.ListView, 49);
            //BitmapImage tmpbmp = new BitmapImage();
            //tmpbmp.SetSource(thumb);
            //imagePreivew.Source = tmpbmp;



        }
コード例 #57
0
        // được gọi khi chọn được hình ảnh và chuyển lại vào page này
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            if (args.Files.Any() == true)
            {
                _imageViewModel.Path = args.Files.First().Path;
                imageView.Source = await Util.LoadImage(args.Files.First());

                // set lại scale nhỏ nhất
                CaculateMinScale(true);
            }
        }
コード例 #58
0
	public void OnFilePickerOpened(FileOpenPickerContinuationEventArgs e)
	{
		if (FilePickerOpened != null)
			FilePickerOpened(this, e);
	}
コード例 #59
0
 public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
 {
     await CopyImageToLocalFolderAsync(args.Files[0]);
 }
コード例 #60
0
ファイル: PivotPage.xaml.cs プロジェクト: OlaSojka/App3
 public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
 {
     if (args.Files.Count > 0)
     {
         XmlReader xmlReader = XmlReader.Create("test.xml", new XmlReaderSettings()); // args.Files[0].Name zamiast chestpain.xml
         XmlSerializer x = new XmlSerializer(typeof(ExpertSystem), "http://tempuri.org/XMLSchema.xsd");
         ExpertSystem expertSystem = null;
         try
         {
             expertSystem = (ExpertSystem) x.Deserialize(xmlReader);
         }
         catch (Exception exception)
         {
             MessageDialog md1 = new MessageDialog("Invalid XML file");
             await md1.ShowAsync();
         }
         if (expertSystem != null)
         {
             MessageDialog md1 = new MessageDialog("Selected file" + args.Files[0].Name);
             await md1.ShowAsync();
             processFile(expertSystem.questions);
         }
     }
     else
     {
         MessageDialog md = new MessageDialog("Operation cancelled");
         await md.ShowAsync();
     }
 }