本文整理汇总了C#中UIPanGestureRecognizer类的典型用法代码示例。如果您正苦于以下问题:C# UIPanGestureRecognizer类的具体用法?C# UIPanGestureRecognizer怎么用?C# UIPanGestureRecognizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UIPanGestureRecognizer类属于命名空间,在下文中一共展示了UIPanGestureRecognizer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BMarkerImageView
public BMarkerImageView(WeakReference parentView, CGPoint location)
{
WeakParent = parentView;
_location = location;
UserInteractionEnabled = true;
Frame = new CGRect (Location.X - 22, Location.Y - 22, 44, 44);
using (var image = UIImage.FromFile ("Images/icon_marker.png"))
{
Image = image;
}
_pan = new UIPanGestureRecognizer (() =>
{
if ((_pan.State == UIGestureRecognizerState.Began || _pan.State == UIGestureRecognizerState.Changed) && (_pan.NumberOfTouches == 1))
{
Center = _pan.LocationInView (_parent);
Location = Center;
_parent.SetNeedsDisplay ();
}
else if (_pan.State == UIGestureRecognizerState.Ended)
{
}
});
_doubleTap = new UITapGestureRecognizer ((gesture) => Crop ()) {
NumberOfTapsRequired = 2, NumberOfTouchesRequired = 1
};
AddGestureRecognizer (_pan);
AddGestureRecognizer (_doubleTap);
}
示例2: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
_panGesture = new UIPanGestureRecognizer(PanGestureRecognized);
View.AddGestureRecognizer(_panGesture);
}
示例3: TouchDrawView
public TouchDrawView(CGRect rect)
: base(rect)
{
linesInProcess = new Dictionary<string, Line>();
this.BackgroundColor = UIColor.White;
this.MultipleTouchEnabled = true;
UITapGestureRecognizer tapRecognizer = new UITapGestureRecognizer(tap);
this.AddGestureRecognizer(tapRecognizer);
UITapGestureRecognizer dbltapRecognizer = new UITapGestureRecognizer(dblTap);
dbltapRecognizer.NumberOfTapsRequired = 2;
this.AddGestureRecognizer(dbltapRecognizer);
UILongPressGestureRecognizer pressRecognizer = new UILongPressGestureRecognizer(longPress);
this.AddGestureRecognizer(pressRecognizer);
moveRecognizer = new UIPanGestureRecognizer(moveLine);
moveRecognizer.WeakDelegate = this;
moveRecognizer.CancelsTouchesInView = false;
this.AddGestureRecognizer(moveRecognizer);
UISwipeGestureRecognizer swipeRecognizer = new UISwipeGestureRecognizer(swipe);
swipeRecognizer.Direction = UISwipeGestureRecognizerDirection.Up;
swipeRecognizer.NumberOfTouchesRequired = 3;
this.AddGestureRecognizer(swipeRecognizer);
selectedColor = UIColor.Red;
}
示例4: HandlePanGesture
void HandlePanGesture (UIPanGestureRecognizer gesture)
{
if (gesture.State == UIGestureRecognizerState.Began) {
gestureStartingPoint = gesture.TranslationInView (textView);
gestureStartingCenter = imageView.Center;
}
else if (gesture.State == UIGestureRecognizerState.Changed) {
CGPoint currentPoint = gesture.TranslationInView(textView);
nfloat distanceX = currentPoint.X - gestureStartingPoint.X;
nfloat distanceY = currentPoint.Y - gestureStartingPoint.Y;
CGPoint newCenter = gestureStartingCenter;
newCenter.X += distanceX;
newCenter.Y += distanceY;
imageView.Center = newCenter;
textView.TextContainer.ExclusionPaths = TranslatedBezierPath ();
}
else if (gesture.State == UIGestureRecognizerState.Ended) {
gestureStartingPoint = new CGPoint (0, 0);
gestureStartingCenter = new CGPoint (0, 0);
}
}
示例5: SlideoutNavigationController
/// <summary>
/// Initializes a new instance of the <see cref="SlideoutNavigationController"/> class.
/// </summary>
public SlideoutNavigationController()
{
SlideSpeed = 0.2f;
SlideWidth = 245f;
// HACK to detect pan gesture from the whole viewport
SlideHeight = float.MaxValue;
LayerShadowing = false;
_internalMenuViewLeft = new ProxyNavigationController {
ParentController = this,
View = { AutoresizingMask = UIViewAutoresizing.FlexibleHeight }
};
_internalMenuViewRight = new ProxyNavigationController {
ParentController = this,
View = { AutoresizingMask = UIViewAutoresizing.FlexibleHeight }
};
_internalMenuViewLeft.SetNavigationBarHidden (DisplayNavigationBarOnLeftMenu, false);
_internalMenuViewRight.SetNavigationBarHidden (DisplayNavigationBarOnRightMenu, false);
_internalTopView = new UIViewController { View = { UserInteractionEnabled = true } };
_internalTopView.View.Layer.MasksToBounds = false;
_tapGesture = new UITapGestureRecognizer ();
_tapGesture.AddTarget (() => Hide ());
_tapGesture.NumberOfTapsRequired = 1;
_panGesture = new UIPanGestureRecognizer {
Delegate = new SlideoutPanDelegate(this),
MaximumNumberOfTouches = 1,
MinimumNumberOfTouches = 1
};
_panGesture.AddTarget (() => Pan (_internalTopView.View));
_internalTopView.View.AddGestureRecognizer (_panGesture);
}
示例6: AddGestures
private void AddGestures()
{
var touchDownGesture = new UILongPressGestureRecognizer(HandleTouchDown) { MinimumPressDuration = 0 };
_canvasView.AddGestureRecognizer(touchDownGesture);
// Tap to select
var tapGesture = new UITapGestureRecognizer(HandleTap);
_canvasView.AddGestureRecognizer(tapGesture);
// Move an element
var elementDragGesture = new UIPanGestureRecognizer(HandlePan);
_canvasView.AddGestureRecognizer(elementDragGesture);
elementDragGesture.ShouldBegin = g => _panShouldBegin;
var selectLongPressGesture = new UILongPressGestureRecognizer(HandleLongPress) { MinimumPressDuration = 0.1 };
_canvasView.AddGestureRecognizer(selectLongPressGesture);
selectLongPressGesture.ShouldReceiveTouch = (g, touch) =>
{
var locationInCanvas = touch.LocationInView(_canvasView);
var touchedElement = ElementUnderPoint(locationInCanvas);
return touchedElement != null && !IsElementSelected(touchedElement);
};
selectLongPressGesture.ShouldRecognizeSimultaneously = (g1, g2) => g2 == elementDragGesture;
touchDownGesture.ShouldRecognizeSimultaneously = (g1, g2) => true;
}
示例7: CreatePanGestureRecognizer
private void CreatePanGestureRecognizer()
{
panGesture = new UIPanGestureRecognizer(() =>
{
if ((panGesture.State == UIGestureRecognizerState.Began || panGesture.State == UIGestureRecognizerState.Changed) && (panGesture.NumberOfTouches == 1))
{
var p0 = panGesture.LocationInView(this);
if (dx == 0)
dx = p0.X - Subviews[0].Center.X;
if (dy == 0)
dy = p0.Y - Subviews[0].Center.Y;
var p1 = new PointF((float)(p0.X - dx), (float)(p0.Y - dy));
Subviews[0].Center = p1;
}
else if (panGesture.State == UIGestureRecognizerState.Ended)
{
dx = 0;
dy = 0;
}
});
}
示例8: RangeSlider
public RangeSlider()
{
_background = new UIView();
_background.BackgroundColor = UIColor.LightGray;
_range = new UIView();
_range.BackgroundColor = UIColor.Blue;
_leftIndicator = CreateIndicator();
_leftIndicatorGesture = new UIPanGestureRecognizer(OnPan);
_rightIndicator = CreateIndicator();
_rightIndicatorGesture = new UIPanGestureRecognizer(OnPan);
_leftTouchArea = new UIView();
_leftTouchArea.BackgroundColor = UIColor.Clear;
_leftTouchArea.AddGestureRecognizer(_leftIndicatorGesture);
_rightTouchArena = new UIView();
_rightTouchArena.BackgroundColor = UIColor.Clear;
_rightTouchArena.AddGestureRecognizer(_rightIndicatorGesture);
AddSubview(_background);
AddSubview(_range);
AddSubview(_leftIndicator);
AddSubview(_rightIndicator);
AddSubview(_leftTouchArea);
AddSubview(_rightTouchArena);
}
示例9: RevealGesture
public void RevealGesture(UIPanGestureRecognizer recognizer)
{
MenuViewController rearVC = (MenuViewController)SidebarViewController;
rearVC.searchBar.ResignFirstResponder ();
base.DragContentView (recognizer);
}
示例10: SlideoutNavigationController
/// <summary>
/// Initializes a new instance of the <see cref="SlideoutNavigationController"/> class.
/// </summary>
public SlideoutNavigationController()
{
SlideSpeed = 0.2f;
SlideWidth = 260f;
SlideHeight = 44f;
LayerShadowing = true;
_internalMenuView = new ProxyNavigationController
{
ParentController = this,
View = { AutoresizingMask = UIViewAutoresizing.FlexibleHeight }
};
//_internalMenuView.SetNavigationBarHidden(true, false);
_internalTopView = new UIViewController { View = { UserInteractionEnabled = true } };
_internalTopView.View.Layer.MasksToBounds = false;
_tapGesture = new UITapGestureRecognizer();
// _tapGesture.AddTarget(new )
_tapGesture.AddTarget(Hide);
_tapGesture.NumberOfTapsRequired = 1;
_panGesture = new UIPanGestureRecognizer
{
Delegate = new SlideoutPanDelegate(this),
MaximumNumberOfTouches = 1,
MinimumNumberOfTouches = 1
};
_panGesture.AddTarget(() => Pan(_internalTopView.View));
_internalTopView.View.AddGestureRecognizer(_panGesture);
}
示例11: createGrab
private void createGrab()
{
float dx = 0;
var panGesture = new UIPanGestureRecognizer ((pg) => {
if ((pg.State == UIGestureRecognizerState.Began || pg.State == UIGestureRecognizerState.Changed) && (pg.NumberOfTouches == 1)) {
var p0 = pg.LocationInView (content);
if (dx == 0)
dx = p0.X - content.Center.X;
var p1 = new PointF (p0.X - dx, content.Center.Y);
//Dont let it go to far right
if (p1.X <= content.Center.X)
content.Center = p1;
//Auto withdrawl after 33%
if (p1.X < content.Frame.Width/3) {
closeIt();
}
} else if (pg.State == UIGestureRecognizerState.Ended) {
dx = 0;
}
});
content.AddGestureRecognizer (panGesture);
}
示例12: ViewDidAppear
public override void ViewDidAppear(bool animated)
{
base.ViewWillAppear (animated);
UINavigationController nav = NavigationController;
MainViewController controller = (MainViewController)nav.ParentViewController; // MainViewController : ZUUIRevealController
// Check if a UIPanGestureRecognizer already sits atop our NavigationBar.
if (nav.NavigationBar.GestureRecognizers == null ||
!(nav.NavigationBar.GestureRecognizers.Contains (navigationBarPanGestureRecognizer))) {
// If not, allocate one and add it.
UIPanGestureRecognizer panGestureRecognizer = new UIPanGestureRecognizer (controller.RevealGesture);
navigationBarPanGestureRecognizer = panGestureRecognizer;
NavigationController.NavigationBar.AddGestureRecognizer (navigationBarPanGestureRecognizer);
}
// Check if we have a revealButton already.
if (NavigationItem.LeftBarButtonItem == null) {
// If not, allocate one and add it.
UIImage imageMenu = UIImage.FromFile ("action_menu.png");
UIButton menuButton = new UIButton (UIButtonType.Custom);
menuButton.SetImage (imageMenu, UIControlState.Normal);
menuButton.Frame = new RectangleF (0.0f, 0.0f, (float)imageMenu.Size.Width, (float)imageMenu.Size.Height);
menuButton.TouchUpInside += (sender, e) => controller.RevealToggle ();
NavigationItem.LeftBarButtonItem = new UIBarButtonItem (menuButton);
}
}
示例13: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
View.Apply (Style.Screen);
NavigationBar.Apply (Style.NavigationBar);
Delegate = new NavDelegate ();
panGesture = new UIPanGestureRecognizer (OnPanGesture) {
// TODO: TableView scroll gestures are not
// compatible with the open / close pan gesture.
ShouldRecognizeSimultaneously = (a, b) => ! (b.View is UITableView),
CancelsTouchesInView = true,
};
View.AddGestureRecognizer (panGesture);
fadeView = new UIView();
fadeView.BackgroundColor = UIColor.FromRGBA (29f / 255f, 29f / 255f, 28f / 255f, 0.5f);
fadeView.Frame = new CGRect (0, 0, View.Frame.Width, View.Frame.Height);
fadeView.Hidden = true;
tapGesture = new UITapGestureRecognizer (CloseMenu) {
ShouldReceiveTouch = (a, b) => true,
ShouldRecognizeSimultaneously = (a, b) => true,
CancelsTouchesInView = true,
};
fadeView.AddGestureRecognizer (tapGesture);
View.Add (fadeView);
}
示例14: OnPanningGesture
private void OnPanningGesture (UIPanGestureRecognizer gesture)
{
switch (gesture.State) {
case UIGestureRecognizerState.Began:
panStart = gesture.TranslationInView (actualContentView);
panLockInHorizDirection = false;
break;
case UIGestureRecognizerState.Changed:
var currentPoint = gesture.TranslationInView (actualContentView);
panDeltaX = panStart.X - currentPoint.X;
if (panDeltaX > 0) {
panDeltaX = 0;
return;
}
if (!panLockInHorizDirection) {
if (Math.Abs (panDeltaX) > 30) {
// User is swiping the cell, lock them into this direction
panLockInHorizDirection = true;
} else if (Math.Abs (panStart.Y - currentPoint.Y) > 5) {
// User is starting to move upwards, let them scroll
gesture.Enabled = false;
}
}
if (-SwipeWidth > panDeltaX) {
panDeltaX = -SwipeWidth;
}
UIView.AnimateNotify (0.1, 0, UIViewAnimationOptions.CurveEaseOut, LayoutActualContentView, null);
break;
case UIGestureRecognizerState.Ended:
if (Editing) {
break;
}
if (!gesture.Enabled) {
gesture.Enabled = true;
}
var velocityX = gesture.VelocityInView (gesture.View).X;
var absolutePanDeltaX = Math.Abs (panDeltaX);
var duration = Math.Max (MinDuration, Math.Min (MaxDuration, (absolutePanDeltaX) / velocityX));
UIView.AnimateNotify (duration, () => LayoutActualContentView (0), isFinished => {
if (isFinished && absolutePanDeltaX > SwipeWidth - 5) {
OnContinueGestureFinished ();
}
});
break;
case UIGestureRecognizerState.Cancelled:
UIView.AnimateNotify (0.3, () => LayoutActualContentView (0), isFinished => gesture.Enabled = isFinished);
break;
}
}
示例15: WireUpDragGestureRecognizer
protected void WireUpDragGestureRecognizer()
{
// create a new tap gesture
UIPanGestureRecognizer gesture = new UIPanGestureRecognizer();
// wire up the event handler (have to use a selector)
gesture.AddTarget(() => HandleDrag(gesture));
// add the gesture recognizer to the view
imgDragMe.AddGestureRecognizer(gesture);
}