当前位置: 首页>>代码示例>>C#>>正文


C# NSSet.ToArray方法代码示例

本文整理汇总了C#中NSSet.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# NSSet.ToArray方法的具体用法?C# NSSet.ToArray怎么用?C# NSSet.ToArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NSSet的用法示例。


在下文中一共展示了NSSet.ToArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TouchesBegan

 public override void TouchesBegan(NSSet touches, UIEvent evt)
 {
     foreach (UITouch touch in touches.ToArray<UITouch>())
     {
         Console.WriteLine(touch);
     }
 }
开发者ID:pedroccrl,项目名称:Xamarin.Plugins-1,代码行数:7,代码来源:GestureMonitor.cs

示例2: TouchesBegan

        public void TouchesBegan(NSSet touchSet, UIEvent evnt)
        {
            if (DispatchEvents) {
                List<TouchHandler> handlers = new List<TouchHandler>(_touchHandlers);

                // Make full-aot aware of the needed ICollection<UITouch> types
                ICollection<UITouch> touches_col = (ICollection<UITouch>)touchSet.ToArray<UITouch>();

                #pragma warning disable 0219
                // this is a tiny hack, make sure the AOT compiler knows about
                // UICollection.Count, as it will need it when we instantiate the list below
                int touches_count = touches_col.Count;
                #pragma warning restore 0219

                List<UITouch> touches = new List<UITouch>(touches_col);

                foreach (TouchHandler handler in handlers) {
                    if (handler.TouchesBegan(touches, evnt)) {
                        break;
                    }
                    if (touches.IsEmpty()) {
                        break;
                    }
                }
            }
        }
开发者ID:hcxyzlm,项目名称:CocosNet-1,代码行数:26,代码来源:TouchDispatcher.cs

示例3: TouchesBegan

		public override void TouchesBegan (NSSet touchesSet, UIEvent evt)
		{
			var touches = touchesSet.ToArray<UITouch> ();
			touchPhaseLabel.Text = "Phase:Touches began";
			touchInfoLabel.Text = "";
		
			var numTaps = touches.Sum (t => t.TapCount);
			if (numTaps >= 2){
				touchInfoLabel.Text = string.Format ("{0} taps", numTaps);
				if (numTaps == 2 && piecesOnTop) {
					// recieved double tap -> align the three pieces diagonal.
					if (firstImage.Center.X == secondImage.Center.X)
						secondImage.Center = new PointF (firstImage.Center.X - 50, firstImage.Center.Y - 50);
					if (firstImage.Center.X == thirdImage.Center.X)
						thirdImage.Center = new PointF (firstImage.Center.X + 50, firstImage.Center.Y + 50);
					if (secondImage.Center.X == thirdImage.Center.X)
						thirdImage.Center = new PointF (secondImage.Center.X + 50, secondImage.Center.Y + 50);
					touchInstructionLabel.Text = "";
				}
					
			} else {
				touchTrackingLabel.Text = "";
			}
			foreach (var touch in touches) {
				// Send to the dispatch method, which will make sure the appropriate subview is acted upon
				DispatchTouchAtPoint (touch.LocationInView (window));
			}
		}
开发者ID:rojepp,项目名称:monotouch-samples,代码行数:28,代码来源:Touches_ClassicViewController.cs

示例4: TouchesBegan

        public override void TouchesBegan(NSSet touchesSet, UIEvent evt)
        {
            var touches = touchesSet.ToArray<UITouch> ();
            touchPhaseLabel.Text = "Phase:Touches began";
            touchInfoLabel.Text = "";

            var numTaps = touches.Sum (t => t.TapCount);
            if (numTaps >= 2){
                touchInfoLabel.Text = string.Format ("{0} taps", numTaps);
                if (numTaps == 2 && piecesOnTop) {
                    // recieved double tap -> align the three pieces diagonal.
                    firstImage.Center = new PointF (padding + firstImage.Frame.Width / 2f,
                        touchInfoLabel.Frame.Bottom + padding + firstImage.Frame.Height / 2f);
                    secondImage.Center = new PointF (View.Bounds.Width / 2f, View.Bounds.Height / 2f);
                    thirdImage.Center = new PointF (View.Bounds.Width - thirdImage.Frame.Width / 2f - padding,
                        touchInstructionLabel.Frame.Top - thirdImage.Frame.Height);
                    touchInstructionLabel.Text = "";
                }

            } else {
                touchTrackingLabel.Text = "";
            }
            foreach (var touch in touches) {
                // Send to the dispatch method, which will make sure the appropriate subview is acted upon
                DispatchTouchAtPoint (touch.LocationInView (View));
            }
        }
开发者ID:BoogieMAN2K,项目名称:monotouch-samples,代码行数:27,代码来源:Touches_ClassicViewController.cs

示例5: ProcessTouches

		void ProcessTouches (NSSet touches)
		{
			if (ripple == null)
				return;
			
			foreach (UITouch touch in touches.ToArray<UITouch> ())
				ripple.InitiateRippleAtLocation (touch.LocationInView (touch.View));
		}
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:8,代码来源:RippleViewController.cs

示例6: ConvertMouse

		public static MouseEventArgs ConvertMouse (UIView view, NSSet touches, UIEvent evt)
		{
			if (touches.Count > 0) {
				UITouch touch = touches.ToArray<UITouch> () [0];
				var location = touch.LocationInView (view);
				return new MouseEventArgs (MouseButtons.Primary, Key.None, location.ToEtoPoint ());
			}
			return new MouseEventArgs (MouseButtons.Primary, Key.None, Point.Empty);
		}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:9,代码来源:Conversions.cs

示例7: TouchesEnded

 public override void TouchesEnded(NSSet touches, UIEvent evt)
 {
     var touchArray = touches.ToArray<UITouch>();
     if(touches.Count>0)
     {
         var coord = touchArray[0].LocationInView(touchArray[0].View);
         interactionLabel.Text= string.Format("{0} ({1},{2})", DescribeTouch(touchArray[0]), coord.X, coord.Y);
         SetTimerToClearMotionLabel();
     }
 }
开发者ID:aaronhe42,项目名称:MonoTouch-Examples,代码行数:10,代码来源:InfoViewController.cs

示例8: TouchesBegan

 public override void TouchesBegan(NSSet touches, UIEvent evt)
 {
     var touchArray = touches.ToArray<UITouch>();
     if(touches.Count>0)
     {
         var coord = touchArray[0].LocationInView(touchArray[0].View);
         if(touchArray[0].TapCount < 2)
             StartCoord = coord;
         interactionLabel.Text= string.Format("{0} ({1},{2})", DescribeTouch(touchArray[0]), coord.X, coord.Y);
     }
 }
开发者ID:aaronhe42,项目名称:MonoTouch-Examples,代码行数:11,代码来源:InfoViewController.cs

示例9: FindBarcodes

        public static BarcodeResult[] FindBarcodes(UIImage image)
        {
            if (image == null)
                throw new ArgumentNullException ("image");

            IntPtr result = FindBarcodesInUIImage (image.Handle);
            if (result == IntPtr.Zero)
                return null;

            NSSet aset = new NSSet (result);
            BarcodeResult[] results = aset.ToArray<BarcodeResult> ();
            aset.Dispose ();

            return results;
        }
开发者ID:WinterGroveProductions,项目名称:monotouch-bindings,代码行数:15,代码来源:extra.cs

示例10: HandleTouches

        private void HandleTouches(NSSet touchesSet)
        {
            var touches = touchesSet.ToArray<UITouch>();

            if (touches != null)
            {
                foreach (var uitouch in touches)
                {
                    var id = uitouch.Handle.ToInt32();
                    var position = NormalizeScreenPosition(CGPointToVector2(uitouch.LocationInView(view)));

                    HandlePointerEvents(id, position, GetState(uitouch));
                }
            }
        }
开发者ID:ItayGal2,项目名称:paradox,代码行数:15,代码来源:InputManager.iOS.cs

示例11: ProcessTouchChange

        void ProcessTouchChange(NSSet touches)
        {
            var touchesArray = touches.ToArray<UITouch> ();

            for (int i = 0; i < touchesArray.Length; ++i)
            {
                var touch = touchesArray [i];

                //Get position touch
                var location = touch.LocationInView (this);
                var id = touch.Handle.ToInt32 ();
                var phase = touch.Phase;

                // seems to be a problem with mono touch reporting a new touch with
                // the same id across multiple frames.
                if (touchState.Keys.Contains (id) && phase == UITouchPhase.Began)
                {
                    phase = UITouchPhase.Stationary;
                }

                var ts = new iOSTouchState ();
                ts.Handle = id;
                ts.LastUpdated = this.frameCounter;
                ts.Location = location;

                ts.Phase = phase;

                if (phase == UITouchPhase.Began)
                {
                    //Console.WriteLine ("add "+id);
                    touchState.Add (id, ts);
                }
                else
                {
                    if (touchState.ContainsKey (id) )
                    {
                        touchState[id] = ts;

                        if (ts.Phase == UITouchPhase.Began)
                        {
                            ts.Phase = UITouchPhase.Stationary;
                        }

                    }
                    else
                    {
                        throw new Exception ("eerrr???");
                    }
                }
            }

            UpdateRawTouches ();

            changedCount++;
        }
开发者ID:gitter-badger,项目名称:blimey,代码行数:55,代码来源:Platform.XamarinIOSApp.cs

示例12: TouchesMoved

        /// <summary>
        /// Called when a touch gesture is moving.
        /// </summary>
        /// <param name="touches">The touches.</param>
        /// <param name="evt">The event arguments.</param>
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            // it seems to be easier to handle touch events here than using UIPanGesturRecognizer and UIPinchGestureRecognizer
            base.TouchesMoved(touches, evt);

            // convert the touch points to an array
            var ta = touches.ToArray<UITouch>();

            if (ta.Length > 0)
            {
                // get current and previous location of the first touch point
                var t1 = ta[0];
                var l1 = t1.LocationInView(this).ToScreenPoint();
                var pl1 = t1.PreviousLocationInView(this).ToScreenPoint();
                var l = l1;
                var t = l1 - pl1;
                var s = new ScreenVector(1, 1);
                if (ta.Length > 1)
                {
                    // get current and previous location of the second touch point
                    var t2 = ta[1];
                    var l2 = t2.LocationInView(this).ToScreenPoint();
                    var pl2 = t2.PreviousLocationInView(this).ToScreenPoint();
                    var d = l1 - l2;
                    var pd = pl1 - pl2;
                    if (!this.KeepAspectRatioWhenPinching)
                    {
                        var scalex = System.Math.Abs(pd.X) > 0 ? System.Math.Abs(d.X / pd.X) : 1;
                        var scaley = System.Math.Abs(pd.Y) > 0 ? System.Math.Abs(d.Y / pd.Y) : 1;
                        s = new ScreenVector(scalex, scaley);
                    }
                    else
                    {
                        var scale = pd.Length > 0 ? d.Length / pd.Length : 1;
                        s = new ScreenVector(scale, scale);
                    }
                }

                var e = new OxyTouchEventArgs { Position = l, DeltaTranslation = t, DeltaScale = s };
                this.ActualController.HandleTouchDelta(this, e);
            }
        }
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:47,代码来源:PlotView.cs

示例13: FillTouches

        /// <summary>
        /// Fills the touches.
        /// </summary>
        /// <param name="touches">The touches.</param>
        private void FillTouches(NSSet touches)
        {
            UITouch[] touchArray = touches.ToArray<UITouch>();
            WaveEngine.Adapter.Input.InputManager inputManager = (WaveEngine.Adapter.Input.InputManager)this.adapter.InputManager;

            List<int> movedIds = new List<int>();

            TouchPanelState oldState = inputManager.CurrentState;
            inputManager.CurrentState.Clear();

            for (int i = 0; i < touchArray.Length; i++)
            {
                UITouch touch = touchArray[i];

                // Position is always the same since we rotate the view
                var position = touch.LocationInView(touch.View);
                position.X *= this.ContentScaleFactor;
                position.Y *= this.ContentScaleFactor;

                int touchId = touch.Handle.ToInt32();

                TouchLocationState state;

                // Touch Type
                switch (touch.Phase)
                {
                    case UITouchPhase.Began:
                        state = TouchLocationState.Pressed;
                        break;
                    case UITouchPhase.Ended:
                    case UITouchPhase.Cancelled:
                        state = TouchLocationState.Release;
                        movedIds.Add(touchId);
                        break;
                    case UITouchPhase.Stationary:
                    case UITouchPhase.Moved:
                        state = TouchLocationState.Moved;
                        movedIds.Add(touchId);
                        break;
                    default:
                        state = TouchLocationState.Invalid;
                        break;
                }

                if (state != TouchLocationState.Release)
                {
                    inputManager.CurrentState.AddTouchLocation(touchId, state, (float)position.X, (float)position.Y);
                }
            }

            foreach (TouchLocation location in oldState)
            {
                if ((location.State == TouchLocationState.Moved || location.State == TouchLocationState.Pressed) && !movedIds.Contains(location.Id))
                {
                    inputManager.CurrentState.AddTouchLocation(location.Id, location.State, location.Position.X, location.Position.Y);
                }
            }
        }
开发者ID:julietsvq,项目名称:Samples,代码行数:62,代码来源:GameView.cs

示例14: FillTouchCollection

		// TODO: Review FillTouchCollection
		private void FillTouchCollection (NSSet touches)
		{
			if (touches.Count == 0)
				return;

			TouchCollection collection = TouchPanel.Collection;
			var touchesArray = touches.ToArray<UITouch> ();
			for (int i = 0; i < touchesArray.Length; ++i) {
				var touch = touchesArray [i];

				//Get position touch
				var location = touch.LocationInView (touch.View);
				var position = GetOffsetPosition (new Vector2 (location.X, location.Y), true);
				var id = touch.Handle.ToInt32 ();

				switch (touch.Phase) {
				case UITouchPhase.Stationary:
				case UITouchPhase.Moved:
					collection.Update (id, TouchLocationState.Moved, position);

					if (i == 0) {
						Mouse.State.X = (int) position.X;
						Mouse.State.Y = (int) position.Y;
					}
					break;
				case UITouchPhase.Began:
					collection.Add (id, position);
					if (i == 0) {
						Mouse.State.X = (int) position.X;
						Mouse.State.Y = (int) position.Y;
						Mouse.State.LeftButton = ButtonState.Pressed;
					}
					break;
				case UITouchPhase.Ended	:
					collection.Update (id, TouchLocationState.Released, position);

					if (i == 0) {
						Mouse.State.X = (int) position.X;
						Mouse.State.Y = (int) position.Y;
						Mouse.State.LeftButton = ButtonState.Released;
					}
					break;
				case UITouchPhase.Cancelled:
					collection.Update (id, TouchLocationState.Invalid, position);
					break;
				default:
					break;
				}
			}
		}
开发者ID:adison,项目名称:Tank-Wars,代码行数:51,代码来源:iOSGameView_Touch.cs

示例15: TouchesBegan

        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            try {
                if (!_touchDown) {
                    var touch = touches.ToArray<UITouch> ()[0];
                    if (ActiveArea.Contains (touch.LocationInView (this))) {
                        _touchDown = true;

                        if (!CanCommand ()) {
                            if (Def != null && Def.ComponentType == LcarsComponentType.Gray) {
                                Sounds.PlayNotActive ();
                            }
                            return;
                        }

                        var prevState = _selState;

                        if (prevState == LcarsComp.SelectionState.NotSelected) {
                            if (_def.NeedsDoubleTap) {
                                _selState = LcarsComp.SelectionState.Pending;
                                NSTimer.CreateScheduledTimer (ConfirmWait, delegate {
                                    _selState = LcarsComp.SelectionState.NotSelected;
                                    OnModelChanged ();
                                });
                            } else {
                                _selState = LcarsComp.SelectionState.Selected;
                            }
                        } else {
                            _selState = LcarsComp.SelectionState.Selected;
                        }

                        if (_selState == LcarsComp.SelectionState.Pending) {
                            Sounds.PlayPendingCommand ();
                        } else {
                            if (prevState == LcarsComp.SelectionState.Pending) {
                                Sounds.PlayConfirmPendingCommand ();
                            } else {
                                PlayConfirmCommand ();
                            }
                        }

                        OnModelChanged ();
                    }
                }
            } catch (Exception error) {
                Log.Error (error);
            }
        }
开发者ID:jorik041,项目名称:lcars,代码行数:48,代码来源:LcarsComponent.cs


注:本文中的NSSet.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。