public void Activate(FileOpenPickerActivatedEventArgs args) { this.fileOpenPickerUI = args.FileOpenPickerUI; this.fileOpenPickerUI.FileRemoved += fileOpenPickerUI_FileRemoved; Window.Current.Content = this; Window.Current.Activate(); }
protected override void OnNavigatedTo(NavigationEventArgs e) { // 获取 FileOpenPickerUI 对象(从 App.xaml.cs 传来的) FileOpenPickerActivatedEventArgs args = (FileOpenPickerActivatedEventArgs)e.Parameter; _fileOpenPickerUI = args.FileOpenPickerUI; _fileOpenPickerUI.Title = "自定义文件打开选取器"; // 注意:选择的文件的扩展名必须匹配 AllowedFileTypes 中的定义(其是在调用端的 FileOpenPicker.FileTypeFilter 中配置的) IReadOnlyList <string> allowedFileTypes = _fileOpenPickerUI.AllowedFileTypes; lblMsg.Text = "allowedFileTypes: " + string.Join(",", allowedFileTypes); lblMsg.Text += Environment.NewLine; lblMsg.Text += "Kind: " + args.Kind; lblMsg.Text += Environment.NewLine; lblMsg.Text += "SplashScreen.ImageLocation: " + args.SplashScreen.ImageLocation; lblMsg.Text += Environment.NewLine; lblMsg.Text += "PreviousExecutionState: " + args.PreviousExecutionState; lblMsg.Text += Environment.NewLine; lblMsg.Text += "CallerPackageFamilyName: " + args.CallerPackageFamilyName; lblMsg.Text += Environment.NewLine; lblMsg.Text += "User.NonRoamableId: " + args.User.NonRoamableId; lblMsg.Text += Environment.NewLine; // _fileOpenPickerUI.Closing += _fileOpenPickerUI_Closing; base.OnNavigatedTo(e); }
public void Activate(FileOpenPickerActivatedEventArgs args) { _saving = false; _open_basket = args.FileOpenPickerUI; Window.Current.Content = this; Window.Current.Activate(); }
public FileOpenPayload(FileOpenPickerUI fileOpenPickerUI) { this.syncObject = new object(); this.fileOpenPickerUI = fileOpenPickerUI; IsMultiSelect = fileOpenPickerUI.SelectionMode == FileSelectionMode.Multiple; FileTypes = fileOpenPickerUI.AllowedFileTypes; }
public FileOpenPage(FileOpenPickerUI pickerUi) { _pickerUi = pickerUi; InitializeComponent(); Loaded += FileOpenPage_Loaded; }
public void Activate(FileOpenPickerActivatedEventArgs args) { // cache FileOpenPickerUI fileOpenPickerUI = args.FileOpenPickerUI; Window.Current.Content = this; this.OnNavigatedTo(null); Window.Current.Activate(); }
public void Activate(FileOpenPickerActivatedEventArgs args) { FileOpenPickerUi = args.FileOpenPickerUI; FileOpenPickerUi.Title = "github"; Window.Current.Content = this; OnNavigatedTo(null); Window.Current.Activate(); }
protected override void OnNavigatedTo(NavigationEventArgs e) { // 获取 FileOpenPickerUI 对象(从 App.xaml.cs 传来的) var args = (FileOpenPickerActivatedEventArgs)e.Parameter; _fileOpenPickerUI = args.FileOpenPickerUI; _fileOpenPickerUI.Title = "自定义文件打开选取器"; base.OnNavigatedTo(e); }
private async void OnFileRemoved(FileOpenPickerUI sender, FileRemovedEventArgs args) { if (args.Id == id) { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { await new Windows.UI.Popups.MessageDialog("File removed from the basket.").ShowAsync(); UpdateButtonState(false); }); } }
private async void OnFileRemoved(FileOpenPickerUI sender, FileRemovedEventArgs args) { // make sure that the item got removed matches the one we added. if (args.Id == id) { // The event handler may be invoked on a background thread, so use the Dispatcher to run the UI-related code on the UI thread. await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { OutputTextBlock.Text = Status.FileRemoved; UpdateButtonState(false); }); } }
/// <summary> /// Invoked when user removes one of the items from the Picker basket /// </summary> /// <param name="sender">The FileOpenPickerUI instance used to contain the available files.</param> /// <param name="e">Event data that describes the file removed.</param> private async void HandleFilePickerUIFileRemoved(FileOpenPickerUI sender, FileRemovedEventArgs e) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { // Synchronize the select items in the UI lists to remove // the item that was removed from the picker's 'basket' var removedSelectedGridItem = FileGridView.SelectedItems.Cast <FileInfo>() .FirstOrDefault(x => x.Title == e.Id); if (removedSelectedGridItem != null) { FileGridView.SelectedItems.Remove(removedSelectedGridItem); } }); }
/// <summary> /// Invoked when another application wants to open files from this application. /// </summary> /// <param name="e">Activation data used to coordinate the process with Windows.</param> public async void Activate(FileOpenPickerActivatedEventArgs e) { _fileOpenPickerUI = e.FileOpenPickerUI; _fileOpenPickerUI.FileRemoved += FilePickerUI_FileRemoved; DefaultViewModel["CanGoUp"] = false; Window.Current.Content = this; Window.Current.Activate(); // TODO: Set this.DefaultViewModel["Files"] to show a collection of items, // each of which should have bindable Image, Title, and Description // Now that the window has been activated, go ahead and load up the files var appInstalledLocation = Package.Current.InstalledLocation; var filesFolder = await appInstalledLocation.GetFolderAsync("FileActivation"); var queryOptions = new QueryOptions(CommonFileQuery.DefaultQuery, new[] { ".wrtbe" }); var query = filesFolder.CreateFileQueryWithOptions(queryOptions); var files = await query.GetFilesAsync(); var filesList = new List <Object>(); foreach (var file in files) { var thumbnail = await file.GetThumbnailAsync(ThumbnailMode.ListView); if (thumbnail != null) { var image = new BitmapImage(); image.SetSource(thumbnail); var result = new TrackedFile { Id = file.FolderRelativeId, Title = file.Name, Image = image, StorageFile = file, }; filesList.Add(result); } } DefaultViewModel["Files"] = filesList; }
/// <summary> /// Used to set up the content to be displayed and connect to the containing File Open Picker /// </summary> /// <param name="fileOpenPickerUI">The file open picker UI element.</param> public void Initialize(FileOpenPickerUI fileOpenPickerUI) { if (fileOpenPickerUI == null) { throw new ArgumentNullException("fileOpenPickerUI"); } // Tie into the containing File Picker object _fileOpenPickerUI = fileOpenPickerUI; _fileOpenPickerUI.FileRemoved += HandleFilePickerUIFileRemoved; // Initialize the ViewModel DefaultViewModel["SelectionMode"] = _fileOpenPickerUI.SelectionMode == FileSelectionMode.Multiple ? ListViewSelectionMode.Multiple : ListViewSelectionMode.Single; DefaultViewModel["Contacts"] = null; DefaultViewModel["SelectedContact"] = null; // Load the contact info LoadContacts(); }
//public async void ActivateFilePicker(FileOpenPickerActivatedEventArgs e) //{ // this.fileOpenPickerUI = e.FileOpenPickerUI; // this.fileOpenPickerUI.FileRemoved += this.fileOpenPickerUI_FileRemoved; // Window.Current.Content = this; // Window.Current.Activate(); // this.ViewModel.FileSelectionMode = ListViewSelectionMode.Extended; // this.ViewModel.AreFilesClickable = false; // await this.ViewModel.LoadPageAsync(null); //} void fileOpenPickerUI_FileRemoved(FileOpenPickerUI sender, FileRemovedEventArgs args) { throw new NotImplementedException(); }
public void Initialize(FileOpenPickerUI fileOpenPicker) { throw new NotImplementedException(); }
void fileOpenPickerUI_FileRemoved(FileOpenPickerUI sender, FileRemovedEventArgs args) { this.fileOpenPickerUI.RemoveFile(args.Id); }
/// <summary> /// Invoked when user removes one of the items from the Picker basket /// </summary> /// <param name="sender">The FileOpenPickerUI instance used to contain the available files.</param> /// <param name="e">Event data that describes the file removed.</param> private void FilePickerUI_FileRemoved(FileOpenPickerUI sender, FileRemovedEventArgs e) { throw new InvalidOperationException("Only single selection is currently supported."); // TODO: Respond to an item being deselected in the picker UI. }
public void Initialize(FileOpenPickerUI fileOpenPicker) { _fileOpenPicker = fileOpenPicker; }
public RecordingPickerPage(FileOpenPickerUI pickerUi) : this() { _pickerUi = pickerUi; }