public async Task EnumerateDevicesAsync(object sender) { //this.State = BluetoothConnectionState.Enumerating; var serviceInfoCollection = await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort)); MenuFlyout mf = new MenuFlyout(); foreach (var serviceInfo in serviceInfoCollection) { MenuFlyoutItem mi = new MenuFlyoutItem(); mi.Text = serviceInfo.Name; //selected_device_global = (DeviceInformation)serviceInfo; mi.Name = serviceInfo.Id; mi.Click += ConnectToServiceAsync; mf.Items.Add(mi); //menu.Commands.Add(new UICommand(serviceInfo.Name, new UICommandInvokedHandler(ConnectToServiceAsync), serviceInfo)); } if (serviceInfoCollection.Count == 0) { MenuFlyoutItem mi = new MenuFlyoutItem(); mi.Text = "No device found..."; this.State = BluetoothConnectionState.Disconnected; mf.Items.Add(mi); } mf.ShowAt(sender as FrameworkElement); }
/// <summary> /// Sets the value of the MenuFlyout property of the specified object. /// </summary> /// <param name="element">Object to set the property on.</param> /// <param name="value">Value to set.</param> public static void SetMenuFlyout(DependencyObject element, MenuFlyout value) { if (element == null) { throw new ArgumentNullException("element"); } element.SetValue(MenuFlyoutProperty, value); }
private void PrepareFlyoutItesm() { menuFlyout = new MenuFlyout(); MenuFlyoutItem camItem = new MenuFlyoutItem(); MenuFlyoutItem phototem = new MenuFlyoutItem(); phototem.Text = "Video Library"; phototem.Tag = "video"; phototem.Click += MenuItem_Click; menuFlyout.Items.Add(phototem); }
private void symbols_Holding(object sender, HoldingRoutedEventArgs e) { MenuFlyout delete = new MenuFlyout(); MenuFlyoutItem deleteItem = new MenuFlyoutItem() { Text = "Delete" }; deleteItem.Click += (s, args) => { //var listitem = s as PPTexClasses.Symbol; this.Symbols.Remove((e.OriginalSource as FrameworkElement).DataContext as PPTexClasses.Symbol); }; delete.Items.Add(deleteItem); delete.ShowAt(sender as FrameworkElement); }
private void PrepareFlyoutItesm() { menuFlyout = new MenuFlyout(); MenuFlyoutItem camItem = new MenuFlyoutItem(); camItem.Text = "Camera"; camItem.Tag = "camera"; camItem.Click += MenuItem_Click; menuFlyout.Items.Add(camItem); MenuFlyoutItem phototem = new MenuFlyoutItem(); phototem.Text = "Photo Library"; phototem.Tag = "photo"; phototem.Click += MenuItem_Click; menuFlyout.Items.Add(phototem); }
public async void buildFlyout(object sender) { // make this await, this wont run async now MenuFlyout menuFlyout = new MenuFlyout(); for (int x = 0; x < recipeController.getCategories().Count; x++) { MenuFlyoutItem flyItem = new MenuFlyoutItem(); flyItem.Text = recipeController.getCategories()[x]; flyItem.Click += FlyItem_Click; menuFlyout.Items.Add(flyItem); } menuFlyout.ShowAt((FrameworkElement)sender); }
public PhotoAlbum() { this.InitializeComponent(); EmptyTextPA = EmptyText; PAPageName = PhotoAlbumViewer; gv = FileList; progressBar = ProgBar; gridContext = GridRightClickContextMenu; Clipboard.ContentChanged += Clipboard_ContentChanged; tabInstance = App.selectedTabInstance; viewModelInstance = tabInstance.instanceViewModel; FileList.DoubleTapped += tabInstance.instanceInteraction.List_ItemClick; SidebarPinItem.Click += tabInstance.instanceInteraction.PinItem_Click; OpenTerminal.Click += tabInstance.instanceInteraction.OpenDirectoryInTerminal; }
private void MenuFlyout_Opening(object sender, object e) { MenuFlyout flyout = sender as MenuFlyout; MenuFlyoutItem albumArtItem = new MenuFlyoutItem() { Icon = new SymbolIcon(Symbol.Pictures), Text = Helper.Localize("See Album Art") }; albumArtItem.Click += async(s, args) => { await new AlbumDialog(AlbumDialogOption.AlbumArt, flyout.Target.DataContext as AlbumView).ShowAsync(); }; flyout.Items.Add(albumArtItem); }
private void More_Click(object sender, RoutedEventArgs e) { var flyout = new MenuFlyout(); var item = new MenuFlyoutItem() { Text = "View Windows specific information" }; item.Click += async(object sender2, RoutedEventArgs e2) => { await Launcher.LaunchUriAsync(new Uri("ms-settings:about")); }; flyout.Items.Add(item); flyout.ShowAt(sender as FrameworkElement); }
public static MenuFlyout ToMenuFlyout(this IContextMenu source, MenuFlyout flyout) { flyout.Items.Clear(); foreach(var item in source.Items) { MenuFlyoutItem menu = new MenuFlyoutItem(); menu.Text = item.Header; menu.Command = new RelayCommand<object>( (param) => { flyout.Hide(); item.Command.Execute(param); }, (param) => { return item.Command.CanExecute(param); }); menu.CommandParameter = item.CommandParameter; flyout.Items.Add(menu); } return flyout; }
private void PrimaryButton_ContextRequested(object sender, RoutedEventArgs args) { var flyout = new MenuFlyout(); flyout.CreateFlyoutItem(new RelayCommand(() => { ViewModel.SendAsCopy = true; Hide(ContentDialogResult.Primary); }), "Send as copy", new FontIcon { Glyph = Icons.DocumentCopy }); flyout.CreateFlyoutItem(new RelayCommand(() => { ViewModel.RemoveCaptions = true; Hide(ContentDialogResult.Primary); }), "Remove captions", new FontIcon { Glyph = Icons.Block }); flyout.ShowAt(sender as FrameworkElement, new FlyoutShowOptions { Placement = FlyoutPlacementMode.BottomEdgeAlignedRight }); }
private void ChangeLanguageButtonClick(object sender, RoutedEventArgs e) { var menu = new MenuFlyout(); foreach (var language in ViewModel.LanguagesToSelect) { var item = new MenuFlyoutItem { Text = language.DisplayName, Tag = language.Locale }; item.Click += ItemOnClick; menu.Items.Add(item); } menu.ShowAt((FrameworkElement)sender); }
private static void OpenTrackMenu(object sender, List <TrackVm> tracks) { var f = new MenuFlyout(); foreach (TrackVm target in tracks) { var mi = new MenuFlyoutItem(); mi.Text = target.Label; mi.Command = target.Select; f.Items.Add(mi); } f.ShowAt((FrameworkElement)sender); }
private void ShowFileContextMenu(FrameworkElement item, Point position) { if (item != null) { MenuFlyout flyout = FlyoutBase.GetAttachedFlyout(item) as MenuFlyout; { flyout.Opened += Flyout_Opened; flyout.Closed += Flyout_Closed; } if (!_isFlyoutOpen) { flyout?.ShowAt(this, position); } } }
/// <inheritdoc/> protected override void OnApplyTemplate() { base.OnApplyTemplate(); var selectAllMenuItem = new MenuFlyoutItem { Text = "WindowsCommunityToolkit_TokenizingTextBox_MenuFlyout_SelectAll".GetLocalized("Microsoft.Toolkit.Uwp.UI.Controls/Resources") }; selectAllMenuItem.Click += (s, e) => this.SelectAllTokensAndText(); var menuFlyout = new MenuFlyout(); menuFlyout.Items.Add(selectAllMenuItem); ContextFlyout = menuFlyout; }
void OpenContextMenu() { if (GetAttachedFlyout() == null) { var flyout = new MenuFlyout(); SetupMenuItems(flyout); ((INotifyCollectionChanged)Cell.ContextActions).CollectionChanged += OnContextActionsChanged; _contextActions = Cell.ContextActions; FlyoutBase.SetAttachedFlyout(CellContent, flyout); } FlyoutBase.ShowAttachedFlyout(CellContent); }
private void ShowDeckContextMenu(DeckInformation deck, UIElement target, Point offset) { if (deck.IsDynamic) { if (dynamicDeckMenuFlyout == null) { dynamicDeckMenuFlyout = Resources["DynamicDeckContextMenu"] as MenuFlyout; } dynamicDeckMenuFlyout.ShowAt(target, offset); } else { deckMenuFlyout.ShowAt(target, offset); } }
private void CreateFlyoutItem(ref MenuFlyout flyout, Func <TLDialog, Visibility> visibility, ICommand command, object parameter, string text) { var value = visibility(parameter as TLDialog); if (value == Visibility.Visible) { var flyoutItem = new MenuFlyoutItem(); //flyoutItem.Loaded += (s, args) => flyoutItem.Visibility = visibility(parameter as TLMessageCommonBase); flyoutItem.Command = command; flyoutItem.CommandParameter = parameter; flyoutItem.Text = text; flyout.Items.Add(flyoutItem); } }
private void LeftColumnRightTapped(object sender, RightTappedRoutedEventArgs e) { var element = sender as UIElement; if (isPointerPressed) { if (leftColumnMenuFlyout == null) { leftColumnMenuFlyout = Resources["LeftColumnContextMenu"] as MenuFlyout; } leftColumnMenuFlyout.ShowAt(element, e.GetPosition(element)); e.Handled = true; } }
public async void buildFlyout(object sender) { // make this await, this wont run async now MenuFlyout menuFlyout = new MenuFlyout(); for (int x = 0; x < recipeController.getCategories().Count; x++) { MenuFlyoutItem flyItem = new MenuFlyoutItem(); flyItem.Text = recipeController.getCategories()[x]; flyItem.Click += FlyItem_Click; menuFlyout.Items.Add(flyItem); } menuFlyout.ShowAt((FrameworkElement)sender); }
protected override Size ArrangeOverride(Size finalSize) { var ret = base.ArrangeOverride(finalSize); if (!haveDynamicOverflow && primary.Count != 0) { uint limit = (uint)Math.Floor(ret.Width / 68) - 1; int currentCount = PrimaryCommands.CountVisible(); if (currentCount != limit && !(currentCount == primary.Count && limit > currentCount)) { reflowing = true; #if WINDOWS_APP secondaryFlyout = null; #endif needseparator = false; PrimaryCommands.Clear(); SecondaryCommands.Clear(); int i = 0; foreach (var item in primary) { if (i < limit) { PrimaryCommands.Add(item); } else { SecondaryCommands.Add(item); } i++; } needseparator = i > limit; foreach (var item in secondary) { SecondaryCommands.Add(item); } reflowing = false; } } return(ret); }
private void Sticker_ContextRequested(UIElement sender, ContextRequestedEventArgs args) { var element = sender as FrameworkElement; var sticker = element.Tag as StickerViewModel; if (sticker == null) { return; } var flyout = new MenuFlyout(); flyout.CreateFlyoutItem(ViewModel.StickerViewCommand, (Sticker)sticker, Strings.Resources.ViewPackPreview, new FontIcon { Glyph = Icons.Stickers }); if (ViewModel.ProtoService.IsStickerFavorite(sticker.StickerValue.Id)) { flyout.CreateFlyoutItem(ViewModel.StickerUnfaveCommand, (Sticker)sticker, Strings.Resources.DeleteFromFavorites, new FontIcon { Glyph = Icons.Unfavorite }); } else { flyout.CreateFlyoutItem(ViewModel.StickerFaveCommand, (Sticker)sticker, Strings.Resources.AddToFavorites, new FontIcon { Glyph = Icons.Favorite }); } if (ViewModel.Type == ViewModels.DialogType.History) { var chat = ViewModel.Chat; if (chat == null) { return; } var self = ViewModel.CacheService.IsSavedMessages(chat); flyout.CreateFlyoutSeparator(); flyout.CreateFlyoutItem(new RelayCommand <Sticker>(anim => ViewModel.StickerSendExecute(anim, null, true)), (Sticker)sticker, Strings.Resources.SendWithoutSound, new FontIcon { Glyph = Icons.Mute }); //flyout.CreateFlyoutItem(new RelayCommand<Sticker>(anim => ViewModel.StickerSendExecute(anim, true, null)), sticker.Get(), self ? Strings.Resources.SetReminder : Strings.Resources.ScheduleMessage, new FontIcon { Glyph = Icons.Schedule }); } args.ShowAt(flyout, element); }
public void MenuFlyoutTripTask_Opening(object sender, object e) { MenuFlyout senderAsMenuFlyout = sender as MenuFlyout; foreach (object menuFlyoutItem in senderAsMenuFlyout.Items) { if (menuFlyoutItem.GetType() == typeof(MenuFlyoutItem)) { // Associate the particular Item with the menu flyout (so the MenuFlyoutItem knows which Item to act upon) ListViewItem itemContainer = senderAsMenuFlyout.Target as ListViewItem; var data = tripTaskLv.ItemFromContainer(itemContainer); tripTaskLv.SelectedItem = data; } } }
private void PrepareFlyoutItesm() { menuFlyout = new MenuFlyout(); MenuFlyoutItem camItem = new MenuFlyoutItem(); camItem.Text = "Camera"; camItem.Tag = "camera"; camItem.Click += MenuItem_Click; menuFlyout.Items.Add(camItem); MenuFlyoutItem phototem = new MenuFlyoutItem(); phototem.Text = "Photo Library"; phototem.Tag = "photo"; phototem.Click += MenuItem_Click; menuFlyout.Items.Add(phototem); }
private void SetupMenuFlyout() { // Associate the menu with the item requesting it. MenuFlyout menu = new MenuFlyout(); menu.Opening += MenuFlyout_Opening; // Add click handlers to the menu flyout items. MenuFlyoutItem item = new MenuFlyoutItem { Text = "Remove item", Icon = new SymbolIcon { Symbol = Symbol.Delete } }; menu.Items.Add(item); }
private void img_RightTapped(object sender, RightTappedRoutedEventArgs e) { Image img = sender as Image; BitmapImage bitMap = img.Source as BitmapImage; //Uri uri = bitMap?.UriSource; sourceImage = ((Image)sender).Tag.ToString(); MenuFlyout myFlyout = new MenuFlyout(); MenuFlyoutItem copyLink = new MenuFlyoutItem { Text = "Copy Image", Height = 30, Width = 120, Padding = new Thickness(0, 0, 0, 0) }; copyLink.Click += fly_Click; myFlyout.Items.Add(copyLink); myFlyout.ShowAt(sender as UIElement, e.GetPosition(sender as UIElement)); }
public OOBEPage() { this.InitializeComponent(); DListModel = _List.ViewModel; ViewModel = new OOBEPageViewModel(DListModel); _ContextMenu = new MenuFlyout(); _ContextMenu.Items.Add(new MenuFlyoutItem { Text = "Exit", Icon = new SymbolIcon(Symbol.Clear) }); Style style = new Style(typeof(MenuFlyoutPresenter)); style.Setters.Add(new Setter(Windows.UI.Xaml.FrameworkElement.MinWidthProperty, 150)); _ContextMenu.MenuFlyoutPresenterStyle = style; }
private void StackPanel_RightTapped(object sender, RightTappedRoutedEventArgs e) { MenuFlyout myFlyout = new MenuFlyout(); MenuFlyoutItem goLastPage = new MenuFlyoutItem { Text = Resource.STR_LAST_PAGE, Height = 30, Width = 100, Padding = new Thickness(0, 0, 0, 0) }; countRep = ((StackPanel)sender).Tag.ToString(); goLastPage.Click += Fly_Click; myFlyout.Items.Add(goLastPage); myFlyout.ShowAt(sender as UIElement, e.GetPosition(sender as UIElement)); }
/// <inheritdoc /> protected override void OnApplyTemplate() { FlyoutButton = GetTemplateChild(FlyoutButtonName) as Button; _parentMenu = this.FindAscendant <Menu>(); IsOpened = false; Items.VectorChanged -= Items_VectorChanged; LayoutUpdated -= MenuItem_LayoutUpdated; if (_menuFlyout == null) { _menuFlyout = new MenuFlyout(); } else { _menuFlyout.Opened -= MenuFlyout_Opened; _menuFlyout.Closed -= MenuFlyout_Closed; } if (FlyoutButton != null) { FlyoutButton.PointerExited -= FlyoutButton_PointerExited; Items.VectorChanged += Items_VectorChanged; _menuFlyout.Placement = _parentMenu.Orientation == Orientation.Horizontal ? FlyoutPlacementMode.Bottom : FlyoutPlacementMode.Right; FlyoutButton.Flyout = _menuFlyout; LayoutUpdated += MenuItem_LayoutUpdated; _menuFlyout.Opened += MenuFlyout_Opened; _menuFlyout.Closed += MenuFlyout_Closed; FlyoutButton.PointerExited += FlyoutButton_PointerExited; _menuFlyout.MenuFlyoutPresenterStyle = _parentMenu.MenuFlyoutStyle; ReAddItemsToFlyout(); if (_isAccessKeySupported) { FlyoutButton.AccessKey = AccessKey; AccessKey = string.Empty; } } base.OnApplyTemplate(); }
private void Menu_ContextRequested(object sender, RoutedEventArgs e) { var viewModel = ViewModel; if (viewModel == null) { return; } var item = viewModel.SelectedItem as GalleryContent; if (item == null) { return; } var flyout = new MenuFlyout(); flyout.CreateFlyoutItem(x => item.CanView, viewModel.ViewCommand, item, Strings.Resources.ShowInChat, new FontIcon { Glyph = Icons.Message }); flyout.CreateFlyoutItem(x => item.CanCopy, viewModel.CopyCommand, item, Strings.Resources.Copy, new FontIcon { Glyph = Icons.Copy }, Windows.System.VirtualKey.C); flyout.CreateFlyoutItem(x => item.CanSave, viewModel.SaveCommand, item, Strings.Additional.SaveAs, new FontIcon { Glyph = Icons.SaveAs }, Windows.System.VirtualKey.S); flyout.CreateFlyoutItem(x => viewModel.CanOpenWith, viewModel.OpenWithCommand, item, Strings.Resources.OpenInExternalApp, new FontIcon { Glyph = Icons.OpenIn }); if (SettingsService.Current.Diagnostics.ShowOpenWithVlc && item.IsVideo) { flyout.CreateFlyoutItem(viewModel.OpenWithVlcCommand, item, Strings.Resources.OpenInExternalApp + " VLC", new FontIcon { Glyph = Icons.Play }); } flyout.CreateFlyoutItem(x => viewModel.CanDelete, viewModel.DeleteCommand, item, Strings.Resources.Delete, new FontIcon { Glyph = Icons.Delete }); if (ApiInfo.CanUseNewFlyoutPlacementMode) { flyout.Placement = FlyoutPlacementMode.BottomEdgeAlignedRight; } flyout.ShowAt(sender as FrameworkElement); }
private void MenuFlyoutItemSettings(ObservableCollection <string> temp) { MenuFlyout flyout = new MenuFlyout(); foreach (var item in temp) { MenuFlyoutItem mi = new MenuFlyoutItem(); string[] values = item.Split(' '); mi.Text = item; mi.Click += filter_Click; flyout.Items.Add(mi); } foreach (var item in flyout.Items) { filter.Items.Insert(filter.Items.Count, item); } }
private void Animation_ContextRequested(UIElement sender, ItemContextRequestedEventArgs <Animation> args) { var element = sender as FrameworkElement; var animation = args.Item; if (animation == null) { return; } var flyout = new MenuFlyout(); if (ViewModel.ProtoService.IsAnimationSaved(animation.AnimationValue.Id)) { flyout.CreateFlyoutItem(ViewModel.AnimationDeleteCommand, animation, Strings.Resources.Delete, new FontIcon { Glyph = Icons.Delete }); } else { flyout.CreateFlyoutItem(ViewModel.AnimationSaveCommand, animation, Strings.Resources.SaveToGIFs, new FontIcon { Glyph = Icons.Gif }); } if (ViewModel.Type == ViewModels.DialogType.History) { var chat = ViewModel.Chat; if (chat == null) { return; } var self = ViewModel.CacheService.IsSavedMessages(chat); flyout.CreateFlyoutSeparator(); flyout.CreateFlyoutItem(new RelayCommand <Animation>(anim => ViewModel.AnimationSendExecute(anim, null, true)), animation, Strings.Resources.SendWithoutSound, new FontIcon { Glyph = Icons.AlertOff }); flyout.CreateFlyoutItem(new RelayCommand <Animation>(anim => ViewModel.AnimationSendExecute(anim, true, null)), animation, self ? Strings.Resources.SetReminder : Strings.Resources.ScheduleMessage, new FontIcon { Glyph = Icons.CalendarClock }); } args.ShowAt(flyout, element); }
private void MenuFlyout_Opening(object sender, object e) { MenuFlyout senderAsMenuFlyout = sender as MenuFlyout; foreach (object menuFlyoutItem in senderAsMenuFlyout.Items) { if (menuFlyoutItem.GetType() == typeof(MenuFlyoutItem)) { // Associate the particular FeedItem with the menu flyout (so the MenuFlyoutItem knows which FeedItem to act upon) ListViewItem itemContainer = senderAsMenuFlyout.Target as ListViewItem; var feedItem = downloadListView.ItemFromContainer(itemContainer) as EpisodeWithState; (menuFlyoutItem as MenuFlyoutItem).CommandParameter = feedItem.Episode; } } }
public ToolsMenuItem(INavigationFacade navigation) { _navigation = navigation; Command = new RelayCommand(() => _navigation.NavigateToMainPage()); Image = new BitmapImage(new Uri("ms-appx:///Assets/MenuIcons/wrench.png")); ContextMenu = new MenuFlyout(); ContextMenu.Items.Add(new MenuFlyoutItem { Text = "Trouver les tables statiques" }); ContextMenu.Items.Add(new MenuFlyoutItem { Text = "Restraindre l'accès aux tables" }); ContextMenu.Items.Add(new MenuFlyoutItem { Text = "Détection des colonnes à générer" }); }
private void Member_ContextRequested(UIElement sender, ContextRequestedEventArgs args) { var flyout = new MenuFlyout(); var element = sender as FrameworkElement; var member = element.Tag as ChatMember; var chat = ViewModel.Chat; if (chat == null || member == null) { return; } ChatMemberStatus status = null; if (chat.Type is ChatTypeBasicGroup basic) { status = ViewModel.ProtoService.GetBasicGroup(basic.BasicGroupId)?.Status; } else if (chat.Type is ChatTypeSupergroup super) { status = ViewModel.ProtoService.GetSupergroup(super.SupergroupId)?.Status; } if (status == null) { return; } if (chat.Type is ChatTypeSupergroup) { flyout.CreateFlyoutItem(MemberPromote_Loaded, ViewModel.MemberPromoteCommand, chat.Type, status, member, Strings.Resources.SetAsAdmin, new FontIcon { Glyph = Icons.Star }); flyout.CreateFlyoutItem(MemberRestrict_Loaded, ViewModel.MemberRestrictCommand, chat.Type, status, member, Strings.Resources.KickFromSupergroup, new FontIcon { Glyph = Icons.LockClosed }); } flyout.CreateFlyoutItem(MemberRemove_Loaded, ViewModel.MemberRemoveCommand, chat.Type, status, member, Strings.Resources.KickFromGroup, new FontIcon { Glyph = Icons.Block }); args.ShowAt(flyout, element); }
private async static void Setup(MenuFlyout menuFlyout) { if (menuFlyout != null) { await SharedLogic.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { core.OptionItems.CollectionChanged += OptionItems_CollectionChanged; menuFlyout.Items.Clear(); MenuFlyoutSubItem addTo = new MenuFlyoutSubItem() { Text = "Add to" }; MenuFlyoutItem properties = new MenuFlyoutItem() { Text = "Properties", Command = core.ShowPropertiesCommand, CommandParameter = null }; MenuFlyoutItem openLoc = new MenuFlyoutItem() { Text = "Open Song Location", Command = core.OpenSongLocationCommand, CommandParameter = null }; menuFlyout.Items.Add(addTo); menuFlyout.Items.Add(openLoc); menuFlyout.Items.Add(properties); foreach (var menuItem in core.OptionItems) { var item = new MenuFlyoutItem() { Text = menuItem.Text, Command = menuItem.Command }; item.CommandParameter = menuItem.CommandParameter == null ? item : menuItem.CommandParameter; if (menuFlyout.GetType() != typeof(CustomFlyout)) { item.Tag = "Current"; } if (addTo.Items.Count == 1) { addTo.Items.Add(new MenuFlyoutSeparator()); } addTo.Items.Add(item); } }); SharedLogic.Player.PropertyChanged += Player_PropertyChanged; } }
private MenuFlyoutReactions(IList <Reaction> reactions, MessageViewModel message, MessageBubble bubble, MenuFlyout flyout) { _reactions = message.ProtoService.IsPremium ? reactions : reactions.Where(x => !x.IsPremium).ToList(); _canUnlockMore = message.ProtoService.IsPremiumAvailable && !message.ProtoService.IsPremium && reactions.Any(x => x.IsPremium); _message = message; _bubble = bubble; _flyout = flyout; InitializeComponent(); var last = flyout.Items.LastOrDefault(); var presenter = last.Ancestors <MenuFlyoutPresenter>().FirstOrDefault(); _presenter = presenter; _popup = new Popup(); var transform = presenter.TransformToVisual(Window.Current.Content); var position = transform.TransformPoint(new Point()); //var relativeFirst = Math.Abs(absolute.Y - position.Y); //var relativeLast = Math.Abs(absolute.Y - (position.Y + presenter.ActualHeight)); var upsideDown = false; //relativeLast < relativeFirst; var count = Math.Min(_reactions.Count, 6); var actualWidth = presenter.ActualSize.X + 18 + 12 + 18; var width = 8 + count * 34 - 2; var padding = actualWidth - width; Shadow.Width = width; Pill.Width = width; ScrollingHost.Width = width; Expand.Visibility = _reactions.Count > 6 ? Visibility.Visible : Visibility.Collapsed; BubbleMedium.VerticalAlignment = upsideDown ? VerticalAlignment.Top : VerticalAlignment.Bottom; BubbleMedium.Margin = new Thickness(0, upsideDown ? -6 : 0, 18, upsideDown ? 0 : -6); BubbleOverlay.VerticalAlignment = upsideDown ? VerticalAlignment.Top : VerticalAlignment.Bottom; BubbleOverlay.Margin = new Thickness(0, upsideDown ? -6 : 0, 18, upsideDown ? 0 : -6); LayoutRoot.Padding = new Thickness(16, upsideDown ? 32 : 16, 16, upsideDown ? 16 : 32); var offset = 0; var visible = _reactions.Count > 6 ? 5 : 6; //Math.Ceiling((width - 8) / 34);
public object Execute(object sender, object parameter) { var eventArgs = parameter as RightTappedRoutedEventArgs; var tappedElement = eventArgs?.OriginalSource as FrameworkElement; if (tappedElement != null) { var contextMenuItemsDelegate = MenuItemsDelegate; if (contextMenuItemsDelegate != null && tappedElement.DataContext != null) { var itemViewModel = tappedElement.DataContext; var contextMenuItems = contextMenuItemsDelegate(itemViewModel); if (contextMenuItems != null) { var menuFlyout = new MenuFlyout(); foreach (var contextMenuItem in contextMenuItems) { if (!contextMenuItem.Title.IsNullOrWhiteSpace() && contextMenuItem.Command != null) { var item = new MenuFlyoutItem { Text = contextMenuItem.Title, Command = contextMenuItem.Command, CommandParameter = itemViewModel }; menuFlyout.Items.Add(item); } } if (menuFlyout.Items.Count > 0) { menuFlyout.ShowAt(tappedElement, eventArgs.GetPosition(tappedElement)); Flyout.SetAttachedFlyout(tappedElement, menuFlyout); Flyout.ShowAttachedFlyout(tappedElement); // This ensures that nested ListView objects don't try to keep handling this right tap. eventArgs.Handled = true; } } } } return null; }
private void AddDateCostGrid_Tapped(object sender, TappedRoutedEventArgs e) { MenuFlyout costMenuFlyout = new MenuFlyout(); costMenuFlyout.Items.Add(getCostMenuFlyoutItem("AA制")); costMenuFlyout.Items.Add(getCostMenuFlyoutItem("你请客")); costMenuFlyout.Items.Add(getCostMenuFlyoutItem("我买单")); costMenuFlyout.ShowAt(AddDateCostGrid); }
private async void AddDateTypeGrid_Tapped(object sender, TappedRoutedEventArgs e) { MenuFlyout typeMenuFlyout = new MenuFlyout(); bool isType = true; try { string datetype = appSetting.Values["datetype_json"].ToString(); if (datetype != "") { JArray datetypeArray = Utils.ReadJso(datetype); for (int i = 0; i < datetypeArray.Count; i++) { JObject jobj = (JObject)datetypeArray[i]; typeMenuFlyout.Items.Add(getTypeMenuFlyoutItem(jobj["type"].ToString())); var b = new DateType(); datetypelist.Add(new DateType { Id = Convert.ToInt32(jobj["id"].ToString()), Type = jobj["type"].ToString() }); } typeMenuFlyout.ShowAt(AddDateTypeGrid); } else isType = false; } catch (Exception) { Debug.WriteLine("发布约,分类数据加载异常"); isType = false; } if (!isType) { showStatus("分类数据加载失败", 1, Visibility.Collapsed); appSetting.Values["datetype_json"] = Utils.ConvertUnicodeStringToChinese(await NetWork.getHttpWebRequest("/date/datetype", new List<KeyValuePair<String, String>>())); } }
private async void AddButton_Click(object sender, RoutedEventArgs e) { var muIDArray = App.muIdList.ToArray().ToList(); AddButton.IsEnabled = false; AddProgressRing.IsActive = true; //if (AddTextBox.Text.Length != 10) //{ // Utils.Message("学号不正确"); //} if (muIDArray.Find(p => p.uId.Equals(AddTextBox.Text)) != null) Utils.Message("此学号已添加"); else { //for (int i = 0; i < 15; i++) string usename = AddTextBox.Text; string useid = usename; string peopleinfo = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/home/searchPeople/peopleList?stu=" + useid, PostORGet: 1); Debug.WriteLine("peopleinfo->" + peopleinfo); if (peopleinfo != "") { try { JObject obj = JObject.Parse(peopleinfo); if (Int32.Parse(obj["state"].ToString()) == 200) { JArray PeopleListArray = Utils.ReadJso(peopleinfo); if (PeopleListArray.Count != 1) { MenuFlyout PeopleListMenuFlyout = new MenuFlyout(); for (int i = 0; i < PeopleListArray.Count; i++) { PersonalIno Personalitem = new PersonalIno(); Personalitem.GetAttribute((JObject)PeopleListArray[i]); PeopleListMenuFlyout.Items.Add(getPeopleListMenuFlyoutItem(Personalitem.Name + "-" + Personalitem.Major + "-" + Personalitem.Stunum)); } PeopleListMenuFlyout.ShowAt(AddTextBox); } else { PersonalIno Personalitem = new PersonalIno(); Personalitem.GetAttribute((JObject)PeopleListArray[0]); if (muIDArray.Find(p => p.uId.Equals(Personalitem.Stunum)) != null) Utils.Message("此学号已添加"); else { if (Personalitem.Stunum == AddTextBox.Text || Personalitem.Name == AddTextBox.Text) App.muIdList.Add(new uIdList { uId = Personalitem.Stunum, uName = Personalitem.Name }); else { MenuFlyout PeopleListMenuFlyout = new MenuFlyout(); PeopleListMenuFlyout.Items.Add(getPeopleListMenuFlyoutItem(Personalitem.Name + "-" + Personalitem.Major + "-" + Personalitem.Stunum)); PeopleListMenuFlyout.ShowAt(AddTextBox); } } } //JObject dataobj = JObject.Parse(obj["data"].ToString()); } else Utils.Message("学号或姓名不正确"); } catch (Exception) { } } AddTextBox.Text = ""; } AddButton.IsEnabled = true; AddProgressRing.IsActive = false; }
private void AddDateSexGrid_Tapped(object sender, TappedRoutedEventArgs e) { MenuFlyout sexMenuFlyout = new MenuFlyout(); sexMenuFlyout.Items.Add(getSexMenuFlyoutItem("不限")); sexMenuFlyout.Items.Add(getSexMenuFlyoutItem("男")); sexMenuFlyout.Items.Add(getSexMenuFlyoutItem("女")); sexMenuFlyout.ShowAt(AddDateSexGrid); }
private void FriendPerson_OnHolding(object sender, HoldingRoutedEventArgs e) { if (e.HoldingState != HoldingState.Started) return; var button = sender as Button; if (button == null) return; var flyout = new MenuFlyout(); if (flyout.Items == null) return; flyout.Items.Add(new MenuFlyoutItem { Text = App.Loader.GetString("Remove"), Command = ViewModel.RemoveFriendCommand, CommandParameter = button.DataContext }); flyout.Items.Add(new MenuFlyoutItem { Text = App.Loader.GetString("ChangeDisplay"), Command = ViewModel.ChangeDisplayNameCommand, CommandParameter = button.DataContext }); flyout.Items.Add(((Friend) button.DataContext).FriendRequestState == FriendRequestState.Blocked ? new MenuFlyoutItem { Text = App.Loader.GetString("Unblock"), Command = ViewModel.UnBlockFriendCommand, CommandParameter = button.DataContext } : new MenuFlyoutItem { Text = App.Loader.GetString("Block"), Command = ViewModel.BlockFriendCommand, CommandParameter = button.DataContext }); flyout.ShowAt((FrameworkElement)sender); // TODO: Refresh CollectionViewSource's after these commands have been executed... Not sure how though. Matt? }
private void FamilyListMethod(Image selectedImage) { // Image selectedImage = e.OriginalSource as Image; // To find which person the user is touching, we look at the owner of the image. However, // sometimes the selected Image is null, because the user's finger isn't exactly in the right // place, and is (for example) touching the text under the image. We return when this happens. if (selectedImage == null) { return; } Person selectedPerson = selectedImage.DataContext as Person; var menu = new MenuFlyout(); // We use our subclass of MenuFlyoutItem to store the selected person // and so pass it to the menu option handlers. var option1 = new MenuFlyoutItem() { Text = "Create note for " + selectedPerson.FriendlyName }; var option2 = new MenuFlyoutItem() { Text = "Add/replace photo for " + selectedPerson.FriendlyName }; var option3 = new MenuFlyoutItem() { Text = "Delete " + selectedPerson.FriendlyName }; option1.Tag = selectedPerson; option2.Tag = selectedPerson; option3.Tag = selectedPerson; option1.Click += menuFlyoutOptionCreateNote; option2.Click += menuFlyoutOptionAddPhotoToPerson; option3.Click += menuFlyoutOptionDeletePerson; menu.Items.Add(option1); if (selectedPerson.FriendlyName != App.EVERYONE) { menu.Items.Add(option2); menu.Items.Add(option3); } menu.ShowAt(selectedImage, new Point(60, 0)); }
private static DateTimeOffset GetReleaseThreshold(MenuFlyout element) { return (DateTimeOffset)element.GetValue(ReleaseThresholdProperty); }
private static void SetReleaseThreshold(MenuFlyout element, DateTimeOffset value) { element.SetValue(ReleaseThresholdProperty, value); }
/// <summary> /// Generated when an item in the listbox is tapped /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListBoxItem_Tapped(object sender, TappedRoutedEventArgs e) { MenuFlyout menu = new MenuFlyout(); MenuFlyoutItem markAsCompleted = new MenuFlyoutItem(); ListBoxItem newTaskList = (ListBoxItem)sender; _lastSelectedListBox = newTaskList; if (((sender as ListBoxItem).Background as SolidColorBrush).Color == Colors.Green) { markAsCompleted.Text = "Mark as incomplete"; markAsCompleted.Click += MenuMarkIncomplete; } else { markAsCompleted.Text = "Mark as completed"; markAsCompleted.Click += MenuMarkAsCompleted; } MenuFlyoutItem menuRemove = new MenuFlyoutItem(); menu.Items.Add(markAsCompleted); menuRemove.Text = "Remove"; menuRemove.Click += MenuRemove; menu.Items.Add(menuRemove); menu.ShowAt((FrameworkElement)sender); }
/// <summary> /// Occurs when an item in the list of loaded keys is clicked. /// </summary> /// <param name="sender">The object where the event handler is attached.</param> /// <param name="e">The event data.</param> private void AgentKeys_ItemClick(object sender, ItemClickEventArgs e) { PrivateKeyAgentKey agentKey = e.ClickedItem as PrivateKeyAgentKey; if (agentKey == null) { return; } var clickedItem = ((ListViewBase)sender).ContainerFromItem(e.ClickedItem); MenuFlyout menuFlyout = new MenuFlyout() { Placement = FlyoutPlacementMode.Bottom, }; MenuFlyoutItem menuItemUnload = new MenuFlyoutItem(); menuItemUnload.Text = "Unload"; menuItemUnload.Tapped += (a, b) => { PrivateKeyAgentManager.PrivateKeyAgent.RemoveSsh2(agentKey.Key.Data); this.AgentKeys.Remove(agentKey); this.SetEmptyHintVisibilities(); }; //MenuFlyoutItem menuItemImport = new MenuFlyoutItem(); //menuItemImport.Text = "Import"; //menuItemImport.Tapped += (a, b) => //{ // PrivateKeysDataSource privateKeysDataSource = (PrivateKeysDataSource)App.Current.Resources["privateKeysDataSource"]; // if (privateKeysDataSource != null) // { // var privateKeysFolder = await PrivateKeysDataSource.GetPrivateKeysFolder(); // char[] fileNameChars = agentKey.Comment.ToCharArray(); // char[] invalidChars = Path.GetInvalidFileNameChars(); // for (int i = 0; i < fileNameChars.Length; i++) // { // if (invalidChars.Contains(fileNameChars[i])) // { // fileNameChars[i] = '_'; // } // } // string fileName = new string(fileNameChars); // agentKey.Key.Key. // var privateKeyFile = await file.CopyAsync(privateKeysFolder, file.Name, NameCollisionOption.GenerateUniqueName); // var privateKeyData = new PrivateKeyData() // { // FileName = privateKeyFile.Name, // Data = (await FileIO.ReadBufferAsync(privateKeyFile)).ToArray(), // }; // privateKeysDataSource.PrivateKeys.Remove(PrivateKeysDataSource.GetPrivateKey(privateKeyData.FileName)); // privateKeysDataSource.PrivateKeys.Add(privateKeyData); // this.SetEmptyHintVisibilities(); // } //}; menuFlyout.Items.Add(menuItemUnload); //menu.Items.Add(menuItemImport); menuFlyout.ShowAt((FrameworkElement)clickedItem); //PopupMenu menu = new PopupMenu(); //menu.Commands.Add(new UICommand("Unload")); //menu.Commands.Add(new UICommand("Save locally")); //var command = await menu.ShowAsync(new Point(0, 0)); //if (command == null) //{ // return; //} }
void OpenContextMenu() { if (FlyoutBase.GetAttachedFlyout(CellContent) == null) { var flyout = new MenuFlyout(); SetupMenuItems(flyout); ((INotifyCollectionChanged)Cell.ContextActions).CollectionChanged += OnContextActionsChanged; _contextActions = Cell.ContextActions; FlyoutBase.SetAttachedFlyout(CellContent, flyout); } FlyoutBase.ShowAttachedFlyout(CellContent); }
private async Task buildList(object sender, bool channel_or_volume) { //PopupMenu menu = new PopupMenu(); MenuFlyout mf = new MenuFlyout(); //var r = await m.ShowAt(inv); // // GET DEVICES FROM SOURCE BASE ON channel_or_volume // true = volume devices // false = channel devices // if there is an iteam in the list, also add "Add new device..." at bottom of the list. if (channel_or_volume) { List<VolumeDevice> vList = ((App)CPRemoteApp.App.Current).deviceController.getVolumeDevices(); foreach(VolumeDevice d in vList) { MenuFlyoutItem mi = new MenuFlyoutItem(); mi.Text = d.get_name(); mi.Click+= selectListItem; mf.Items.Add(mi); } MenuFlyoutItem new_vol = new MenuFlyoutItem(); new_vol.Text = "Add new volume device..."; new_vol.Click+= addNewVolumeDevice; mf.Items.Add(new_vol); } else { List<ChannelDevice> cList = ((App)CPRemoteApp.App.Current).deviceController.getChannelDevices(); foreach (ChannelDevice d in cList) { MenuFlyoutItem mi = new MenuFlyoutItem(); mi.Text = d.get_name(); mi.Click += selectListItem; mf.Items.Add(mi); } MenuFlyoutItem new_chan = new MenuFlyoutItem(); new_chan.Text = "Add new channel device..."; new_chan.Click += addNewChannelDevice; mf.Items.Add(new_chan); } mf.ShowAt(sender as FrameworkElement); }
private async void AddImageThumbnailsToLayout() { if (Directory.Exists(ApplicationData.Current.LocalFolder.Path + "\\Images")) { // Create menu for right clicking/holding images menu = new MenuFlyout(); menu.Placement = FlyoutPlacementMode.Right; MenuFlyoutItem openItem = new MenuFlyoutItem(); openItem.Text = "Open"; openItem.Click += OpenItem_Click; MenuFlyoutItem shareItem = new MenuFlyoutItem(); shareItem.Text = "Share"; shareItem.Click += ShareItem_Click; MenuFlyoutItem deleteItem = new MenuFlyoutItem(); deleteItem.Text = "Delete"; deleteItem.Click += DeleteItem_Click; menu.Items.Add(openItem); menu.Items.Add(shareItem); menu.Items.Add(deleteItem); menu.Closed += Menu_Closed; StorageFolder imageFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("Images"); var images = await imageFolder.GetItemsAsync(); StackPanel horizontalStackPanel = new StackPanel(); horizontalStackPanel.Orientation = Orientation.Horizontal; vertStackPanel.Children.Add(horizontalStackPanel); int numImagesInRow = (int)((Window.Current.Bounds.Width - 200) / 200); int positionInRow = 0; foreach (IStorageItem image in images) { if (image.GetType() == typeof(StorageFile)) { StorageFile file = image as StorageFile; Image imageToAdd = new Image(); BitmapImage bitmap = new BitmapImage(); var thumb = await file.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.PicturesView); await bitmap.SetSourceAsync(thumb); var fileToken = StorageApplicationPermissions.FutureAccessList.Add(image); imageToAdd.Name = fileToken; imageToAdd.Source = bitmap; imageToAdd.Margin = new Thickness(1.5); imageToAdd.Tapped += ImageToAdd_Tapped; imageToAdd.Holding += ImageToAdd_Holding; imageToAdd.RightTapped += ImageToAdd_RightTapped; if (positionInRow > numImagesInRow) { horizontalStackPanel = new StackPanel(); horizontalStackPanel.Orientation = Orientation.Horizontal; vertStackPanel.Children.Add(horizontalStackPanel); positionInRow = 0; } horizontalStackPanel.Children.Add(imageToAdd); positionInRow++; } } } }
private void BuildMainMenu() { Items = new ObservableCollection<object>() { new MenuItemViewModel { Title = Translations.Info_Title, Icon = Views.InfoPage.PAGE_ICON, Description = "Information across all areas & departments.", NavigationCommand = new RelayCommand(p => { _navigationMediator.NavigateAsync(typeof(Views.InfoPage), forceNewStack: true); }), ChildTypes = new List<Type>() { typeof(Views.InfoPage), typeof(Views.InfoGroupDetailPage) } }, new MenuItemViewModel { Title = Translations.EventSchedule_Title, Icon = Views.EventsPage.PAGE_ICON, Description = "What's happening, when & where?", NavigationCommand = new RelayCommand(p => { _navigationMediator.NavigateAsync(typeof(Views.EventsPage), forceNewStack: true); }), ChildTypes = new List<Type>() { typeof(Views.EventsPage), typeof(Views.EventsByDayPage), typeof(Views.EventDetailPage) } }, new MenuItemViewModel{ Title = Translations.Dealers_Title, Icon = Views.DealerListPage.PAGE_ICON, Description = "List of dealers and their merchandise.", NavigationCommand = new RelayCommand(p => { _navigationMediator.NavigateAsync(typeof(Views.DealerListPage), forceNewStack: true); }), ChildTypes = new List<Type>() { typeof(Views.DealerListPage), typeof(Views.DealerDetailPage) } }, new MenuItemViewModel{ Title = "Maps", Icon = "\uE128", Description = "Convention space maps to help navigating.", NavigationCommand = new RelayCommand(p => { _navigationMediator.NavigateAsync(typeof(Views.MapsPage), forceNewStack: true); }), ChildTypes = new List<Type>() { typeof(Views.MapsPage), typeof(Views.MapDetailPage) } }, new object(), new MenuItemViewModel{ Title = "Feedback", Icon = "\uE8DF", Description = "Let us know how the app works for you.", NavigationCommand = new RelayCommand(p => { var flyout = new MenuFlyout(); flyout.Items.Add(new MenuFlyoutItem() { Text = "Send feedback", Command = new RelayCommand(async a => { await Launcher.LaunchUriAsync(new Uri(@"http://goo.gl/forms/6hejPn85maAohLJm1")); }) }); flyout.Items.Add(new MenuFlyoutItem() { Text = "Report a bug", Command = new RelayCommand(async a => { await Launcher.LaunchUriAsync(new Uri(@"http://goo.gl/forms/IwckZ8lONCDRZooQ2")); }) }); flyout.Items.Add(new MenuFlyoutItem() { Text = "Write a review", Command = new RelayCommand(async a => { await Windows.System.Launcher.LaunchUriAsync( new Uri("ms-windows-store:reviewapp?appid=" + CurrentApp.AppId)); }) }); flyout.ShowAt((FrameworkElement)p); }), ChildTypes = new List<Type>() } }; }
public static MenuFlyout ToMenuFlyout(this IContextMenu source) { MenuFlyout flyout = new MenuFlyout(); return source.ToMenuFlyout(flyout); }
private void typeTextBlock_Tapped(object sender, TappedRoutedEventArgs e) { MenuFlyout typeMenuFlyout = new MenuFlyout(); bool isType = true; try { string datetype = appSetting.Values["datetype_json"].ToString(); if (datetype != "") { JArray datetypeArray = Utils.ReadJso(datetype); datetypelist.Add(new DateType { Id = 0, Type = "全部分类" }); for (int i = 0; i < datetypeArray.Count; i++) { JObject jobj = (JObject)datetypeArray[i]; typeMenuFlyout.Items.Add(getTypeMenuFlyoutItem(jobj["type"].ToString())); var b = new DateType(); datetypelist.Add(new DateType { Id = Convert.ToInt32(jobj["id"].ToString()), Type = jobj["type"].ToString() }); } typeMenuFlyout.ShowAt(typeTextBlock); } else isType = false; } catch (Exception) { Debug.WriteLine("主页,分类数据加载异常"); isType = false; } if (!isType) { showStatus("分类数据加载失败", 1, Visibility.Collapsed); getDatetypeInfor(); } }
private void sortTextBlock_Tapped(object sender, TappedRoutedEventArgs e) { MenuFlyout sortMenuFlyout = new MenuFlyout(); sortMenuFlyout.Items.Add(getsortMenuFlyoutItem("默认排序")); sortMenuFlyout.Items.Add(getsortMenuFlyoutItem("创建时间")); sortMenuFlyout.Items.Add(getsortMenuFlyoutItem("剩余时间")); sortMenuFlyout.Items.Add(getsortMenuFlyoutItem("参与人数")); sortMenuFlyout.Items.Add(getsortMenuFlyoutItem("用户信用")); sortMenuFlyout.ShowAt(sortTextBlock); }
void SetupMenuItems(MenuFlyout flyout) { foreach (MenuItem item in Cell.ContextActions) { var flyoutItem = new MenuFlyoutItem(); flyoutItem.SetBinding(MenuFlyoutItem.TextProperty, "Text"); flyoutItem.Command = new MenuItemCommand(item); flyoutItem.DataContext = item; flyout.Items.Add(flyoutItem); } }
private async void mAddButton() { var muIDArray = App.muIdList.ToArray().ToList(); AddButton.IsEnabled = false; AddProgressRing.IsActive = true; //if (AddTextBox.Text.Length != 10) //{ // Utils.Message("学号不正确"); //} if (muIDArray.Find(p => p.uId.Equals(AddTextBox.Text)) != null) Utils.Message("此学号已添加"); else { string usename = AddTextBox.Text; string useid = usename; string peopleinfo = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/home/searchPeople/peopleList?stu=" + useid, PostORGet: 1); Debug.WriteLine("peopleinfo->" + peopleinfo); //peopleinfo = "{\"state\":200,\"info\":\"success\",\"data\":[{\"stunum\":\"2014210825\",\"name\":\"\\u6768\\u5b87\",\"gender\":\"\\u7537 \",\"classnum\":\"0201410\",\"major\":\"\\u7535\\u5b50\\u5de5\\u7a0b\\u7c7b\",\"depart\":\"\\u5149\\u7535\\u5de5\\u7a0b\\u5b66\\u9662\",\"grade\":\"2014 \"},{\"stunum\":\"2015211173\",\"name\":\"\\u6768\\u5b87\",\"gender\":\"\\u7537 \",\"classnum\":\"03081502\",\"major\":\"\\u5de5\\u7a0b\\u7ba1\\u7406\",\"depart\":\"\\u7ecf\\u6d4e\\u7ba1\\u7406\\u5b66\\u9662\",\"grade\":\"2015 \"},{\"stunum\":\"2013211594\",\"name\":\"\\u6768\\u5b87\\u661f\",\"gender\":\"\\u7537 \",\"classnum\":\"0441302\",\"major\":\"\\u4fe1\\u606f\\u5b89\\u5168\",\"depart\":\"\\u8ba1\\u7b97\\u673a\\u79d1\\u5b66\\u4e0e\\u6280\\u672f\\u5b66\\u9662\",\"grade\":\"2013 \"},{\"stunum\":\"2014212099\",\"name\":\"\\u6768\\u5b87\\u822a\",\"gender\":\"\\u7537 \",\"classnum\":\"0611403\",\"major\":\"\\u751f\\u7269\\u533b\\u5b66\\u5de5\\u7a0b\",\"depart\":\"\\u751f\\u7269\\u4fe1\\u606f\\u5b66\\u9662\",\"grade\":\"2014 \"},{\"stunum\":\"2015212379\",\"name\":\"\\u6768\\u5b87\\u4f73\",\"gender\":\"\\u5973 \",\"classnum\":\"07111503\",\"major\":\"\\u6cd5\\u5b66\\u7c7b\",\"depart\":\"\\u6cd5\\u5b66\\u9662\",\"grade\":\"2015 \"},{\"stunum\":\"2015213755\",\"name\":\"\\u6768\\u5b87\\u5b81\",\"gender\":\"\\u5973 \",\"classnum\":\"12121504\",\"major\":\"\\u6570\\u5b57\\u5a92\\u4f53\\u827a\\u672f\\u4e0e\\u52a8\\u753b\\u5927\\u7c7b\",\"depart\":\"\\u4f20\\u5a92\\u827a\\u672f\\u5b66\\u9662\",\"grade\":\"2015 \"},{\"stunum\":\"2012213099\",\"name\":\"\\u6768\\u5b87\\u822a\",\"gender\":\"\\u7537 \",\"classnum\":\"0841201\",\"major\":\"\\u673a\\u68b0\\u8bbe\\u8ba1\\u5236\\u9020\\u53ca\\u5176\\u81ea\\u52a8\\u5316\",\"depart\":\"\\u5148\\u8fdb\\u5236\\u9020\\u5de5\\u7a0b\\u5b66\\u9662\",\"grade\":\"2012 \"}]}"; if (peopleinfo != "") { try { JObject obj = JObject.Parse(peopleinfo); if (Int32.Parse(obj["state"].ToString()) == 200) { JArray PeopleListArray = Utils.ReadJso(peopleinfo); if (PeopleListArray.Count != 1) { MenuFlyout PeopleListMenuFlyout = new MenuFlyout(); for (int i = 0; i < PeopleListArray.Count; i++) { PersonalIno Personalitem = new PersonalIno(); Personalitem.GetAttribute((JObject)PeopleListArray[i]); PeopleListMenuFlyout.Items.Add(getPeopleListMenuFlyoutItem(Personalitem.Name + "-" + Personalitem.Major + "-" + Personalitem.Stunum)); } PeopleListMenuFlyout.ShowAt(AddTextBox); } else { PersonalIno Personalitem = new PersonalIno(); Personalitem.GetAttribute((JObject)PeopleListArray[0]); if (muIDArray.Find(p => p.uId.Equals(Personalitem.Stunum)) != null) Utils.Message("此学号已添加"); else { if (Personalitem.Stunum == AddTextBox.Text || Personalitem.Name == AddTextBox.Text) App.muIdList.Add(new uIdList { uId = Personalitem.Stunum, uName = Personalitem.Name }); else { MenuFlyout PeopleListMenuFlyout = new MenuFlyout(); PeopleListMenuFlyout.Items.Add(getPeopleListMenuFlyoutItem(Personalitem.Name + "-" + Personalitem.Major + "-" + Personalitem.Stunum)); PeopleListMenuFlyout.ShowAt(AddTextBox); } } } //JObject dataobj = JObject.Parse(obj["data"].ToString()); } else Utils.Message("学号或姓名不正确"); } catch (Exception) { } } AddTextBox.Text = ""; } AddButton.IsEnabled = true; AddProgressRing.IsActive = false; }
void DoHolding(object sender) { if (((sender as StackPanel).DataContext as MyRenderItem).Word != -1) { Flyout ContextFlyout = new Flyout(); StackPanel Panel = new StackPanel(); //Panel.SetValue(NameProperty, "TopLevel"); //Panel.Name = "TopLevel"; Panel.DataContext = this; ContextFlyout.Content = Panel; Panel.Children.Add(new ItemsControl() { ItemsPanel = Resources["VirtualPanelTemplate"] as ItemsPanelTemplate, ItemTemplate = Resources["WrapTemplate"] as DataTemplate, ItemsSource = VirtualizingWrapPanelAdapter.GroupRenderModels(System.Linq.Enumerable.Select(AppSettings.ChData.GetMorphologicalDataForWord(((sender as StackPanel).DataContext as MyRenderItem).Chapter, ((sender as StackPanel).DataContext as MyRenderItem).Verse, ((sender as StackPanel).DataContext as MyRenderItem).Word).Items, (Arr) => new MyRenderItem((XMLRender.RenderArray.RenderItem)Arr)).ToList(), UIChanger.MaxWidth) }); VirtualizingStackPanel.SetVirtualizationMode((Panel.Children.Last() as ItemsControl), VirtualizationMode.Recycling); Panel.Children.Add(new Button() { Content = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("CopyToClipboard/Text") }); (Panel.Children.Last() as Button).Click += (object _sender, RoutedEventArgs _e) => { #if WINDOWS_APP || WINDOWS_UWP Windows.ApplicationModel.DataTransfer.DataPackage package = new Windows.ApplicationModel.DataTransfer.DataPackage(); package.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText); Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(package); #else global::Windows.System.LauncherOptions options = new global::Windows.System.LauncherOptions(); options.PreferredApplicationDisplayName = "Clipboarder"; options.PreferredApplicationPackageFamilyName = "InTheHandLtd.Clipboarder"; options.DisplayApplicationPicker = false; global::Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format("clipboard:Set?Text={0}", Uri.EscapeDataString(string.Empty))), options); #endif }; Panel.Children.Add(new Button() { Content = new TextBlock() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("Share/Text") } }); (Panel.Children.Last() as Button).Click += (object _sender, RoutedEventArgs _e) => { //#if WINDOWS_APP Windows.ApplicationModel.DataTransfer.DataPackage package = new Windows.ApplicationModel.DataTransfer.DataPackage(); package.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText); Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested += (Windows.ApplicationModel.DataTransfer.DataTransferManager __sender, Windows.ApplicationModel.DataTransfer.DataRequestedEventArgs __e) => { __e.Request.Data.Properties.Title = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("DisplayName"); __e.Request.Data.Properties.Description = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("Description"); __e.Request.Data.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText); Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested -= null; }; Windows.ApplicationModel.DataTransfer.DataTransferManager.ShowShareUI(); //#else // Microsoft.Phone.Tasks.ShareStatusTask shareStatusTask = new Microsoft.Phone.Tasks.ShareStatusTask(); // shareStatusTask.Status = string.Empty; // shareStatusTask.Show(); //#endif }; FlyoutBase.SetAttachedFlyout(sender as StackPanel, ContextFlyout); FlyoutBase.ShowAttachedFlyout(sender as StackPanel); } else if (((sender as StackPanel).DataContext as MyRenderItem).Chapter != -1) { MenuFlyout ContextFlyout = new MenuFlyout(); int idxMark = Array.FindIndex(AppSettings.Bookmarks, (Item) => Item[0] == Division && Item[1] == Selection && Item[2] == ((sender as StackPanel).DataContext as MyRenderItem).Chapter && Item[3] == ((sender as StackPanel).DataContext as MyRenderItem).Verse); ContextFlyout.Items.Add(new MenuFlyoutItem() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString((idxMark == -1 ? "AddBookmark" : "RemoveBookmark") + "/Text") }); (ContextFlyout.Items.Last() as MenuFlyoutItem).Click += (object _sender, RoutedEventArgs _e) => { List<int[]> marks = AppSettings.Bookmarks.ToList(); if (idxMark != -1) { marks.RemoveAt(idxMark); } else { marks.Add(new int[] { Division, Selection, ((sender as StackPanel).DataContext as MyRenderItem).Chapter, ((sender as StackPanel).DataContext as MyRenderItem).Verse }); } AppSettings.Bookmarks = marks.ToArray(); }; ContextFlyout.Items.Add(new MenuFlyoutItem() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("CopyToClipboard/Text") }); (ContextFlyout.Items.Last() as MenuFlyoutItem).Click += (object _sender, RoutedEventArgs _e) => { #if WINDOWS_APP || WINDOWS_UWP Windows.ApplicationModel.DataTransfer.DataPackage package = new Windows.ApplicationModel.DataTransfer.DataPackage(); package.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText); Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(package); #else global::Windows.System.LauncherOptions options = new global::Windows.System.LauncherOptions(); options.PreferredApplicationDisplayName = "Clipboarder"; options.PreferredApplicationPackageFamilyName = "InTheHandLtd.Clipboarder"; options.DisplayApplicationPicker = false; global::Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format("clipboard:Set?Text={0}", Uri.EscapeDataString(string.Empty))), options); #endif }; ContextFlyout.Items.Add(new MenuFlyoutItem() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("Share/Text") }); (ContextFlyout.Items.Last() as MenuFlyoutItem).Click += (object _sender, RoutedEventArgs _e) => { //#if WINDOWS_APP Windows.ApplicationModel.DataTransfer.DataPackage package = new Windows.ApplicationModel.DataTransfer.DataPackage(); package.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText); Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested += (Windows.ApplicationModel.DataTransfer.DataTransferManager __sender, Windows.ApplicationModel.DataTransfer.DataRequestedEventArgs __e) => { __e.Request.Data.Properties.Title = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("DisplayName"); __e.Request.Data.Properties.Description = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("Description"); __e.Request.Data.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText); Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested -= null; }; Windows.ApplicationModel.DataTransfer.DataTransferManager.ShowShareUI(); //#else // Microsoft.Phone.Tasks.ShareStatusTask shareStatusTask = new Microsoft.Phone.Tasks.ShareStatusTask(); // shareStatusTask.Status = string.Empty; // shareStatusTask.Show(); //#endif }; ContextFlyout.Items.Add(new MenuFlyoutItem() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("SetPlaybackVerse/Text") }); (ContextFlyout.Items.Last() as MenuFlyoutItem).Click += (object _sender, RoutedEventArgs _e) => { ViewModel.CurrentVerse = (sender as StackPanel).DataContext as MyRenderItem; for (int count = 0; count <= ViewModel.VerseReferences.Count() - 1; count++) { if (ViewModel.VerseReferences[count] == ViewModel.CurrentVerse) { CurrentPlayingItem = count; break; } VersePlayer.Source = null; } }; //ContextFlyout.Items.Add(new MenuFlyoutItem() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("ShowExegesis/Text") }); //(ContextFlyout.Items.Last() as MenuFlyoutItem).Click += (object _sender, RoutedEventArgs _e) => { }; FlyoutBase.SetAttachedFlyout(sender as StackPanel, ContextFlyout); FlyoutBase.ShowAttachedFlyout(sender as StackPanel); } }
/// <summary> /// Does what the function name states. /// /// Because Map Markers are child elements of the MapControl, they cannot be a natural /// anchor point for the flyout to display. Thus we need to manually anchor the flyout /// based on the marker pressed. /// </summary> private static void ShowFlyoutAboveMapMarker(MapControl sender, Stop stop, MenuFlyout flyout) { var stopGeo = new BasicGeoposition { Latitude = stop.Lat, Longitude = stop.Long }; Point markerPoint; sender.GetOffsetFromLocation(new Geopoint(stopGeo), out markerPoint); flyout.ShowAt(sender, markerPoint); }
private void FilterAppBarToggleButton_Click(object sender, RoutedEventArgs e) { MenuFlyout JXLMenuFlyout = new MenuFlyout(); JXLMenuFlyout.Items.Add(getJXLMenuFlyoutItem("二教")); JXLMenuFlyout.Items.Add(getJXLMenuFlyoutItem("三教")); JXLMenuFlyout.Items.Add(getJXLMenuFlyoutItem("四教")); JXLMenuFlyout.Items.Add(getJXLMenuFlyoutItem("五教")); JXLMenuFlyout.Items.Add(getJXLMenuFlyoutItem("八教")); JXLMenuFlyout.ShowAt(FilterAppBarToggleButton); }