Beispiel #1
0
 /// <summary>
 /// Implements IFileSavePickerContinuable. 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 ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
 {
     if (args.File != null)
     {
         await LoadSaveFileAsync(args.File);
     }
 }
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            // 由 SaveFilePicker 返回时执行。
            FileSavePickerContinuationEventArgs fileSavePickerContinuationEventArgs = args as FileSavePickerContinuationEventArgs;

            if (fileSavePickerContinuationEventArgs != null)
            {
                Frame rootFrame = Window.Current.Content as Frame;
                if (rootFrame != null)
                {
                    IContinueFileSave continueFileSave = rootFrame.Content as IContinueFileSave;
                    if (continueFileSave != null)
                    {
                        continueFileSave.ContinueFileSave(fileSavePickerContinuationEventArgs);
                    }
                }
            }

            // 确保程序运行。
            Window.Current.Activate();

            await UmengAnalytics.StartTrackAsync(appkey, "Marketplace");
        }
 /// <summary>
 /// Handle the returned file from file picker
 /// This method is triggered by ContinuationManager based on ActivationKind
 /// </summary>
 /// <param name="args">File save picker continuation activation argment. It cantains the file user selected with file save picker </param>
 public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
 {
     StorageFile file = args.File;
     if (file != null)
     {
         // Prevent updates to the remote version of the file until we finish making changes and call CompleteUpdatesAsync.
         CachedFileManager.DeferUpdates(file);
         // write to file
         await FileIO.WriteTextAsync(file, file.Name);
         // Let Windows know that we're finished changing the file so the other app can update the remote version of the file.
         // Completing updates may require Windows to ask for user input.
         FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file);
         if (status == FileUpdateStatus.Complete)
         {
             OutputTextBlock.Text = "File " + file.Name + " was saved.";
         }
         else
         {
             OutputTextBlock.Text = "File " + file.Name + " couldn't be saved.";
         }
     }
     else
     {
         OutputTextBlock.Text = "Operation cancelled.";
     }
 }
Beispiel #4
0
 public void OnFilePickerSaved(FileSavePickerContinuationEventArgs e)
 {
     if (FilePickerSaved != null)
     {
         FilePickerSaved(this, e);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Handle the returned file from file picker
        /// This method is triggered by ContinuationManager based on ActivationKind
        /// </summary>
        /// <param name="args">File save picker continuation activation argment. It cantains the file user selected with file save picker </param>
        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            StorageFile file = args.File;

            if (file != null)
            {
                // Prevent updates to the remote version of the file until we finish making changes and call CompleteUpdatesAsync.
                CachedFileManager.DeferUpdates(file);
                // write to file
                await FileIO.WriteTextAsync(file, file.Name);

                // Let Windows know that we're finished changing the file so the other app can update the remote version of the file.
                // Completing updates may require Windows to ask for user input.
                FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file);

                if (status == FileUpdateStatus.Complete)
                {
                    OutputTextBlock.Text = "File " + file.Name + " was saved.";
                }
                else
                {
                    OutputTextBlock.Text = "File " + file.Name + " couldn't be saved.";
                }
            }
            else
            {
                OutputTextBlock.Text = "Operation cancelled.";
            }
        }
Beispiel #6
0
        public async void ContinueFileSave(FileSavePickerContinuationEventArgs fileSavePickerContinuationEventArgs)
        {
            StorageFile file = fileSavePickerContinuationEventArgs.File;

            if (file != null)
            {
                await SaveFile(file);
            }
        }
        internal async void WinPhonePickedFile(FileSavePickerContinuationEventArgs arguments)
        {
            var file = arguments.File;
            if (file == null)
            {
                return;
            }

            await SaveTextFile(file);
        }
        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            if (args.File == null)
                return;

            if (!await SaveImageAsync(args.File))
                return;

            SaveButton.IsEnabled = true;
        }
Beispiel #9
0
        internal async void WinPhonePickedFile(FileSavePickerContinuationEventArgs arguments)
        {
            var file = arguments.File;

            if (file == null)
            {
                return;
            }

            await SaveTextFile(file);
        }
Beispiel #10
0
        public async void HandleFileSave(FileSavePickerContinuationEventArgs args)
        {
            if (args.File == null)
            {
                return;
            }

            Windows.Storage.CachedFileManager.DeferUpdates(args.File);
            await Windows.Storage.FileIO.WriteTextAsync(args.File, string.Join("\n\n", SavedCode));

            await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(args.File);
        }
Beispiel #11
0
        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            if (args.File == null)
            {
                return;
            }

            if (!await SaveImageAsync(args.File))
            {
                return;
            }

            SaveButton.IsEnabled = true;
        }
        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {

            await ViewModel.ContinueFileSavePickerAsync(args);
            if (args.File != null)
            {
                var rl = ResourceLoader.GetForCurrentView("Messages");
                string message = string.Format(rl.GetString("FileSavedFrmt"), args.File.Name);

                MessageDialog dlg = new MessageDialog(message, "Sport Camera");
                await dlg.ShowAsync();
            }

        }
 /// <summary>
 /// Handle the returned files from file picker
 /// This method is triggered by ContinuationManager based on ActivationKind
 /// </summary>
 /// <param name="args">File save picker continuation activation argment. It cantains the file user selected with file save picker </param>
 public void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
 {
     StorageFile file = args.File;
     if (file != null)
     {
         fileToken = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(file);
         MainPage.Current.NotifyUser(String.Format(@"Received file: {0}", file.Name), NotifyType.StatusMessage);
         WriteFileButton.IsEnabled = true;
     }
     else
     {
         MainPage.Current.NotifyUser("Operation cancelled.", NotifyType.StatusMessage); ;
     }
 }
Beispiel #14
0
        /// <summary>
        /// Handle the returned files from file picker
        /// This method is triggered by ContinuationManager based on ActivationKind
        /// </summary>
        /// <param name="args">File save picker continuation activation argment. It cantains the file user selected with file save picker </param>
        public void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            StorageFile file = args.File;

            if (file != null)
            {
                fileToken = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(file);
                MainPage.Current.NotifyUser(String.Format(@"Received file: {0}", file.Name), NotifyType.StatusMessage);
                WriteFileButton.IsEnabled = true;
            }
            else
            {
                MainPage.Current.NotifyUser("Operation cancelled.", NotifyType.StatusMessage);;
            }
        }
Beispiel #15
0
        public async void ContinueFileSavePickerAsync(FileSavePickerContinuationEventArgs args)
        {
            System.Diagnostics.Debug.WriteLine(DebugTag + "ContinueFileSavePicker()");
            bool        success = false;
            StorageFile file    = args.File;

            if (file != null && (args.ContinuationData["Operation"] as string) == SelectDestinationOperationName)
            {
                success = await SaveImageFileAsync(file);

                NameOfSavedFile = file.Name;
            }

            NotifySavedResult(success);
            App.ContinuationManager.MarkAsStale();
        }
Beispiel #16
0
        // For attachemnt to save and open
        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            if ((args.File != null))
            {
                // open existing file
                StorageFolder localFolder    = ApplicationData.Current.LocalFolder;
                StorageFile   noteAttachment = await localFolder.GetFileAsync(args.File.Name);

                // save to new location
                await FileIO.WriteBufferAsync(args.File, await FileIO.ReadBufferAsync(noteAttachment));

                // delete old one
                await CRMNotes.DeleteTemporaryData();

                // Then open
                await Launcher.LaunchFileAsync(args.File);
            }
        }
Beispiel #17
0
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(MainPage)))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            if (args.Kind == ActivationKind.PickSaveFileContinuation)
            {
                FileSavePickerContinuationEventArgs fileArgs = (FileSavePickerContinuationEventArgs)args;
                if (fileArgs.File != null)
                {
                    await SavedFile.CopyAndReplaceAsync(fileArgs.File);

                    await Task.Delay(500);

                    await new MessageDialog("Done!").ShowAsync();
                }
            }

            Window.Current.Activate();
        }
        private async void ExportSaveGameContinue(IContinuationActivatedEventArgs e)
        {
            // Returns if no target file was selected.
            FileSavePickerContinuationEventArgs args = e as FileSavePickerContinuationEventArgs;

            if (args == null || args.File == null)
            {
                return;
            }

            // Gets the source filename.
            string sourceFilename = args.ContinuationData.GetValueOrDefault <string>(ExportSavegameSourceFileKey);

            if (sourceFilename == null)
            {
                return;
            }

            // Copies the source file to the target file.
            StorageFile targetFile = args.File;

            try
            {
                using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    using (IsolatedStorageFileStream isfs = isf.OpenFile(sourceFilename, System.IO.FileMode.Open, System.IO.FileAccess.Read))
                    {
                        using (Stream outputStream = await targetFile.OpenStreamForWriteAsync())
                        {
                            await isfs.CopyToAsync(outputStream);
                        }
                    }
                }

                MessageBox.Show(String.Format("Export succeeded to {0}.", targetFile.Path), "Success", MessageBoxButton.OK);
            }
            catch (Exception ex)
            {
                DebugUtils.DumpException(ex, "Export savegame");
                MessageBox.Show(String.Format("Cannot export savegame to {0}. An error occured: {1}", targetFile.Path, ex.Message), "Error", MessageBoxButton.OK);
            }
        }
        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            if ((args.ContinuationData["Operation"] as string) == "ExportDatabase" && args.File != null)
            {
                StorageFile file = args.File;

                IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.ReadWrite);

                DataManager.ConnectToDatabase();
                String exportStatus = DataManager.ExportToFile(fileStream.AsStream());
                DataManager.CloseConnection();

                fileStream.Dispose();

                MessageBox.Show(exportStatus);
            }
            else
            {
                MessageBox.Show("Export fehlgeschlagen!");
            }
        }
Beispiel #20
0
        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            var file = args.File;

            if (file == null)
            {
                CurtainPrompt.ShowError("Backup cancelled.");
                return;
            }

            using (Insights.TrackTime("Create Backup"))
            {
                UiBlockerUtility.Block("Backing up (this may take a bit)...");

                App.Locator.SqlService.Dispose();
                App.Locator.BgSqlService.Dispose();

                try
                {
                    var data = await AutcpFormatHelper.CreateBackup(ApplicationData.Current.LocalFolder);

                    using (var stream = await file.OpenStreamForWriteAsync())
                    {
                        await stream.WriteAsync(data, 0, data.Length);
                    }
                }
                catch (Exception e)
                {
                    Insights.Report(e, "Where", "Creating Backup");
                    CurtainPrompt.ShowError("Problem creating backup.");
                }

                App.Locator.SqlService.Initialize();
                App.Locator.BgSqlService.Initialize();
                UiBlockerUtility.Unblock();
            }

            CurtainPrompt.Show("Backup completed.");
        }
	public void OnFilePickerSaved(FileSavePickerContinuationEventArgs e)
	{
		if (FilePickerSaved != null)
			FilePickerSaved(this, e);
	}
        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            var file = args.File;

            if (file == null)
            {
                CurtainPrompt.ShowError("Backup cancelled.");
                return;
            }

            using (Insights.TrackTime("Create Backup"))
            {
                UiBlockerUtility.Block("Backing up (this may take a bit)...");

                App.Locator.SqlService.Dispose();
                App.Locator.BgSqlService.Dispose();

                try
                {
                    var data = await AutcpFormatHelper.CreateBackup(ApplicationData.Current.LocalFolder);
                    using (var stream = await file.OpenStreamForWriteAsync())
                    {
                        await stream.WriteAsync(data, 0, data.Length);
                    }
                }
                catch (Exception e)
                {
                    Insights.Report(e, "Where", "Creating Backup");
                    CurtainPrompt.ShowError("Problem creating backup.");
                }

                App.Locator.SqlService.Initialize();
                App.Locator.BgSqlService.Initialize();
                UiBlockerUtility.Unblock();
            }

            CurtainPrompt.Show("Backup completed.");
        }
        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            // Show loader
            _mainPage.ShowLoader();

            MeasurementModel measurement = _mainPage.GlobalMeasurementModel.GetMeasurementById(this.MeasurementPageViewModel.MeasurementViewModel.Id);
            StorageFile file = args.File;
            if (file != null && measurement != null)
            {
                await System.Threading.Tasks.Task.Delay(500);
                _mainPage.ShowNotifyMessage(String.Format("Messung wird exportiert! Dies kann einige Zeit dauern."), NotifyLevel.Info);

                // Prevent updates to the remote version of the file until we finish making changes and call CompleteUpdatesAsync.
                CachedFileManager.DeferUpdates(file);

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                await ExportService.ExportSamplesAsync(file, measurement.Filename, new ExportSettingModel(true, true, true, true, true));
                stopwatch.Stop();
                Debug.WriteLine("Export data within: {0}", stopwatch.Elapsed.Duration());

                // Let Windows know that we're finished changing the file so the other app can update the remote version of the file.
                // Completing updates may require Windows to ask for user input.
                FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file);

                if (status == FileUpdateStatus.Complete)
                {
                    _mainPage.ShowNotifyMessage(String.Format("Messung wurde innerhalb von '{0:f4}' Sekunden exportiert.", 
                        stopwatch.Elapsed.Duration().TotalSeconds), NotifyLevel.Info);
                }
                else { _mainPage.ShowNotifyMessage("Messung konnte nicht exportiert werden.", NotifyLevel.Warn); }
            }
            else { _mainPage.ShowNotifyMessage("Exportiervorgang abgebrochen.", NotifyLevel.Warn); }
            // Hide loader
            _mainPage.HideLoader();
        }
        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            if ((args.ContinuationData["Operation"] as string) == "ExportDatabase" && args.File != null)
            {
                ExportToFile(args.File);
            }
            else
            {
                MessageDialog msg = new MessageDialog("Export fehlgeschlagen!");

                await msg.ShowAsync();
            }
        }
 /// <summary>
 /// Implements IFileSavePickerContinuable. 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 ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
 {
     if (args.File != null)
     {
         await LoadSaveFileAsync(args.File);
     }
 }
Beispiel #26
0
 // Code zur Ausführung bei der Rückgabe einer Vertragsaktivierung wie z. B. einem "Auswahlvertrag zum Öffnen von Dateien" oder einer Dateispeicherauswahl
 // mit der ausgewählten Datei oder anderen Rückgabewerten
 private void Application_ContractActivated(object sender, IActivatedEventArgs e)
 {
     if (e != null)
     {
         switch (e.Kind)
         {
             case ActivationKind.PickFileContinuation: FileOpenPickerContinuationArgs = e as FileOpenPickerContinuationEventArgs; break;
             case ActivationKind.PickSaveFileContinuation: FileSavePickerContinuationArgs = e as FileSavePickerContinuationEventArgs; break;
         }
     }
 }
 public void ContinueFileSave(FileSavePickerContinuationEventArgs fileSavePickerContinuationEventArgs)
 {
     // 交由 ViewModel 继续保存。
     ViewModel.ContinueFileSave(fileSavePickerContinuationEventArgs);
 }
        public async void ContinueFileSavePickerAsync(FileSavePickerContinuationEventArgs args)
        {
            System.Diagnostics.Debug.WriteLine(DebugTag + "ContinueFileSavePicker()");
            bool success = false;
            StorageFile file = args.File;

            if (file != null && (args.ContinuationData["Operation"] as string) == SelectDestinationOperationName)
            {
                success = await SaveImageFileAsync(file);
                NameOfSavedFile = file.Name;
            }

            NotifySavedResult(success);
            App.ContinuationManager.MarkAsStale();
        }
 public void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
 {
     FileManager.Instance.ContinueFileSavePickerAsync(args);
 }
        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            if ((args.ContinuationData["Operation"] as string) == "ExportDatabase" && args.File != null)
            {
                StorageFile file = args.File;

                IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.ReadWrite);

                DataManager.ConnectToLocalStorageDatabase();
                String exportStatus = DataManager.ExportToFile(fileStream);
                DataManager.CloseConnection();

                fileStream.Dispose();

                MessageBox.Show(exportStatus);
            }
            else
            {
                MessageBox.Show("Export fehlgeschlagen!");
            }

            exportDatabase = false;
        }
 public void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
 {
     FileManager.Instance.ContinueFileSavePickerAsync(args);
 }
        /// <summary>
        /// Handle the returned file from file picker
        /// This method is triggered by ContinuationManager based on ActivationKind
        /// </summary>
        /// <param name="args">File save picker continuation activation argment. It cantains the file user selected with file save picker </param>
        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            StorageFile videoFile = args.File;

            if (videoFile != null)
            {
                IRandomAccessStream videoStream = await videoFile.OpenAsync(FileAccessMode.ReadWrite);

                m_picture = new PictureWriter(videoStream, m_videoWidth, m_videoHeight);

                // Add frames to the video.
                ProcessVideoRing.IsActive = true;
                VideoElement.AreTransportControlsEnabled = false;
                ImageBtn.IsEnabled  = false;
                EncodeBtn.IsEnabled = false;
                statusText.Text     = "Encoding...";

                foreach (StorageFile file in m_files)
                {
                    Windows.Storage.FileProperties.ImageProperties properties = await file.Properties.GetImagePropertiesAsync();

                    float scaleOfWidth  = (float)m_videoWidth / properties.Width;
                    float scaleOfHeight = (float)m_videoHeight / properties.Height;
                    float scale         = scaleOfHeight > scaleOfWidth ?
                                          scaleOfWidth : scaleOfHeight;
                    uint width  = (uint)(properties.Width * scale);
                    uint height = (uint)(properties.Height * scale);

                    using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read))
                    {
                        for (int i = 0; i < 10; ++i)
                        {
                            BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream);

                            PixelDataProvider dataProvider = await decoder.GetPixelDataAsync(
                                BitmapPixelFormat.Bgra8,
                                BitmapAlphaMode.Straight,
                                new BitmapTransform { ScaledWidth = width, ScaledHeight = height },
                                ExifOrientationMode.RespectExifOrientation,
                                ColorManagementMode.ColorManageToSRgb);

                            m_picture.AddFrame(dataProvider.DetachPixelData(), (int)width, (int)height);
                        }
                    }
                }
                m_picture.Finalize();
                m_picture = null;

                VideoElement.AreTransportControlsEnabled = true;
                ImageBtn.IsEnabled        = true;
                EncodeBtn.IsEnabled       = true;
                statusText.Text           = "The image files are encoded successfully. You can review the video.";
                ProcessVideoRing.IsActive = false;

                videoStream.Dispose();
                videoStream = null;
                videoStream = await videoFile.OpenAsync(FileAccessMode.Read);

                VideoElement.SetSource(videoStream, videoFile.ContentType);
            }
        }