Exemplo n.º 1
0
 private void BtnTotalLeft_MouseClick(object sender, MouseEventArgs e)
 {
     lathatosagok();
     Left = 0;
     BtnTotalLeft.Hide();
     BtnLeft.Hide();
 }
        void ReleaseDesignerOutlets()
        {
            if (BtnLeft != null)
            {
                BtnLeft.Dispose();
                BtnLeft = null;
            }

            if (BtnRight != null)
            {
                BtnRight.Dispose();
                BtnRight = null;
            }

            if (BtnSelStart != null)
            {
                BtnSelStart.Dispose();
                BtnSelStart = null;
            }

            if (MapContainer != null)
            {
                MapContainer.Dispose();
                MapContainer = null;
            }
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            RequestWindowFeature(WindowFeatures.NoTitle);
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            var view = Resource.Layout.Main;

            SetContentView(view);

            VisorVideo        = FindViewById <MjpegView>(Resource.Id.mjpegView);
            LblMensaje        = FindViewById <TextView>(Resource.Id.textMensaje);
            BtnForward        = FindViewById <ImageButton>(Resource.Id.imageButtonForward);
            BtnBackward       = FindViewById <ImageButton>(Resource.Id.imageButtonBackward);
            BtnLeft           = FindViewById <ImageButton>(Resource.Id.imageButtonLeft);
            BtnRight          = FindViewById <ImageButton>(Resource.Id.imageButtonRight);
            BtnStop           = FindViewById <ImageButton>(Resource.Id.imageButtonStop);
            BtnLuces          = FindViewById <ImageButton>(Resource.Id.imageButtonLeds);
            BtnSettings       = FindViewById <ImageButton>(Resource.Id.imageButtonSetting);
            BtnCentrarCamara  = FindViewById <Button>(Resource.Id.btnCentrarCamara);
            HorizontalSeekBar = FindViewById <SeekBar>(Resource.Id.horizontalSeekBar);
            VerticalSeekBar   = FindViewById <VerticalSeekBar>(Resource.Id.verticalSeekBar);

            VisorVideo?.SetResolution(widthVideoResolution, heightVideoResolution);

            BtnForward.Touch += (sender, args) =>
            {
                if (args.Event.Action == MotionEventActions.Down)
                {
                    BtnForward.SetImageResource(Resource.Drawable.sym_forward_1);
                    SendData(CMD_Forward);
                }
                else if (args.Event.Action == MotionEventActions.Up)
                {
                    SendData(CMD_Stop);
                    BtnForward.SetImageResource(Resource.Drawable.sym_forward);
                }
            };
            BtnBackward.Touch += (sender, args) =>
            {
                if (args.Event.Action == MotionEventActions.Down)
                {
                    BtnBackward.SetImageResource(Resource.Drawable.sym_backward_1);
                    SendData(CMD_Backward);
                }
                else if (args.Event.Action == MotionEventActions.Up)
                {
                    SendData(CMD_Stop);
                    BtnBackward.SetImageResource(Resource.Drawable.sym_backward);
                }
            };
            BtnLeft.Touch += (sender, args) =>
            {
                if (args.Event.Action == MotionEventActions.Down)
                {
                    BtnLeft.SetImageResource(Resource.Drawable.sym_left_1);
                    SendData(CMD_TurnLeft);
                }
                else if (args.Event.Action == MotionEventActions.Up)
                {
                    SendData(CMD_Stop);
                    BtnLeft.SetImageResource(Resource.Drawable.sym_left);
                }
            };
            BtnRight.Touch += (sender, args) =>
            {
                if (args.Event.Action == MotionEventActions.Down)
                {
                    BtnRight.SetImageResource(Resource.Drawable.sym_right_1);
                    SendData(CMD_TurnRight);
                }
                else if (args.Event.Action == MotionEventActions.Up)
                {
                    SendData(CMD_Stop);
                    BtnRight.SetImageResource(Resource.Drawable.sym_right);
                }
            };
            BtnStop.Touch += (sender, args) =>
            {
                try
                {
                    if (args.Event.Action == MotionEventActions.Down)
                    {
                        //BeginStreaming(CameraUrl);
                        //RequestedOrientation = RequestedOrientation == ScreenOrientation.Landscape
                        //    ? ScreenOrientation.ReverseLandscape
                        //    : ScreenOrientation.Landscape;
                        verFPS = !verFPS;
                        VisorVideo.SetDisplayMode(MjpegView.SizeStandard);
                        VisorVideo.SetDisplayMode(MjpegView.SizeFullscreen);
                        VisorVideo.ShowFps(verFPS);
                    }
                }
                catch (Exception ex)
                {
                    LblMensaje.Text = ex.Message;
                }
            };
            BtnLuces.Touch += (sender, args) =>
            {
                try
                {
                    if (args.Event.Action == MotionEventActions.Down)
                    {
                        ledsOn = !ledsOn;
                        SendData(ledsOn ? CMD_ledon : CMD_ledoff);
                        BtnLuces.SetImageResource(ledsOn ? Resource.Drawable.sym_light : Resource.Drawable.sym_light_off);
                    }
                }
                catch (Exception ex)
                {
                    LblMensaje.Text = ex.Message;
                }
            };
            BtnSettings.Touch += (sender, args) =>
            {
                try
                {
                    if (args.Event.Action == MotionEventActions.Down)
                    {
                        StartActivity(typeof(Settings));
                    }
                }
                catch (Exception ex)
                {
                    LblMensaje.Text = ex.Message;
                }
            };
            HorizontalSeekBar.Max      = MaxCameraServoValue;
            HorizontalSeekBar.Progress = 90;
            var waitingX = false;

            HorizontalSeekBar.ProgressChanged += (sender, args) =>
            {
                if (args.Progress >= MinCameraServoValue)
                {
                    if (!waitingX)
                    {
                        Task.Factory.StartNew(() =>
                        {
                            waitingX = true;
                            Thread.Sleep(50);
                            waitingX = false;
                            RunOnUiThread(() => SendData($"{CMD_SetServoX}{args.Progress}"));
                        });
                    }
                }
            };
            VerticalSeekBar.Max      = MaxCameraServoValue;
            VerticalSeekBar.Progress = 90;
            VerticalSeekBar.LayoutParameters.Width = ViewGroup.LayoutParams.WrapContent;
            var waitingY = false;

            VerticalSeekBar.ProgressChanged += (sender, args) =>
            {
                if (args.Progress >= MinCameraServoValue)
                {
                    if (!waitingY)
                    {
                        Task.Factory.StartNew(() =>
                        {
                            waitingY = true;
                            Thread.Sleep(50);
                            waitingY = false;
                            RunOnUiThread(() => SendData($"{CMD_SetServoY}{args.Progress}"));
                        });
                    }
                }
            };
            BtnCentrarCamara.Click += (sender, args) =>
            {
                VerticalSeekBar.Progress = 90;
                Thread.Sleep(100);
                HorizontalSeekBar.Progress = 90;
            };
            // Get our button from the layout resource,
            // and attach an event to it
            //var button = FindViewById<Button>(Resource.Id.btnAlert);
            //LblMensaje = FindViewById<TextView>(Resource.Id.lblMessage);
            //button.Click += (sender, args) =>
            //{
            //    //var textBox = FindViewById<TextView>(Resource.Id.txtBox1);
            //    //Console.WriteLine(textBox.Text);
            //    //var alert = new AlertDialog.Builder(this);
            //    //alert.SetMessage(textBox.Text);
            //    //alert.SetTitle("Toma mensajaco");
            //    //alert.SetNeutralButton("OK", new EventHandler<DialogClickEventArgs>((sender, args) => { }));
            //    //alert.Show();
            //    DetectNetwork();
            //};
            BeginStreaming(CameraUrl);
        }