public override void OnReceive(Context context, Intent intent) { if (intent.Action == Intent.ActionBootCompleted) { Intent pushIntent = new Intent(context, typeof(GPSAndroid)); context.StartService(pushIntent); InvokeAbortBroadcast(); } else if (intent.Action == PercursoBLL.ACAO_PARAR_SIMULACAO) { GPSUtils.pararSimulacao(); MensagemUtils.pararNotificaoPermanente(PercursoBLL.NOTIFICACAO_SIMULACAO_PERCURSO_ID); InvokeAbortBroadcast(); } else if (intent.Action == PercursoBLL.ACAO_PARAR_GRAVACAO) { PercursoBLL regraPercurso = PercursoFactory.create(); regraPercurso.pararGravacao(); //MensagemUtils.pararNotificaoPermanente(PercursoBLL.NOTIFICACAO_GRAVAR_PERCURSO_ID); InvokeAbortBroadcast(); } else if (intent.Action == "Fechar") { NotificationManager notificationManager = (NotificationManager)context.GetSystemService(Context.NotificationService); notificationManager.Cancel(1); System.Environment.Exit(0); Process.KillProcess(Process.MyPid()); } }
private static void executarPosicao(LocalizacaoInfo local) { try { _ultimaLocalizacao = local; RadarBLL regraRadar = RadarFactory.create(); PercursoBLL regraPercurso = PercursoFactory.create(); if (RadarBLL.RadarAtual != null) { if (!regraRadar.radarContinuaAFrente(local, RadarBLL.RadarAtual)) { RadarBLL.RadarAtual = null; } } else { double distanciaRadar = (local.Velocidade < 90) ? PreferenciaUtils.DistanciaAlertaUrbano : PreferenciaUtils.DistanciaAlertaEstrada; RadarInfo radar = regraRadar.calcularRadar(local, distanciaRadar); if (radar != null) { local.Distancia = regraRadar.calcularDistancia(local.Latitude, local.Longitude, radar.Latitude, radar.Longitude); if (PreferenciaUtils.AlertaInteligente) { if ((local.Velocidade - 5) > radar.Velocidade) { avisarRadar(local, radar); } } else { avisarRadar(local, radar); } } } 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); } catch (Exception e) { ErroPage.exibir(e); } }
public static PercursoBLL create() { if (_Percurso == null) { _Percurso = new PercursoBLL(); } return(_Percurso); }
protected override void OnAppearing() { base.OnAppearing(); PercursoBLL regraPercurso = PercursoFactory.create(); var percursos = regraPercurso.listar(); this.BindingContext = percursos; PercursoUtils.PaginaAtual = this; }
protected override void OnAppearing() { PercursoBLL regraPercurso = PercursoFactory.create(); percursoListView.ItemTemplate = new DataTemplate(typeof(PercursoPageCell)); percursoListView.SetBinding(ListView.ItemsSourceProperty, new Binding(".")); var percursos = regraPercurso.listar(); //desc.VerticalOptions = LayoutOptions.Center; desc.HorizontalOptions = LayoutOptions.Fill; desc.WidthRequest = TelaUtils.LarguraSemPixel * 0.7; 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"); 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); if (percursos.Count > 0) { //percursoListView.SetBinding(Label.TextProperty, new Binding("Data")); this.BindingContext = percursos; } }
private void gravarPercurso() { PercursoBLL regraPercurso = PercursoFactory.create(); if (regraPercurso.iniciarGravacao()) { _RootLayout.Children.Remove(_GravarButton); _RootLayout.Children.Add(_PararButton); } else { MensagemUtils.avisar("Não foi possível iniciar a gravação!"); } }
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); }
private async void pararPercurso() { var retorno = await DisplayActionSheet("Tem certeza que deseja parar a gravação?", null, null, "Parar", "Continuar gravando"); if (retorno == "Parar") { PercursoBLL regraPercurso = PercursoFactory.create(); if (regraPercurso.pararGravacao()) { _RootLayout.Children.Remove(_PararButton); _RootLayout.Children.Add(_GravarButton); var percursos = regraPercurso.listar(); _PercursoListView.BindingContext = percursos; } else { MensagemUtils.avisar("Não foi possível parar a gravação!"); } } }
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 } }; }
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; }
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); }
void gravarPercurso(object sender, EventArgs e) { //Label gravarButton = (Label)sender; PercursoBLL regraPercurso = PercursoFactory.create(); if (PercursoBLL.Gravando) { if (regraPercurso.pararGravacao()) { gravarLabel.Text = "Gravar Percurso!"; infoLabel.Text = "Toque aqui para iniciar a gravação"; stackDescricaoGravando.Children.Add(gravarLabel); stackDescricaoGravando.Children.Add(infoLabel); stackDescricaoGravando.Children.Remove(desc); icoPlay.Source = ImageSource.FromFile("Play.png"); Emagine.Utils.MensagemUtils.avisar("Gravação finalizada!"); Emagine.Utils.MensagemUtils.pararNotificaoPermanente(PercursoBLL.NOTIFICACAO_GRAVAR_PERCURSO_ID); var percursos = regraPercurso.listar(); percursoListView.BindingContext = percursos; percursoListView.ItemTemplate = new DataTemplate(typeof(PercursoPageCell)); percursoListView.SetBinding(ListView.ItemsSourceProperty, new Binding(".")); } else { Emagine.Utils.MensagemUtils.avisar("Não foi possível parar a gravação!"); } } else { if (regraPercurso.iniciarGravacao((s2, e2) => { tempoCorrendo.Text = e2.Ponto.TempoGravacao.ToString(); tempoParado.Text = e2.Ponto.TempoParadoStr; paradas.Text = e2.Ponto.QuantidadeParadaStr; velocidadeMedia.Text = e2.Ponto.VelocidadeMediaStr; velocidadeMaxima.Text = e2.Ponto.VelocidadeMaximaStr; radares.Text = e2.Ponto.QuantidadeRadarStr; })) { stackDescricaoGravando.Children.Remove(gravarLabel); stackDescricaoGravando.Children.Remove(infoLabel); stackDescricaoGravando.Children.Add(desc); /* * //PercursoInfo percursoInfo = new PercursoInfo(); * * tempoCorrendo.Text = percursoInfo.TempoGravacaoStr ; * * tempoParado.Text = percursoInfo.TempoParadoStr; * * paradas.Text = percursoInfo.QuantidadeParadaStr; * * velocidadeMedia.Text = percursoInfo.VelocidadeMediaStr; * * velocidadeMaxima.Text = percursoInfo.VelocidadeMaximaStr; * * radares.Text = percursoInfo.QuantidadeRadarStr; */ icoPlay.Source = ImageSource.FromFile("Stop.png"); Emagine.Utils.MensagemUtils.avisar("Iniciando gravação do percurso!"); Emagine.Utils.MensagemUtils.notificarPermanente( PercursoBLL.NOTIFICACAO_GRAVAR_PERCURSO_ID, "Gravando Percurso...", "", PercursoBLL.NOTIFICACAO_PARAR_PERCURSO_ID, "Parar", PercursoBLL.ACAO_PARAR_GRAVACAO ); } else { Emagine.Utils.MensagemUtils.avisar("Não foi possível iniciar a gravação!"); } } }