GetPosition() public method

public GetPosition ( [ relativeTo ) : Point
relativeTo [
return Point
 private void ImageToAdd_RightTapped(object sender, RightTappedRoutedEventArgs e)
 {
     if (sender.GetType() == typeof(Image))
         ImageToAdd_CreateDropDownMenu(sender as Image, e.GetPosition(sender as Image));
     else
         throw new Exception("Error: Expected sender to be Image but was: " + sender.GetType().ToString());
 }
        private void AccountList_RightTapped(object sender, RightTappedRoutedEventArgs e)
        {
            var senderElement = sender as FrameworkElement;
            var flyoutBase = FlyoutBase.GetAttachedFlyout(senderElement) as MenuFlyout;

            flyoutBase?.ShowAt(senderElement, e.GetPosition(senderElement));
        }
示例#3
0
        private void Grid_RightTapped(object sender, Windows.UI.Xaml.Input.RightTappedRoutedEventArgs e)
        {
            var ObjectPressed = (sender as Grid).DataContext as ListedItem;

            gv.SelectedItem = ObjectPressed;
            context.ShowAt(sender as Grid, e.GetPosition(sender as Grid));
        }
 protected override void OnRightTapped(RightTappedRoutedEventArgs e) {
     if (_IsPointerPressed) {
         ShowContextMenu(null, e.GetPosition(null));
         e.Handled = true;
     }
     base.OnRightTapped(e);
 }
示例#5
0
 private void UiElementOnRightTapped(object sender, RightTappedRoutedEventArgs e)
 {
     if (isPointerPressed)
     {
         ShowMenu(e.GetPosition(uiElement));
         e.Handled = true;
     }
 }
 private void LayoutRoot_RightTapped(object sender, RightTappedRoutedEventArgs e)
 {
     if (IsHolding)
         return;
     var targetElement = sender as FrameworkElement;
     MenuFlyout flyout = (MenuFlyout)FlyoutBase.GetAttachedFlyout(targetElement);
     flyout.ShowAt(targetElement, e.GetPosition(targetElement));
 }
示例#7
0
 private void OcrListItem_RightTapped(object sender, RightTappedRoutedEventArgs e)
 {
     FrameworkElement element = sender as FrameworkElement;
     if (element == null)
     {
         return;
     }
     var flyout = FlyoutBase.GetAttachedFlyout(element) as MenuFlyout;
     flyout?.ShowAt(this, e.GetPosition(null));
 }
        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 void drawingCanvas_RightTapped(object sender, RightTappedRoutedEventArgs e)
        {
            Point mouseLocation = e.GetPosition(this.drawingCanvas);
            Circle myCircle = new Circle(100);

            if (myCircle is IDraw)
            {
                IDraw drawCircle = myCircle;
                drawCircle.SetLocation((int)mouseLocation.X, (int)mouseLocation.Y);
                drawCircle.Draw(drawingCanvas);
            }
            if (myCircle is IColor)
            {
                IColor colorCircle = myCircle;
                colorCircle.SetColor(Colors.HotPink);
            }
        }
        private void TrackItem_RightTapped(object sender, Windows.UI.Xaml.Input.RightTappedRoutedEventArgs e)
        {
            FrameworkElement  senderElement = sender as FrameworkElement;
            FlyoutBase        flyoutBase    = FlyoutBase.GetAttachedFlyout(senderElement);
            FlyoutShowOptions options       = new FlyoutShowOptions
            {
                Placement = FlyoutPlacementMode.RightEdgeAlignedTop,
                Position  = e.GetPosition(senderElement),
                ShowMode  = FlyoutShowMode.Standard
            };

            flyoutBase.ShowAt(senderElement, options);
            //update focus state
            Messenger.Default.Send(new MessengerHelper
            {
                Action = MessengerAction.RightTapped,
                Target = TargetView.Tracks,
                Item   = senderElement.DataContext as ItemBase
            });

            e.Handled = true;

            flyoutBase.Closed += TracksFlyoutBase_Closed;
        }
示例#11
0
 private void listView_RightTapped(object sender, RightTappedRoutedEventArgs e)
 {
     if (((FrameworkElement)e.OriginalSource).DataContext != null)
     {
         selectedListViewItemStr = ((FrameworkElement)e.OriginalSource).DataContext.ToString();
         lVcontextMenu.ShowAt(listView, e.GetPosition(listView));
     }
 }
示例#12
0
        private async void ItemView_ItemRightTapped(object sender, RightTappedRoutedEventArgs e)
        {
            var pos = e.GetPosition(this);

            var elements = VisualTreeHelper.FindElementsInHostCoordinates(pos, ((UIElement)sender));

            FrameworkElement selectedElement = null;
            Station selectedStation = null;

            //I could refactor this
            if (sender is GridView)
            {
                selectedElement = (FrameworkElement)elements.FirstOrDefault(x => x.GetType() == typeof(GridViewItem));
            }
            else if (sender is ListView)
            {
                selectedElement = (FrameworkElement)elements.FirstOrDefault(x => x.GetType() == typeof(ListViewItem));
            }

            if (selectedElement != null)
            {
                e.Handled = true;

                selectedStation = (Station)selectedElement.DataContext;

                PopupMenu menu = new PopupMenu();
                menu.Commands.Add(new UICommand(LocalizationManager.GetLocalizedValue("GotoHomepageMenu"), (command) =>
                {
                    Windows.System.Launcher.LaunchUriAsync(selectedStation.HomepageUrl);
                }));

                this.BottomAppBar.IsSticky = true;
                this.TopAppBar.IsSticky = true;

                var chosenCommand = await menu.ShowForSelectionAsync(new Rect(pos, selectedElement.RenderSize));

                this.BottomAppBar.IsSticky = false;
                this.TopAppBar.IsSticky = false;

            }
        }
 object selected_item;  //选中项的数据源
 /// <summary>
 /// 右键收藏,弹出菜单
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Border_RightTapped(object sender, RightTappedRoutedEventArgs e)
 {
     UIElement uie = e.OriginalSource as UIElement;
     selected_item = (e.OriginalSource as FrameworkElement).DataContext;
     (this.Resources["contextMenu"] as MenuFlyout).ShowAt(uie, e.GetPosition(uie));           
 }
示例#14
0
 private void PhotoAlbumViewer_RightTapped(object sender, Windows.UI.Xaml.Input.RightTappedRoutedEventArgs e)
 {
     gridContext.ShowAt(sender as Grid, e.GetPosition(sender as Grid));
 }
        private void OnTextBlockRightTapped(object sender, RightTappedRoutedEventArgs e) {
            StackPanel stackPanel = new StackPanel();

            // Create two Button controls and add to StackPanel
            Button btn1 = new Button {
                Content = "Larger font",
                Tag = 1.2,
                HorizontalAlignment = HorizontalAlignment.Center,
                Margin = new Thickness(12)
            };
            btn1.Click += OnButtonClick;
            stackPanel.Children.Add(btn1);

            Button btn2 = new Button {
                Content = "Smaller font",
                Tag = 1 / 1.2,
                HorizontalAlignment = HorizontalAlignment.Center,
                Margin = new Thickness(12)
            };
            btn2.Click += OnButtonClick;
            stackPanel.Children.Add(btn2);

            // Create three RadioButton controls and add to StackPanel
            string[] names = { "Red", "Green", "Blue" };
            Color[] colors = { Colors.Red, Colors.Green, Colors.Blue };

            for (int i = 0; i < names.Length; i++) {
                RadioButton radioButton = new RadioButton {
                    Content = names[i],
                    Foreground = new SolidColorBrush(colors[i]),
                    IsChecked = (txtblk.Foreground as SolidColorBrush).Color == colors[i],
                    Margin = new Thickness(12)
                };
                radioButton.Checked += OnRadioButtonChecked;
                stackPanel.Children.Add(radioButton);
            }

            // Create a Border for the StackPanel
            Border border = new Border {
                Child = stackPanel,
                Background = this.Resources["ApplicationPageBackgroundThemeBrush"] as SolidColorBrush,
                BorderBrush = this.Resources["ApplicationForegroundThemeBrush"] as SolidColorBrush,
                BorderThickness = new Thickness(1),
                Padding = new Thickness(24),
            };

            // Create the Popup object
            Popup popup = new Popup {
                Child = border,
                IsLightDismissEnabled = true
            };

            // Adjust location based on content size
            border.Loaded += (loadedSender, loadedArgs) => {
                Point point = e.GetPosition(this);
                point.X -= border.ActualWidth / 2;
                point.Y -= border.ActualHeight;

                // Leave at least a quarter inch margin
                popup.HorizontalOffset =
                    Math.Min(this.ActualWidth - border.ActualWidth - 24,
                    Math.Max(24, point.X));

                popup.VerticalOffset =
                    Math.Min(this.ActualHeight - border.ActualHeight - 24,
                    Math.Max(24, point.Y));

                // Set keyboard focus to first element
                btn1.Focus(FocusState.Programmatic);
            };

            // Open the popup
            popup.IsOpen = true;
        }
 /// <summary>
 /// Fired when the image is right clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ContentRoot_RightTapped(object sender, RightTappedRoutedEventArgs e)
 {
     FrameworkElement element = sender as FrameworkElement;
     if (element != null)
     {
         Point p = e.GetPosition(element);
         flyoutMenu.ShowAt(element, p);
     }
 }
        protected override void OnRightTapped(RightTappedRoutedEventArgs e)
        {
            if (_IsPointerPressed)
            {
                var MyObject = (e.OriginalSource as FrameworkElement).DataContext as SampleDataModel;

                ShowContextMenu(MyObject, null, e.GetPosition(null));
                e.Handled = true;
            }

            base.OnRightTapped(e);
        }
示例#18
0
        private void Files_Right_Click(object sender, RightTappedRoutedEventArgs e)
        {
            //var s = (FrameworkElement)sender;
            var d = ((FrameworkElement)e.OriginalSource).DataContext;
            System.Diagnostics.Debug.WriteLine("Selected Type :" + d.GetType());

            Models.Node node = (Models.Node)d;

            Files.SelectedItem = node;
            System.Diagnostics.Debug.WriteLine("Selected item :" + ((Models.Node)Files.SelectedItem).Label);

            ShowContextMenu(null, e.GetPosition(null));
        }
示例#19
0
 private async void ImageRightTapped(object sender, RightTappedRoutedEventArgs e)
 {
     if (!_isShowingContextMenu)
     {
         _isShowingContextMenu = true;
         await ImageHoldingOrRightTapped(sender, (ui) => { return e.GetPosition(ui); });
     }
 }
示例#20
0
 private void TranslationItemRightTapped(object sender, RightTappedRoutedEventArgs e)
 {
     if (!_isShowingContextMenu)
     {
         _isShowingContextMenu = true;
         TranslationItemHoldingOrRightTapped(sender, e.GetPosition(null), e.OriginalSource);
     }
 }