Esempio n. 1
0
        public PercursoInfo pegar(int id)
        {
            PercursoInfo percurso = _percursoDB.pegar(id);

            atualizar(percurso);
            return(percurso);
        }
 public PercursoResumoPage(PercursoInfo percurso)
 {
     _Percurso = percurso;
     inicializarComponente();
     atualizar();
     Content = _ResumoListView;
 }
Esempio n. 3
0
        public void atualizarEndereco()
        {
            if (InternetUtils.estarConectado())
            {
                var percursos = _percursoDB.listarEnderecoNulo();
                if (percursos.Count > 0)
                {
                    int idPercurso = percursos[0].Id;
                    var pontos     = _pontoDB.listar(idPercurso);
                    if (pontos.Count() > 0)
                    {
                        float lat = (float)(from p in pontos select p.Latitude).Last();
                        float lon = (float)(from p in pontos select p.Longitude).Last();

                        GeocoderUtils.pegarAsync(lat, lon, (sender, e) =>
                        {
                            var endereco          = e.Endereco;
                            PercursoInfo percurso = new PercursoInfo()
                            {
                                Id       = idPercurso,
                                Endereco = endereco.Logradouro + " " + endereco.Complemento + " " + endereco.Bairro + " " + endereco.Cidade + " " + endereco.Uf + " " + endereco.CEP
                            };
                            gravar(percurso);
                            atualizarEndereco();
                        });
                    }
                }
            }
        }
Esempio n. 4
0
        public bool iniciarGravacao()
        {
            if (PercursoUtils.Gravando)
            {
                return(false);
            }
            PercursoInfo percurso = new PercursoInfo();

            gravar(percurso);
            //atualizarEndereco();
            PercursoUtils.PercursoAtual = percurso;
            //_dataAnterior = DateTime.MinValue;
            //_ultimoMovimentoReal = DateTime.MinValue;
            PercursoUtils.Gravando  = true;
            PercursoUtils.Latitude  = 0;
            PercursoUtils.Longitude = 0;
            //_emMovimento = true;
            //MensagemUtils.notificar(2, "Gravando Percurso", "Gravando percurso agora!");
            MensagemUtils.avisar("Iniciando gravação do percurso!");
            MensagemUtils.notificarPermanente(
                NOTIFICACAO_GRAVAR_PERCURSO_ID,
                "Gravando Percurso...", "",
                NOTIFICACAO_PARAR_PERCURSO_ID,
                "Parar", ACAO_PARAR_GRAVACAO
                );
            return(true);
        }
Esempio n. 5
0
 private void atualizar(PercursoInfo percurso)
 {
     if (percurso != null)
     {
         var pontos = _pontoDB.listar(percurso.Id);
         percurso.Pontos = pontos;
     }
 }
Esempio n. 6
0
        public int gravar(PercursoInfo percurso)
        {
            //percurso.Id = _percursoDB.gravar(percurso);
            var grava = _percursoDB.gravar(percurso);

            atualizarEndereco(percurso);
            return(grava);
            //return percurso.Id;
        }
Esempio n. 7
0
        public TimeSpan tempoParado(PercursoInfo percurso)
        {
            TimeSpan total = new TimeSpan();

            if (percurso.Pontos.Count > 0)
            {
                DateTime maiorTempo = (from p in percurso.Pontos select p.Data).Max();
                DateTime menorTempo = (from p in percurso.Pontos select p.Data).Min();
                total = maiorTempo.Subtract(menorTempo);
            }
            return(total);
        }
Esempio n. 8
0
        public void excluir(int id)
        {
            PercursoInfo percurso = _percursoDB.pegar(id);

            if (percurso != null)
            {
                foreach (PercursoPontoInfo ponto in percurso.Pontos)
                {
                    _pontoDB.excluir(ponto.Id);
                }
            }
            _percursoDB.excluir(id);
        }
Esempio n. 9
0
        private void inicializarMenu()
        {
            var excluiPercurso = new MenuItem
            {
                Text = "Excluir"
            };

            excluiPercurso.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            excluiPercurso.Clicked += (sender, e) =>
            {
                PercursoInfo percurso      = (PercursoInfo)((MenuItem)sender).BindingContext;
                PercursoBLL  regraPercurso = PercursoFactory.create();
                regraPercurso.excluir(percurso.Id);

                ListView percursoListView = this.Parent as ListView;

                percursoListView.SetBinding(ListView.ItemsSourceProperty, new Binding("."));

                var percursos = regraPercurso.listar();
                percursoListView.BindingContext = percursos;
                percursoListView.ItemTemplate   = new DataTemplate(typeof(PercursoPageCell));
            };

            var simulaPercurso = new MenuItem
            {
                Text = "Simular"
            };

            simulaPercurso.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            simulaPercurso.Clicked += (sender, e) =>
            {
                PercursoInfo percurso = (PercursoInfo)((MenuItem)sender).BindingContext;
                if (percurso != null)
                {
                    GPSUtils.simularPercurso(percurso.Id);
                }
                OnAppearing();
            };

            ContextActions.Add(simulaPercurso);
            ContextActions.Add(excluiPercurso);
        }
Esempio n. 10
0
        public void atualizarEndereco(PercursoInfo percurso)
        {
            if (!InternetUtils.estarConectado())
            {
                return;
            }
            if (percurso.Pontos.Count == 0)
            {
                return;
            }

            var ponto = percurso.Pontos.Last();

            GeocoderUtils.pegarAsync((float)ponto.Latitude, (float)ponto.Longitude, (sender, e) =>
            {
                var endereco      = e.Endereco;
                percurso.Endereco = endereco.Logradouro + " " + endereco.Complemento + " " + endereco.Bairro + " " + endereco.Cidade + " " + endereco.Uf + " " + endereco.CEP;
                gravar(percurso);
            });
        }
Esempio n. 11
0
        public bool iniciarGravacao()
        {
            if (PercursoUtils.Gravando)
            {
                return(false);
            }
            PercursoInfo percurso = new PercursoInfo();

            gravar(percurso);
            PercursoUtils.PercursoAtual = percurso;
            PercursoUtils.Gravando      = true;
            PercursoUtils.Latitude      = 0;
            PercursoUtils.Longitude     = 0;
            MensagemUtils.avisar("Iniciando gravação do percurso!");
            MensagemUtils.notificarPermanente(
                NOTIFICACAO_GRAVAR_PERCURSO_ID,
                "Gravando Percurso...", "",
                NOTIFICACAO_PARAR_PERCURSO_ID,
                "Parar", ACAO_PARAR_GRAVACAO
                );
            return(true);
        }
Esempio n. 12
0
        public int gravar(PercursoInfo percurso)
        {
            lock (locker)
            {
                if (percurso.Id != 0)
                {
                    return(database.Update(percurso));
                    //return percurso.Id;
                }
                else
                {
                    return(database.Insert(percurso));

                    /*
                     * return (
                     *  from p in database.Table<PercursoInfo>()
                     *  orderby p.Id
                     *  select p.Id
                     * ).Take(1).FirstOrDefault();
                     */
                }
            }
        }
Esempio n. 13
0
        public PercursoPageCell()
        {
            var excluiPercurso = new MenuItem
            {
                Text = "Excluir"
            };

            excluiPercurso.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            excluiPercurso.Clicked += (sender, e) =>
            {
                PercursoInfo percurso      = (PercursoInfo)((MenuItem)sender).BindingContext;
                PercursoBLL  regraPercurso = PercursoFactory.create();
                regraPercurso.excluir(percurso.Id);

                ListView percursoListView = this.Parent as ListView;

                percursoListView.SetBinding(ListView.ItemsSourceProperty, new Binding("."));

                var percursos = regraPercurso.listar();
                percursoListView.BindingContext = percursos;
                percursoListView.ItemTemplate   = new DataTemplate(typeof(PercursoPageCell));
            };

            var simulaPercurso = new MenuItem
            {
                Text = "Simular"
            };

            simulaPercurso.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            simulaPercurso.Clicked += (sender, e) =>
            {
                PercursoInfo percurso = (PercursoInfo)((MenuItem)sender).BindingContext;
                if (percurso != null)
                {
                    GPSUtils.simularPercurso(percurso.Id);
                }
                OnAppearing();
            };

            ContextActions.Add(simulaPercurso);
            ContextActions.Add(excluiPercurso);

            desc.HorizontalOptions = LayoutOptions.Fill;
            desc.VerticalOptions   = LayoutOptions.CenterAndExpand;
            desc.Spacing           = 1;

            tempoCorrendo.HorizontalOptions    = LayoutOptions.Start;
            tempoParado.HorizontalOptions      = LayoutOptions.Start;
            paradas.HorizontalOptions          = LayoutOptions.Start;
            paradas.VerticalOptions            = LayoutOptions.Center;
            velocidadeMaxima.HorizontalOptions = LayoutOptions.Start;
            velocidadeMedia.HorizontalOptions  = LayoutOptions.Start;
            radares.HorizontalOptions          = LayoutOptions.Start;

            relogioIco.Source      = ImageSource.FromFile("relogio_20x20_preto.png");
            paradoIco.Source       = ImageSource.FromFile("mao_20x20_preto.png");
            ampulhetaIco.Source    = ImageSource.FromFile("ampulheta_20x20_preto.png");
            velocimetroIco.Source  = ImageSource.FromFile("velocimetro_20x20_preto.png");
            velocimetroIco2.Source = ImageSource.FromFile("velocimetro_20x20_preto.png");
            radarIco.Source        = ImageSource.FromFile("radar_20x20_preto.png");

            tempoCorrendo.SetBinding(Label.TextProperty, new Binding("TempoGravacaoStr", stringFormat: "Tempo: {0}"));
            tempoCorrendo.FontSize = 14;
            tempoParado.SetBinding(Label.TextProperty, new Binding("TempoParadoStr", stringFormat: "Parado: {0}"));
            tempoParado.FontSize = 14;

            paradas.SetBinding(Label.TextProperty, new Binding("QuantidadeParadaStr", stringFormat: "Paradas: {0}"));
            paradas.FontSize = 14;
            velocidadeMedia.SetBinding(Label.TextProperty, new Binding("VelocidadeMediaStr", stringFormat: "V Méd: {0}"));
            velocidadeMedia.FontSize = 14;
            velocidadeMaxima.SetBinding(Label.TextProperty, new Binding("VelocidadeMaximaStr", stringFormat: "V Max: {0}"));
            velocidadeMaxima.FontSize = 14;
            radares.SetBinding(Label.TextProperty, new Binding("QuantidadeRadarStr", stringFormat: "Radares: {0}"));
            radares.FontSize = 14;

            desc.Children.Add(relogioIco);
            desc.Children.Add(tempoCorrendo);
            desc.Children.Add(ampulhetaIco);
            desc.Children.Add(tempoParado);
            desc.Children.Add(paradoIco);
            desc.Children.Add(paradas);
            desc.Children.Add(velocimetroIco);
            desc.Children.Add(velocidadeMedia);
            desc.Children.Add(velocimetroIco2);
            desc.Children.Add(velocidadeMaxima);
            desc.Children.Add(radarIco);
            desc.Children.Add(radares);

            Frame cardLeft = new Frame()
            {
                HorizontalOptions = LayoutOptions.Center,
                Margin            = new Thickness(0, 0, 0, 90),
                WidthRequest      = TelaUtils.LarguraSemPixel * 0.2
            };

            StackLayout cardLeftStack = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill
            };

            Image percursoIco = new Image()
            {
                Source            = ImageSource.FromFile("percursos.png"),
                WidthRequest      = cardLeft.WidthRequest * 0.3,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Start
            };

            BoxView linha = new BoxView()
            {
                HeightRequest     = 1,
                BackgroundColor   = Color.FromHex(TemaInfo.DividerColor),
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Start
            };

            Label distanciaText = new Label()
            {
                FontSize          = 14,
                TextColor         = Color.FromHex(TemaInfo.PrimaryColor),
                FontFamily        = "Roboto-Condensed",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Start
            };

            distanciaText.SetBinding(Label.TextProperty, new Binding("DistanciaTotalStr"));

            cardLeftStack.Children.Add(percursoIco);
            cardLeftStack.Children.Add(distanciaText);
            cardLeft.Content = cardLeftStack;

            Frame cardRigth = new Frame()
            {
                HorizontalOptions = LayoutOptions.Start,
                WidthRequest      = TelaUtils.LarguraSemPixel * 0.7
            };

            if (TelaUtils.Orientacao == "Landscape")
            {
                cardLeft.Margin        = new Thickness(0, 0, 0, 70);
                cardLeft.WidthRequest  = TelaUtils.LarguraSemPixel * 0.15;
                cardRigth.WidthRequest = TelaUtils.LarguraSemPixel * 0.5;
            }
            if (TelaUtils.Orientacao == "LandscapeLeft" || TelaUtils.Orientacao == "LandscapeRight")
            {
                cardLeft.Margin        = new Thickness(0, 0, 0, 70);
                cardLeft.WidthRequest  = TelaUtils.LarguraSemPixel * 0.15;
                cardRigth.WidthRequest = TelaUtils.LarguraSemPixel * 0.5;
            }
            StackLayout cardRigthStackVer = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Spacing     = 1
            };


            Label titulo = new Label()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                FontSize          = 26,
                FontFamily        = "Roboto-Condensed",
                TextColor         = Color.FromHex(TemaInfo.PrimaryColor)
            };

            titulo.SetBinding(Label.TextProperty, new Binding("Titulo"));

            Label endereco = new Label()
            {
                //Text = "Rua H-149, 1-73 Cidade Vera Cruz/ Aparecida de Goiânia",
                WidthRequest      = TelaUtils.LarguraSemPixel * 0.7,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                FontSize          = 16,
                FontFamily        = "Roboto-Condensed",
                //HorizontalTextAlignment = TextAlignment.Start
            };

            endereco.SetBinding(Label.TextProperty, new Binding("Endereco"));


            cardRigthStackVer.Children.Add(titulo);
            cardRigthStackVer.Children.Add(linha);
            cardRigthStackVer.Children.Add(endereco);
            cardRigthStackVer.Children.Add(desc);

            cardRigth.Content = cardRigthStackVer;

            View = new StackLayout()
            {
                Margin            = new Thickness(5, 0, 5, 0),
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Fill,
                WidthRequest      = TelaUtils.LarguraSemPixel,
                Children          =
                {
                    cardLeft,
                    cardRigth
                }
            };
        }
Esempio n. 14
0
        public static bool simularPercurso(int idPercurso)
        {
            if (_simulando)
            {
                Emagine.Utils.MensagemUtils.avisar("Já existe uma simulação em andamento.");
                return(false);
            }
            PercursoBLL regraPercurso = PercursoFactory.create();

            _percursoSimulado = regraPercurso.pegar(idPercurso);
            _simulando        = true;
            _indexPercuso     = 0;
            _ultimoPonto      = DateTime.MinValue;
            if (_percursoSimulado == null)
            {
                Emagine.Utils.MensagemUtils.avisar("Percurso não encontrado.");
                return(false);
            }
            if (_percursoSimulado.Pontos.Count() == 0)
            {
                MensagemUtils.avisar("Nenhum movimento registrado nesse percurso.");
                return(false);
            }
            //MensagemUtils.notificarPermanente(NOTIFICACAO_SIMULACAO_ID, "Simulando percurso!", string.Empty);
            MensagemUtils.notificarPermanente(
                PercursoBLL.NOTIFICACAO_SIMULACAO_PERCURSO_ID,
                "Radar Club", "Simulando percurso...",
                PercursoBLL.NOTIFICACAO_SIMULACAO_PARAR_PERCURSO_ID,
                "Parar",
                PercursoBLL.ACAO_PARAR_SIMULACAO
                );
            MensagemUtils.avisar("Iniciando simulação!");

            /*
             * var task = Task.Factory.StartNew(() =>
             * {
             *  while (_simulando)
             *  {
             *      if (_indexPercuso < _percursoSimulado.Pontos.Count())
             *      {
             *          PercursoPontoInfo ponto = _percursoSimulado.Pontos[_indexPercuso];
             *
             *                                  LocalizacaoInfo local = new LocalizacaoInfo
             *                                  {
             *                                          Latitude = ponto.Latitude,
             *                                          Longitude = ponto.Longitude,
             *                                          Sentido = ponto.Sentido,
             *                                          Precisao = ponto.Precisao,
             *                                          Tempo = ponto.Data,
             *                                          Velocidade = ponto.Velocidade
             *                                  };
             *                                  //executarPosicao(local);
             *                                  ThreadUtils.RunOnUiThread(() =>
             *                                  {
             *                                          executarPosicao(local);
             *                                  });
             *
             *
             *          if (_ultimoPonto != DateTime.MinValue)
             *          {
             *              TimeSpan delay = ponto.Data.Subtract(_ultimoPonto);
             *              Task.Delay((int)delay.TotalMilliseconds).Wait();
             *              //_ultimoPonto = ponto.Data;
             *          }
             *          _ultimoPonto = ponto.Data;
             *          _indexPercuso++;
             *      }
             *      else {
             *          pararSimulacao();
             *          break;
             *      }
             *  }
             * });
             */
            return(true);
        }
Esempio n. 15
0
        public int gravar(PercursoInfo percurso)
        {
            var grava = _percursoDB.gravar(percurso);

            return(grava);
        }
Esempio n. 16
0
        public ResumoPercursoPage(PercursoInfo percursoinfo)
        {
            var percurso = percursoinfo;

            this.Title = "Resumo do percurso";

            /*
             * var menu = new ToolbarItem {
             *  Text = "Mapa",
             * };
             * menu.Clicked += (sender, e) =>
             * {
             *  NavigationX.create(this).PushAsync(new MapaPagePercurso(percurso.Id));
             * };
             * ToolbarItems.Add(menu);
             */

            AbsoluteLayout listaView = new AbsoluteLayout();

            listaView.VerticalOptions   = LayoutOptions.Fill;
            listaView.HorizontalOptions = LayoutOptions.Fill;
            listaView.BackgroundColor   = Color.Transparent;

            //GrupoBLL regraGrupo = GrupoFactory.create();

            /*
             *          _resumo = new ObservableCollection<ResumoInfo>();
             *          ObservableCollection<ResumoItemInfo> resumoParada = new ObservableCollection<ResumoItemInfo>();
             *
             *          resumoParada.Add(new ResumoItemInfo() { Descricao = "Latitude", Valor = "-10.897765" });
             *          resumoParada.Add(new ResumoItemInfo() { Descricao = "Longitude", Valor = "-15.447853" });
             *          resumoParada.Add(new ResumoItemInfo() { Descricao = "Data", Valor = "10 / DEZ" });
             *          resumoParada.Add(new ResumoItemInfo() { Descricao = "Tempo", Valor = "00:30:55" });
             *
             *          ObservableCollection<ResumoItemInfo> resumoRadar = new ObservableCollection<ResumoItemInfo>();
             *
             *          resumoRadar.Add(new ResumoItemInfo() { Descricao = "Latitude", Valor = "-10.897765" });
             *          resumoRadar.Add(new ResumoItemInfo() { Descricao = "Longitude", Valor = "-15.447853" });
             *          resumoRadar.Add(new ResumoItemInfo() { Descricao = "Data", Valor = "10 / DEZ" });
             *          resumoRadar.Add(new ResumoItemInfo() { Descricao = "Velocidade", Valor = "40 Km/h" });
             *          resumoRadar.Add(new ResumoItemInfo() { Descricao = "Minha Velocidade", Valor = "60 Km/h" });
             *
             *          ObservableCollection<ResumoItemInfo> resumoDespesas = new ObservableCollection<ResumoItemInfo>();
             *
             *          resumoDespesas.Add(new ResumoItemInfo() { Descricao = "Latitude", Valor = "-10.897765" });
             *          resumoDespesas.Add(new ResumoItemInfo() { Descricao = "Longitude", Valor = "-15.447853" });
             *          resumoDespesas.Add(new ResumoItemInfo() { Descricao = "Data", Valor = "10 / DEZ" });
             *          resumoDespesas.Add(new ResumoItemInfo() { Descricao = "Valor", Valor = "120.00 R$" });
             *
             *          ObservableCollection<ResumoItemInfo> resumoPoliciaRodoviaria = new ObservableCollection<ResumoItemInfo>();
             *
             *          resumoPoliciaRodoviaria.Add(new ResumoItemInfo() { Descricao = "Latitude", Valor = "-10.897765" });
             *          resumoPoliciaRodoviaria.Add(new ResumoItemInfo() { Descricao = "Longitude", Valor = "-15.447853" });
             *          resumoPoliciaRodoviaria.Add(new ResumoItemInfo() { Descricao = "Data", Valor = "10 / DEZ" });
             *
             *          _resumo.Add(new ResumoInfo() { Nome = "Radar", Imagem = "radar_40.png",Items = resumoRadar });
             *          _resumo.Add(new ResumoInfo()
             *          {
             *                  Nome = "Paradas",
             *                  Imagem = "ic_pan_tool_black_24dp.png",
             *                  Items = resumoParada
             *          });
             *          _resumo.Add(new ResumoInfo() { Nome = "Despesas", Imagem = "ic_monetization_on_black_24dp.png",Items = resumoDespesas });
             *          _resumo.Add(new ResumoInfo() { Nome = "Polícia Rodoviária", Imagem = "policiarodoviaria.png",Items = resumoPoliciaRodoviaria });
             *          _resumo.Add(new ResumoInfo() { Nome = "Despesas", Imagem = "ic_monetization_on_black_24dp.png",Items = resumoDespesas });
             */
            var regraPercurso = PercursoFactory.create();
            var lista         = regraPercurso.listarResumo(percursoinfo.Id);

            _resumo = regraPercurso.converterParaRotinaEscrotaDoCarlos(lista);

            ListView listaResumos = new ListView();

            //listaResumos.RowHeight = 200;
            listaResumos.ItemTemplate = new DataTemplate(celulaResumo);

            listaResumos.ItemTapped += OnTap;
            listaResumos.SetBinding(ListView.ItemsSourceProperty, new Binding("."));
            listaResumos.HasUnevenRows  = true;
            listaResumos.SeparatorColor = Color.Transparent;
            //listaResumos.VerticalOptions = LayoutOptions.FillAndExpand;
            //listaResumos.HorizontalOptions = LayoutOptions.Center;
            AbsoluteLayout.SetLayoutBounds(listaResumos, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(listaResumos, AbsoluteLayoutFlags.All);
            //var grupos = regraGrupo.listar();
            listaResumos.BindingContext = _resumo;

            listaView.Children.Add(listaResumos);


            Content = listaView;
        }