public IHttpActionResult PostMotos(Motos motos)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Motos.Add(motos);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (MotosExists(motos.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = motos.ID }, motos));
        }
        public IHttpActionResult PutMotos(int id, Motos motos)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != motos.ID)
            {
                return(BadRequest());
            }

            db.Entry(motos).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MotosExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, Motos motos)
        {
            if (id != motos.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(motos);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MotosExists(motos.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            ViewBag.Clientes = new SelectList(_context.Clientes, "id", "nombreCliente", id);

            return(View(motos));
        }
        public IHttpActionResult GetMotos(int id)
        {
            Motos motos = db.Motos.Find(id);

            if (motos == null)
            {
                return(NotFound());
            }

            return(Ok(motos));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create(Motos motos)
        {
            if (ModelState.IsValid)
            {
                _context.Add(motos);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(motos));
        }
Exemplo n.º 6
0
        // GET: Motos/Delete/5
        public ActionResult Delete(int?Id)
        {
            if (Id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Motos motos = db.Motos.Find(Id);

            if (motos == null)
            {
                return(HttpNotFound());
            }
            return(View(motos));
        }
        public IHttpActionResult DeleteMotos(int id)
        {
            Motos motos = db.Motos.Find(id);

            if (motos == null)
            {
                return(NotFound());
            }

            db.Motos.Remove(motos);
            db.SaveChanges();

            return(Ok(motos));
        }
Exemplo n.º 8
0
 public ActionResult Delete(int?Id, FormCollection collection)
 {
     try
     {
         Motos motos = db.Motos.Find(Id);
         db.Motos.Remove(motos);
         db.SaveChanges();
         TempData["success"] = "Moto excluída com sucesso";
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 9
0
 public ActionResult Edit([Bind(Include = "id, marca, modelo, cilindrada, ano")] Motos motos)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(motos).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             TempData["success"] = "Moto editada com sucesso";
             return(RedirectToAction("Index"));
         }
         return(View());
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 10
0
 public ActionResult Create([Bind(Include = "id, marca, modelo, cilindrada, ano")] Motos motos)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Motos.Add(motos);
             db.SaveChanges();
             TempData["success"] = "Moto criada com sucesso";
             return(RedirectToAction("Index"));
         }
         return(View(motos));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 11
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            LoadModelLabels();

            var manager = (CameraManager)this.GetSystemService(Context.CameraService);

            var numCameras = manager.GetCameraIdList().Length;

            if (numCameras == 0)
            {
                s.MessageBox(this, "Erro", "Infelizmente o MotoDetector não funcionará no seu dispositivo, " +
                             "pois ele não suporta a API Camera2.", null);
            }

            var cameraIDs = new List <string>();

            for (var i = 0; i < numCameras; i++)
            {
                var cameraId        = manager.GetCameraIdList()[i];
                var characteristics = manager.GetCameraCharacteristics(cameraId);

                // We don't use a front facing camera in this sample.
                var facing = (Integer)characteristics.Get(CameraCharacteristics.LensFacing);
                if (facing != null && facing == (Integer.ValueOf((int)LensFacing.Front)))
                {
                }
                else
                {
                    cameraIDs.Add(cameraId);
                }
            }

            NumberOfCameras = cameraIDs.Count;

            SavedDataStore = SaveData.Load();

            if (SavedDataStore == null)
            {
                SavedDataStore = new SaveData();
            }

            if (SavedDataStore.Camera == "")
            {
                SavedDataStore.Camera = cameraIDs[0];
            }

            context = this;

            MotosList = Motos.Get();

            AppCenter.Start("6ef03cf3-90e1-4478-a070-4446c0e3e78c", typeof(Analytics), typeof(Crashes));

            this.RequestWindowFeature(WindowFeatures.NoTitle);

            this.Window.AddFlags(WindowManagerFlags.Fullscreen);
            this.Window.AddFlags(WindowManagerFlags.KeepScreenOn);

            SetContentView(Resource.Layout.mainwindow);

            cameraSurface            = new CameraSurfaceView(this);
            canvasView               = new SKCanvasView(this);
            canvasView.PaintSurface += Canvas_PaintSurface;

            var mainView = this.FindViewById <FrameLayout>(Resource.Id.frameLayoutMain);

            mainView.AddView(canvasView);
            mainView.AddView(cameraSurface);

            var mainLayout = this.FindViewById <LinearLayout>(Resource.Id.linearLayoutMain);

            mainLayout.BringToFront();
            canvasView.BringToFront();

            var proc = System.Diagnostics.Process.GetCurrentProcess();

            var rb1 = this.FindViewById <RadioButton>(Resource.Id.radioButton1);
            var rb2 = this.FindViewById <RadioButton>(Resource.Id.radioButton2);
            var rb3 = this.FindViewById <RadioButton>(Resource.Id.radioButton3);
            var rb4 = this.FindViewById <RadioButton>(Resource.Id.radioButton4);

            if (NumberOfCameras == 1)
            {
                rb2.Enabled = false;
                rb3.Enabled = false;
                rb4.Enabled = false;
            }
            else if (NumberOfCameras == 2)
            {
                rb3.Enabled = false;
                rb4.Enabled = false;
            }
            else if (NumberOfCameras == 3)
            {
                rb4.Enabled = false;
            }

            switch (cameraIDs.IndexOf(SavedDataStore.Camera))
            {
            case 0:
                rb1.Selected = true;
                break;

            case 1:
                rb2.Selected = true;
                break;

            case 2:
                rb3.Selected = true;
                break;

            case 3:
                rb4.Selected = true;
                break;
            }

            var rg = this.FindViewById <RadioGroup>(Resource.Id.radioGroup1);

            rg.CheckedChange += (s, e) =>
            {
                if (rb1.Id.Equals(e.CheckedId))
                {
                    SavedDataStore.Camera = cameraIDs[0];
                }
                else if (rb2.Id.Equals(e.CheckedId))
                {
                    SavedDataStore.Camera = cameraIDs[1];
                }
                else if (rb3.Id.Equals(e.CheckedId))
                {
                    SavedDataStore.Camera = cameraIDs[2];
                }
                else
                {
                    SavedDataStore.Camera = cameraIDs[3];
                }
                SavedDataStore.Save();
                ConfigureCapture();
            };

            var btnInfo = this.FindViewById <ImageButton>(Resource.Id.btnInfo);

            btnInfo.Click += (sender, e) =>
            {
                DisplayMotoDetails();
            };

            var btnSettings = this.FindViewById <ImageButton>(Resource.Id.imageButtonSettings);

            btnSettings.Click += (sender, e) =>
            {
                DisplaySettingsView();
            };

            var imgwarning = MainActivity.context.FindViewById <ImageButton>(Resource.Id.imageButtonWarning);

            imgwarning.Visibility = ViewStates.Gone;

            imgwarning.Click += (sender, e) =>
            {
                this.RunOnUiThread(() =>
                {
                    imgwarning.Visibility = ViewStates.Gone; var layout = MainActivity.context.FindViewById <LinearLayout>(Resource.Id.linearLayoutLabelPanel);
                    layout.SetBackgroundColor(Android.Graphics.Color.ParseColor("#bc000000"));
                    var txtView = MainActivity.context.FindViewById <TextView>(Resource.Id.txtObjID);
                    txtView.SetTextColor(Android.Graphics.Color.White);
                });
            };

            var zoomslider = MainActivity.context.FindViewById <SeekBar>(Resource.Id.seekBarZoom);

            zoomslider.ProgressChanged += (s, e) =>
            {
                var   characteristics = manager.GetCameraCharacteristics(SavedDataStore.Camera);
                float maxZoom         = (float)characteristics.Get(CameraCharacteristics.ScalerAvailableMaxDigitalZoom);
                float currentZoom     = 1.0f;
                if (zoomslider.Progress >= 100)
                {
                    currentZoom = maxZoom;
                }
                else
                {
                    currentZoom = (float)zoomslider.Progress / 100.0f * maxZoom;
                }
                var  controller = cameraSurface.cameraAnalyzer.cameraController;
                Rect m          = (Rect)characteristics.Get(CameraCharacteristics.SensorInfoActiveArraySize);
                var  w          = (m.Right - m.Left) / 2.5;
                var  h          = (m.Bottom - m.Top) / 2.5;
                var  factor     = currentZoom / maxZoom;
                Rect m1         = new Rect((int)(m.Left + w * factor), (int)(m.Top + h * factor), (int)(m.Right - w * factor), (int)(m.Bottom - h * factor));
                controller.mPreviewRequestBuilder.Set(CaptureRequest.ScalerCropRegion, m1);
                controller.mCameraCaptureSessionCallback.OnConfigured(controller.mCaptureSession);
            };

            var zoomexposure = MainActivity.context.FindViewById <SeekBar>(Resource.Id.seekBarExposure);

            zoomexposure.ProgressChanged += (s, e) =>
            {
                var   characteristics = manager.GetCameraCharacteristics(SavedDataStore.Camera);
                float value           = (float)zoomexposure.Progress;
                var   range1          = (Android.Util.Range)characteristics.Get(CameraCharacteristics.ControlAeCompensationRange);
                int   minExposure     = (int)range1.Lower;
                int   maxExposure     = (int)range1.Upper;
                if (minExposure == 0 && maxExposure == 0)
                {
                    Toast.MakeText(this, "A lente selecionada não suporta Compensação da Exposição.", ToastLength.Long).Show();
                    return;
                }
                int adjustedvalue = (int)(value * ((float)maxExposure - (float)minExposure) / 200.0f);
                var controller    = cameraSurface.cameraAnalyzer.cameraController;
                controller.mPreviewRequestBuilder.Set(CaptureRequest.ControlAeExposureCompensation, adjustedvalue);
                controller.mCameraCaptureSessionCallback.OnConfigured(controller.mCaptureSession);
            };

            var sw = new Stopwatch();

            sw.Start();

            var tim = new Timer();

            tim.Interval = 1000;

            tim.Elapsed += (s, e) =>
            {
                var cpu = (proc.TotalProcessorTime.TotalMilliseconds / sw.ElapsedMilliseconds) * 100;
                var mem = proc.WorkingSet64 / 1024 / 1024;
                this.RunOnUiThread(() =>
                {
                    var txtCPU  = this.FindViewById <TextView>(Resource.Id.textViewCPU);
                    var txtMEM  = this.FindViewById <TextView>(Resource.Id.textViewMEM);
                    var txtFPS  = this.FindViewById <TextView>(Resource.Id.textViewFPS);
                    var txtAFPS = this.FindViewById <TextView>(Resource.Id.textViewAFPS);
                    txtCPU.SetTextColor(Color.White);
                    if (cpu < 40)
                    {
                        txtCPU.SetTextColor(Color.Green);
                    }
                    if (cpu > 40)
                    {
                        txtCPU.SetTextColor(Color.Yellow);
                    }
                    if (cpu > 80)
                    {
                        txtCPU.SetTextColor(Color.Red);
                    }
                    txtCPU.Text  = cpu.ToString("N2") + "%";
                    txtMEM.Text  = mem.ToString() + " MB";
                    txtAFPS.Text = PlateAndMotoStats.ProcessingFps.ToString("N0") + " (DET) / " + PlateAndMotoStats.CameraFps.ToString("N0") + " (CAPT) FPS";
                    txtFPS.Text  = RESID + " / " + FPS + " FPS";
                });
            };

            tim.Start();
        }