/// <summary>
        /// Toucheses the moved.
        /// </summary>
        /// <param name="touches">Touches.</param>
        /// <param name="evt">Evt.</param>
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            base.TouchesMoved(touches, evt);

            var touch = evt.AllTouches.AnyObject as UITouch;

            if (touch.View is UIImageView)
            {
                var mustReturnToOldRotation = false;

                var degrees = GetRotationValueOfView(touch.View);
                if (Math.Abs(degrees / 45) % 2 == 1)
                {
                    mustReturnToOldRotation = true;

                    degrees += 45.0f;
                    var radians = Math.PI / 180 * degrees;
                    touch.View.Transform = CGAffineTransform.MakeRotation((float)radians);
                }

                int rawX = (int)touch.LocationInView(View).X;
                int rawY = (int)touch.LocationInView(View).Y;

                var xDelta = rawX - _oldX;
                var yDelta = rawY - _oldY;

                var touchLocation = touch.LocationInView(View);
                var frame         = touch.View.Frame;
                frame.X          = View.Window.Frame.X + touchLocation.X - _oldX;
                frame.Y          = View.Window.Frame.Y + touchLocation.Y - _oldY;
                touch.View.Frame = frame;

                _viewModel.MoveKite((int)touch.View.Tag, new Position
                {
                    X = (float)touch.View.Frame.X,
                    Y = (float)touch.View.Frame.Y
                });

                if (mustReturnToOldRotation)
                {
                    degrees -= 45.0f;
                    var radians = Math.PI / 180 * degrees;
                    touch.View.Transform = CGAffineTransform.MakeRotation((float)radians);
                }

                _drawView.UpdateTeam(_viewModel.Team);
                View.SetNeedsDisplay();
                _drawView.SetNeedsDisplay();
            }
        }
Beispiel #2
0
 public override void TouchesMoved(NSSet touches, UIEvent evt)
 {
     base.TouchesMoved(touches, evt);
     foreach (UITouch touch in touches.Cast <UITouch>())
     {
         var point = touch.LocationInView(DrawView);
         DrawView.Lines[DrawView.Lines.Count - 1].strokeWidth = BrushSize.Value;
         DrawView.Lines[DrawView.Lines.Count - 1].color       = uIColors[selectedColor];
         DrawView.Lines[DrawView.Lines.Count - 1].point.Add(point);
     }
     DrawView.SetNeedsDisplay();
 }
Beispiel #3
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            base.TouchesBegan(touches, evt);
            foreach (UITouch touch in touches.Cast <UITouch>())
            {
                var point   = touch.LocationInView(DrawView);
                var newline = new FingerPaint.Line();

                newline.point.Add(point);
                newline.strokeWidth = BrushSize.Value;
                newline.color       = uIColors[selectedColor];

                DrawView.Lines.Add(newline);
            }
            DrawView.SetNeedsDisplay();
        }
        private void Reset()
        {
            TurningButtonPressed(true);

            foreach (var view in View.Subviews)
            {
                view.RemoveFromSuperview();
            }

            _gridView = new GridView
            {
                Frame           = new CGRect(0, 0, View.Frame.Width, View.Frame.Height),
                BackgroundColor = UIColor.White
            };
            View.AddSubview(_gridView);

            _drawView = new DrawView
            {
                Frame           = new CGRect(0, 0, View.Frame.Width, View.Frame.Height),
                BackgroundColor = UIColor.FromWhiteAlpha(0.0f, 0.0f)
            };
            View.AddSubview(_drawView);

            _commentView = new UILabel(new CGRect(50, 50, 200, 150))
            {
                TextColor = UIColor.FromRGB(139, 0, 0)
            };
            View.AddSubview(_commentView);

            DrawPilots();
            DrawRevKites();

            _viewModel.Team.Pilots.Clear();
            _viewModel.AddPilot(new Pilot
            {
                Name        = "Vienna",
                PlaceInLine = 1,
                Position    = new Position
                {
                    X = (float)_pilotVienna.Frame.X,
                    Y = (float)_pilotVienna.Frame.Y
                },
                Kite = new Kite
                {
                    Rotation = GetRotationValueOfView(_kiteVienna),
                    Position = new Position
                    {
                        X = (float)_kiteVienna.Frame.X,
                        Y = (float)_kiteVienna.Frame.Y
                    }
                }
            });

            _viewModel.AddPilot(new Pilot
            {
                Name        = "Tim",
                PlaceInLine = 2,
                Position    = new Position
                {
                    X = (float)_pilotTim.Frame.X,
                    Y = (float)_pilotTim.Frame.Y
                },
                Kite = new Kite
                {
                    Rotation = GetRotationValueOfView(_kiteTim),
                    Position = new Position
                    {
                        X = (float)_kiteTim.Frame.X,
                        Y = (float)_kiteTim.Frame.Y
                    }
                }
            });

            _viewModel.AddPilot(new Pilot
            {
                Name        = "Mario",
                PlaceInLine = 3,
                Position    = new Position
                {
                    X = (float)_pilotMario.Frame.X,
                    Y = (float)_pilotMario.Frame.Y
                },
                Kite = new Kite
                {
                    Rotation = GetRotationValueOfView(_kiteMario),
                    Position = new Position
                    {
                        X = (float)_kiteMario.Frame.X,
                        Y = (float)_kiteMario.Frame.Y
                    }
                }
            });

            _viewModel.AddPilot(new Pilot
            {
                Name        = "Twan",
                PlaceInLine = 4,
                Position    = new Position
                {
                    X = (float)_pilotTwan.Frame.X,
                    Y = (float)_pilotTwan.Frame.Y
                },
                Kite = new Kite
                {
                    Rotation = GetRotationValueOfView(_kiteTwan),
                    Position = new Position
                    {
                        X = (float)_kiteTwan.Frame.X,
                        Y = (float)_kiteTwan.Frame.Y
                    }
                }
            });

            _viewModel.AddPilot(new Pilot
            {
                Name        = "Judith",
                PlaceInLine = 5,
                Position    = new Position
                {
                    X = (float)_pilotJudith.Frame.X,
                    Y = (float)_pilotJudith.Frame.Y
                },
                Kite = new Kite
                {
                    Rotation = GetRotationValueOfView(_kiteJudith),
                    Position = new Position
                    {
                        X = (float)_kiteJudith.Frame.X,
                        Y = (float)_kiteJudith.Frame.Y
                    }
                }
            });

            _viewModel.AddPilot(new Pilot
            {
                Name        = "Sanne",
                PlaceInLine = 6,
                Position    = new Position
                {
                    X = (float)_pilotSanne.Frame.X,
                    Y = (float)_pilotSanne.Frame.Y
                },
                Kite = new Kite
                {
                    Rotation = GetRotationValueOfView(_kiteSanne),
                    Position = new Position
                    {
                        X = (float)_kiteSanne.Frame.X,
                        Y = (float)_kiteSanne.Frame.Y
                    }
                }
            });

            _drawView.UpdateTeam(_viewModel.Team);
            _drawView.SetNeedsDisplay();
        }