private static MenuFlyoutSubItem GetExpandableItem(ExpandableMenuItemViewModel viewModel) { var item = new MenuFlyoutSubItem(); item.SetBinding(MenuFlyoutSubItem.TextProperty, new Binding { Source = viewModel, Path = new PropertyPath(nameof(MenuItemViewModelBase.Text)), Mode = BindingMode.OneWay }); item.SetBinding(ToolTipService.ToolTipProperty, new Binding { Source = viewModel, Path = new PropertyPath(nameof(MenuItemViewModelBase.Description)), Mode = BindingMode.OneWay }); item.SetBinding(MenuFlyoutSubItem.IconProperty, new Binding { Source = viewModel, Path = new PropertyPath(nameof(MenuItemViewModelBase.Icon)), Converter = IconConverter, Mode = BindingMode.OneWay }); item.SetBinding(MenuExtension.SubItemsProperty, new Binding { Source = viewModel, Path = new PropertyPath(nameof(ExpandableMenuItemViewModel.SubItems)), Mode = BindingMode.OneWay }); return(item); }
private void AppendPhotoMenu() { // Photo > var photoMenuItem = new MenuFlyoutSubItem { Text = MenuItems.Main.Photo }; photoMenuItem.IsEnabled = false; // Photo > Details var menuItem = new MenuFlyoutItem { Text = MenuItems.Photo.Details }; menuItem.Click += Menu_Photo_Details_Click; photoMenuItem.Items.Add(menuItem); // Photo > Move menuItem = new MenuFlyoutItem { Text = MenuItems.Photo.Move }; menuItem.IsEnabled = _albums.Count() > 1 ? true : false; menuItem.Click += Menu_Photo_Move_Click; photoMenuItem.Items.Add(menuItem); // Photo > Delete menuItem = new MenuFlyoutItem { Text = MenuItems.Photo.Delete }; menuItem.Click += Menu_Photo_Delete_Click; photoMenuItem.Items.Add(menuItem); Menu.Items.Add(photoMenuItem); }
private void Grid_Holding(object sender, HoldingRoutedEventArgs e) { // simple checkup for holding release for this sample, though this probalby need better handling startedHolding = !startedHolding; if (startedHolding) { MenuFlyout myFlyout = new MenuFlyout(); MenuFlyoutItem firstItem = new MenuFlyoutItem { Text = "Play" }; MenuFlyoutSubItem subItem = new MenuFlyoutSubItem { Text = "Add To" }; MenuFlyoutItem item1 = new MenuFlyoutItem { Text = "Test" }; MenuFlyoutItem item2 = new MenuFlyoutItem { Text = "Sri" }; subItem.Items.Add(item1); subItem.Items.Add(item2); myFlyout.Items.Add(firstItem); myFlyout.Items.Add(subItem); FrameworkElement senderElement = sender as FrameworkElement; myFlyout.ShowAt(senderElement); } }
private void populateAnnotateFlyout() { MenuFlyoutSubItem ActivityMenu = new MenuFlyoutSubItem(); ActivityMenu.Text = "Tag Activity"; foreach (ActivityViewModel activity in _home.ActivityCollection) { MenuFlyoutItem curMenuItem = new MenuFlyoutItem(); curMenuItem.Text = activity.name; curMenuItem.Click += TagActivity_Click; curMenuItem.Foreground = new SolidColorBrush(activity.color); curMenuItem.Tag = activity.name; ActivityMenu.Items.Add(curMenuItem); } annonateFlyout.Items.Add(ActivityMenu); MenuFlyoutSubItem ResidentMenu = new MenuFlyoutSubItem(); ResidentMenu.Text = "Tag Resident"; foreach (ResidentViewModel resident in _home.ResidentCollection) { MenuFlyoutItem curMenuItem = new MenuFlyoutItem(); curMenuItem.Text = resident.name; curMenuItem.Click += TagResident_Click; curMenuItem.Foreground = new SolidColorBrush(resident.color); curMenuItem.Tag = resident.name; ResidentMenu.Items.Add(curMenuItem); } annonateFlyout.Items.Add(ResidentMenu); }
private void AppendAlbumsMenu() { var albumsMenu = new MenuFlyoutSubItem { Text = MenuItems.Main.Albums }; // Add 'Main' Album if (MainAlbum != null) { albumsMenu.Items.Add(AlbumViewModelToMenuFlyoutItem(MainAlbum)); } // Add Other Albums _albums.Where(album => !album.IsMain ?? false) .Select(album => AlbumViewModelToMenuFlyoutItem(album)).ToList() .ForEach(albumMenuItem => albumsMenu.Items.Add(albumMenuItem)); albumsMenu.Items.Add(new MenuFlyoutSeparator()); var menuItem = new MenuFlyoutItem { Text = MenuItems.Albums.NewAlbum }; menuItem.Click += Menu_Albums_Add_Click; albumsMenu.Items.Add(menuItem); Menu.Items.Add(albumsMenu); }
public FormattedTextBox() { DefaultStyleKey = typeof(FormattedTextBox); ClipboardCopyFormat = RichEditClipboardFormat.PlainText; Paste += OnPaste; _proofingMenu = new MenuFlyoutSubItem(); _proofingMenu.Text = "Spelling"; ContextFlyout = new MenuFlyout(); ContextFlyout.Opening += OnContextFlyoutOpening; ContextFlyout.Closing += OnContextFlyoutClosing; DisabledFormattingAccelerators = DisabledFormattingAccelerators.All; KeyboardAcceleratorPlacementMode = KeyboardAcceleratorPlacementMode.Hidden; CreateKeyboardAccelerator(VirtualKey.B); CreateKeyboardAccelerator(VirtualKey.I); CreateKeyboardAccelerator(VirtualKey.U); CreateKeyboardAccelerator(VirtualKey.X, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift); CreateKeyboardAccelerator(VirtualKey.M, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift); CreateKeyboardAccelerator(VirtualKey.K); CreateKeyboardAccelerator(VirtualKey.N, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift); Loaded += OnLoaded; Unloaded += OnUnloaded; SizeChanged += OnSizeChanged; }
public static MenuFlyoutItemBase GetFlyoutItem(BaseMenuFlyoutItemViewModel item) { if (item is MenuFlyoutSubItemViewModel subItemViewModel) { MenuFlyoutSubItem flyoutSubItem = new MenuFlyoutSubItem() { Text = subItemViewModel.Text, Tag = subItemViewModel.Tag, IsEnabled = subItemViewModel.IsEnabled, Icon = new FontIcon() { Glyph = subItemViewModel.IconGlyph.PreventNull(string.Empty) } }; foreach (var item2 in subItemViewModel.SubItems) { flyoutSubItem.Items.Add(GetMenuItem(item2)); } return(flyoutSubItem); } else { return(GetStandardItem(item)); } }
public FormattedTextBox() { DefaultStyleKey = typeof(FormattedTextBox); ClipboardCopyFormat = RichEditClipboardFormat.PlainText; _proofingMenu = new MenuFlyoutSubItem(); _proofingMenu.Text = "Spelling"; ContextFlyout = new MenuFlyout(); ContextFlyout.Opening += OnContextFlyoutOpening; ContextFlyout.Closing += OnContextFlyoutClosing; if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.RichEditBox", "DisabledFormattingAccelerators")) { DisabledFormattingAccelerators = DisabledFormattingAccelerators.All; } if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "KeyboardAcceleratorPlacementMode")) { KeyboardAcceleratorPlacementMode = KeyboardAcceleratorPlacementMode.Hidden; CreateKeyboardAccelerator(VirtualKey.B); CreateKeyboardAccelerator(VirtualKey.I); CreateKeyboardAccelerator(VirtualKey.U); CreateKeyboardAccelerator(VirtualKey.X, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift); CreateKeyboardAccelerator(VirtualKey.M, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift); CreateKeyboardAccelerator(VirtualKey.K); CreateKeyboardAccelerator(VirtualKey.N, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift); } Loaded += OnLoaded; Unloaded += OnUnloaded; }
private async void LoadGeDanType() { try { var firstmenu = new MenuFlyoutItem() { Text = "全部分类", Tag = "" }; firstmenu.Click += GeDanTypeClicked; GeDanTypeMenu.Items.Add(firstmenu); var httpclient = new System.Net.Http.HttpClient(); var json = await httpclient.GetStringAsync("http://mobilecdn.kugou.com/api/v3/tag/list?pid=0&plat=0&apiver=2"); var obj = Windows.Data.Json.JsonObject.Parse(json); var data = Class.data.DataContractJsonDeSerialize <List <GeDanTypeData> >(obj.GetNamedObject("data").GetNamedArray("info").ToString()); data.RemoveAt(0); foreach (var group in data) { var list = new MenuFlyoutSubItem(); list.Text = group.name; foreach (var item in group.children) { var menu = new MenuFlyoutItem(); menu.Text = item.name; menu.Tag = item.special_tag_id; menu.Click += GeDanTypeClicked; list.Items.Add(menu); } GeDanTypeMenu.Items.Add(list); } } catch (Exception) { } }
public static void CreateFlyoutSeparator(this MenuFlyoutSubItem flyout) { if (flyout.Items.Count > 0 && flyout.Items[flyout.Items.Count - 1] is MenuFlyoutItem) { flyout.Items.Add(new MenuFlyoutSeparator()); } }
public static MenuFlyoutSubItem GetSortByMenuSubItem(Dictionary <SortBy, Action> actions, Action reverse = null) { var sortByItem = new MenuFlyoutSubItem() { Text = Helper.Localize("Sort") }; if (reverse != null) { var reverseItem = new MenuFlyoutItem() { Text = Helper.LocalizeMessage("Reverse Playlist") }; reverseItem.Click += (sender, args) => reverse.Invoke(); sortByItem.Items.Add(reverseItem); sortByItem.Items.Add(new MenuFlyoutSeparator()); } foreach (var pair in actions) { string sortby = Helper.LocalizeMessage("Sort By " + pair.Key.ToStr()); var item = new MenuFlyoutItem() { Text = sortby }; item.Click += (sender, args) => pair.Value?.Invoke(); sortByItem.Items.Add(item); } return(sortByItem); }
private async void Chat_ContextRequested(UIElement sender, ContextRequestedEventArgs args) { var viewModel = ViewModel; if (viewModel == null) { return; } var flyout = new MenuFlyout(); var element = sender as FrameworkElement; var chat = element.Tag as Chat; var position = chat.GetPosition(ViewModel.Items.ChatList); if (position == null) { return; } var muted = ViewModel.CacheService.GetNotificationSettingsMuteFor(chat) > 0; flyout.CreateFlyoutItem(DialogArchive_Loaded, viewModel.ChatArchiveCommand, chat, chat.Positions.Any(x => x.List is ChatListArchive) ? Strings.Resources.Unarchive : Strings.Resources.Archive, new FontIcon { Glyph = Icons.Archive }); flyout.CreateFlyoutItem(DialogPin_Loaded, viewModel.ChatPinCommand, chat, position.IsPinned ? Strings.Resources.UnpinFromTop : Strings.Resources.PinToTop, new FontIcon { Glyph = position.IsPinned ? Icons.Unpin : Icons.Pin }); if (viewModel.Items.ChatList is ChatListFilter chatListFilter) { flyout.CreateFlyoutItem(viewModel.FolderRemoveCommand, (chatListFilter.ChatFilterId, chat), Strings.Resources.FilterRemoveFrom, new FontIcon { Glyph = "\uE92B", FontFamily = App.Current.Resources["TelegramThemeFontFamily"] as FontFamily }); } else { var response = await ViewModel.ProtoService.SendAsync(new GetChatListsToAddChat(chat.Id)) as ChatLists; if (response != null && response.ChatListsValue.Count > 0) { var filters = ViewModel.CacheService.ChatFilters; var item = new MenuFlyoutSubItem(); item.Text = Strings.Resources.FilterAddTo; item.Icon = new FontIcon { Glyph = "\uE929", FontFamily = App.Current.Resources["TelegramThemeFontFamily"] as FontFamily }; foreach (var chatList in response.ChatListsValue.OfType <ChatListFilter>()) { var filter = filters.FirstOrDefault(x => x.Id == chatList.ChatFilterId); if (filter != null) { item.Items.Add(new MenuFlyoutItem { Command = ViewModel.FolderAddCommand, CommandParameter = (filter.Id, chat), Text = filter.Title, Icon = new FontIcon { Glyph = Icons.FromFilter(Icons.ParseFilter(filter.IconName)), FontFamily = App.Current.Resources["TelegramThemeFontFamily"] as FontFamily } });
public MenuFlyoutItemBase GetMenuFlyoutItem() { var menu = this; if (menu.HasChild) { var result = new MenuFlyoutSubItem() { Text = menu.Title, }; foreach (var item in menu.Items) { result.Items.Add(item.GetMenuFlyoutItem()); } return(result); } else { return(new MenuFlyoutItem() { Text = menu.Title, Command = menu.Command, }); } }
private void MenuFlyoutBehavior_OnCreateMenu(object sender, CreateMenuEventArgs e) { e.Menu = new MenuFlyout(); var changeStateItem = new MenuFlyoutSubItem { Text = SBoardResources.Get("Menu.ChangeStatus"), }; e.Menu.Items.Add(changeStateItem); foreach (var state in this.ViewModel.States) { var stateItem = new MenuFlyoutItem { Text = state.Name, }; changeStateItem.Items.Add(stateItem); stateItem.Click += (_, __) => { this.ViewModel.SelectedState = state; this.ViewModel.ChangeState.ExecuteAsyncTask(); }; } }
private static void AddItems(IList <MenuFlyoutItemBase> menu, IEnumerable <IMenuFlyoutItem> items) { foreach (var item in items) { if (item is MenuFlyoutSeparatorViewModel) { menu.Add(new MenuFlyoutSeparator()); } else if (item is MenuFlyoutItemViewModel vm) { var mfi = new MenuFlyoutItem { Text = vm.Text, Command = vm.OnSelect, CommandParameter = vm.Path, IsEnabled = vm.IsEnabled, }; if (!string.IsNullOrEmpty(vm.Path)) { ToolTipService.SetToolTip(mfi, vm.Path); } menu.Add(mfi); } else if (item is MenuFlyoutSubItemViewModel svm) { var mfsi = new MenuFlyoutSubItem { Text = svm.Text, IsEnabled = svm.IsEnabled && svm.Items.Count > 0, }; AddItems(mfsi.Items, svm.Items); menu.Add(mfsi); } } }
private void StackPanel_RightTapped(object sender, Windows.UI.Xaml.Input.RightTappedRoutedEventArgs e) { var songMenuFlyoutSubItem = new MenuFlyoutSubItem() { Text = "AddToPlayList" }; var icon = new BitmapIcon() { UriSource = new Uri("ms-appx:///Assets/Images/songGeneral.png") }; var playLists = PlayListManager.GetAllPlayLists(); foreach (var playlist in playLists) { var playListMenuFlyoutItem = new MenuFlyoutItem() { Text = playlist.Title }; playListMenuFlyoutItem.Click += AddToPlaylistMenu_ItemClick; songMenuFlyoutSubItem.Items.Add(playListMenuFlyoutItem); } var addToPlaylistFlyout = new MenuFlyout(); addToPlaylistFlyout.Items.Add(songMenuFlyoutSubItem); FrameworkElement senderElement = sender as FrameworkElement; addToPlaylistFlyout.ShowAt(sender as UIElement, e.GetPosition(sender as UIElement)); }
private void AddItemToMenu(ToolbarItemWrapper item) { if (item.Item is ToolbarPicker) { var pickerItem = (ToolbarPicker)item.Item; var menuItem = new MenuFlyoutSubItem(); menuItem.DataContext = item; menuItem.Text = item.Item.Title; foreach (var toolbarSubItem in ((ToolbarPicker)item.Item).Items) { var menuSubItem = new ToggleMenuFlyoutItem(); menuSubItem.DataContext = toolbarSubItem; menuSubItem.Text = toolbarSubItem.Title; menuSubItem.Click += MenuSubItem_Click; menuSubItem.IsChecked = toolbarSubItem == pickerItem.SelectedItem; menuItem.Items.Add(menuSubItem); } MenuFlyout.Items.Add(menuItem); } else { var menuItem = new MenuFlyoutItem(); menuItem.DataContext = item; menuItem.Text = item.Item.Title; menuItem.Command = ((ToolbarButton)item.Item).Command; MenuFlyout.Items.Add(menuItem); } MenuButton.Opacity = 1; }
public static async Task GenerateSubMenuItemsAsync(IList <MenuFlyoutItemBase> Items, ContextMenuItem[] SubMenus, RoutedEventHandler ClickHandler) { foreach (ContextMenuItem SubItem in SubMenus) { if (SubItem.SubMenus.Length > 0) { MenuFlyoutSubItem Item = new MenuFlyoutSubItem { Text = SubItem.Name, Tag = SubItem, MinWidth = 150, MaxWidth = 350, Icon = new FontIcon { FontFamily = new Windows.UI.Xaml.Media.FontFamily("Segoe MDL2 Assets"), Glyph = "\uE2AC" } }; await GenerateSubMenuItemsAsync(Item.Items, SubItem.SubMenus, ClickHandler); Items.Add(Item); } else { MenuFlyoutItemWithImage FlyoutItem = new MenuFlyoutItemWithImage { Text = SubItem.Name, Tag = SubItem, MinWidth = 150, MaxWidth = 350 }; if (SubItem.IconData.Length != 0) { using (MemoryStream Stream = new MemoryStream(SubItem.IconData)) { BitmapImage Bitmap = new BitmapImage(); await Bitmap.SetSourceAsync(Stream.AsRandomAccessStream()); FlyoutItem.ImageIcon = Bitmap; } } else { FlyoutItem.Icon = new FontIcon { FontFamily = new Windows.UI.Xaml.Media.FontFamily("Segoe MDL2 Assets"), Glyph = "\uE2AC" }; } FlyoutItem.Click += ClickHandler; Items.Add(FlyoutItem); } } }
public static MenuFlyoutSubItem GetShuffleSubItem() { MenuFlyoutSubItem subItem = GetShuffleMenu().ToSubItem(); subItem.Name = ShuffleSubItemName; subItem.Text = Helper.Localize("RandomPlay"); subItem.Icon = new SymbolIcon(Symbol.Shuffle); return(subItem); }
/// <summary> /// Clicks on a child menu sub option with the specified item name. /// </summary> /// <param name="name">The name of the sub-item to click.</param> /// <returns>The clicked <see cref="MenuFlyoutSubItem"/>.</returns> public MenuFlyoutSubItem ClickChildSubOption(string name) { MenuFlyoutSubItem item = this.ChildMenuSubItems.FirstOrDefault( element => element.Element.GetAttribute("Name") .Equals(name, StringComparison.CurrentCultureIgnoreCase)); item.Click(); return(item); }
private async void Context_SongChanged(object sender, EventArgs e) { await Dispatcher.RunAsync(CoreDispatcherPriority.High, () => { lock (this) { var s = sender as SongViewModel; if (MoreMenu.Items[1] is MenuFlyoutSeparator) { } else { MoreMenu.Items.RemoveAt(1); } if (!s.Song.IsPodcast) { if (!s.Song.Performers.IsNullorEmpty()) { if (s.Song.Performers.Length == 1) { var menuItem = new MenuFlyoutItem() { Text = $"{s.Song.Performers[0]}", Icon = new FontIcon() { Glyph = "\uE136" } }; menuItem.Click += OpenArtistViewDialog; MoreMenu.Items.Insert(1, menuItem); } else { var sub = new MenuFlyoutSubItem() { Text = $"{Consts.Localizer.GetString("PerformersText")}", Icon = new FontIcon() { Glyph = "\uE136" } }; foreach (var item in s.Song.Performers) { var menuItem = new MenuFlyoutItem() { Text = item }; menuItem.Click += OpenArtistViewDialog; sub.Items.Add(menuItem); } MoreMenu.Items.Insert(1, sub); } } } } }); }
public static MenuFlyoutSubItem ToSubItem(this MenuFlyout flyout) { MenuFlyoutSubItem subItem = new MenuFlyoutSubItem(); foreach (var item in flyout.Items) { subItem.Items.Add(item); } return(subItem); }
public static MenuFlyout ToMenuFlyout(this MenuFlyoutSubItem subItem) { MenuFlyout flyout = new MenuFlyout(); foreach (var item in subItem.Items) { flyout.Items.Add(item); } return(flyout); }
private void FlyoutBase_OnOpening(object sender, object e) { var menuflyuout = sender as MenuFlyout; var addon = menuflyuout.Items.First().Tag as Addon; MenuFlyoutItemBase temp = menuflyuout.Items.FirstOrDefault(item => item.Name.Equals("VersionsMenuFlyout")); if (temp != null) { menuflyuout.Items.Remove(temp); var submenu = new MenuFlyoutSubItem() { Name = "VersionsMenuFlyout", Text = "Versions" }; foreach (var download in addon.Downloads) { var menuItem = new MenuFlyoutItem() { Text = download.ToString() }; menuItem.Click += async(a, b) => { if (addon.IsIgnored) { var updateAddonDialog = new ContentDialog() { Title = "Can't update ignored addon", PrimaryButtonText = "Ok" }; var response = await updateAddonDialog.ShowAsync(); } else { var updateAddonDialog = new ContentDialog() { Title = "Update Addon?", Content = "Update to " + download.ReleaseType + " " + download.Version + "?", PrimaryButtonText = "Ok", CloseButtonText = "Cancel" }; var response = await updateAddonDialog.ShowAsync(); if (response == ContentDialogResult.Primary) { await Tasks.UpdateAddon(addon, download); } } }; submenu.Items.Add(menuItem); } menuflyuout.Items.Insert(menuflyuout.Items.Count - 1, submenu); } }
private void AddEncodingItem(Encoding encoding, MenuFlyoutSubItem reopenWithEncoding, MenuFlyoutSubItem saveWithEncoding) { const int EncodingMenuFlyoutItemHeight = 30; const int EncodingMenuFlyoutItemFontSize = 14; var reopenWithEncodingItem = new MenuFlyoutItem() { Text = EncodingUtility.GetEncodingName(encoding), FlowDirection = FlowDirection.LeftToRight, Height = EncodingMenuFlyoutItemHeight, FontSize = EncodingMenuFlyoutItemFontSize }; reopenWithEncodingItem.Click += async(sender, args) => { var selectedTextEditor = NotepadsCore.GetSelectedTextEditor(); if (selectedTextEditor != null) { try { await selectedTextEditor.ReloadFromEditingFile(encoding); NotificationCenter.Instance.PostNotification( _resourceLoader.GetString("TextEditor_NotificationMsg_FileReloaded"), 1500); } catch (Exception ex) { var fileOpenErrorDialog = NotepadsDialogFactory.GetFileOpenErrorDialog(selectedTextEditor.EditingFilePath, ex.Message); await DialogManager.OpenDialogAsync(fileOpenErrorDialog, awaitPreviousDialog : false); if (!fileOpenErrorDialog.IsAborted) { NotepadsCore.FocusOnSelectedTextEditor(); } } } }; reopenWithEncoding.Items?.Add(reopenWithEncodingItem); var saveWithEncodingItem = new MenuFlyoutItem() { Text = EncodingUtility.GetEncodingName(encoding), FlowDirection = FlowDirection.LeftToRight, Height = EncodingMenuFlyoutItemHeight, FontSize = EncodingMenuFlyoutItemFontSize }; saveWithEncodingItem.Click += (sender, args) => { NotepadsCore.GetSelectedTextEditor()?.TryChangeEncoding(encoding); }; saveWithEncoding.Items?.Add(saveWithEncodingItem); }
public static MenuFlyoutSeparator CreateFlyoutSeparator(this MenuFlyoutSubItem flyout) { if (flyout.Items.Count > 0 && (flyout.Items[flyout.Items.Count - 1] is MenuFlyoutItem or MenuFlyoutSubItem)) { var separator = new MenuFlyoutSeparator(); flyout.Items.Add(separator); return(separator); } return(null); }
private void MenuFromEnum(MenuFlyoutSubItem menu, Type type, RoutedEventHandler onClicked) { menu.Items.Clear(); foreach (var v in Enum.GetValues(type)) { ToggleMenuFlyoutItem item = new ToggleMenuFlyoutItem(); item.Text = v.ToString(); item.Tag = v; item.Click += onClicked; menu.Items.Add(item); } }
public FormattedTextBox() { DefaultStyleKey = typeof(FormattedTextBox); ClipboardCopyFormat = RichEditClipboardFormat.PlainText; Paste += OnPaste; _proofingFlyout = new MenuFlyoutSubItem(); _proofingFlyout.Text = Strings.Resources.lng_spellchecker_submenu; SelectionFlyout = new Flyout { Content = _selectionFlyout = new FormattedTextFlyout(this), AllowFocusOnInteraction = false, ShouldConstrainToRootBounds = false, ShowMode = FlyoutShowMode.TransientWithDismissOnPointerMoveAway, FlyoutPresenterStyle = App.Current.Resources["CommandFlyoutPresenterStyle"] as Style, }; ContextFlyout = new MenuFlyout(); ContextFlyout.Opening += OnContextFlyoutOpening; ContextFlyout.Closing += OnContextFlyoutClosing; DisabledFormattingAccelerators = DisabledFormattingAccelerators.All; KeyboardAcceleratorPlacementMode = KeyboardAcceleratorPlacementMode.Hidden; CreateKeyboardAccelerator(VirtualKey.B); CreateKeyboardAccelerator(VirtualKey.I); CreateKeyboardAccelerator(VirtualKey.U); CreateKeyboardAccelerator(VirtualKey.X, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift); CreateKeyboardAccelerator(VirtualKey.M, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift); CreateKeyboardAccelerator(VirtualKey.P, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift); CreateKeyboardAccelerator(VirtualKey.K); CreateKeyboardAccelerator(VirtualKey.N, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift); // Overridden but not used CreateKeyboardAccelerator(VirtualKey.E); Loaded += OnLoaded; Unloaded += OnUnloaded; SizeChanged += OnSizeChanged; TextChanging += OnTextChanging; TextChanged += OnTextChanged; SelectionChanged += OnSelectionChanged; }
public static MenuFlyoutSubItem AppendRecentAddedItem(MenuFlyoutSubItem parent, object title, List <Music> songs, int limit) { if (songs.Count > 0) { var recenItem = new MenuFlyoutItem() { Text = title is string stringTitle?Helper.LocalizeMessage(stringTitle) : title.ToString() }; recenItem.Click += (sender, args) => { MediaHelper.SetPlaylistAndPlay(songs.RandItems(limit)); }; parent.Items.Add(recenItem); } return(parent); }
public AppMenu(EventHandler ItemClicked) { Placement = FlyoutPlacementMode.Bottom; for (int bookNumber = 0; bookNumber < Book.BookList.Length; bookNumber++) { MenuFlyoutSubItem subItem = new MenuFlyoutSubItem(); Book book = Book.BookList[bookNumber]; subItem.Text = book.Caption; for (int chapterNumber = 0; chapterNumber < book.ChapterCount; chapterNumber++) { subItem.Items.Add(new AppMenuItem(ItemClicked, bookNumber, chapterNumber)); } Items.Add(subItem); } }