本文整理汇总了C#中Windows.UI.Xaml.Input.RightTappedRoutedEventArgs.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# RightTappedRoutedEventArgs.GetPosition方法的具体用法?C# RightTappedRoutedEventArgs.GetPosition怎么用?C# RightTappedRoutedEventArgs.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Input.RightTappedRoutedEventArgs
的用法示例。
在下文中一共展示了RightTappedRoutedEventArgs.GetPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImageToAdd_RightTapped
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());
}
示例2: OnRightTapped
protected override void OnRightTapped(RightTappedRoutedEventArgs e) {
if (_IsPointerPressed) {
ShowContextMenu(null, e.GetPosition(null));
e.Handled = true;
}
base.OnRightTapped(e);
}
示例3: AccountList_RightTapped
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));
}
示例4: LayoutRoot_RightTapped
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));
}
示例5: UiElementOnRightTapped
private void UiElementOnRightTapped(object sender, RightTappedRoutedEventArgs e)
{
if (isPointerPressed)
{
ShowMenu(e.GetPosition(uiElement));
e.Handled = true;
}
}
示例6: OcrListItem_RightTapped
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));
}
示例7: OnTextBlockRightTapped
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));
}
示例8: drawingCanvas_RightTapped
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);
}
}
示例9: Border_RightTapped
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));
}
示例10: ItemView_ItemRightTapped
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;
}
}
示例11: OnRightTapped
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);
}
示例12: ContentRoot_RightTapped
/// <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);
}
}
示例13: Files_Right_Click
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));
}
示例14: OnTextBlockRightTapped
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;
}
示例15: listView_RightTapped
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));
}
}