本文整理汇总了C#中UITapGestureRecognizer.LocationInView方法的典型用法代码示例。如果您正苦于以下问题:C# UITapGestureRecognizer.LocationInView方法的具体用法?C# UITapGestureRecognizer.LocationInView怎么用?C# UITapGestureRecognizer.LocationInView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UITapGestureRecognizer
的用法示例。
在下文中一共展示了UITapGestureRecognizer.LocationInView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: tapGame
void tapGame (UITapGestureRecognizer gestureRecognizer)
{
if (gestureRecognizer.State == UIGestureRecognizerState.Recognized &&
DidSelect != null) {
CGPoint point = gestureRecognizer.LocationInView (this);
CGRect bounds = Bounds;
CGPoint normalizedPoint = point;
normalizedPoint.X -= bounds.X + bounds.Size.Width / 2;
normalizedPoint.X *= 3 / bounds.Size.Width;
normalizedPoint.X = (float)Math.Round (normalizedPoint.X);
normalizedPoint.X = (float)Math.Max (normalizedPoint.X, -1);
normalizedPoint.X = (float)Math.Min (normalizedPoint.X, 1);
TTTMoveXPosition xPosition = (TTTMoveXPosition)(int)normalizedPoint.X;
normalizedPoint.Y -= bounds.Y + bounds.Size.Height / 2;
normalizedPoint.Y *= 3 / bounds.Size.Height;
normalizedPoint.Y = (float)Math.Round (normalizedPoint.Y);
normalizedPoint.Y = (float)Math.Max (normalizedPoint.Y, -1);
normalizedPoint.Y = (float)Math.Min (normalizedPoint.Y, 1);
TTTMoveYPosition yPosition = (TTTMoveYPosition)(int)normalizedPoint.Y;
if (CanSelect == null || CanSelect (this, xPosition, yPosition))
DidSelect (this, xPosition, yPosition);
}
}
示例2: OnTap
private void OnTap(UITapGestureRecognizer recognizer)
{
var cgPoint = recognizer.LocationInView(Control);
var location = ((MKMapView)Control).ConvertPoint(cgPoint, Control);
((MyBaseMap)Element).OnTap(new Position(location.Latitude, location.Longitude));
}
示例3: HandleSwipe
public void HandleSwipe(UITapGestureRecognizer recognizer)
{
// get the point of the swipe action
PointF point = recognizer.LocationInView(this);
// TODO: do something with the swipe
if (OnTapped != null)
OnTapped(point);
}
示例4: OnTap
private void OnTap(UITapGestureRecognizer e)
{
var view = e.View;
var location = e.LocationInView(view);
var subview = view.HitTest(location, null);
if (subview == view)
{
_element.SendBackgroundClick();
}
}
示例5: HandleSwiperTapGesture
public void HandleSwiperTapGesture (UITapGestureRecognizer press)
{
if (press.State == UIGestureRecognizerState.Recognized) {
// Where did the user tap?
CGPoint point = press.LocationInView (press.View);
// Get the NSIndexPath for that cell
NSIndexPath indexPath = TableView.IndexPathForRowAtPoint (point);
if (indexPath == null) {
return;
}
// Get the UITableViewCell the user tapped
var cell = TableView.CellAt (indexPath) as SwiperTableViewCell;
// If the cell is 'open' then check if the user is tapping the right or left button, otherwise close the drawer
if (cell != null && cell.Open) {
if (cell.LeftOpen && point.X < cell.LeftButtonOffset) { // Left Button
var leftTitle = "Left Button";
var leftMessage = SwiperStrings[indexPath.Row];
PresentAlert (leftTitle, leftMessage);
return;
}
if (cell.RightOpen && point.X > cell.RightButtonOffset) { // Right Button
var rightTitle = "Right Button";
var rightMessage = SwiperStrings[indexPath.Row];
PresentAlert (rightTitle, rightMessage);
return;
}
cell.CloseSlideButtons ();
return;
}
// Business as usual
RowSelected (TableView, indexPath);
return;
}
}
示例6: ColorTap
void ColorTap(UITapGestureRecognizer tapGestureRecognizer)
{
if (tapGestureRecognizer.State != UIGestureRecognizerState.Ended)
return;
CGPoint tapLocation = tapGestureRecognizer.LocationInView (ContentView);
UIView view = ContentView.HitTest (tapLocation, null);
// If the user tapped on a color (identified by its tag), notify the delegate.
ListColor color = (ListColor)(int)view.Tag;
SelectedColor = color;
ViewController.OnListColorCellDidChangeSelectedColor (SelectedColor);
}
示例7: HandleTapGesture
void HandleTapGesture (UITapGestureRecognizer sender)
{
if (sender.State != UIGestureRecognizerState.Ended)
return;
CGPoint initialPinchPoint = sender.LocationInView (CollectionView);
NSIndexPath tappedCellPath = CollectionView.IndexPathForItemAtPoint (initialPinchPoint);
if (tappedCellPath != null) {
cellCount--;
CollectionView.PerformBatchUpdates (delegate {
CollectionView.DeleteItems (new NSIndexPath [] { tappedCellPath });
}, null);
} else {
cellCount++;
CollectionView.PerformBatchUpdates (delegate {
CollectionView.InsertItems (new NSIndexPath[] {
NSIndexPath.FromItemSection (0, 0)
});
}, null);
}
}
示例8: SingleTap
/// <summary>
/// Called when the map was single tapped at a certain location.
/// </summary>
/// <param name="tap">Tap.</param>
private void SingleTap(UITapGestureRecognizer tap)
{
//RectangleF2D rect = _rect;
RectangleF rect = this.Frame;
if (rect.Width > 0 && rect.Height > 0)
{
this.StopCurrentAnimation();
if (this.MapTapEvent != null)
{
View2D view = this.CreateView(rect);
PointF location = tap.LocationInView(this);
double[] sceneCoordinates = view.FromViewPort(rect.Width, rect.Height, location.X, location.Y);
this.MapTapEvent(this.Map.Projection.ToGeoCoordinates(sceneCoordinates[0], sceneCoordinates[1]));
}
}
}
示例9: ImageDoubleTapped
// Gesture Recognizer Methods
private void ImageDoubleTapped(UITapGestureRecognizer sender)
{
if (Flags.ScrollViewIsAnimatingAZoom)
return;
PointF rawLocation = sender.LocationInView (sender.View);
PointF point = ScrollView.ConvertPointFromView (rawLocation, sender.View);
RectangleF targetZoomRect;
UIEdgeInsets targetInsets;
if (ScrollView.ZoomScale == 1.0f) {
ScrollView.AccessibilityHint = AccessibilityHintZoomedIn ();
float zoomWidth = View.Bounds.Size.Width / JTSImageViewController.JTSImageViewController_TargetZoomForDoubleTap;
float zoomHeight = View.Bounds.Size.Height / JTSImageViewController.JTSImageViewController_TargetZoomForDoubleTap;
targetZoomRect = new RectangleF (point.X - (zoomWidth / 2.0f), point.Y - (zoomHeight / 2.0f), zoomWidth, zoomHeight);
targetInsets = ContentInsetForScrollView(JTSImageViewController.JTSImageViewController_TargetZoomForDoubleTap);
} else {
ScrollView.AccessibilityHint = AccessibilityHintZoomedOut ();
float zoomWidth = View.Bounds.Size.Width * ScrollView.ZoomScale;
float zoomHeight = View.Bounds.Size.Height * ScrollView.ZoomScale;
targetZoomRect = new RectangleF (point.X - (zoomWidth / 2.0f), point.Y - (zoomHeight / 2.0f), zoomWidth, zoomHeight);
targetInsets = ContentInsetForScrollView (1.0f);
}
View.UserInteractionEnabled = false;
Flags.ScrollViewIsAnimatingAZoom = true;
ScrollView.ContentInset = targetInsets;
ScrollView.ZoomToRect (targetZoomRect, true);
InvokeInBackground(() => {
Thread.Sleep((int)(0.35 * 1000));
InvokeOnMainThread(() => {
this.View.UserInteractionEnabled = true;
Flags.ScrollViewIsAnimatingAZoom = false;
});
});
}
示例10: tap
void tap(UITapGestureRecognizer gr)
{
CGPoint point = gr.LocationInView(this);
this.selectedLine = lineAtPoint(point);
// If we just tapped, remove all lines in process
// so that a tap does not result in a new line
linesInProcess.Clear();
if (selectedLine != null) {
this.BecomeFirstResponder();
// Grab the menu controller
UIMenuController menu = UIMenuController.SharedMenuController;
// Create a new "Delete" UIMenuItem
UIMenuItem deleteItem = new UIMenuItem("Delete", new Selector("deleteLine:"));
menu.MenuItems = new UIMenuItem[] {deleteItem};
// Tell the menu item where it should come from and show it
menu.SetTargetRect(new CGRect(point.X, point.Y, 2, 2), this);
menu.SetMenuVisible(true, true);
UIGestureRecognizer[] grs = this.GestureRecognizers;
foreach (UIGestureRecognizer gestRec in grs) {
if (gestRec.GetType() != new UITapGestureRecognizer().GetType()) {
gestRec.Enabled = false;
}
}
} else {
// Hide the menu if no line is selected
UIMenuController menu = UIMenuController.SharedMenuController;
menu.SetMenuVisible(false, true);
UIGestureRecognizer[] grs = this.GestureRecognizers;
foreach (UIGestureRecognizer gestRec in grs) {
if (gestRec.GetType() != new UITapGestureRecognizer().GetType()) {
gestRec.Enabled = true;
}
}
}
this.SetNeedsDisplay();
}
示例11: ViewDidLoad
public override void ViewDidLoad ()
{
scannerView = new ZXingScannerView(new RectangleF(0, 0, this.View.Frame.Width, this.View.Frame.Height));
scannerView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
this.View.AddSubview(scannerView);
this.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
if (Scanner.UseCustomOverlay && Scanner.CustomOverlay != null)
overlayView = Scanner.CustomOverlay;
else
overlayView = new ZXingDefaultOverlayView(this.Scanner, new RectangleF(0, 0, this.View.Frame.Width, this.View.Frame.Height),
() => Scanner.Cancel(), () => Scanner.ToggleTorch());
if (overlayView != null)
{
UITapGestureRecognizer tapGestureRecognizer = new UITapGestureRecognizer ();
tapGestureRecognizer.AddTarget (() => {
var pt = tapGestureRecognizer.LocationInView(overlayView);
//scannerView.Focus(pt);
Console.WriteLine("OVERLAY TOUCH: " + pt.X + ", " + pt.Y);
});
tapGestureRecognizer.CancelsTouchesInView = false;
tapGestureRecognizer.NumberOfTapsRequired = 1;
tapGestureRecognizer.NumberOfTouchesRequired = 1;
overlayView.AddGestureRecognizer (tapGestureRecognizer);
overlayView.Frame = new RectangleF(0, 0, this.View.Frame.Width, this.View.Frame.Height);
overlayView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
this.View.AddSubview(overlayView);
this.View.BringSubviewToFront(overlayView);
}
}
示例12: SingleTap
/// <summary>
/// Called when the map was single tapped at a certain location.
/// </summary>
/// <param name="tap">Tap.</param>
private void SingleTap(UITapGestureRecognizer tap)
{
CGRect rect = this.Frame;
if (rect.Width > 0 && rect.Height > 0 && this.Map != null)
{
this.StopCurrentAnimation();
if (this.MapTapEvent != null)
{
View2D view = this.CreateView(rect);
CGPoint location = tap.LocationInView(this);
double[] sceneCoordinates = view.FromViewPort(rect.Width, rect.Height, location.X, location.Y);
this.MapTapEvent(this.Map.Projection.ToGeoCoordinates(sceneCoordinates[0], sceneCoordinates[1]));
}
// notify controls map was tapped.
this.NotifyMapTapToControls();
}
}
示例13: DidSingleTap
private void DidSingleTap(UITapGestureRecognizer recognizer)
{
if (scrollView.ZoomScale == scrollView.MinimumZoomScale)
{
HideDoneButton();
}
else if (scrollView.ZoomScale == scrollView.MaximumZoomScale)
{
CGPoint pointInView = recognizer.LocationInView(_imageView);
ZoomInZoomOut(pointInView);
}
}
示例14: HandleTap
private void HandleTap(UITapGestureRecognizer gesture)
{
var locationInCanvas = gesture.LocationInView(_canvasView);
var touchedElement = ElementUnderPoint(locationInCanvas);
bool didTouchElement = touchedElement != null;
ClearSelection();
if (didTouchElement)
{
SetElementSelected(touchedElement, selected: true);
}
}
示例15: TapGestureRecognizer
public void TapGestureRecognizer(UITapGestureRecognizer sender)
{
var enabledGestures = TouchPanel.EnabledGestures;
if ((enabledGestures & GestureType.Tap) != 0)
{
TouchPanel.GestureList.Enqueue(new GestureSample(GestureType.Tap, new TimeSpan(_nowUpdate.Ticks), new Vector2 (sender.LocationInView (sender.View)), new Vector2 (sender.LocationInView (sender.View)), new Vector2(0,0), new Vector2(0,0)));
}
}