Ejemplo n.º 1
0
 private void inicializarReativarButton()
 {
     _reativarButton = new MenuItem
     {
         CommandParameter = "{Binding .}",
         Text             = "Reativar",
         IsDestructive    = true
     };
     _reativarButton.Clicked += (object sender, EventArgs e) =>
     {
         RadarBLL  regraRadar = RadarFactory.create();
         RadarInfo radar      = (RadarInfo)((MenuItem)sender).BindingContext;
         radar.Ativo = true;
         regraRadar.gravar(radar);
         var radarListView = (ListView)this.Parent;
         var contentPagina = (ContentPage)radarListView.Parent;
         var pagina        = (RadarListaPage)contentPagina.Parent;
         pagina.atualizarRadar();
     };
     ContextActions.Add(_reativarButton);
 }
Ejemplo n.º 2
0
        protected override void OnAppearing()
        {
            RadarBLL regraRadar = RadarFactory.create();

            RadarListView.RowHeight   = 150;
            RadarListView.ItemTapped += OnTap;
            regraRadar.atualizarEndereco();
            RadarListView.SetBinding(ListView.ItemsSourceProperty, new Binding("."));
            RadarListView.ItemTemplate = new DataTemplate(typeof(ConteudoCelula));

            var radar = regraRadar.listar(true);

            //desc.VerticalOptions = LayoutOptions.Center;


            if (radar.Count > 0)
            {
                //percursoListView.SetBinding(Label.TextProperty, new Binding("Data"));
                this.BindingContext = radar;
            }
        }
Ejemplo n.º 3
0
        public void atualizarAreaVisivel(MapSpan region)
        {
            //var center = region.Center;
            var latitudeDelta  = region.LatitudeDegrees / 2;
            var longitudeDelta = region.LongitudeDegrees / 2;

            if (!(latitudeDelta <= PreferenciaUtils.GPSDeltaMax && longitudeDelta <= PreferenciaUtils.GPSDeltaMax))
            {
                return;
            }

            RadarBLL regraRadar = RadarFactory.create();
            var      radares    = regraRadar.listar(region.Center.Latitude, region.Center.Longitude, latitudeDelta, longitudeDelta);

            //var radares = regraRadar.listar();

            foreach (RadarInfo radar in radares)
            {
                adicionarRadar(radar);
            }
        }
Ejemplo n.º 4
0
        public RadarListaPage()
        {
            Title = "Meus Radares";

            /*
             * _ativoListView.ItemTapped += (sender, e) => {
             *  if (e == null)
             *      return;
             * };
             */

            RadarBLL regraRadar = RadarFactory.create();

            regraRadar.atualizarEndereco();
            var paginaAtivo = criarPaginaAtiva();

            var paginaInativo = criarPaginaInativo();

            atualizarRadar();
            Children.Add(paginaAtivo);
            Children.Add(paginaInativo);
        }
Ejemplo n.º 5
0
            public ConteudoCelula()
            {
                MenuItem excluirRadar = new MenuItem();

                excluirRadar.CommandParameter = "{Binding .}";
                excluirRadar.Text             = "Excluir";
                excluirRadar.IsDestructive    = true;
                excluirRadar.Clicked         += (object sender, EventArgs e) =>
                {
                    RadarInfo radar      = (RadarInfo)((MenuItem)sender).BindingContext;
                    RadarBLL  regraRadar = RadarFactory.create();
                    regraRadar.excluir(radar.Id);
                    var RadarListView = this.Parent as ListView;

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

                    var percursos = regraRadar.listar(true);
                    RadarListView.BindingContext = percursos;
                    RadarListView.ItemTemplate   = new DataTemplate(typeof(ConteudoCelula));
                };

                this.ContextActions.Add(excluirRadar);


                //desc.VerticalOptions = LayoutOptions.Center;
                desc.HorizontalOptions = LayoutOptions.FillAndExpand;
                desc.Orientation       = StackOrientation.Horizontal;

                StackLayout main = new StackLayout()
                {
                    Margin            = new Thickness(5, 0, 5, 0),
                    VerticalOptions   = LayoutOptions.Fill,
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.Fill,
                    WidthRequest      = TelaUtils.LarguraSemPixel
                };

                Frame cardLeft = new Frame()
                {
                    HorizontalOptions = LayoutOptions.Start,
                    Margin            = new Thickness(0, 0, 0, 0),
                    WidthRequest      = main.WidthRequest * 0.2
                };

                StackLayout cardLeftStack = new StackLayout()
                {
                    Orientation = StackOrientation.Vertical
                };

                Image percursoIco = new Image()
                {
                    Source            = ImageSource.FromFile("meusradares.png"),
                    WidthRequest      = cardLeft.WidthRequest / 1.5,
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.CenterAndExpand
                };


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

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

                WrapLayout cardRigthStackHor = new WrapLayout()
                {
                    //Orientation = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.Fill,
                    VerticalOptions   = LayoutOptions.Fill,
                    Spacing           = 1
                };
                StackLayout cardRigthStackVer = new StackLayout()
                {
                    Orientation = StackOrientation.Vertical,
                    Spacing     = 1
                };

                Label titulo = new Label()
                {
                    //Text = "31/0ut - 17:41",
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    FontSize          = 26,
                    FontFamily        = "Roboto-Condensed",
                    TextColor         = Color.FromHex(TemaInfo.PrimaryColor)
                };

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

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

                limite.SetBinding(Label.TextProperty, new Binding("VelocidadeStr"));


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

                latitude.SetBinding(Label.TextProperty, new Binding("LatitudeText"));

                Label longitude = new Label()
                {
                    //Text = "Longitude: -49,23480 ",
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    FontSize          = 14,
                    FontFamily        = "Roboto-Condensed",
                    TextColor         = Color.FromHex(TemaInfo.PrimaryColor)
                };

                longitude.SetBinding(Label.TextProperty, new Binding("LongitudeText"));


                Label angulo = new Label()
                {
                    //Text = "Ângulo: 179.0 ",
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    FontSize          = 14,
                    FontFamily        = "Roboto-Condensed",
                    TextColor         = Color.FromHex(TemaInfo.PrimaryColor)
                };

                angulo.SetBinding(Label.TextProperty, new Binding("DirecaoText"));


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

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


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

                if (TelaUtils.Orientacao == "LandscapeLeft" || TelaUtils.Orientacao == "LandscapeRight")
                {
                    percursoIco.WidthRequest = cardLeft.WidthRequest / 2;
                    //cardLeft.WidthRequest = main.WidthRequest * 0.15;
                    cardRigth.WidthRequest = main.WidthRequest * 0.45;
                }
                cardRigthStackVer.Children.Add(titulo);
                cardRigthStackVer.Children.Add(linha);
                cardRigthStackHor.Children.Add(limite);
                cardRigthStackHor.Children.Add(latitude);
                cardRigthStackHor.Children.Add(longitude);
                cardRigthStackHor.Children.Add(angulo);
                cardRigthStackVer.Children.Add(cardRigthStackHor);
                cardRigthStackVer.Children.Add(endereco);

                cardRigthStackVer.WidthRequest = main.WidthRequest * 0.8;
                cardRigth.Content = cardRigthStackVer;
                main.Children.Add(cardLeft);
                main.Children.Add(cardRigth);

                View = main;
            }
Ejemplo n.º 6
0
        protected virtual void inicializarComponente()
        {
            _GPSSentidoLabel = new Label
            {
                Text     = "0º",
                FontSize = 16,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center
            };
            AbsoluteLayout.SetLayoutBounds(_GPSSentidoLabel, new Rectangle(0.9, 0.12, 0.15, 0.15));
            //AbsoluteLayout.SetLayoutBounds(_PrecisaoLabel, new Rectangle(0.11, 0.12, 0.15, 0.15));
            AbsoluteLayout.SetLayoutFlags(_GPSSentidoLabel, AbsoluteLayoutFlags.All);

            _VelocidadeRadarLabel = new Label
            {
                Text     = "Velocidade",
                FontSize = 16,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center
            };
            if (Device.OS == TargetPlatform.iOS)
            {
            }
            AbsoluteLayout.SetLayoutBounds(_VelocidadeRadarLabel, new Rectangle(1, 0.950, 1, 0.1));
            AbsoluteLayout.SetLayoutFlags(_VelocidadeRadarLabel, AbsoluteLayoutFlags.All);

            _DistanciaRadarLabel = new Label
            {
                Text     = "0 m",
                FontSize = 16,
                //HorizontalTextAlignment = TextAlignment.Center,
                //VerticalTextAlignment = TextAlignment.Center
            };
            //AbsoluteLayout.SetLayoutBounds(_DistanciaRadarLabel, new Rectangle(1, 0.975, 1, 0.1));
            //AbsoluteLayout.SetLayoutFlags(_DistanciaRadarLabel, AbsoluteLayoutFlags.All);


            if (PreferenciaUtils.ExibirBotaoRemover)
            {
                _RemoverRadarButton = new Image
                {
                    Aspect        = Aspect.AspectFit,
                    Source        = ImageSource.FromFile("menos.png"),
                    WidthRequest  = 180,
                    HeightRequest = 180
                };
                AbsoluteLayout.SetLayoutBounds(_RemoverRadarButton, new Rectangle(0.93, 0.975, 0.2, 0.2));
                AbsoluteLayout.SetLayoutFlags(_RemoverRadarButton, AbsoluteLayoutFlags.All);

                _RemoverRadarButton.GestureRecognizers.Add(
                    new TapGestureRecognizer()
                {
                    Command = new Command(() =>
                    {
                        //var regraAviso = new AvisoSonoroBLL();
                        //regraAviso.play(RadarTipoEnum.RadarFixo, 40, 300);
                        //AudioUtils.play(AudioEnum.Alarm001);
                        //MensagemUtils.avisar("teste");
                        //var downloader = new DownloaderAtualizacao();
                        //downloader.download();

                        if (InternetUtils.estarConectado())
                        {
                            LocalizacaoInfo local = GPSUtils.UltimaLocalizacao;
                            float latitude        = (float)local.Latitude;
                            float longitude       = (float)local.Longitude;
                            GeocoderUtils.pegarAsync(latitude, longitude, (sender, e) =>
                            {
                                var endereco = e.Endereco;
                                ClubManagement.Utils.MensagemUtils.avisar(endereco.Logradouro);
                            });
                        }



                        try
                        {
                            LocalizacaoInfo local = GPSUtils.UltimaLocalizacao;
                            if (local != null)
                            {
                                RadarBLL regraRadar = RadarFactory.create();
                                regraRadar.gravar(local, false);
                                MensagemUtils.avisar("Radar incluído com sucesso.");
                            }
                            else
                            {
                                MensagemUtils.avisar("Nenhum movimento registrado pelo GPS.");
                            }
                        }
                        catch (Exception e)
                        {
                            MensagemUtils.avisar(e.Message);
                        }
                    }
                                          )
                });
            }
            if (PreferenciaUtils.ExibirBotaoAdicionar)
            {
                _AdicionarRadarButton = new Image
                {
                    Aspect        = Aspect.AspectFit,
                    Source        = ImageSource.FromFile("mais.png"),
                    WidthRequest  = 180,
                    HeightRequest = 180
                };
                AbsoluteLayout.SetLayoutBounds(_AdicionarRadarButton, new Rectangle(0.93, 0.975, 0.2, 0.2));
                AbsoluteLayout.SetLayoutFlags(_AdicionarRadarButton, AbsoluteLayoutFlags.All);


                if (TelaUtils.Orientacao == "Landscape")
                {
                    AbsoluteLayout.SetLayoutBounds(_AdicionarRadarButton, new Rectangle(1, 0.5, 0.2, 0.2));
                    AbsoluteLayout.SetLayoutFlags(_AdicionarRadarButton, AbsoluteLayoutFlags.All);
                }
                _AdicionarRadarButton.GestureRecognizers.Add(
                    new TapGestureRecognizer()
                {
                    Command = new Command(() =>
                    {
                        //var regraAviso = new AvisoSonoroBLL();
                        //regraAviso.play(RadarTipoEnum.RadarFixo, 40, 300);
                        //AudioUtils.play(AudioEnum.Alarm001);
                        //MensagemUtils.avisar("teste");
                        //var downloader = new DownloaderAtualizacao();
                        //downloader.download();

                        if (InternetUtils.estarConectado())
                        {
                            LocalizacaoInfo local = GPSUtils.UltimaLocalizacao;
                            float latitude        = (float)local.Latitude;
                            float longitude       = (float)local.Longitude;
                            GeocoderUtils.pegarAsync(latitude, longitude, (sender, e) =>
                            {
                                var endereco = e.Endereco;
                                ClubManagement.Utils.MensagemUtils.avisar(endereco.Logradouro);
                            });
                        }



                        try
                        {
                            LocalizacaoInfo local = GPSUtils.UltimaLocalizacao;
                            if (local != null)
                            {
                                RadarBLL regraRadar = RadarFactory.create();
                                regraRadar.gravar(local, false);
                                MensagemUtils.avisar("Radar incluído com sucesso.");
                            }
                            else
                            {
                                MensagemUtils.avisar("Nenhum movimento registrado pelo GPS.");
                            }
                        }
                        catch (Exception e)
                        {
                            MensagemUtils.avisar(e.Message);
                        }
                    }
                                          )
                });
            }


            _BussolaFundo = new Image
            {
                Aspect        = Aspect.AspectFit,
                Source        = ImageSource.FromFile("bussolacorpo.png"),
                WidthRequest  = 180,
                HeightRequest = 180
            };
            AbsoluteLayout.SetLayoutBounds(_BussolaFundo, new Rectangle(0.93, 0, 0.2, 0.2));
            AbsoluteLayout.SetLayoutFlags(_BussolaFundo, AbsoluteLayoutFlags.All);

            _BussolaAgulha = new Image
            {
                Aspect        = Aspect.AspectFit,
                Source        = ImageSource.FromFile("bussolaagulha.png"),
                WidthRequest  = 180,
                HeightRequest = 180
            };
            AbsoluteLayout.SetLayoutBounds(_BussolaAgulha, new Rectangle(0.93, 0, 0.2, 0.2));
            AbsoluteLayout.SetLayoutFlags(_BussolaAgulha, AbsoluteLayoutFlags.All);

            _PrecisaoFundoImage = new Image
            {
                Aspect        = Aspect.AspectFit,
                Source        = ImageSource.FromFile("bussolacorpo.png"),
                WidthRequest  = 180,
                HeightRequest = 180
            };
            AbsoluteLayout.SetLayoutBounds(_PrecisaoFundoImage, new Rectangle(0.07, 0, 0.2, 0.2));
            AbsoluteLayout.SetLayoutFlags(_PrecisaoFundoImage, AbsoluteLayoutFlags.All);

            _PrecisaoImage = new Image
            {
                Aspect        = Aspect.AspectFit,
                Source        = ImageSource.FromFile("sat04.png"),
                WidthRequest  = 180,
                HeightRequest = 180
            };
            AbsoluteLayout.SetLayoutBounds(_PrecisaoImage, new Rectangle(0.11, 0.04, 0.15, 0.15));
            AbsoluteLayout.SetLayoutFlags(_PrecisaoImage, AbsoluteLayoutFlags.All);

            _PrecisaoLabel = new Label
            {
                Text     = "0 m",
                FontSize = 16,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center
            };
            //AbsoluteLayout.SetLayoutBounds(_PrecisaoLabel, new Rectangle(0.1, 0.025, 0.1, 0.1));
            AbsoluteLayout.SetLayoutBounds(_PrecisaoLabel, new Rectangle(0.11, 0.12, 0.15, 0.15));
            AbsoluteLayout.SetLayoutFlags(_PrecisaoLabel, AbsoluteLayoutFlags.All);
        }
Ejemplo n.º 7
0
        public VelocimetroPage()
        {
            Title = "Velocimetro";
            inicializarComponente();
            PercursoBLL percursoBLL = new PercursoBLL();

            percursoBLL.atualizarEndereco();

            _velocimetro = new Velocimetro
            {
                VerticalOptions   = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                WidthRequest      = TelaUtils.Largura,
                HeightRequest     = TelaUtils.Altura,
                BackgroundColor   = Color.Transparent,
                Margin            = new Thickness(0, 50, 0, 0)
            };

            _absoluteLayout = new AbsoluteLayout();
            //absoluteLayout.HorizontalOptions = LayoutOptions.Fill;

            Frame placa = new Frame();

            placa.HorizontalOptions = LayoutOptions.FillAndExpand;
            placa.VerticalOptions   = LayoutOptions.FillAndExpand;
            StackLayout dentroPlaca = new StackLayout();

            dentroPlaca.HorizontalOptions = LayoutOptions.FillAndExpand;
            dentroPlaca.VerticalOptions   = LayoutOptions.Fill;
            dentroPlaca.Orientation       = StackOrientation.Vertical;
            dentroPlaca.Spacing           = 1;


            RadarBLL radarBLL = RadarFactory.create();

            _radarImage = new Image();

            _radarImage.Aspect            = Aspect.Fill;
            _radarImage.WidthRequest      = 50;
            _radarImage.HeightRequest     = 50;
            _radarImage.VerticalOptions   = LayoutOptions.CenterAndExpand;
            _radarImage.HorizontalOptions = LayoutOptions.Center;

            Label fiscalizacao = new Label();

            fiscalizacao.Text              = "FISCALIZAÇÃO ELETRÔNICA";
            fiscalizacao.FontSize          = 10;
            fiscalizacao.TextColor         = Color.Black;
            fiscalizacao.VerticalOptions   = LayoutOptions.CenterAndExpand;
            fiscalizacao.HorizontalOptions = LayoutOptions.Center;

            caminhoLivre                   = new Label();
            caminhoLivre.Text              = "CAMINHO LIVRE";
            caminhoLivre.FontSize          = 10;
            caminhoLivre.TextColor         = Color.Black;
            caminhoLivre.VerticalOptions   = LayoutOptions.CenterAndExpand;
            caminhoLivre.HorizontalOptions = LayoutOptions.Center;

            _DistanciaRadarLabel.TextColor         = Color.Black;
            _DistanciaRadarLabel.VerticalOptions   = LayoutOptions.CenterAndExpand;
            _DistanciaRadarLabel.HorizontalOptions = LayoutOptions.Center;


            if (TelaUtils.Dispositivo == "Pad")
            {
                _velocimetro.Margin       = new Thickness(0, -50, 0, 0);
                _radarImage.WidthRequest  = 70;
                _radarImage.HeightRequest = 70;
                AbsoluteLayout.SetLayoutBounds(placa, new Rectangle(0.52, 1, 0.3, 0.25));
                AbsoluteLayout.SetLayoutFlags(placa, AbsoluteLayoutFlags.All);
            }
            else
            {
                AbsoluteLayout.SetLayoutBounds(placa, new Rectangle(0.5, 0.9, 0.4, 0.3));
                AbsoluteLayout.SetLayoutFlags(placa, AbsoluteLayoutFlags.All);
            }


            if (TelaUtils.Orientacao == "Landscape")
            {
                _velocimetro.Margin = new Thickness(0, -40, 0, 0);

                double size = Math.Sqrt(Math.Pow(TelaUtils.LarguraDPI, 2) + Math.Pow(TelaUtils.AlturaDPI, 2));

                if (size > 6)
                {
                    AbsoluteLayout.SetLayoutBounds(placa, new Rectangle(0.4, 1, 0.25, 0.25));
                    AbsoluteLayout.SetLayoutFlags(placa, AbsoluteLayoutFlags.All);
                }
                else
                {
                    if (size > 7)
                    {
                        AbsoluteLayout.SetLayoutBounds(placa, new Rectangle(0.35, 1, 0.25, 0.25));
                        AbsoluteLayout.SetLayoutFlags(placa, AbsoluteLayoutFlags.All);
                    }
                    else
                    {
                        AbsoluteLayout.SetLayoutBounds(placa, new Rectangle(0.78, 0.5, 0.25, 0.5));
                        AbsoluteLayout.SetLayoutFlags(placa, AbsoluteLayoutFlags.All);
                    }
                }


                //placa.Margin = new Thickness(TelaUtils.LarguraSemPixel / 3, 0, 0, 0);

                _radarImage.WidthRequest  = 50;
                _radarImage.HeightRequest = 50;

                AbsoluteLayout.SetLayoutBounds(_BussolaFundo, new Rectangle(1, 0.05, 0.2, 0.2));
                AbsoluteLayout.SetLayoutFlags(_BussolaFundo, AbsoluteLayoutFlags.All);
                AbsoluteLayout.SetLayoutBounds(_BussolaAgulha, new Rectangle(1, 0.05, 0.2, 0.2));
                AbsoluteLayout.SetLayoutFlags(_BussolaAgulha, AbsoluteLayoutFlags.All);
                AbsoluteLayout.SetLayoutBounds(_GPSSentidoLabel, new Rectangle(1, 0.25, 0.2, 0.2));
                AbsoluteLayout.SetLayoutFlags(_GPSSentidoLabel, AbsoluteLayoutFlags.All);

                AbsoluteLayout.SetLayoutBounds(_PrecisaoFundoImage, new Rectangle(1, 0.8, 0.2, 0.2));
                AbsoluteLayout.SetLayoutFlags(_PrecisaoFundoImage, AbsoluteLayoutFlags.All);
                AbsoluteLayout.SetLayoutBounds(_PrecisaoImage, new Rectangle(1, 0.8, 0.2, 0.2));
                AbsoluteLayout.SetLayoutFlags(_PrecisaoImage, AbsoluteLayoutFlags.All);
                AbsoluteLayout.SetLayoutBounds(_PrecisaoLabel, new Rectangle(1, 1, 0.2, 0.2));
                AbsoluteLayout.SetLayoutFlags(_PrecisaoLabel, AbsoluteLayoutFlags.All);

                //AbsoluteLayout.SetLayoutBounds(_VelocidadeRadarLabel, new Rectangle(0.8, 0.85, 0.2, 0.2));
                //AbsoluteLayout.SetLayoutFlags(_VelocidadeRadarLabel, AbsoluteLayoutFlags.All);
                //AbsoluteLayout.SetLayoutBounds(_DistanciaRadarLabel, new Rectangle(0.8, 0.95, 0.2, 0.2));
                //AbsoluteLayout.SetLayoutFlags(_DistanciaRadarLabel, AbsoluteLayoutFlags.All);

                //_AdicionarRadarButton.Margin = new Thickness(TelaUtils.LarguraSemPixel / 2 + 200, 0, 0, 20);
            }

            if (TelaUtils.Orientacao == "LandscapeLeft" || TelaUtils.Orientacao == "LandscapeRight")
            {
                if (TelaUtils.Dispositivo == "Pad")
                {
                    _velocimetro.Margin = new Thickness(10, -310, 0, 0);

                    AbsoluteLayout.SetLayoutBounds(placa, new Rectangle(0.52, 1, 0.2, 0.3));
                    AbsoluteLayout.SetLayoutFlags(placa, AbsoluteLayoutFlags.All);
                    _radarImage.VerticalOptions = LayoutOptions.StartAndExpand;
                }
                else
                {
                    _velocimetro.Margin = new Thickness(TelaUtils.Largura * 0.5 - 70, -270, 0, 0);
                    AbsoluteLayout.SetLayoutBounds(_velocimetro, new Rectangle(1, 1, 1, 0.5));
                    AbsoluteLayout.SetLayoutFlags(_velocimetro, AbsoluteLayoutFlags.All);
                    _radarImage.WidthRequest             = 40;
                    _radarImage.HeightRequest            = 40;
                    _radarImage.Margin                   = new Thickness(0, -9, 0, 0);
                    fiscalizacao.Margin                  = new Thickness(0, -5, 0, 0);
                    fiscalizacao.VerticalOptions         = LayoutOptions.FillAndExpand;
                    fiscalizacao.FontSize                = 9;
                    dentroPlaca.Margin                   = new Thickness(0, -5, 0, 0);
                    _DistanciaRadarLabel.VerticalOptions = LayoutOptions.Start;
                    AbsoluteLayout.SetLayoutBounds(placa, new Rectangle(0.5, 1, 0.2, 0.3));
                    AbsoluteLayout.SetLayoutFlags(placa, AbsoluteLayoutFlags.All);
                }
            }
            Padding = 5;

            /*
             * Content = new AbsoluteLayout
             * {
             * Children = {
             * _velocimetro,
             * _GPSSentidoLabel,
             * _VelocidadeRadarLabel,
             * _DistanciaRadarLabel,
             * _AdicionarRadarButton,
             * _BussolaFundo,
             * _BussolaAgulha,
             * _PrecisaoFundoImage,
             * _PrecisaoImage,
             * _PrecisaoLabel
             * }
             * };
             */

            dentroPlaca.Children.Add(_radarImage);

            dentroPlaca.Children.Add(caminhoLivre);



            dentroPlaca.Children.Add(fiscalizacao);
            dentroPlaca.Children.Add(_DistanciaRadarLabel);

            _absoluteLayout.Children.Add(_velocimetro);
            placa.Content = dentroPlaca;
            _absoluteLayout.Children.Add(placa);

            //  absoluteLayout.Children.Add(_VelocidadeRadarLabel);
            //  absoluteLayout.Children.Add(_DistanciaRadarLabel);
            if (PreferenciaUtils.Bussola)
            {
                _absoluteLayout.Children.Add(_BussolaFundo);
                _absoluteLayout.Children.Add(_BussolaAgulha);
                _absoluteLayout.Children.Add(_GPSSentidoLabel);
            }
            if (PreferenciaUtils.SinalGPS)
            {
                _absoluteLayout.Children.Add(_PrecisaoFundoImage);
                _absoluteLayout.Children.Add(_PrecisaoImage);
                _absoluteLayout.Children.Add(_PrecisaoLabel);
            }
            if (PreferenciaUtils.ExibirBotaoAdicionar)
            {
                _absoluteLayout.Children.Add(_AdicionarRadarButton);
            }
            Content = _absoluteLayout;
        }
Ejemplo n.º 8
0
 private static LocalizacaoInfo executarPosicao(LocalizacaoInfo local)
 {
     try
     {
         var regraPercurso = PercursoFactory.create();
         if (PreferenciaUtils.SalvarPercurso && !PercursoUtils.Gravando && local.Velocidade > 20)
         {
             var inicializou = regraPercurso.iniciarGravacao();
         }
         _ultimaLocalizacao = local;
         RadarBLL regraRadar = RadarFactory.create();
         if (RadarBLL.RadarAtual != null)
         {
             if (regraRadar.radarContinuaAFrente(local, RadarBLL.RadarAtual))
             {
                 RadarInfo radar = RadarBLL.RadarAtual;
                 local.Distancia = calcularDistancia(local.Latitude, local.Longitude, radar.Latitude, radar.Longitude);
             }
             else
             {
                 RadarBLL.RadarAtual = null;
             }
         }
         else
         {
             double    distanciaRadar = (local.Velocidade < 90) ? PreferenciaUtils.DistanciaAlertaUrbano : PreferenciaUtils.DistanciaAlertaEstrada;
             RadarInfo radar          = regraRadar.calcularRadar(local, distanciaRadar);
             if (radar != null)
             {
                 local.Distancia = calcularDistancia(local.Latitude, local.Longitude, radar.Latitude, radar.Longitude);
                 if (PreferenciaUtils.AlertaInteligente)
                 {
                     if ((local.Velocidade - 5) > radar.Velocidade)
                     {
                         avisarRadar(local, radar);
                     }
                 }
                 else
                 {
                     if (local.Velocidade > 15)
                     {
                         avisarRadar(local, radar);
                     }
                 }
             }
         }
         regraPercurso.executarGravacao(local, RadarBLL.RadarAtual);
         var visualPage = GlobalUtils.Visual;
         if (visualPage != null)
         {
             visualPage.VelocidadeAtual = (float)local.Velocidade;
             visualPage.Precisao        = local.Precisao;
             visualPage.Sentido         = local.Sentido;
             RadarInfo radar = RadarBLL.RadarAtual;
             if (radar != null)
             {
                 visualPage.VelocidadeRadar = radar.Velocidade;
                 visualPage.DistanciaRadar  = (float)local.Distancia;
             }
             else
             {
                 visualPage.VelocidadeRadar = 0;
                 visualPage.DistanciaRadar  = 0;
             }
             visualPage.atualizarPosicao(local);
             visualPage.redesenhar();
         }
         //regraPercurso.executarGravacao(local, RadarBLL.RadarAtual);
         //MensagemUtils.avisar(MemoryUtils.getInfo().ToString());
     }
     catch (Exception e) {
         ErroPage.exibir(e);
     }
     return(local);
 }
Ejemplo n.º 9
0
        public IList <PercursoResumoInfo> listarResumo(int idPercuso)
        {
            var regraRadar = RadarFactory.create();

            var percurso = pegar(idPercuso);
            var pontos   = percurso.Pontos.ToList();

            var resumos = new List <PercursoResumoInfo>();

            var inicio  = pontos[0];
            var chegada = pontos[pontos.Count - 1];

            pontos.Remove(inicio);
            pontos.Remove(chegada);

            resumos.Add(new PercursoResumoInfo {
                Icone     = "partida.png",
                Descricao = "Saída",
                Data      = inicio.Data,
                Distancia = 0,
                Latitude  = (float)inicio.Latitude,
                Longitude = (float)inicio.Longitude,
                Tempo     = TimeSpan.Zero
            });

            var      idRadarOld         = inicio.IdRadar;
            var      dataOld            = inicio.Data;
            var      latitudeOld        = (float)inicio.Latitude;
            var      longitudeOld       = (float)inicio.Longitude;
            double   distanciaAcumulada = 0;
            TimeSpan tempoAcumulado     = TimeSpan.Zero;

            double   distancia = 0;
            TimeSpan tempo     = TimeSpan.Zero;

            foreach (var ponto in percurso.Pontos)
            {
                distancia = GPSUtils.calcularDistancia(latitudeOld, longitudeOld, ponto.Latitude, ponto.Longitude);
                tempo     = ponto.Data.Subtract(dataOld);
                if (distancia > DISTANCIA_MINIMA_RESUMO)
                {
                    distanciaAcumulada += distancia;
                    tempoAcumulado      = tempoAcumulado.Add(tempo);
                    if (tempo.TotalSeconds > TEMPO_MINIMO_PARADO)
                    {
                        resumos.Add(new PercursoParadoInfo
                        {
                            Icone     = "para.png",
                            Descricao = "Parada",
                            Data      = ponto.Data,
                            Tempo     = tempoAcumulado,
                            Distancia = distanciaAcumulada,
                            Latitude  = (float)ponto.Latitude,
                            Longitude = (float)ponto.Longitude,
                        });
                        distanciaAcumulada = 0;
                        tempoAcumulado     = TimeSpan.Zero;
                    }
                    if (idRadarOld != ponto.IdRadar && ponto.IdRadar > 0)
                    {
                        var ultimoPonto = (
                            from p in percurso.Pontos
                            where p.IdRadar == ponto.IdRadar
                            orderby p.Data descending
                            select p
                            ).FirstOrDefault <PercursoPontoInfo>();
                        var radar = regraRadar.pegar(ponto.IdRadar);
                        if (radar != null)
                        {
                            distancia           = GPSUtils.calcularDistancia(latitudeOld, longitudeOld, ultimoPonto.Latitude, ultimoPonto.Longitude);
                            distanciaAcumulada += distancia;
                            resumos.Add(new PercursoRadarInfo
                            {
                                Icone           = radar.Imagem,
                                Descricao       = radar.Titulo,
                                Data            = ultimoPonto.Data,
                                Distancia       = distanciaAcumulada,
                                Latitude        = (float)ultimoPonto.Latitude,
                                Longitude       = (float)ultimoPonto.Longitude,
                                Tempo           = tempoAcumulado,
                                MinhaVelocidade = ultimoPonto.Velocidade,
                                Velocidade      = radar.Velocidade,
                                Tipo            = radar.Tipo
                            });
                        }
                        idRadarOld         = ponto.IdRadar;
                        distanciaAcumulada = 0;
                        tempoAcumulado     = TimeSpan.Zero;
                    }

                    dataOld      = ponto.Data;
                    latitudeOld  = (float)ponto.Latitude;
                    longitudeOld = (float)ponto.Longitude;
                }
            }

            distancia           = GPSUtils.calcularDistancia(latitudeOld, longitudeOld, chegada.Latitude, chegada.Longitude);
            tempo               = chegada.Data.Subtract(dataOld);
            distanciaAcumulada += distancia;
            tempoAcumulado      = tempoAcumulado.Add(tempo);
            resumos.Add(new PercursoResumoInfo
            {
                Icone     = "chegada.png",
                Descricao = "Chegada",
                Data      = chegada.Data,
                Tempo     = tempoAcumulado,
                Distancia = distanciaAcumulada,
                Latitude  = (float)chegada.Latitude,
                Longitude = (float)chegada.Longitude,
            });

            var regraGasto = GastoFactory.create();
            var gastos     = regraGasto.listar(idPercuso);

            foreach (var gasto in gastos)
            {
                resumos.Add(new PercursoGastoInfo
                {
                    Icone      = "ic_monetization_on_black_24dp.png",
                    Descricao  = gasto.Observacao,
                    Data       = gasto.DataInclusao,
                    Tempo      = TimeSpan.Zero,
                    Distancia  = 0,
                    Latitude   = (float)gasto.Latitude,
                    Longitude  = (float)gasto.Longitude,
                    FotoBase64 = gasto.FotoBase64
                });
            }

            var retorno = (
                from r in resumos
                orderby r.Data
                select r
                ).ToList();

            return(retorno);
        }