private Entry GetEntry(MenuFlyoutItem menuFlyoutItem)
 {
     string tag = menuFlyoutItem.Tag.ToString();
     Expression<Func<Entry, bool>> expression = (k => k.Name.Equals(tag));
     Entry entry = DataHandler.Instance.GetEntry(expression);
     return entry;
 }
        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); 
        }
 public void RegisterForShare(MenuFlyoutItem menuFlyoutItem, string url, string description = "")
 {
     _url = url;
     _description = description;
     
     DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
     dataTransferManager.DataRequested += ShareUrlHandler;
     DataTransferManager.ShowShareUI();
 }
 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);
 }
        async void GetPairedDevices(object sender, RoutedEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("Getting list of paired devices");
            try
            {
                DeviceInformationCollection DeviceInfoCollection = await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort));

                var numDevices = DeviceInfoCollection.Count();

                _pairedDevices = new ObservableCollection<PairedDeviceInfo>();
                _pairedDevices.Clear();

                FlyoutBase mn = ConnectButton.Flyout;
                MenuFlyout m = (MenuFlyout)mn;
                m.Items.Clear();

                if (numDevices == 0)
                {
                    System.Diagnostics.Debug.WriteLine("No paired devices found.");
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("{0} paired devices found.", numDevices);

                    foreach (var deviceInfo in DeviceInfoCollection)
                    {
                        _pairedDevices.Add(new PairedDeviceInfo(deviceInfo));

                        ToggleMenuFlyoutItem fi = new ToggleMenuFlyoutItem();
                        fi.Text = deviceInfo.Name;

                        if (NowConnectedDevice != null && NowConnectedDevice.Id == deviceInfo.Id )
                        {
                            fi.IsChecked = true;
                        }
                        else
                        {
                            fi.IsChecked = false;
                        }
                        fi.Click += new RoutedEventHandler((ss, ev) => MenuFlyoutItemDevice_Click(ss, ev, deviceInfo, fi));
                        m.Items.Add(fi);
                    }
                }
                MenuFlyoutSeparator fs = new MenuFlyoutSeparator();
                m.Items.Add(fs);
                MenuFlyoutItem f = new MenuFlyoutItem();
                f.Text = "Refresh";
                f.Click += new RoutedEventHandler(GetPairedDevices);
                m.Items.Add(f);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("GetPairedDevices: " + ex.Message);
            }
        }
        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);
 }
 void AudioStreams_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     audioStreams.Items.Clear();
     foreach (var item in App.ViewModel.AudioStreams)
     {
         MenuFlyoutItem i = new MenuFlyoutItem()
         {
             Text = item.Name,
             Tag = "audio " + item.Id,
         };
         i.Click += selectStream_Click;
         audioStreams.Items.Add(i);
     }
 }
 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;
 }
Example #10
0
        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);
        }
Example #11
0
        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;
        }
Example #12
0
        //点击分享按钮后执行的动作
        private void MenuFlyoutItem_Click_1(object sender, RoutedEventArgs e)
        {
            MenuFlyoutItem mn = (MenuFlyoutItem)e.OriginalSource;

            DataTransferManager.ShowShareUI();
        }
Example #13
0
 private async void OpenInEdge_Click(object sender, RoutedEventArgs e)
 {
     MenuFlyoutItem stack = (MenuFlyoutItem)sender;
     PFeedItem      p     = (PFeedItem)stack.DataContext;
     await Windows.System.Launcher.LaunchUriAsync(new Uri(p.link));
 }
Example #14
0
        private void MenuFlyout_Opening(object sender, object e)
        {
            // Handles forming the flyout when opening the main FontFilter
            // drop down menu.
            if (sender is MenuFlyout menu)
            {
                // Reset to default menu
                while (menu.Items.Count > 8)
                {
                    menu.Items.RemoveAt(8);
                }

                // force menu width to match the source button
                foreach (var sep in menu.Items.OfType <MenuFlyoutSeparator>())
                {
                    sep.MinWidth = FontListFilter.ActualWidth;
                }

                // add users collections
                if (ViewModel.FontCollections.Items.Count > 0)
                {
                    menu.Items.Add(new MenuFlyoutSeparator());
                    foreach (var item in ViewModel.FontCollections.Items)
                    {
                        var m = new MenuFlyoutItem {
                            DataContext = item, Text = item.Name, FontSize = 16
                        };
                        m.Click += (s, a) =>
                        {
                            if (m.DataContext is UserFontCollection u)
                            {
                                if (!FontsSemanticZoom.IsZoomedInViewActive)
                                {
                                    FontsSemanticZoom.IsZoomedInViewActive = true;
                                }

                                ViewModel.SelectedCollection = u;
                            }
                        };
                        menu.Items.Add(m);
                    }
                }

                if (!FontFinder.HasAppxFonts && !FontFinder.HasRemoteFonts)
                {
                    FontSourceSeperator.Visibility = CloudFontsOption.Visibility = AppxOption.Visibility = Visibility.Collapsed;
                }
                else
                {
                    FontSourceSeperator.Visibility = Visibility.Visible;
                    CloudFontsOption.SetVisible(FontFinder.HasRemoteFonts);
                    AppxOption.SetVisible(FontFinder.HasAppxFonts);
                }

                void SetCommand(MenuFlyoutItemBase b, ICommand c)
                {
                    b.FontSize = 16;
                    if (b is MenuFlyoutSubItem i)
                    {
                        foreach (var child in i.Items)
                        {
                            SetCommand(child, c);
                        }
                    }
                    else if (b is MenuFlyoutItem m)
                    {
                        m.Command = c;
                    }
                }

                foreach (var item in menu.Items)
                {
                    SetCommand(item, FilterCommand);
                }
            }
        }
 public static void SetIsDestructive(this MenuFlyoutItem menuFlyoutItem, bool isDestructive)
 {
     menuFlyoutItem.SetValue(IsDestructiveProperty, isDestructive);
 }
Example #16
0
        /// <summary>
        /// Add data view part into page
        /// </summary>
        /// <param name="container">Container</param>
        private void AddDataViewPart(Panel container)
        {
            ModuleData = new ListView()
            {
                Name   = nameof(ModuleData),
                Margin = new Thickness(0, 10, 0, 0),
                HorizontalAlignment = HorizontalAlignment.Stretch,
                SelectionMode       = ListViewSelectionMode.Single,
                ItemsSource         = (DataContext as ViewModelBase).GetPropertyValue("Source")
            };
            ApplicationBase.Current.PropertyChangedNotifier.RegisterProperty(ModuleData, ListView.ItemsSourceProperty, "Source", viewModelType);

            ScrollViewer.SetVerticalScrollBarVisibility(ModuleData, ScrollBarVisibility.Auto);

            MenuFlyout menuFlyout = new MenuFlyout();

            editFlyoutItem = new MenuFlyoutItem()
            {
                Text    = "Edit",
                Icon    = new SymbolIcon(Symbol.Edit),
                Command = (DataContext as ViewModelBase).GetPropertyValue("EditCommand") as ICommand
            };

            detailFlyoutItem = new MenuFlyoutItem()
            {
                Text    = "Detail",
                Icon    = new SymbolIcon(Symbol.FullScreen),
                Command = (DataContext as ViewModelBase).GetPropertyValue("ShowDetailCommand") as ICommand
            };

            removeFlyoutItem = new MenuFlyoutItem()
            {
                Text    = "Remove",
                Icon    = new SymbolIcon(Symbol.Delete),
                Command = (DataContext as ViewModelBase).GetPropertyValue("RemoveCommand") as ICommand
            };

            menuFlyout.Items.Add(editFlyoutItem);
            menuFlyout.Items.Add(detailFlyoutItem);
            menuFlyout.Items.Add(removeFlyoutItem);
            ModuleData.ContextFlyout = menuFlyout;

            Style itemStyle = new Style()
            {
                TargetType = typeof(ListViewItem)
            };

            Setter itemHorizontalContentAlignmentSetter = new Setter()
            {
                Property = HorizontalContentAlignmentProperty,
                Value    = HorizontalAlignment.Stretch
            };

            itemStyle.Setters.Add(itemHorizontalContentAlignmentSetter);
            ModuleData.ItemContainerStyle = itemStyle;

            ModuleData.AddHandler(RightTappedEvent, new RightTappedEventHandler(Item_RightTapped), true);

            Binding moduleDataSelectionModeBinding = new Binding()
            {
                Source = (DataContext as ViewModelBase).GetPropertyValue("ListSelectionMode"),
                Mode   = BindingMode.OneWay
            };

            BindingOperations.SetBinding(ModuleData, ListView.SelectionModeProperty, moduleDataSelectionModeBinding);
            ApplicationBase.Current.PropertyChangedNotifier.RegisterProperty(ModuleData, ListView.SelectionModeProperty, "ListSelectionMode", viewModelType);

            container.Children.Add(ModuleData);
        }
Example #17
0
        public void Choose_Measurement(object sender, RoutedEventArgs e)
        {
            List <Measurement> measurements = new List <Measurement>();

            Device[]   devices = Exp.Devices;
            MenuFlyout menu    = new MenuFlyout();
            Button     butt    = (Button)sender;

            if (devices != null)
            {
                foreach (Device d in devices)
                {
                    foreach (Sensor s in d.Sensors)
                    {
                        foreach (Measurement m in s.Measurements)
                        {
                            measurements.Add(m);
                        }
                    }
                }
            }

            if (measurements.Count < 1)
            {
                MenuFlyoutItem item = new MenuFlyoutItem()
                {
                    Text      = "No Connected Devices",
                    IsEnabled = false,
                    FontSize  = 18
                };
                menu.Items.Add(item);
            }
            for (int i = 0; i < measurements.Count; i++)
            {
                MenuFlyoutItem item = new MenuFlyoutItem()
                {
                    Text     = measurements[i].Name,
                    FontSize = 18,
                    Tag      = measurements[i]
                };
                menu.Items.Add(item);
                item.Click += delegate(object s, RoutedEventArgs arg)
                {
                    VariableNode sel = butt.Tag as VariableNode;
                    sel.MeasureSource = (Measurement)((MenuFlyoutItem)s).Tag;
                    sel.UnitSource    = -1;
                    Exp.Save();
                };
            }
            MenuFlyoutItem ok = new MenuFlyoutItem()
            {
                Text     = "Create Custom Measurement",
                FontSize = 18
            };

            ok.Click += async delegate
            {
                Measurement m = await Create_Custom_Measurement();

                if (m != null)
                {
                    VariableNode sel = butt.Tag as VariableNode;
                    sel.MeasureSource = m;
                    sel.UnitSource    = -1;
                    Exp.Save();
                }
            };
            menu.Items.Add(ok);
            menu.ShowAt(butt);
        }
Example #18
0
        public void RightClickContextMenu_Opening(object sender, object e)
        {
            ClearSelection();
            var shiftPressed = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down);

            SetShellContextmenu(BaseLayoutContextFlyout, shiftPressed, false);
            var newItemMenu = (MenuFlyoutSubItem)BaseLayoutContextFlyout.Items.SingleOrDefault(x => x.Name == "NewEmptySpace");

            if (newItemMenu == null || cachedNewContextMenuEntries == null)
            {
                return;
            }
            if (!newItemMenu.Items.Any(x => (x.Tag as string) == "CreateNewFile"))
            {
                var separatorIndex = newItemMenu.Items.IndexOf(newItemMenu.Items.Single(x => x.Name == "NewMenuFileFolderSeparator"));
                foreach (var newEntry in Enumerable.Reverse(cachedNewContextMenuEntries))
                {
                    MenuFlyoutItem menuLayoutItem;
                    if (newEntry.Icon != null)
                    {
                        var image = new BitmapImage();
#pragma warning disable CS4014
                        image.SetSourceAsync(newEntry.Icon);
#pragma warning restore CS4014
                        menuLayoutItem = new MenuFlyoutItemWithImage()
                        {
                            Text       = newEntry.Name,
                            BitmapIcon = image,
                            Tag        = "CreateNewFile"
                        };
                    }
                    else
                    {
                        menuLayoutItem = new MenuFlyoutItem()
                        {
                            Text = newEntry.Name,
                            Icon = new FontIcon()
                            {
                                FontFamily = App.Current.Resources["FluentUIGlyphs"] as Windows.UI.Xaml.Media.FontFamily,
                                Glyph      = "\xea00"
                            },
                            Tag = "CreateNewFile"
                        };
                    }
                    menuLayoutItem.Command          = ParentShellPageInstance.InteractionOperations.CreateNewFile;
                    menuLayoutItem.CommandParameter = newEntry;
                    newItemMenu.Items.Insert(separatorIndex + 1, menuLayoutItem);
                }
            }
            var isPinned = App.SidebarPinnedController.Model.Items.Contains(
                ParentShellPageInstance.FilesystemViewModel.WorkingDirectory);
            if (isPinned)
            {
                LoadMenuFlyoutItemByName("UnpinDirectoryFromSidebar");
                UnloadMenuFlyoutItemByName("PinDirectoryToSidebar");
            }
            else
            {
                LoadMenuFlyoutItemByName("PinDirectoryToSidebar");
                UnloadMenuFlyoutItemByName("UnpinDirectoryFromSidebar");
            }
        }
        private async Task BuildOpenRecentButtonSubItems()
        {
            var openRecentSubItem = new MenuFlyoutSubItem
            {
                Text = _resourceLoader.GetString("MainMenu_Button_Open_Recent/Text"),
                Icon = new FontIcon {
                    Glyph = "\xE81C"
                },
                Name = "MenuOpenRecentlyUsedFileButton",
            };

            var MRUFileList = new HashSet <string>();

            foreach (var item in await MRUService.Get(top: 10))
            {
                if (item is StorageFile file)
                {
                    if (MRUFileList.Contains(file.Path))
                    {
                        // MRU might contains files with same path (User opens a recently used file after renaming it)
                        // So we need to do the decouple here
                        continue;
                    }
                    var newItem = new MenuFlyoutItem()
                    {
                        Text = file.Path
                    };
                    ToolTipService.SetToolTip(newItem, file.Path);
                    newItem.Click += async(sender, args) => { await OpenFile(file); };
                    openRecentSubItem.Items?.Add(newItem);
                    MRUFileList.Add(file.Path);
                }
            }

            var oldOpenRecentSubItem = MainMenuButtonFlyout.Items?.FirstOrDefault(i => i.Name == openRecentSubItem.Name);

            if (oldOpenRecentSubItem != null)
            {
                MainMenuButtonFlyout.Items.Remove(oldOpenRecentSubItem);
            }

            openRecentSubItem.IsEnabled = false;
            if (openRecentSubItem.Items?.Count > 0)
            {
                openRecentSubItem.Items?.Add(new MenuFlyoutSeparator());

                var clearRecentlyOpenedSubItem =
                    new MenuFlyoutItem()
                {
                    Text = _resourceLoader.GetString("MainMenu_Button_Open_Recent_ClearRecentlyOpenedSubItem_Text")
                };
                clearRecentlyOpenedSubItem.Click += async(sender, args) =>
                {
                    MRUService.ClearAll();
                    await BuildOpenRecentButtonSubItems();
                };
                openRecentSubItem.Items?.Add(clearRecentlyOpenedSubItem);
                openRecentSubItem.IsEnabled = true;
            }

            if (MainMenuButtonFlyout.Items != null)
            {
                var indexToInsert = MainMenuButtonFlyout.Items.IndexOf(MenuOpenFileButton) + 1;
                MainMenuButtonFlyout.Items.Insert(indexToInsert, openRecentSubItem);
            }
        }
Example #20
0
        public async void OnXamlRendered(FrameworkElement control)
        {
            if (dataGrid != null)
            {
                dataGrid.Sorting         -= DataGrid_Sorting;
                dataGrid.LoadingRowGroup -= DataGrid_LoadingRowGroup;
            }

            dataGrid = control.FindDescendant("dataGrid") as DataGrid;
            if (dataGrid != null)
            {
                dataGrid.Sorting         += DataGrid_Sorting;
                dataGrid.LoadingRowGroup += DataGrid_LoadingRowGroup;
                dataGrid.ItemsSource      = await viewModel.GetDataAsync();

                var comboBoxColumn = dataGrid.Columns.FirstOrDefault(x => x.Tag.Equals("Mountain")) as DataGridComboBoxColumn;
                if (comboBoxColumn != null)
                {
                    comboBoxColumn.ItemsSource = await viewModel.GetMountains();
                }
            }

            if (groupButton != null)
            {
                groupButton.Click -= GroupButton_Click;
            }

            groupButton = control.FindDescendant("groupButton") as AppBarButton;
            if (groupButton != null)
            {
                groupButton.Click += GroupButton_Click;
            }

            if (rankLowItem != null)
            {
                rankLowItem.Click -= RankLowItem_Click;
            }

            rankLowItem = control.FindName("rankLow") as MenuFlyoutItem;
            if (rankLowItem != null)
            {
                rankLowItem.Click += RankLowItem_Click;
            }

            if (rankHighItem != null)
            {
                rankHighItem.Click -= RankHigh_Click;
            }

            rankHighItem = control.FindName("rankHigh") as MenuFlyoutItem;
            if (rankHighItem != null)
            {
                rankHighItem.Click += RankHigh_Click;
            }

            if (heightLowItem != null)
            {
                heightLowItem.Click -= HeightLow_Click;
            }

            heightLowItem = control.FindName("heightLow") as MenuFlyoutItem;
            if (heightLowItem != null)
            {
                heightLowItem.Click += HeightLow_Click;
            }

            if (heightHighItem != null)
            {
                heightHighItem.Click -= HeightHigh_Click;
            }

            heightHighItem = control.FindName("heightHigh") as MenuFlyoutItem;
            if (heightHighItem != null)
            {
                heightHighItem.Click += HeightHigh_Click;
            }

            var clearFilter = control.FindName("clearFilter") as MenuFlyoutItem;

            if (clearFilter != null)
            {
                clearFilter.Click += this.ClearFilter_Click;
            }
        }
Example #21
0
        public static MenuFlyout MakeGuildMemberMenu(GuildMember member)
        {
            MenuFlyout menu = new MenuFlyout();

            menu.MenuFlyoutPresenterStyle = (Style)App.Current.Resources["MenuFlyoutPresenterStyle1"];

            // Add "Profile" button
            MenuFlyoutItem profile = new MenuFlyoutItem()
            {
                Text = App.GetString("/Flyouts/Profile"),
                Tag  = member.User,
                Icon = new SymbolIcon(Symbol.ContactInfo)
            };

            profile.Click += FlyoutManager.OpenProfile;
            menu.Items.Add(profile);

            // If member is not the current user
            if (member.User.Id != LocalState.CurrentUser.Id)
            {
                // Add "Message" button
                MenuFlyoutItem message = new MenuFlyoutItem()
                {
                    Text = App.GetString("/Flyouts/Message"),
                    Tag  = member.User.Id,
                    Icon = new SymbolIcon(Symbol.Message)
                };
                message.Click += FlyoutManager.MessageUser;
                menu.Items.Add(message);
            }


            // Add Seperator
            MenuFlyoutSeparator sep1 = new MenuFlyoutSeparator();

            menu.Items.Add(sep1);

            // If member is not the current user
            if (member.User.Id != LocalState.CurrentUser.Id)
            {
                // Create "Invite to Server" subitem
                MenuFlyoutSubItem InviteToServer = new MenuFlyoutSubItem()
                {
                    Text = App.GetString("/Flyouts/InviteToServer")
                };

                // Add guilds with permission to list
                foreach (KeyValuePair <string, LocalModels.Guild> guild in LocalState.Guilds)
                {
                    // Administrator or has Create Instant Invite permissions
                    if (guild.Value.permissions.Administrator || guild.Value.permissions.CreateInstantInvite)
                    {
                        // Add Guild item
                        MenuFlyoutItem item = new MenuFlyoutItem()
                        {
                            Text = guild.Value.Raw.Name, Tag = new Tuple <string, string>(guild.Value.channels.FirstOrDefault().Value.raw.Id, member.User.Id)
                        };
                        item.Click += FlyoutManager.InviteToServer;
                        InviteToServer.Items.Add(item);
                    }
                }

                // Add Invite to server
                menu.Items.Add(InviteToServer);
            }

            // Create "Add Friend" button
            MenuFlyoutItem addFriend = new MenuFlyoutItem()
            {
                Text = App.GetString("/Flyouts/AddFriend"),
                Tag  = member.User.Id,
                Icon = new SymbolIcon(Symbol.AddFriend)
            };

            addFriend.Click += FlyoutManager.AddFriend;

            // Create "Remove Friend" button
            MenuFlyoutItem removeFriend = new MenuFlyoutItem()
            {
                Text       = App.GetString("/Flyouts/RemoveFriend"),
                Tag        = member.User.Id,
                Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 71, 71)),
                Icon       = new SymbolIcon(Symbol.ContactPresence)
            };

            removeFriend.Click += FlyoutManager.RemoveFriend;

            // Create "Block" button
            MenuFlyoutItem block = new MenuFlyoutItem()
            {
                Text       = App.GetString("/Flyouts/Block"),
                Tag        = member.User.Id,
                Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 71, 71)),
                Icon       = new SymbolIcon(Symbol.BlockContact)
            };

            block.Click += FlyoutManager.BlockUser;

            // Create "Unblock" button
            MenuFlyoutItem unBlock = new MenuFlyoutItem()
            {
                Text = App.GetString("/Flyouts/Unblock"),
                Tag  = member.User.Id,
                Icon = new SymbolIcon(Symbol.ContactPresence)
            };

            unBlock.Click += FlyoutManager.RemoveFriend;

            // Create "Accept Friend Request" button
            MenuFlyoutItem acceptFriendRequest = new MenuFlyoutItem()
            {
                Text = App.GetString("/Flyouts/AcceptFriendRequest"),
                Tag  = member.User.Id,
                Icon = new SymbolIcon(Symbol.AddFriend)
            };

            acceptFriendRequest.Click += FlyoutManager.AddFriend;

            // Choose buttons to add
            if (LocalState.Friends.ContainsKey(member.User.Id))
            {
                switch (LocalState.Friends[member.User.Id].Type)
                {
                // No relation
                case 0:
                    // Add "Add Friend" and "Block" buttons
                    menu.Items.Add(addFriend);
                    menu.Items.Add(block);
                    break;

                // Friends
                case 1:
                    // Add "Remove Friend" and "Block" buttons
                    menu.Items.Add(removeFriend);
                    menu.Items.Add(block);
                    break;

                // Blocked
                case 2:
                    // Add "Unblock" button
                    menu.Items.Add(unBlock);
                    break;

                // Incoming Friend Request
                case 3:
                    // Add "Accept Friend Request" and "Block" buttons
                    menu.Items.Add(acceptFriendRequest);
                    menu.Items.Add(block);
                    break;

                // Outgoing Friend Request
                case 4:
                    // Add "Block" button
                    menu.Items.Add(block);
                    break;
                }
            }
            // Member is current user
            else if (member.User.Id == LocalState.CurrentUser.Id)
            {
                // No buttons for current user
            }
            else
            {
                // Default to no relation
                menu.Items.Add(addFriend);
                menu.Items.Add(block);
            }


            // If member is not current user
            if (member.User.Id != LocalState.CurrentUser.Id)
            {
                // Add Separator
                MenuFlyoutSeparator sep2 = new MenuFlyoutSeparator();
                menu.Items.Add(sep2);
            }

            // If can change user's nickname
            if (Permissions.CanChangeNickname(member.User.Id, App.CurrentGuildId))
            {
                // Add "Change Nickname" button
                MenuFlyoutItem changeNickname = new MenuFlyoutItem()
                {
                    Text = App.GetString("/Flyouts/ChangeNickname"),
                    Tag  = member.User.Id,
                    Icon = new SymbolIcon(Symbol.Rename)
                };
                changeNickname.Click += FlyoutManager.ChangeNickname;
                menu.Items.Add(changeNickname);
            }

            // If Current User has manage roles permission
            if (LocalState.Guilds[App.CurrentGuildId].permissions.Administrator || LocalState.Guilds[App.CurrentGuildId].permissions.ManageRoles)
            {
                // Create "Roles" subitem
                MenuFlyoutSubItem roles = new MenuFlyoutSubItem()
                {
                    Text = App.GetString("/Flyouts/Roles")
                           //Tag = member.Raw.User.Id,
                           //Icon = new SymbolIcon(Symbol.)
                };

                // Add Server's roles to Role SubItem
                foreach (Role role in LocalState.CurrentGuild.roles.Values.OrderByDescending(x => x.Position))
                {
                    ToggleMenuFlyoutItem roleItem = new ToggleMenuFlyoutItem()
                    {
                        Text       = role.Name,
                        Tag        = new Tuple <string, string>(role.Id, member.User.Id),
                        Foreground = Common.IntToColor(role.Color),
                        IsChecked  = member.Roles != null && member.Roles.Contains(role.Id),
                        //Style = (Style)App.Current.Resources["ToggleOnlyCheckbox"],
                        IsEnabled = LocalState.Guilds[App.CurrentGuildId].members[LocalState.CurrentUser.Id].Roles.FirstOrDefault() != null && role.Position < LocalState.Guilds[App.CurrentGuildId].roles[LocalState.Guilds[App.CurrentGuildId].members[LocalState.CurrentUser.Id].Roles.FirstOrDefault()].Position || LocalState.Guilds[App.CurrentGuildId].Raw.OwnerId == LocalState.CurrentUser.Id  //TODO: Double check role system
                    };
                    roleItem.Click += FlyoutManager.AddRole;
                    if (role.Name != "@everyone")
                    {
                        roles.Items.Add(roleItem);
                    }
                }

                // Add Roles subitem to menu
                menu.Items.Add(roles);
            }

            // If Current User has kick members permission
            if ((LocalState.Guilds[App.CurrentGuildId].permissions.Administrator || LocalState.Guilds[App.CurrentGuildId].permissions.KickMembers) && LocalState.Guilds[App.CurrentGuildId].GetHighestRole(member.Roles).Position < LocalState.Guilds[App.CurrentGuildId].GetHighestRole(LocalState.Guilds[App.CurrentGuildId].members[LocalState.CurrentUser.Id].Roles).Position || LocalState.Guilds[App.CurrentGuildId].Raw.OwnerId == LocalState.CurrentUser.Id && member.User.Id != LocalState.CurrentUser.Id)
            {
                // Add "Kick Member" button
                MenuFlyoutItem kickMember = new MenuFlyoutItem()
                {
                    Text       = App.GetString("/Flyouts/KickMember"),
                    Tag        = member.User.Id,
                    Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 71, 71)),
                    Icon       = new SymbolIcon(Symbol.BlockContact)
                };
                kickMember.Click += FlyoutManager.KickMember;
                menu.Items.Add(kickMember);
            }
            // If Member is current user and current user is not owner
            else if (member.User.Id == LocalState.CurrentUser.Id && LocalState.Guilds[App.CurrentGuildId].Raw.OwnerId != LocalState.CurrentUser.Id)
            {
                // Add "Leave Server" button
                MenuFlyoutItem leaveServer = new MenuFlyoutItem()
                {
                    Text       = App.GetString("/Flyouts/LeaveServer"),
                    Tag        = member.User.Id,
                    Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 71, 71)),
                    Icon       = new SymbolIcon(Symbol.Remove)
                };
                leaveServer.Click += FlyoutManager.LeaveServer;
                menu.Items.Add(leaveServer);
            }

            // If User has ban members permission
            if (((LocalState.Guilds[App.CurrentGuildId].permissions.Administrator || LocalState.Guilds[App.CurrentGuildId].permissions.BanMembers) && LocalState.Guilds[App.CurrentGuildId].GetHighestRole(member.Roles).Position < LocalState.Guilds[App.CurrentGuildId].GetHighestRole(LocalState.Guilds[App.CurrentGuildId].members[LocalState.CurrentUser.Id].Roles).Position) || LocalState.Guilds[App.CurrentGuildId].Raw.OwnerId == LocalState.CurrentUser.Id && member.User.Id != LocalState.CurrentUser.Id)
            {
                // Add "Ban Member" button
                MenuFlyoutItem banMember = new MenuFlyoutItem()
                {
                    Text       = App.GetString("/Flyouts/BanMember"),
                    Tag        = member.User.Id,
                    Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 71, 71)),
                    Icon       = new SymbolIcon(Symbol.BlockContact)
                };
                banMember.Click += FlyoutManager.BanMember;
                menu.Items.Add(banMember);
            }

            // If member is a bot
            if (member.User.Bot)
            {
                // Add Separator
                menu.Items.Add(new MenuFlyoutSeparator());

                // Add extra bot specific stuff
                foreach (var feature in BotExtrasManager.GetBotFeatures(member.User.Id))
                {
                    MenuFlyoutItem link = new MenuFlyoutItem()
                    {
                        Text = feature.Name,
                        Tag  = feature.Url,
                        Icon = new FontIcon()
                        {
                            Glyph = feature.Icon
                        }
                    };
                    link.Click += FlyoutManager.OpenURL;
                    menu.Items.Add(link);
                }
            }

            return(menu);
        }
        private void SongList_ContextRequested(UIElement sender, Windows.UI.Xaml.Input.ContextRequestedEventArgs args)
        {
            // Walk up the tree to find the ListViewItem.
            // There may not be one if the click wasn't on an item.
            var requestedElement = (FrameworkElement)args.OriginalSource;

            while ((requestedElement != sender) && !(requestedElement is SelectorItem))
            {
                requestedElement = (FrameworkElement)VisualTreeHelper.GetParent(requestedElement);
            }
            var model = (sender as ListViewBase).ItemFromContainer(requestedElement) as SongViewModel;

            if (requestedElement != sender)
            {
                // set album name of flyout
                var albumMenu = MainPage.Current.SongFlyout.Items.First(x => x.Name == "AlbumMenu") as MenuFlyoutItem;
                albumMenu.Text       = model.Album;
                albumMenu.Visibility = Visibility.Collapsed;

                // remove performers in flyout
                var index = MainPage.Current.SongFlyout.Items.IndexOf(albumMenu);
                while (!(MainPage.Current.SongFlyout.Items[index + 1] is MenuFlyoutSeparator))
                {
                    MainPage.Current.SongFlyout.Items.RemoveAt(index + 1);
                }
                // add song's performers to flyout
                if (!model.Song.Performers.IsNullorEmpty())
                {
                    if (model.Song.Performers.Length == 1)
                    {
                        var menuItem = new MenuFlyoutItem()
                        {
                            Text = $"{model.Song.Performers[0]}",
                            Icon = new FontIcon()
                            {
                                Glyph = "\uE136"
                            }
                        };
                        menuItem.Click += MainPage.Current.MenuFlyoutArtist_Click;
                        MainPage.Current.SongFlyout.Items.Insert(index + 1, menuItem);
                    }
                    else
                    {
                        var sub = new MenuFlyoutSubItem()
                        {
                            Text = $"{Consts.Localizer.GetString("PerformersText")}:",
                            Icon = new FontIcon()
                            {
                                Glyph = "\uE136"
                            }
                        };
                        foreach (var item in model.Song.Performers)
                        {
                            var menuItem = new MenuFlyoutItem()
                            {
                                Text = item
                            };
                            menuItem.Click += MainPage.Current.MenuFlyoutArtist_Click;
                            sub.Items.Add(menuItem);
                        }
                        MainPage.Current.SongFlyout.Items.Insert(index + 1, sub);
                    }
                }

                if (args.TryGetPosition(requestedElement, out var point))
                {
                    MainPage.Current.SongFlyout.ShowAt(requestedElement, point);
                }
                else
                {
                    MainPage.Current.SongFlyout.ShowAt(requestedElement);
                }

                args.Handled = true;
            }
        }
Example #23
0
        private List <MenuFlyoutItemBase> GenerateMenu(string folderPath, List <MenuInfo> menuInfos)
        {
            return(menuInfos.Select(it =>
            {
                if (string.IsNullOrEmpty(it.Title))
                {
                    return new MenuFlyoutSeparator() as MenuFlyoutItemBase;
                }

                var title = it.Title.Replace("&", "");
                var quickIndex = it.Title.IndexOf('&');
                KeyboardAccelerator keyboardAccelerator = null;
                if (quickIndex != -1)
                {
                    if (Enum.TryParse <VirtualKey>(it.Title[quickIndex + 1].ToString(), out var quickKey))
                    {
                        keyboardAccelerator = new KeyboardAccelerator
                        {
                            Key = quickKey
                        };
                        if (quickIndex > 0 && it.Title[quickIndex - 1] == '(')
                        {
                            var endIndex = it.Title.Substring(quickIndex).IndexOf(')');
                            if (endIndex != -1)
                            {
                                title = title.Remove(quickIndex - 1, endIndex + 1);
                            }
                        }
                    }
                }

                MenuFlyoutItemBase result = null;

                if (it.SubMenu.Any())
                {
                    var subItem = new MenuFlyoutSubItem
                    {
                        Text = title
                    };
                    GenerateMenu(folderPath, it.SubMenu).ForEach(m => subItem.Items.Add(m));
                    result = subItem;
                }
                else
                {
                    var item = new MenuFlyoutItem
                    {
                        Text = title,
                        Command = MenuCommand,
                        CommandParameter = new ContextMenuAction
                        {
                            Type = ContextMenuAction.ActionType.InvokeCommand,
                            MenuId = Convert.ToInt32(it.Id),
                            Path = folderPath,
                        }
                    };

                    result = item;
                }

                if (keyboardAccelerator != null)
                {
                    result.KeyboardAccelerators.Add(keyboardAccelerator);
                }

                return result;
            }).ToList());
        }
Example #24
0
        public async Task Verify_MenuBarItem_Bounds()
        {
            using (StyleHelper.UseFluentStyles())
            {
                var flyoutItem = new MenuFlyoutItem {
                    Text = "Open..."
                };
                var menuBarItem = new MenuBarItem
                {
                    Title = "File",
                    Items =
                    {
                        flyoutItem,
                        new MenuFlyoutItem {
                            Text = "Don't open..."
                        }
                    }
                };

                var menuBar = new MenuBar
                {
                    Items =
                    {
                        menuBarItem
                    }
                };

                var contentSpacer = new Border {
                    Background = new SolidColorBrush(Colors.Tomato), Margin = new Thickness(20)
                };
                Grid.SetRow(contentSpacer, 1);

                var hostPanel = new Grid
                {
                    Children =
                    {
                        menuBar,
                        contentSpacer
                    },
                    RowDefinitions =
                    {
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Star)
                        }
                    }
                };

                WindowHelper.WindowContent = hostPanel;
                await WindowHelper.WaitForLoaded(hostPanel);

                var peer = new MenuBarItemAutomationPeer(menuBarItem);
                try
                {
                    peer.Invoke();

                    await WindowHelper.WaitForLoaded(flyoutItem);

                    var menuBarItemBounds = menuBarItem.GetOnScreenBounds();

                    var flyoutItemBounds = flyoutItem.GetOnScreenBounds();

                    var menuBarBounds = menuBar.GetOnScreenBounds();

                    Assert.AreEqual(32, menuBarItemBounds.Height, 1);

                    var expectedY = 39.0;
#if __ANDROID__
                    if (!FeatureConfiguration.Popup.UseNativePopup)
                    {
                        // If using managed popup, the expected offset must be adjusted for the status bar
                        expectedY += menuBarBounds.Y;
                    }
#endif

                    Assert.AreEqual(5, flyoutItemBounds.X, 3);
                    Assert.AreEqual(expectedY, flyoutItemBounds.Y, 3);
                }
                finally
                {
                    peer.Collapse();
                }
            }
        }
        //选择需要查询的周数
        private void WeekMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuFlyoutItem menuFlyoutItem = sender as MenuFlyoutItem;

            LoadScheduleData(int.Parse(menuFlyoutItem.Tag.ToString()));
        }
 public MenuFlyoutItemEvents(MenuFlyoutItem This)
     : base(This)
 {
     this.This = This;
 }
Example #27
0
        public void InitContextMemu()
        {
            contextFlyout = new MenuFlyout();
            MenuFlyoutItem copyItem = new MenuFlyoutItem
            {
                Text = "Copy",
            };

            copyItem.Click += (s, e) =>
            {
                var data = new Windows.ApplicationModel.DataTransfer.DataPackage();
                data.Properties.Add("entity", (s as FrameworkElement).DataContext);
                Clipboard.SetContent(data);
            };
            contextFlyout.Items.Add(copyItem);
            contextFlyout.Items.Add(new MenuFlyoutSeparator());

            MenuFlyoutItem addItem = new MenuFlyoutItem
            {
                Text = "Add",
            };

            addItem.Click += (s, e) =>
            {
                var command = DataContext.GetType().GetMethod("Add");
                if (command != null)
                {
                    command.Invoke(DataContext, new object[0]);
                }
            };
            contextFlyout.Items.Add(addItem);

            MenuFlyoutItem openItem = new MenuFlyoutItem
            {
                Text = "Open",
            };

            openItem.Click += (s, e) =>
            {
                var command = DataContext.GetType().GetMethod("Open");
                if (command != null)
                {
                    command.Invoke(DataContext, new object[1] {
                        (s as FrameworkElement).DataContext
                    });
                }
            };
            contextFlyout.Items.Add(openItem);

            MenuFlyoutItem removeItem = new MenuFlyoutItem
            {
                Text = "Remove",
            };

            removeItem.Click += (s, e) =>
            {
                var command = DataContext.GetType().GetMethod("Remove");
                if (command != null)
                {
                    command.Invoke(DataContext, new object[1] {
                        (s as FrameworkElement).DataContext
                    });
                }
            };
            contextFlyout.Items.Add(removeItem);

            //contextFlyout.ShowAt(targetControl, new Point(x,y));
        }
Example #28
0
        /// <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;
            //}
        }
Example #30
0
        private void TableOfContents_ContextMenuRequested(object sender, ContextMenuRequestedEventArgs e)
        {
            if (e.TreeViewNode is KmlNode node)
            {
                if (node.Viewpoint != null)
                {
                    var item = new MenuFlyoutItem()
                    {
                        Text = "Fly to"
                    };
                    Camera camera = null;
                    if (node.Viewpoint.Type == KmlViewpointType.LookAt)
                    {
                        camera = new Camera(node.Viewpoint.Location, node.Viewpoint.Range, node.Viewpoint.Heading, node.Viewpoint.Pitch, node.Viewpoint.Roll);
                    }
                    else
                    {
                        camera = new Camera(node.Viewpoint.Location, node.Viewpoint.Heading, node.Viewpoint.Pitch, node.Viewpoint.Roll);
                    }

                    item.Click += (s, e2) => sceneView.SetViewpointAsync(new Viewpoint(node.Viewpoint.Location, camera));
                    e.MenuItems.Add(item);
                }
                else if (node is KmlPlacemark kp && kp.Geometry != null)
                {
                    var item = new MenuFlyoutItem()
                    {
                        Text = "Fly to"
                    };
                    item.Click += (s, e2) => sceneView.SetViewpointAsync(new Viewpoint(kp.Geometry));
                    e.MenuItems.Add(item);
                }
                if (node is KmlNetworkLink knl)
                {
                    var item = new MenuFlyoutItem()
                    {
                        Text = "Refresh"
                    };
                    item.Click += (s, e2) => knl.Refresh();
                    e.MenuItems.Add(item);
                    if (knl.RefreshMode == KmlRefreshMode.OnInterval)
                    {
                        item = new MenuFlyoutItem()
                        {
                            Text = "Disable autorefresh"
                        };
                        item.Click += (s, e2) => knl.RefreshMode = KmlRefreshMode.OnChange;
                        e.MenuItems.Add(item);
                    }
                }
                else if (node is KmlTour tour)
                {
                    var item = new MenuFlyoutItem()
                    {
                        Text = tour.TourStatus == KmlTourStatus.Playing ? "Stop" : "Play"
                    };
                    item.Click += (s, e2) => ToggleTour(tour);
                    e.MenuItems.Add(item);
                }
            }
        }
Example #31
0
		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);
			}
		}
Example #32
0
        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 MenuFlyoutItem getTypeMenuFlyoutItem(string text)
 {
     MenuFlyoutItem menuFlyoutItem = new MenuFlyoutItem();
     menuFlyoutItem.Text = text;
     menuFlyoutItem.Click += typeMenuFlyoutItem_click;
     return menuFlyoutItem;
 }
        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));
        }
Example #35
0
        private async Task SetPathBoxDropDownFlyout(MenuFlyout flyout, PathBoxItem pathItem)
        {
            var nextPathItemTitle = App.CurrentInstance.NavigationToolbar.PathComponents
                                    [App.CurrentInstance.NavigationToolbar.PathComponents.IndexOf(pathItem) + 1].Title;
            IList <StorageFolderWithPath> childFolders = new List <StorageFolderWithPath>();

            try
            {
                var folder = await ItemViewModel.GetFolderWithPathFromPathAsync(pathItem.Path);

                childFolders = await folder.GetFoldersWithPathAsync(string.Empty);
            }
            catch
            {
                // Do nothing.
            }
            finally
            {
                flyout.Items?.Clear();
            }

            if (childFolders.Count == 0)
            {
                var flyoutItem = new MenuFlyoutItem
                {
                    Icon = new FontIcon {
                        FontFamily = Application.Current.Resources["FluentUIGlyphs"] as FontFamily, Glyph = "\uEC17"
                    },
                    Text = "SubDirectoryAccessDenied".GetLocalized(),
                    //Foreground = (SolidColorBrush)Application.Current.Resources["SystemControlErrorTextForegroundBrush"],
                    FontSize = 12
                };
                flyout.Items.Add(flyoutItem);
                return;
            }

            var boldFontWeight = new FontWeight {
                Weight = 800
            };
            var normalFontWeight = new FontWeight {
                Weight = 400
            };
            var customGlyphFamily = Application.Current.Resources["FluentUIGlyphs"] as FontFamily;

            var workingPath = App.CurrentInstance.NavigationToolbar.PathComponents
                              [App.CurrentInstance.NavigationToolbar.PathComponents.Count - 1].
                              Path.TrimEnd(Path.DirectorySeparatorChar);

            foreach (var childFolder in childFolders)
            {
                var isPathItemFocused = childFolder.Item.Name == nextPathItemTitle;

                var flyoutItem = new MenuFlyoutItem
                {
                    Icon = new FontIcon
                    {
                        FontFamily = customGlyphFamily,
                        Glyph      = "\uEA5A",
                        FontWeight = isPathItemFocused ? boldFontWeight : normalFontWeight
                    },
                    Text       = childFolder.Item.Name,
                    FontSize   = 12,
                    FontWeight = isPathItemFocused ? boldFontWeight : normalFontWeight
                };

                if (workingPath != childFolder.Path)
                {
                    flyoutItem.Click += (sender, args) => App.CurrentInstance.ContentFrame.Navigate(AppSettings.GetLayoutType(), childFolder.Path);
                }

                flyout.Items.Add(flyoutItem);
            }
        }
 public static bool GetIsDestructive(this MenuFlyoutItem menuFlyoutItem)
 {
     return((bool)menuFlyoutItem.GetValue(IsDestructiveProperty));
 }
        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 MenuFlyoutItem getPeopleListMenuFlyoutItem(string text)
 {
     MenuFlyoutItem menuFlyoutItem = new MenuFlyoutItem();
     menuFlyoutItem.Text = text;
     menuFlyoutItem.Click += PeopleListMenuFlyoutItem_click;
     return menuFlyoutItem;
 }
Example #39
0
        private void Connect_Device_To_Experiment_Click(object sender, RoutedEventArgs e)
        {
            MenuFlyoutItem b = (MenuFlyoutItem)sender;

            Connect_Device_To_Experiment((Device)b.Tag);
        }
Example #40
0
        private async void ListMail_Loaded(object sender, RoutedEventArgs e)
        {
            //----------------------------------------------------------------------------------------------Десериализация юзера
            var file = await folder.CreateFileAsync("UserData.xml", CreationCollisionOption.OpenIfExists);

            str = await FileIO.ReadTextAsync(file);

            var stream = await file.OpenStreamForReadAsync();

            if (str.Length != 0)
            {
                user = (List <UserData>)xml2.Deserialize(stream);
            }
            else
            {
                user = new List <UserData>();
            }

            stream.Close();
            //----------------------------------------------------------------------------------------------Десериализация айдишника

            file = await folder.CreateFileAsync("ID.xml", CreationCollisionOption.OpenIfExists);

            str = await FileIO.ReadTextAsync(file);

            var stream1 = await file.OpenStreamForReadAsync();

            if (str.Length != 0)
            {
                id = (int)xml.Deserialize(stream1);
            }
            else
            {
                id = 0;
            }

            stream1.Close();

            try
            {
                ic = new ImapClient(user[id].imap, user[id].Login, user[id].Pass, AuthMethods.Login, 993, true);
                var mailbox = ic.ListMailboxes("", "*");

                string[] mailboxes = new string[3];
                if (user[id].imap == "imap.mail.ru")
                {
                    mailboxes = new string[] { "Отправленные", "Черновики", "Корзина", }
                }
                ;
                if (user[id].imap == "imap.gmail.com")
                {
                    mailboxes = new string[] { "[Gmail]/Отправленные", "[Gmail]/Черновики", "[Gmail]/Корзина", }
                }
                ;
                if (user[id].imap == "imap.yandex.ru")
                {
                    mailboxes = new string[] { "Исходящие", "Черновики", "Удаленные", }
                }
                ;
                if (user[id].imap == "imap.rambler.ru")
                {
                    mailboxes = new string[] { "SentBox", "DraftBox", "Trash", }
                }
                ;

                if (navName == "Исходящие")
                {
                    ic.SelectMailbox(mailboxes[0]);
                }
                if (navName == "Черновик")
                {
                    ic.SelectMailbox(mailboxes[1]);
                }
                if (navName == "Корзина")
                {
                    ic.SelectMailbox(mailboxes[2]);
                }
                if (navName == "Входящие")
                {
                    ic.SelectMailbox("INBOX");
                }
                if (navName == "")
                {
                    ic.SelectMailbox("INBOX");
                }


                mm = ic.GetMessages(0, ic.GetMessageCount(), false);
                foreach (MailMessage mail in mm)
                {
                    ListBoxItem message = new ListBoxItem();
                    message.Content      = mail.Subject;
                    message.RightTapped += (s, ev) =>
                    {
                        MenuFlyout flyout = new MenuFlyout();

                        MenuFlyoutItem answer = new MenuFlyoutItem();
                        answer.Text = "Ответить";
                        flyout.Items.Add(answer);
                        answer.Click += (send, eve) =>
                        {
                            var frame = this.Frame as Frame;
                            frame.Navigate(typeof(EditPage), mail.From.Address.ToString());
                            //ic.DeleteMessage(mail);
                            //ic.Expunge();
                            //var frame = this.Frame as Frame;
                            //frame.Navigate(typeof(MailPage));
                        };

                        FlyoutBase.SetAttachedFlyout(message, flyout);
                        FlyoutBase.ShowAttachedFlyout((FrameworkElement)s);
                    };
                    ListMail.Items.Add(message);
                }

                ic.Dispose();
            }
            catch (Exception ex)
            {
                ContentDialog prog = new ContentDialog()
                {
                    Title             = "Ошибка",
                    Content           = $"Произошла ошибка: {ex.Message}",
                    PrimaryButtonText = "OK"
                };
                try
                {
                    await prog.ShowAsync();
                }
                catch { };
            }
        }
Example #41
0
        public static void Hyperlink_ContextRequested(UIElement sender, ContextRequestedEventArgs args)
        {
            var text = sender as RichTextBlock;

            if (args.TryGetPosition(sender, out Point point))
            {
                if (point.X < 0 || point.Y < 0)
                {
                    point = new Point(Math.Max(point.X, 0), Math.Max(point.Y, 0));
                }

                var length = text.SelectedText.Length;
                if (length > 0)
                {
                    var link = text.SelectedText;

                    var copy = new MenuFlyoutItem {
                        Text = Strings.Resources.Copy, DataContext = link
                    };

                    copy.Click += LinkCopy_Click;

                    var flyout = new MenuFlyout();
                    flyout.Items.Add(copy);
                    flyout.ShowAt(sender, point);

                    args.Handled = true;
                }
                else
                {
                    var hyperlink = text.GetHyperlinkFromPoint(point);
                    if (hyperlink == null)
                    {
                        return;
                    }

                    var link = GetEntity(hyperlink);
                    if (link == null)
                    {
                        return;
                    }

                    var open = new MenuFlyoutItem {
                        Text = Strings.Resources.Open, DataContext = link
                    };
                    var copy = new MenuFlyoutItem {
                        Text = Strings.Resources.Copy, DataContext = link
                    };

                    open.Click += LinkOpen_Click;
                    copy.Click += LinkCopy_Click;

                    var flyout = new MenuFlyout();
                    flyout.Items.Add(open);
                    flyout.Items.Add(copy);
                    flyout.ShowAt(sender, point);

                    args.Handled = true;
                }
            }
        }
Example #42
0
        /// <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;
            //}
        }
Example #43
0
        private void topMore_Click(object sender, RoutedEventArgs e)
        {
            List <string> list = new List <string>();

            foreach (Album album in AlbumsList.SelectedItems)
            {
                var songs = Ctr_Song.Current.GetSongsByAlbum(album);
                foreach (Song s in songs)
                {
                    list.Add(s.SongURI);
                }
            }

            MenuFlyout menu = new MenuFlyout()
            {
                MenuFlyoutPresenterStyle = Application.Current.Resources["MenuFlyoutModernStyle"] as Style,
            };

            MenuFlyoutItem item1 = new MenuFlyoutItem()
            {
                Text  = ApplicationInfo.Current.Resources.GetString("Play"),
                Tag   = "",
                Style = Application.Current.Resources["ModernMenuFlyoutItem"] as Style,
            };

            item1.Click += (s, a) =>
            {
                MessageService.SendMessageToBackground(new SetPlaylistMessage(list));
            };

            menu.Items.Add(item1);

            menu.Items.Add(new MenuFlyoutSeparator());

            MenuFlyoutItem item2 = new MenuFlyoutItem()
            {
                Text  = ApplicationInfo.Current.Resources.GetString("AddToPlaylist"),
                Tag   = "",
                Style = Application.Current.Resources["ModernMenuFlyoutItem"] as Style,
            };

            item2.Click += (s, a) =>
            {
                MessageService.SendMessageToBackground(new AddSongsToPlaylist(list));
            };

            menu.Items.Add(item2);

            MenuFlyoutItem item3 = new MenuFlyoutItem()
            {
                Text  = ApplicationInfo.Current.Resources.GetString("AddToPlaylistFile"),
                Tag   = "",
                Style = Application.Current.Resources["ModernMenuFlyoutItem"] as Style,
            };

            item3.Click += (s, a) =>
            {
                if (PageHelper.MainPage != null)
                {
                    PageHelper.MainPage.CreateAddToPlaylistPopup(list);
                }
            };

            menu.Items.Add(item3);

            MenuFlyoutItem item4 = new MenuFlyoutItem()
            {
                Text  = ApplicationInfo.Current.Resources.GetString("PlayNext"),
                Tag   = "\uEA52",
                Style = Application.Current.Resources["ModernMenuFlyoutItem"] as Style,
            };

            item4.Click += (s, a) =>
            {
                MessageService.SendMessageToBackground(new AddSongsToPlaylist(list, true));
            };

            menu.Items.Add(item4);

            menu.Items.Add(new MenuFlyoutSeparator());

            MenuFlyoutItem item5 = new MenuFlyoutItem()
            {
                Text  = ApplicationInfo.Current.Resources.GetString("Share"),
                Tag   = "",
                Style = Application.Current.Resources["ModernMenuFlyoutItem"] as Style,
            };

            item5.Click += async(s, a) =>
            {
                if (await this.ShareMediaItem(list, Enumerators.MediaItemType.Song) == false)
                {
                    MessageDialog md = new MessageDialog(ApplicationInfo.Current.Resources.GetString("ShareErrorMessage"));
                    await md.ShowAsync();
                }
            };

            menu.Items.Add(item5);

            menu.ShowAt(sender as FrameworkElement);
        }
Example #44
0
        private void LoadMenu()
        {
            var gobalmenu = new MenuFlyoutSubItem();
            var sexmenu   = new MenuFlyoutSubItem();

            switch (selectType)
            {
            case Grobal.all:
                gobalmenu.Text = "全国";
                var gobalmenu1 = new MenuFlyoutItem();
                gobalmenu1.Tag      = "gobal";
                gobalmenu1.Text     = "本省";
                gobalmenu1.TabIndex = 3;
                gobalmenu1.Click   += FliterMenu_Clicked;
                gobalmenu.Items.Add(gobalmenu1);
                break;

            case Grobal.part:
                gobalmenu.Text = "本省";
                var gobalmenu2 = new MenuFlyoutItem();
                gobalmenu2.Tag      = "gobal";
                gobalmenu2.Text     = "全国";
                gobalmenu2.TabIndex = 0;
                gobalmenu2.Click   += FliterMenu_Clicked;
                gobalmenu.Items.Add(gobalmenu2);
                break;

            default:
                break;
            }
            switch (genderType)
            {
            case Sex.index:
                sexmenu.Text = "男/女";
                var sexmenu1 = new MenuFlyoutItem();
                sexmenu1.Tag      = "sex";
                sexmenu1.Text     = "男";
                sexmenu1.TabIndex = 1;
                sexmenu1.Click   += FliterMenu_Clicked;
                sexmenu.Items.Add(sexmenu1);
                var sexmenu2 = new MenuFlyoutItem();
                sexmenu2.Tag      = "sex";
                sexmenu2.Text     = "女";
                sexmenu2.TabIndex = 0;
                sexmenu2.Click   += FliterMenu_Clicked;
                sexmenu.Items.Add(sexmenu2);
                break;

            case Sex.boy:
                sexmenu.Text = "男";
                var sexmenu3 = new MenuFlyoutItem();
                sexmenu3.Tag      = "sex";
                sexmenu3.Text     = "男/女";
                sexmenu3.TabIndex = -1;
                sexmenu3.Click   += FliterMenu_Clicked;
                sexmenu.Items.Add(sexmenu3);
                var sexmenu4 = new MenuFlyoutItem();
                sexmenu4.Tag      = "sex";
                sexmenu4.Text     = "女";
                sexmenu4.TabIndex = 0;
                sexmenu4.Click   += FliterMenu_Clicked;
                sexmenu.Items.Add(sexmenu4);
                break;

            case Sex.girl:
                sexmenu.Text = "女";
                var sexmenu5 = new MenuFlyoutItem();
                sexmenu5.Tag      = "sex";
                sexmenu5.Text     = "男/女";
                sexmenu5.TabIndex = -1;
                sexmenu5.Click   += FliterMenu_Clicked;
                sexmenu.Items.Add(sexmenu5);
                var sexmenu6 = new MenuFlyoutItem();
                sexmenu6.Tag      = "sex";
                sexmenu6.Text     = "男";
                sexmenu6.TabIndex = 1;
                sexmenu6.Click   += FliterMenu_Clicked;
                sexmenu.Items.Add(sexmenu6);
                break;

            default:
                break;
            }
            filtermenu.Items.Clear();
            filtermenu.Items.Add(gobalmenu);
            filtermenu.Items.Add(sexmenu);
        }