コード例 #1
0
        public OrientationPage()
        {
            vm = new OrientationViewModel();
            InitializeComponent ();
            deviceOrientation = new GetDeviceOrientation();
            initViewModel();

            CrossDeviceMotion.Current.SensorValueChanged += (s, a) =>
            {
                deviceOrientation.sensorRegistration(s, a);
                initViewModel();
               // x_pos = Double.Parse(this.x.Text);
            };

            this.BindingContext = vm;
        }
コード例 #2
0
        public BasePage()
        {
            vm = new OrientationViewModel();
            InitializeComponent ();

            deviceOrientation = new GetDeviceOrientation();
            initViewModel();

            LeftToolbarItems = new ObservableCollection<ToolbarItem>();

            BoxView bv1 = new BoxView();
            bv1.Color = Color.Green;
            rect = new Rectangle(.35, .5, 50, 50);
            AbsoluteLayout.SetLayoutBounds(bv1, rect);
            AbsoluteLayout.SetLayoutFlags(bv1, AbsoluteLayoutFlags.PositionProportional);

            al.Children.Add(bv1);

            CrossDeviceMotion.Current.SensorValueChanged += (s, a) =>
            {
                deviceOrientation.sensorRegistration(s, a);
                initViewModel();

                x_position = deviceOrientation.distanceMoveX( vm.RotationX);
                //y_position= deviceOrientation.distanceMoveX(vm.RotationY);
                //y_position -= 0.5 * vm.ValueY * Math.Pow(deviceOrientation.dt, 2);

                // x_pos.Text = "X: " + x_position + " Y: " + vm.ValueX + " Z: "+vm.ValueZ;
                //bv1.Rotation = vm.Rotation;
                //bv1.RotationX = vm.RotationX;
                //bv1.RotationY = vm.RotationY;
                AbsoluteLayout.SetLayoutBounds(bv1, new Rectangle(x_position, y_position, 50, 50));
            };

            this.BindingContext = vm;
        }