Ejemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            _engine.CurrentValueChanged += UpdateUI;
            Timer t = new Timer(_engine.Tick, null, 0, 1000);

            DrawableView view1 = FindViewById <DrawableView>(Resource.Id.drawable_view1);

            view1.Touch += View1_Touch;

            Button generatorButton = FindViewById <Button>(Resource.Id.btn_generators);

            generatorButton.Click += OpenGeneratorsActivity;
        }
Ejemplo n.º 2
0
        private void View1_Touch(object sender, View.TouchEventArgs e)
        {
            if (e.Event.Action == MotionEventActions.Down)
            {
                _singlePointerEvent = true;
            }

            if (!_gestureLock && e.Event.Action == MotionEventActions.Move)
            {
                var coordinates = new List <TouchObject>();
                foreach (var i in Enumerable.Range(0, e.Event.PointerCount))
                {
                    coordinates.Add(new TouchObject(e.Event.GetX(i), e.Event.GetY(i), _engine.ValuePerClick.ToString(ValueFormat.Scientific)));
                    _engine.Click();
                }

                DrawableView view1 = FindViewById <DrawableView>(Resource.Id.drawable_view1);
                view1.AddClickCoordinates(coordinates);
                view1.Invalidate();

                _singlePointerEvent = false;
                _gestureLock        = true;
            }

            if (e.Event.Action == MotionEventActions.Up)
            {
                if (_singlePointerEvent)
                {
                    var coordinates = new List <TouchObject>();
                    coordinates.Add(new TouchObject(e.Event.GetX(), e.Event.GetY(), _engine.ValuePerClick.ToString(ValueFormat.Scientific)));
                    _engine.Click();

                    DrawableView view1 = FindViewById <DrawableView>(Resource.Id.drawable_view1);
                    view1.AddClickCoordinates(coordinates);
                    view1.Invalidate();
                }

                //The last finger has left the screen so we are ready to process a new Move action.
                _gestureLock = false;
            }
        }