ShowAsync() public method

public ShowAsync ( [ invocationPoint ) : IAsyncOperation
invocationPoint [
return IAsyncOperation
Esempio n. 1
0
        private async void OnTapped(object sender, TappedRoutedEventArgs e)
        {
            TextBlock tb = sender as TextBlock;
            PopupMenu menu = new PopupMenu();
            UICommandInvokedHandler invokedHandler = (cmd) =>
            {
                SolidColorBrush brush = cmd.Id as SolidColorBrush;
                tb.Foreground = brush;
            };

            UICommand cmdRed = new UICommand("红", invokedHandler, new SolidColorBrush(Colors.Red));
            UICommand cmdOrange = new UICommand("橙", invokedHandler, new SolidColorBrush(Colors.Orange));
            UICommand cmdPurple = new UICommand("紫", invokedHandler, new SolidColorBrush(Colors.Purple));

            menu.Commands.Add(cmdRed);
            menu.Commands.Add(cmdOrange);
            menu.Commands.Add(cmdPurple);

            GeneralTransform gt = tb.TransformToVisual(null);

            Point popupPoint = gt.TransformPoint(new Point(0d, tb.ActualHeight));

            await menu.ShowAsync(popupPoint);


        }
Esempio n. 2
0
        public async Task showPopupMenu(string msg)
        {

            PopupMenu dialog = new PopupMenu();
            dialog.Commands.Add(new UICommand(msg, OnCommand, 0));
            dialog.Commands.Add(new UICommand("No", OnCommand, 1));
            dialog.Commands.Add(new UICommandSeparator());
            dialog.Commands.Add(new UICommand("Close", OnCommand, 2));
            await dialog.ShowAsync(new Point(10, 10));
        }
        async void OnTextBlockRightTapped(object sender, RightTappedRoutedEventArgs e) {
            PopupMenu popupMenu = new PopupMenu();
            popupMenu.Commands.Add(new UICommand("Larger Font", OnFontSizeChanged, 1.2));
            popupMenu.Commands.Add(new UICommand("Smaller Font", OnFontSizeChanged, 1 / 1.2));
            popupMenu.Commands.Add(new UICommandSeparator());
            popupMenu.Commands.Add(new UICommand("Red", OnColorChanged, Colors.Red));
            popupMenu.Commands.Add(new UICommand("Green", OnColorChanged, Colors.Green));
            popupMenu.Commands.Add(new UICommand("Blue", OnColorChanged, Colors.Blue));

            await popupMenu.ShowAsync(e.GetPosition(this));
        }
        private async void BtnAvatar_OnClick(object sender, RoutedEventArgs e)
        {
            var popupMenu = new PopupMenu();

            popupMenu.Commands.Add(new UICommand("From File", AvatarFromFile));
            popupMenu.Commands.Add(new UICommand("From Camera", AvatarFromCamera));

            var button = (Button)sender;
            var transform = button.TransformToVisual(this);
            var point = transform.TransformPoint(new Point(45, -10));
            
            await popupMenu.ShowAsync(point);
        }
Esempio n. 5
0
        public override void ActionSheet(ActionSheetConfig config)
        {
            var sheet = new PopupMenu();
            foreach (var opt in config.Options)
                sheet.Commands.Add(new UICommand(opt.Text, x => opt.TryExecute()));

            if (config.Cancel != null)
                sheet.Commands.Add(new UICommand(config.Cancel.Text, x => config.Cancel.TryExecute()));

            if (config.Destructive != null)
                sheet.Commands.Add(new UICommand(config.Destructive.Text, x => config.Destructive.TryExecute()));

            sheet.ShowAsync(new Point(0, 0));
        }
        private async void HandleMoreButton(object sender, RoutedEventArgs e)
        {
            var popup = new PopupMenu();
            popup.Commands.Add(new UICommand("Take Picture", (args) => {

                // try and unsnap, then show...
                if(ApplicationView.TryUnsnap())
                    this.ViewModel.TakePhotoCommand.Execute(null);

            }));
            popup.Commands.Add(new UICommand("Capture Location", (args) =>  this.ViewModel.CaptureLocationCommand.Execute(null)));

            // show...
            await popup.ShowAsync(((FrameworkElement)sender).GetPointForContextMenu());
        }
        private async void HandleMoreButton(object sender, RoutedEventArgs e)
        {
            var popup = new PopupMenu();
            popup.Commands.Add(new UICommand("Take Picture", async (args) =>
            {

                //// try and unsnap, then show...
                //if (ApplicationView.TryUnsnap())
                //    this.ViewModel.TakePhotoCommand.Execute(null);

                await this.ShowAlertAsync("Make the app full screen to use the camera.");

            }));
            popup.Commands.Add(new UICommand("Capture Location", (args) => 
            {
                var viewModel = (IEditReportPageViewModel)this.GetViewModel();
                viewModel.CaptureLocationCommand.Execute(null);
            }));

            // show...
            await popup.ShowAsync(((FrameworkElement)sender).GetPointForContextMenu());
        }
        protected override async void OnTapped(TappedRoutedEventArgs e)
        {
            if (!e.Handled)
            {
                var source = e.OriginalSource as FrameworkElement;
                if (source != null)
                {
                    var attr = DataContext as PersistentObjectAttribute;
                    if (attr != null)
                    {
                        var args = new AttributeContextMenuArgs(attr);
                        ((StoreHooks)Service.Current.Hooks).AttributeContextMenu(args);
                        if (args.Commands.Count > 0)
                        {
                            if (args.AutoExecuteFirst && args.Commands.Count == 1)
                                args.Commands[0].Invoked(args.Commands[0]);
                            else
                            {
                                var popupMenu = new PopupMenu();
                                args.Commands.Run(popupMenu.Commands.Add);

                                var point = source.TransformToVisual(null).TransformPoint(e.GetPosition(this));
                                await popupMenu.ShowAsync(point);
                            }

                            e.Handled = true;
                        }
                    }
                }
            }

            base.OnTapped(e);
        }
        private async void speedButton_Click(object sender, RoutedEventArgs e)
        {
            // Create menu and add commands
            var popupMenu = new PopupMenu();

            popupMenu.Commands.Add(new UICommand("4.0x", command => mediaElement.PlaybackRate = 4.0));
            popupMenu.Commands.Add(new UICommand("2.0x", command => mediaElement.PlaybackRate = 2.0));
            popupMenu.Commands.Add(new UICommand("1.5x", command => mediaElement.PlaybackRate = 1.5));
            popupMenu.Commands.Add(new UICommand("1.0x", command => mediaElement.PlaybackRate = 1.0));
            popupMenu.Commands.Add(new UICommand("0.5x", command => mediaElement.PlaybackRate = 0.5));

            // Get button transform and then offset it by half the button
            // width to center. This will show the popup just above the button.
            var button = (Button)sender;
            var transform = button.TransformToVisual(null);
            var point = transform.TransformPoint(new Point(button.ActualWidth / 2, 0));
            
            // Show popup
            IUICommand result = await popupMenu.ShowAsync(point);
            if (result != null)
            {
                button.Content = result.Label;
            }
        }
Esempio n. 10
0
        private async void ShowPopup(string parameter)
        {
            WwwFormUrlDecoder decoder = new WwwFormUrlDecoder(parameter);
            Debug.WriteLine(decoder.GetFirstValueByName("num"));
            Debug.WriteLine(decoder.GetFirstValueByName("offset"));
            var menu = new PopupMenu();
            menu.Commands.Add(new UICommand("Citer", (command) =>
            {
                Debug.WriteLine("VM Open param=" + parameter);
            }));

            var chosenCommand = await menu.ShowAsync(new Point(100, Convert.ToDouble(decoder.GetFirstValueByName("offset")) + 44.0));
            if (chosenCommand == null)
            {
                Debug.WriteLine("VM Dismiss param=" + parameter);
            }
        }
        public async void speedButton_Click(object sender, RoutedEventArgs e)
        {
            // Create menu and add commands
            var popupMenu = new PopupMenu();

            popupMenu.Commands.Add(new UICommand("4.0x", command => Player.PlaybackSession.PlaybackRate = 4.0));
            popupMenu.Commands.Add(new UICommand("2.0x", command => Player.PlaybackSession.PlaybackRate = 2.0));
            popupMenu.Commands.Add(new UICommand("1.5x", command => Player.PlaybackSession.PlaybackRate = 1.5));
            popupMenu.Commands.Add(new UICommand("1.0x", command => Player.PlaybackSession.PlaybackRate = 1.0));
            popupMenu.Commands.Add(new UICommand("0.5x", command => Player.PlaybackSession.PlaybackRate = 0.5));

            // Get button transform and then offset it by half the button
            // width to center. This will show the popup just above the button.
            var control = sender as Control;
            var transform = control.TransformToVisual(null);
            var point = transform.TransformPoint(new Point(control.ActualWidth / 2, 0));

            // Show popup
            var selected = await popupMenu.ShowAsync(point);
        }
Esempio n. 12
0
 private async void CategoryControl_RightTapped(object sender, RightTappedRoutedEventArgs e)
 {
     PopupMenu favoriteContextMenu = new PopupMenu();
     favoriteContextMenu.Commands.Add(new UICommand(loader.GetString("ContextButton_Unfavorite"), (command) =>
     {
         var dataContext = (sender as Control).DataContext;
         if (dataContext is FavoriteItem<Category>)
         {
             var context = dataContext as FavoriteItem<Category>;
             if (context != null)
             {
                 FavoriteCategoryDS.Instance.Remove(context);
             }
         }
         else if (dataContext is FavoriteItem<Author>)
         {
             var context = dataContext as FavoriteItem<Author>;
             if (context != null)
             {
                 FavoriteAuthorDS.Instance.Remove(context);
             }
         }
         else if (dataContext is Post)
         {
             var context = dataContext as Post;
             if (context != null)
             {
                 FavoritePostDS.Instance.RemoveFav(context);
             }
         }
     }));
    await favoriteContextMenu.ShowAsync((sender as Control).TransformToVisual(Window.Current.Content).TransformPoint(new Point(50,50)));
 }
Esempio n. 13
0
        private async void OpenFile(object sender, RoutedEventArgs e)
        {
            var resourceLoader = new ResourceLoader();
            var popupMenu = new PopupMenu();
            popupMenu.Commands.Add(new UICommand(resourceLoader.GetString("OpenVideo"), h => OpenVideo()));



            var transform = RootGrid.TransformToVisual(this);
            var point = transform.TransformPoint(new Point(Window.Current.Bounds.Width - 110, 200));
            await popupMenu.ShowAsync(point);
        }
Esempio n. 14
0
        public async void CreateVLCMenu()
        {
            var resourceLoader = new ResourceLoader();
            var popupMenu = new PopupMenu();
            popupMenu.Commands.Add(new UICommand(resourceLoader.GetString("PrivacyStatement"), async h => await ExternalStorage()));

            popupMenu.Commands.Add(new UICommand("Media servers", async h => await MediaServers()));


            var transform = RootGrid.TransformToVisual(this);
            var point = transform.TransformPoint(new Point(270, 110));
            await popupMenu.ShowAsync(point);
        }
        async void mediaElement_RightTapped(object sender, RightTappedRoutedEventArgs e)
        {

            Rightbar.IsOpen = true;
            Leftbar.IsOpen = true;
            Bottombar.IsOpen = true;
            Topbar.IsOpen = true;
            try
            {
                //var button = (MediaElement)sender;
                //var transform = button.TransformToVisual(this);
                //var point = transform.TransformPoint(new Windows.Foundation.Point(0, 0));

                PopupMenu p = new PopupMenu();
                p.Commands.Add(new UICommand("Play", null, 0));
                p.Commands.Add(new UICommand("Pause", null, 1));
                p.Commands.Add(new UICommand("Next", null, 2));
                p.Commands.Add(new UICommand("Previous", null, 3));
                p.Commands.Add(new UICommandSeparator());
                p.Commands.Add(new UICommand("Open", null, 4));

                var selectedCommand = await p.ShowAsync(_pos);
                if (selectedCommand != null)
                {


                    switch ((int)selectedCommand.Id)
                    {
                        case 0:
                            mediaElement.Play();
                            break;
                        case 1:
                            mediaElement.Pause();
                            // mediaElement.SeekWhileScrubbing = true;

                            break;
                        case 2:
                            nextvideo_Click(sender, e);
                            break;
                        case 3:
                            recentvideo_Click(sender, e);
                            break;
                        case 4:
                            button1_Click(sender, e);
                            break;
                    }
                }
            }
            catch
            {
                ErrorCorrecting("011");
            }

        }
        private void speedButton_Click(object sender, RoutedEventArgs e)
        {
            // Create menu and add commands
            var popupMenu = new PopupMenu();

            popupMenu.Commands.Add(new UICommand("4.0x", command => CurrentPlayer.PlaybackRate = 4.0));
            popupMenu.Commands.Add(new UICommand("2.0x", command => CurrentPlayer.PlaybackRate = 2.0));
            popupMenu.Commands.Add(new UICommand("1.5x", command => CurrentPlayer.PlaybackRate = 1.5));
            popupMenu.Commands.Add(new UICommand("1.0x", command => CurrentPlayer.PlaybackRate = 1.0));
            popupMenu.Commands.Add(new UICommand("0.5x", command => CurrentPlayer.PlaybackRate = 0.5));

            // Get button transform and then offset it by half the button
            // width to center. This will show the popup just above the button.
            var button = (Button)sender;
            var transform = button.TransformToVisual(null);
            var point = transform.TransformPoint(new Point(button.Width / 2, 0));
            
            // Show popup
            var ignoreAsyncResult = popupMenu.ShowAsync(point);

        }
Esempio n. 17
0
        internal override async Task OnActionCommand(ActionBase action, object obj)
        {
            if (action.Options != null && action.Options.Length > 0)
            {
                var button = obj as Button;
                if (button != null)
                {
                    var popupMenu = new PopupMenu();
                    foreach (var option in action.Options)
                        popupMenu.Commands.Add(new UICommand(option, async c => await action.Execute(c.Label)));

                    var point = button.TransformToVisual(null).TransformPoint(new Point(button.ActualWidth, 0d));
                    await popupMenu.ShowAsync(point);
                    return;
                }
            }

            await action.Execute(null);
        }