/// <summary> /// Checks whether the device running is capable of using certain capabilities and if not hides them /// </summary> private void CheckDeviceCapabilities() { // Check for the Share Button if (DataTransferManager.IsSupported()) { UIShareButtonVisibility = true; } else { UIShareButtonVisibility = false; } // #TODO Check for the Print Button // Check for Always on Top capability if (ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay)) { UIAlwaysOnTopButtonVisibility = true; UICloseAlwaysOnTopButtonVisibility = false; } else { UIAlwaysOnTopButtonVisibility = false; UICloseAlwaysOnTopButtonVisibility = false; } }
public void ShareContent() { if (DataTransferManager.IsSupported()) { _dataTransferManager.DataRequested += DataTransferManager_DataRequested; DataTransferManager.ShowShareUI(); } }
public static void Share(string content) { if (DataTransferManager.IsSupported()) { _ShareText = content; var dataTransferManager = DataTransferManager.GetForCurrentView(); dataTransferManager.DataRequested += DataTransferManager_DataRequested; DataTransferManager.ShowShareUI(); } }
public async override void Execute() { if (!DataTransferManager.IsSupported()) { await new MessageDialog("当前设备不支持共享.").ShowAsync(); return; } var view = DataTransferManager.GetForCurrentView(); view.DataRequested += View_DataRequested; DataTransferManager.ShowShareUI(); }
/// <summary> /// Show share UI if it is supported. /// </summary> public void ShowShareUI() { if (PlatformInfo.IsRedstoneRelease) { if (!DataTransferManager.IsSupported()) { return; } } DataTransferManager.ShowShareUI(); }
public DataTransferManagerTestsViewModel(CoreDispatcher dispatcher) : base(dispatcher) { if (DataTransferManager.IsSupported()) { _dataTransferManager = DataTransferManager.GetForCurrentView(); _dataTransferManager.DataRequested += DataRequested; Disposables.Add(Disposable.Create(() => { _dataTransferManager.DataRequested -= DataRequested; })); } }
/// <summary> /// Checks whether the device running is capable of using certain capabilities and if not hides them /// </summary> private void CheckDeviceCapabilities() { // Check for the Share Button if (DataTransferManager.IsSupported()) { UiShareButtonVisibility = Visibility.Visible; } else { UiShareButtonVisibility = Visibility.Collapsed; } // #TODO Check for the Print Button }
private async void Page_Loaded(object sender, RoutedEventArgs e) { _shellVm = Application.Current.Resources["ShellVM"] as ShellViewModel; if (DataTransferManager.IsSupported()) { DataTransferManager manager = DataTransferManager.GetForCurrentView(); manager.DataRequested += async(s, args) => { var currentlyPlaying = SharedLogic.Instance.Player.CurrentlyPlayingFile; DataRequest dataRequest = args.Request; dataRequest.Data.Properties.Title = $"{currentlyPlaying.Title} by {currentlyPlaying.LeadArtist}"; dataRequest.Data.Properties.Description = "Now baking toast from BreadPlayer"; if (!string.IsNullOrEmpty(currentlyPlaying.AttachedPicture)) { var albumArt = await StorageFile.GetFileFromPathAsync(currentlyPlaying.AttachedPicture); List <IStorageItem> imageItems = new List <IStorageItem>(); imageItems.Add(albumArt); dataRequest.Data.SetStorageItems(imageItems); RandomAccessStreamReference imageStreamRef = RandomAccessStreamReference.CreateFromFile(albumArt); dataRequest.Data.Properties.Thumbnail = imageStreamRef; dataRequest.Data.SetBitmap(imageStreamRef); } dataRequest.Data.SetHtmlFormat($"Now listening to {currentlyPlaying.Title} by {currentlyPlaying.LeadArtist}.\r\n\r\nGet BreadPlayer for your device: http://bit.ly/2wIqkHX"); dataRequest.Data.SetText($"Now listening to {currentlyPlaying.Title} by {currentlyPlaying.LeadArtist}.\r\n\r\nGet BreadPlayer for your device: http://bit.ly/2wIqkHX"); dataRequest.Data.SetWebLink(new Uri("http://bit.ly/2wIqkHX")); }; } //events for providing seeking ability to the positon slider. Window.Current.CoreWindow.PointerPressed += (s, args) => { if (positionSlider.GetBoundingRect().Contains(args.CurrentPoint.Position) && !positionSlider.IsDragging()) { _isPressed = true; _shellVm.DontUpdatePosition = true; } }; Window.Current.CoreWindow.PointerReleased += (s, args) => { if (_isPressed && !positionSlider.IsDragging()) { positionSlider.UpdatePosition(_shellVm, true); _isPressed = false; } }; await((NowPlayingViewModel)Resources["NowPlayingVM"]).Init().ConfigureAwait(false); }
//private void TopScroller_OnTopScrollingRequested(object sender, EventArgs e) //{ // ReadmeScrollViewer.ChangeView(null, 0, null, false); //} private void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args) { if (DataTransferManager.IsSupported()) { if (!string.IsNullOrEmpty(ViewModel.Repository.HtmlUrl)) { args.Request.Data.SetText(ViewModel.Repository.HtmlUrl); args.Request.Data.Properties.Title = Windows.ApplicationModel.Package.Current.DisplayName; } else { args.Request.FailWithDisplayText("Nothing to share"); } } }
protected override void DocumentViewOnGainedFocus() { if (!DataTransferManager.IsSupported()) { return; } try { var dataTransferManager = DataTransferManager.GetForCurrentView(); dataTransferManager.DataRequested += DataTransferManager_DataRequested; } catch { // Will fail if in the background. } }
private void DocumentViewOnGainedFocus(RoutedEventArgs obj) { if (!DataTransferManager.IsSupported()) { return; } try { var dataTransferManager = DataTransferManager.GetForCurrentView(); dataTransferManager.DataRequested += DataTransferManager_DataRequested; } catch { // Will fail if in the background. } }
public ImageViewerPage() { InitializeComponent(); DataTransferManager.GetForCurrentView().DataRequested += (s, e) => { e.Request.Data.Properties.Title = "分享自iV2EX"; e.Request.Data.SetText(_imageUrl); e.Request.Data.SetBitmap(RandomAccessStreamReference.CreateFromFile(_file)); }; var share = Observable.FromEventPattern <RoutedEventArgs>(ShareImage, nameof(ShareImage.Click)) .ObserveOnCoreDispatcher() .Subscribe(x => { if (DataTransferManager.IsSupported()) { DataTransferManager.ShowShareUI(); } }); var save = Observable.FromEventPattern <RoutedEventArgs>(SaveImage, nameof(SaveImage.Click)) .ObserveOnCoreDispatcher() .Subscribe(async x => { try { var library = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures); var path = await library.SaveFolder.CreateFolderAsync("iV2EX", CreationCollisionOption.OpenIfExists); await _file.CopyAsync(path, _file.Name + Path.GetExtension(_imageUrl), NameCollisionOption.ReplaceExisting); ToastTips.ShowTips("已经保存到图片库"); } catch { ToastTips.ShowTips("保存失败"); } }); var menu = Observable.FromEventPattern <TappedRoutedEventArgs>(MenuItemPanel, nameof(MenuItemPanel.Tapped)) .ObserveOnCoreDispatcher() .Subscribe(x => MenuItemPanel.ContextFlyout.ShowAt(MenuItemPanel)); _events = new List <IDisposable> { share, save, menu }; }
private static void ConfigureDataTransferManager() { if (_configuredDataTransferManager) { return; } _configuredDataTransferManager = true; try { // Hook up share handler // IsSupported method was added in API contract 3 bool isSupported = ApiInformation.IsMethodPresent(typeof(DataTransferManager).FullName, nameof(DataTransferManager.IsSupported)); // If the IsSupported method exists if (isSupported) { // Use that to determine whether it's supported isSupported = DataTransferManager.IsSupported(); } else { // Otherwise, only desktop/mobile before API contract 3 supports it isSupported = !ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 3) && (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Desktop" || AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile"); } if (isSupported) { var dataTransferManager = DataTransferManager.GetForCurrentView(); dataTransferManager.DataRequested += DataTransferManager_DataRequested; IsSharingSupported = true; } } catch (Exception ex) { TelemetryExtension.Current?.TrackException(ex); } }
/// <summary> /// Initializes a new instance of the MainPage class. /// </summary> public MainPage() { InitializeComponent(); _navigationHelper = new NavigationHelper(this); _navigationHelper.LoadState += _navigationHelper_LoadState; _navigationHelper.SaveState += _navigationHelper_SaveState; // ReSharper disable once UseNameofExpression if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Symbol", "Share")) { ShareButton.Icon = new SymbolIcon(Symbol.Share); } if (ReorderGridAnimation.IsSupported) { ReorderGridAnimation.SetDuration(StickerGridView, 300); } if (!DataTransferManager.IsSupported() || AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Xbox") { ShareButton.Visibility = Visibility.Collapsed; } }
public void RightClickItemContextMenu_Opening(object sender, object e) { var shiftPressed = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down); var showOpenMenu = (SelectedItems.Count == 1) && SelectedItem.PrimaryItemAttribute == StorageItemTypes.File && !string.IsNullOrEmpty(SelectedItem.FileExtension) && SelectedItem.FileExtension.Equals(".msi", StringComparison.OrdinalIgnoreCase); SetShellContextmenu(BaseLayoutItemContextFlyout, shiftPressed, showOpenMenu); if (!AppSettings.ShowCopyLocationOption) { UnloadMenuFlyoutItemByName("CopyLocationItem"); } if (!DataTransferManager.IsSupported()) { UnloadMenuFlyoutItemByName("ShareItem"); } // Find selected items that are not folders if (SelectedItems.Any(x => x.PrimaryItemAttribute != StorageItemTypes.Folder)) { UnloadMenuFlyoutItemByName("SidebarPinItem"); UnloadMenuFlyoutItemByName("OpenInNewTab"); UnloadMenuFlyoutItemByName("OpenInNewWindowItem"); if (SelectedItems.Count == 1) { if (!string.IsNullOrEmpty(SelectedItem.FileExtension)) { if (SelectedItem.IsShortcutItem) { (this.FindName("OpenItem") as MenuFlyoutItemBase).Visibility = Visibility.Visible; UnloadMenuFlyoutItemByName("OpenItemWithAppPicker"); UnloadMenuFlyoutItemByName("RunAsAdmin"); UnloadMenuFlyoutItemByName("RunAsAnotherUser"); UnloadMenuFlyoutItemByName("CreateShortcut"); } else if (SelectedItem.FileExtension.Equals(".zip", StringComparison.OrdinalIgnoreCase)) { UnloadMenuFlyoutItemByName("OpenItem"); UnloadMenuFlyoutItemByName("OpenItemWithAppPicker"); UnloadMenuFlyoutItemByName("RunAsAdmin"); UnloadMenuFlyoutItemByName("RunAsAnotherUser"); (this.FindName("CreateShortcut") as MenuFlyoutItemBase).Visibility = Visibility.Visible; } else if (SelectedItem.FileExtension.Equals(".exe", StringComparison.OrdinalIgnoreCase) || SelectedItem.FileExtension.Equals(".bat", StringComparison.OrdinalIgnoreCase)) { (this.FindName("OpenItem") as MenuFlyoutItemBase).Visibility = Visibility.Visible; UnloadMenuFlyoutItemByName("OpenItemWithAppPicker"); (this.FindName("RunAsAdmin") as MenuFlyoutItemBase).Visibility = Visibility.Visible; (this.FindName("RunAsAnotherUser") as MenuFlyoutItemBase).Visibility = Visibility.Visible; (this.FindName("CreateShortcut") as MenuFlyoutItemBase).Visibility = Visibility.Visible; } else if (SelectedItem.FileExtension.Equals(".msi", StringComparison.OrdinalIgnoreCase)) { UnloadMenuFlyoutItemByName("OpenItem"); UnloadMenuFlyoutItemByName("OpenItemWithAppPicker"); UnloadMenuFlyoutItemByName("RunAsAdmin"); (this.FindName("RunAsAnotherUser") as MenuFlyoutItemBase).Visibility = Visibility.Visible; (this.FindName("CreateShortcut") as MenuFlyoutItemBase).Visibility = Visibility.Visible; } else if (SelectedItem.FileExtension.Equals(".appx", StringComparison.OrdinalIgnoreCase) || SelectedItem.FileExtension.Equals(".msix", StringComparison.OrdinalIgnoreCase) || SelectedItem.FileExtension.Equals(".appxbundle", StringComparison.OrdinalIgnoreCase) || SelectedItem.FileExtension.Equals(".msixbundle", StringComparison.OrdinalIgnoreCase)) { (this.FindName("OpenItemWithAppPicker") as MenuFlyoutItemBase).Visibility = Visibility.Visible; UnloadMenuFlyoutItemByName("RunAsAdmin"); UnloadMenuFlyoutItemByName("RunAsAnotherUser"); (this.FindName("CreateShortcut") as MenuFlyoutItemBase).Visibility = Visibility.Visible; } else { (this.FindName("OpenItem") as MenuFlyoutItemBase).Visibility = Visibility.Visible; (this.FindName("OpenItemWithAppPicker") as MenuFlyoutItemBase).Visibility = Visibility.Visible; UnloadMenuFlyoutItemByName("RunAsAdmin"); UnloadMenuFlyoutItemByName("RunAsAnotherUser"); (this.FindName("CreateShortcut") as MenuFlyoutItemBase).Visibility = Visibility.Visible; } } } else if (SelectedItems.Count > 1) { UnloadMenuFlyoutItemByName("OpenItem"); UnloadMenuFlyoutItemByName("OpenItemWithAppPicker"); UnloadMenuFlyoutItemByName("CreateShortcut"); } } else // All are folders or shortcuts to folders { UnloadMenuFlyoutItemByName("OpenItem"); UnloadMenuFlyoutItemByName("OpenItemWithAppPicker"); if (SelectedItems.Any(x => x.IsShortcutItem)) { UnloadMenuFlyoutItemByName("SidebarPinItem"); UnloadMenuFlyoutItemByName("CreateShortcut"); } else if (SelectedItems.Count == 1) { (this.FindName("SidebarPinItem") as MenuFlyoutItemBase).Visibility = Visibility.Visible; (this.FindName("CreateShortcut") as MenuFlyoutItemBase).Visibility = Visibility.Visible; (this.FindName("OpenItem") as MenuFlyoutItemBase).Visibility = Visibility.Visible; } else { (this.FindName("SidebarPinItem") as MenuFlyoutItemBase).Visibility = Visibility.Visible; UnloadMenuFlyoutItemByName("CreateShortcut"); } if (SelectedItems.Count <= 5 && SelectedItems.Count > 0) { (this.FindName("OpenInNewTab") as MenuFlyoutItemBase).Visibility = Visibility.Visible; (this.FindName("OpenInNewWindowItem") as MenuFlyoutItemBase).Visibility = Visibility.Visible; //this.FindName("SidebarPinItem"); //this.FindName("OpenInNewTab"); //this.FindName("OpenInNewWindowItem"); } else if (SelectedItems.Count > 5) { UnloadMenuFlyoutItemByName("OpenInNewTab"); UnloadMenuFlyoutItemByName("OpenInNewWindowItem"); } } //check the file extension of the selected item ParentShellPageInstance.ContentPage.SelectedItemsPropertiesViewModel.CheckFileExtension(); }
public static List <ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(BaseLayoutCommandsViewModel commandsViewModel, List <ListedItem> selectedItems, SelectedItemsPropertiesViewModel selectedItemsPropertiesViewModel) { return(new List <ContextMenuFlyoutItemViewModel>() { new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutRestore/Text".GetLocalized(), Glyph = "\uE8E5", Command = commandsViewModel.RestoreItemCommand, ShowInRecycleBin = true, ShowItem = selectedItems.All(x => x.IsRecycleBinItem) }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutOpenItem/Text".GetLocalized(), Glyph = "\uE8E5", Command = commandsViewModel.OpenItemCommand, IsPrimary = true, ShowItem = selectedItems.Count <= 10, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutCreateFolderWithSelection/Text".GetLocalized(), ColoredIcon = new ColoredIconModel() { BaseLayerGlyph = "\u0033", OverlayLayerGlyph = "\u0034" }, Command = commandsViewModel.CreateFolderWithSelection, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutOpenItemWith/Text".GetLocalized(), Glyph = "\uE17D", Command = commandsViewModel.OpenItemWithApplicationPickerCommand, CollapseLabel = true, ShowItem = selectedItems.All(i => i.PrimaryItemAttribute == Windows.Storage.StorageItemTypes.File && !i.IsShortcutItem), }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutOpenFileLocation/Text".GetLocalized(), Glyph = "\uE8DA", Command = commandsViewModel.OpenFileLocationCommand, ShowItem = selectedItems.All(i => i.IsShortcutItem), }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutOpenInNewPane/Text".GetLocalized(), Glyph = "\uF117", GlyphFontFamilyName = "CustomGlyph", Command = commandsViewModel.OpenDirectoryInNewPaneCommand, ShowItem = App.AppSettings.IsDualPaneEnabled && selectedItems.All(i => i.PrimaryItemAttribute == Windows.Storage.StorageItemTypes.Folder), SingleItemOnly = true, IsPrimary = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutOpenInNewTab/Text".GetLocalized(), Glyph = "\uF113", GlyphFontFamilyName = "CustomGlyph", Command = commandsViewModel.OpenDirectoryInNewTabCommand, ShowItem = selectedItems.Count < 5 && selectedItems.All(i => i.PrimaryItemAttribute == Windows.Storage.StorageItemTypes.Folder), IsPrimary = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutOpenInNewWindow/Text".GetLocalized(), Glyph = "\uE737", Command = commandsViewModel.OpenInNewWindowItemCommand, ShowItem = selectedItems.Count < 5 && selectedItems.All(i => i.PrimaryItemAttribute == Windows.Storage.StorageItemTypes.Folder), IsPrimary = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutSetAs/Text".GetLocalized(), ShowItem = selectedItemsPropertiesViewModel.IsSelectedItemImage, Items = new List <ContextMenuFlyoutItemViewModel>() { new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutSetAsDesktopBackground/Text".GetLocalized(), Glyph = "\uE91B", Command = commandsViewModel.SetAsDesktopBackgroundItemCommand, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutSetAsLockscreenBackground/Text".GetLocalized(), Glyph = "\uF114", GlyphFontFamilyName = "CustomGlyph", Command = commandsViewModel.SetAsLockscreenBackgroundItemCommand, }, } }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutContextFlyoutRunAsAdmin/Text".GetLocalized(), Glyph = "\uE7EF", Command = commandsViewModel.RunAsAdminCommand, ShowItem = new string[] { ".bat", ".exe", "cmd" }.Contains(selectedItems.FirstOrDefault().FileExtension) }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutContextFlyoutRunAsAnotherUser/Text".GetLocalized(), Glyph = "\uE7EE", Command = commandsViewModel.RunAsAnotherUserCommand, ShowItem = new string[] { ".bat", ".exe", "cmd" }.Contains(selectedItems.FirstOrDefault().FileExtension) }, new ContextMenuFlyoutItemViewModel() { ItemType = ItemType.Separator, ShowInRecycleBin = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutCut/Text".GetLocalized(), Glyph = "\uE8C6", Command = commandsViewModel.CutItemCommand, KeyboardAccelerator = new KeyboardAccelerator { Key = Windows.System.VirtualKey.X, Modifiers = Windows.System.VirtualKeyModifiers.Control, IsEnabled = false, }, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutCopy/Text".GetLocalized(), //Glyph = "\uE8C8", ColoredIcon = new ColoredIconModel() { BaseLayerGlyph = "\u0021", OverlayLayerGlyph = "\u0022", }, Command = commandsViewModel.CopyItemCommand, ShowInRecycleBin = true, KeyboardAccelerator = new KeyboardAccelerator { Key = Windows.System.VirtualKey.C, Modifiers = Windows.System.VirtualKeyModifiers.Control, IsEnabled = false, }, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutCopyLocation/Text".GetLocalized(), ColoredIcon = new ColoredIconModel() { BaseLayerGlyph = "\u002F", OverlayLayerGlyph = "\u0030" }, Command = commandsViewModel.CopyPathOfSelectedItemCommand, SingleItemOnly = true, IsPrimary = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutContextFlyoutPaste/Text".GetLocalized(), //Glyph = "\uE16D", ColoredIcon = new ColoredIconModel() { BaseLayerGlyph = "\u0023", OverlayLayerGlyph = "\u0024", }, Command = commandsViewModel.PasteItemsFromClipboardCommand, ShowItem = selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.Folder), SingleItemOnly = true, IsEnabled = App.MainViewModel.IsPasteEnabled, KeyboardAccelerator = new KeyboardAccelerator { Key = Windows.System.VirtualKey.V, Modifiers = Windows.System.VirtualKeyModifiers.Control, IsEnabled = false, }, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutShortcut/Text".GetLocalized(), Glyph = "\uF10A", GlyphFontFamilyName = "CustomGlyph", Command = commandsViewModel.CreateShortcutCommand, ShowItem = !selectedItems.FirstOrDefault().IsShortcutItem, SingleItemOnly = true, IsPrimary = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutDelete/Text".GetLocalized(), //Glyph = "\uE74D", ColoredIcon = new ColoredIconModel() { BaseLayerGlyph = "\u0035", OverlayLayerGlyph = "\u0036" }, Command = commandsViewModel.DeleteItemCommand, ShowInRecycleBin = true, IsPrimary = true, KeyboardAccelerator = new KeyboardAccelerator { Key = Windows.System.VirtualKey.Delete, IsEnabled = false, }, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutRename/Text".GetLocalized(), //Glyph = "\uE8AC", ColoredIcon = new ColoredIconModel() { BaseLayerGlyph = "\u0027", OverlayLayerGlyph = "\u0028", }, Command = commandsViewModel.RenameItemCommand, SingleItemOnly = true, KeyboardAccelerator = new KeyboardAccelerator { Key = Windows.System.VirtualKey.F2, IsEnabled = false, }, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutShare/Text".GetLocalized(), //Glyph = "\uE72D", ColoredIcon = new ColoredIconModel() { BaseLayerGlyph = "\u0025", OverlayLayerGlyph = "\u0026", }, Command = commandsViewModel.ShareItemCommand, ShowItem = DataTransferManager.IsSupported() && !selectedItems.Any(i => i.IsHiddenItem), IsPrimary = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutExtractionOptions".GetLocalized(), Glyph = "\xF11A", ShowItem = selectedItems.Count == 1 && selectedItems.First().PrimaryItemAttribute == StorageItemTypes.File && new [] { ".zip", ".msix", ".msixbundle" }.Contains(selectedItems.First().FileExtension.ToLowerInvariant()), GlyphFontFamilyName = "CustomGlyph", Items = new List <ContextMenuFlyoutItemViewModel>() { new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutExtractFilesOption".GetLocalized(), Command = commandsViewModel.DecompressArchiveCommand, Glyph = "\xF11A", GlyphFontFamilyName = "CustomGlyph" }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutExtractHereOption".GetLocalized(), Command = commandsViewModel.DecompressArchiveHereCommand, Glyph = "\xF11A", GlyphFontFamilyName = "CustomGlyph" }, new ContextMenuFlyoutItemViewModel() { Text = string.Format("BaseLayoutItemContextFlyoutExtractToChildFolder".GetLocalized(), Path.GetFileNameWithoutExtension(selectedItems.First().ItemName)), Command = commandsViewModel.DecompressArchiveToChildFolderCommand, Glyph = "\xF11A", GlyphFontFamilyName = "CustomGlyph" } } }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutPinToFavorites/Text".GetLocalized(), Glyph = "\uE840", Command = commandsViewModel.SidebarPinItemCommand, ShowItem = selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.Folder && !x.IsPinned), IsPrimary = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutContextFlyoutUnpinFromFavorites/Text".GetLocalized(), Glyph = "\uE77A", Command = commandsViewModel.SidebarUnpinItemCommand, ShowItem = selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.Folder && x.IsPinned), IsPrimary = true, }, new ContextMenuFlyoutItemViewModel() { Text = "PinItemToStart/Text".GetLocalized(), Glyph = "\uE840", Command = commandsViewModel.PinItemToStartCommand, ShowOnShift = true, ShowItem = selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.Folder && !x.IsItemPinnedToStart), SingleItemOnly = true, }, new ContextMenuFlyoutItemViewModel() { Text = "UnpinItemFromStart/Text".GetLocalized(), Glyph = "\uE77A", Command = commandsViewModel.UnpinItemFromStartCommand, ShowOnShift = true, ShowItem = selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.Folder && x.IsItemPinnedToStart), SingleItemOnly = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutProperties/Text".GetLocalized(), //Glyph = "\uE946", ColoredIcon = new ColoredIconModel() { BaseLayerGlyph = "\u0031", OverlayLayerGlyph = "\u0032" }, Command = commandsViewModel.ShowPropertiesCommand, }, new ContextMenuFlyoutItemViewModel() { ItemType = ItemType.Separator, Tag = "OverflowSeparator", IsHidden = true, }, new ContextMenuFlyoutItemViewModel() { Text = "ContextMenuMoreItemsLabel".GetLocalized(), Glyph = "\xE712", ID = "ItemOverflow", Tag = "ItemOverflow", IsHidden = true, }, }); }
public static List <ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(BaseLayoutCommandsViewModel commandsViewModel, List <ListedItem> selectedItems, SelectedItemsPropertiesViewModel selectedItemsPropertiesViewModel) { return(new List <ContextMenuFlyoutItemViewModel>() { new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutRestore/Text".GetLocalized(), Glyph = "\uE8E5", Command = commandsViewModel.RestoreItemCommand, ShowInRecycleBin = true, ShowItem = selectedItems.All(x => x.IsRecycleBinItem) }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutOpenItem/Text".GetLocalized(), Glyph = "\uE8E5", Command = commandsViewModel.OpenItemCommand, IsPrimary = true, ShowItem = selectedItems.Count <= 10, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutCreateFolderWithSelection/Text".GetLocalized(), Glyph = "\uE1DA", Command = commandsViewModel.CreateFolderWithSelection, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutOpenItemWith/Text".GetLocalized(), Glyph = "\uE17D", Command = commandsViewModel.OpenItemWithApplicationPickerCommand, ShowItem = selectedItems.All(i => i.PrimaryItemAttribute == Windows.Storage.StorageItemTypes.File && !i.IsShortcutItem), }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutOpenFileLocation/Text".GetLocalized(), Glyph = "\uE8DA", Command = commandsViewModel.OpenFileLocationCommand, ShowItem = selectedItems.All(i => i.IsShortcutItem), }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutOpenInNewPane/Text".GetLocalized(), Glyph = "\uF117", GlyphFontFamilyName = "CustomGlyph", Command = commandsViewModel.OpenDirectoryInNewPaneCommand, ShowItem = App.AppSettings.IsDualPaneEnabled && selectedItems.All(i => i.PrimaryItemAttribute == Windows.Storage.StorageItemTypes.Folder), SingleItemOnly = true, IsPrimary = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutOpenInNewTab/Text".GetLocalized(), Glyph = "\uF113", GlyphFontFamilyName = "CustomGlyph", Command = commandsViewModel.OpenDirectoryInNewTabCommand, ShowItem = selectedItems.Count < 5 && selectedItems.All(i => i.PrimaryItemAttribute == Windows.Storage.StorageItemTypes.Folder), IsPrimary = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutOpenInNewWindow/Text".GetLocalized(), Glyph = "\uE737", Command = commandsViewModel.OpenInNewWindowItemCommand, ShowItem = selectedItems.Count < 5 && selectedItems.All(i => i.PrimaryItemAttribute == Windows.Storage.StorageItemTypes.Folder), IsPrimary = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutSetAs/Text".GetLocalized(), ShowItem = selectedItemsPropertiesViewModel.IsSelectedItemImage, Items = new List <ContextMenuFlyoutItemViewModel>() { new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutSetAsDesktopBackground/Text".GetLocalized(), Glyph = "\uE91B", Command = commandsViewModel.SetAsDesktopBackgroundItemCommand, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutSetAsLockscreenBackground/Text".GetLocalized(), Glyph = "\uF114", GlyphFontFamilyName = "CustomGlyph", Command = commandsViewModel.SetAsLockscreenBackgroundItemCommand, }, } }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutContextFlyoutRunAsAdmin/Text".GetLocalized(), Glyph = "\uE7EF", Command = commandsViewModel.RunAsAdminCommand, ShowItem = new string[] { ".bat", ".exe", "cmd" }.Contains(selectedItems.FirstOrDefault().FileExtension) }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutContextFlyoutRunAsAnotherUser/Text".GetLocalized(), Glyph = "\uE7EE", Command = commandsViewModel.RunAsAnotherUserCommand, ShowItem = new string[] { ".bat", ".exe", "cmd" }.Contains(selectedItems.FirstOrDefault().FileExtension) }, new ContextMenuFlyoutItemViewModel() { Text = "ContextMenuMoreItemsLabel".GetLocalized(), Glyph = "\xE712", ID = "ItemOverflow" }, new ContextMenuFlyoutItemViewModel() { ItemType = ItemType.Separator, ShowInRecycleBin = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutCut/Text".GetLocalized(), Glyph = "\uE8C6", Command = commandsViewModel.CutItemCommand, KeyboardAccelerator = new KeyboardAccelerator { Key = Windows.System.VirtualKey.X, Modifiers = Windows.System.VirtualKeyModifiers.Control, IsEnabled = false, }, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutCopy/Text".GetLocalized(), Glyph = "\uE8C8", Command = commandsViewModel.CopyItemCommand, ShowInRecycleBin = true, KeyboardAccelerator = new KeyboardAccelerator { Key = Windows.System.VirtualKey.C, Modifiers = Windows.System.VirtualKeyModifiers.Control, IsEnabled = false, }, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutCopyLocation/Text".GetLocalized(), Glyph = "\uE167", Command = commandsViewModel.CopyPathOfSelectedItemCommand, SingleItemOnly = true, IsPrimary = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutContextFlyoutPaste/Text".GetLocalized(), Glyph = "\uE16D", Command = commandsViewModel.PasteItemsFromClipboardCommand, ShowItem = selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.Folder), SingleItemOnly = true, IsEnabled = App.InteractionViewModel.IsPasteEnabled, KeyboardAccelerator = new KeyboardAccelerator { Key = Windows.System.VirtualKey.V, Modifiers = Windows.System.VirtualKeyModifiers.Control, IsEnabled = false, }, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutShortcut/Text".GetLocalized(), Glyph = "\uF10A", GlyphFontFamilyName = "CustomGlyph", Command = commandsViewModel.CreateShortcutCommand, ShowItem = !selectedItems.FirstOrDefault().IsShortcutItem, SingleItemOnly = true, IsPrimary = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutDelete/Text".GetLocalized(), Glyph = "\uE74D", Command = commandsViewModel.DeleteItemCommand, ShowInRecycleBin = true, IsPrimary = true, KeyboardAccelerator = new KeyboardAccelerator { Key = Windows.System.VirtualKey.Delete, IsEnabled = false, }, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutRename/Text".GetLocalized(), Glyph = "\uE8AC", Command = commandsViewModel.RenameItemCommand, SingleItemOnly = true, KeyboardAccelerator = new KeyboardAccelerator { Key = Windows.System.VirtualKey.F2, IsEnabled = false, }, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutShare/Text".GetLocalized(), Glyph = "\uE72D", Command = commandsViewModel.ShareItemCommand, ShowItem = DataTransferManager.IsSupported() && !selectedItems.Any(i => i.IsHiddenItem), IsPrimary = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutPinToSidebar/Text".GetLocalized(), Glyph = "\uE840", Command = commandsViewModel.SidebarPinItemCommand, ShowItem = selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.Folder && !x.IsPinned), IsPrimary = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutContextFlyoutUnpinDirectoryFromSidebar/Text".GetLocalized(), Glyph = "\uE77A", Command = commandsViewModel.SidebarUnpinItemCommand, ShowItem = selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.Folder && x.IsPinned), IsPrimary = true, }, new ContextMenuFlyoutItemViewModel() { Text = "PinItemToStart/Text".GetLocalized(), Glyph = "\uE840", Command = commandsViewModel.PinItemToStartCommand, ShowOnShift = true, ShowItem = selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.Folder && !x.IsItemPinnedToStart), SingleItemOnly = true, }, new ContextMenuFlyoutItemViewModel() { Text = "UnpinItemFromStart/Text".GetLocalized(), Glyph = "\uE77A", Command = commandsViewModel.UnpinItemFromStartCommand, ShowOnShift = true, ShowItem = selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.Folder && x.IsItemPinnedToStart), SingleItemOnly = true, }, new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutProperties/Text".GetLocalized(), Glyph = "\uE946", Command = commandsViewModel.ShowPropertiesCommand, } }); }
public override bool CanExecute(ClientImageModel parameter) { return(DataTransferManager.IsSupported()); }