criado dialogo padrao

This commit is contained in:
Diego Freitas 2025-03-26 14:42:33 -03:00
parent 9338e6d39b
commit 58162c62f9
38 changed files with 923 additions and 153 deletions

Binary file not shown.

View File

@ -3,20 +3,12 @@
"WorkspaceRootPath": "C:\\ZendionINC\\agrobot_base\\AgroBase\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|c:\\zendioninc\\agrobot_base\\agrobase\\agrobase\\models\\variaveis.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\models\\variaveis.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|c:\\zendioninc\\agrobot_base\\agrobase\\agrobase\\models\\mapasmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\models\\mapasmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|C:\\ZendionINC\\agrobot_base\\AgroBase\\agrobase\\models\\operacoes\\operacaomodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\models\\operacoes\\operacaomodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|C:\\ZendionINC\\agrobot_base\\AgroBase\\agrobase\\models\\operacoes\\operacaomapagpsmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\models\\operacoes\\operacaomapagpsmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|c:\\zendioninc\\agrobot_base\\agrobase\\agrobase\\models\\trajetoriamapaoperacaomodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\models\\trajetoriamapaoperacaomodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|c:\\zendioninc\\agrobot_base\\agrobase\\agrobase\\forms\\frmsimulacaomapagps.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form",
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\forms\\frmsimulacaomapagps.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form"
}
],
"DocumentGroupContainers": [
@ -31,54 +23,27 @@
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "Variaveis.cs",
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Variaveis.cs",
"RelativeDocumentMoniker": "AgroBase\\Models\\Variaveis.cs",
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Variaveis.cs",
"RelativeToolTip": "AgroBase\\Models\\Variaveis.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAKsEAAAAAAAA",
"Title": "MapasModel.cs",
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\MapasModel.cs",
"RelativeDocumentMoniker": "AgroBase\\Models\\MapasModel.cs",
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\MapasModel.cs",
"RelativeToolTip": "AgroBase\\Models\\MapasModel.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABQAAABLAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-03-20T12:50:31.51Z",
"WhenOpened": "2025-03-26T16:57:44.581Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "OperacaoModel.cs",
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Operacoes\\OperacaoModel.cs",
"RelativeDocumentMoniker": "AgroBase\\Models\\Operacoes\\OperacaoModel.cs",
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Operacoes\\OperacaoModel.cs",
"RelativeToolTip": "AgroBase\\Models\\Operacoes\\OperacaoModel.cs",
"ViewState": "AQIAAAwBAAAAAAAAAIA4wLUFAAAtAAAA",
"Title": "frmSimulacaoMapaGPS.cs [Design]",
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Forms\\frmSimulacaoMapaGPS.cs",
"RelativeDocumentMoniker": "AgroBase\\Forms\\frmSimulacaoMapaGPS.cs",
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Forms\\frmSimulacaoMapaGPS.cs [Design]",
"RelativeToolTip": "AgroBase\\Forms\\frmSimulacaoMapaGPS.cs [Design]",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-03-19T22:01:26.068Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "OperacaoMapaGPSModel.cs",
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Operacoes\\OperacaoMapaGPSModel.cs",
"RelativeDocumentMoniker": "AgroBase\\Models\\Operacoes\\OperacaoMapaGPSModel.cs",
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Operacoes\\OperacaoMapaGPSModel.cs",
"RelativeToolTip": "AgroBase\\Models\\Operacoes\\OperacaoMapaGPSModel.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABEAAAAIAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-03-18T11:05:46.524Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "TrajetoriaMapaOperacaoModel.cs",
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\TrajetoriaMapaOperacaoModel.cs",
"RelativeDocumentMoniker": "AgroBase\\Models\\TrajetoriaMapaOperacaoModel.cs",
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\TrajetoriaMapaOperacaoModel.cs",
"RelativeToolTip": "AgroBase\\Models\\TrajetoriaMapaOperacaoModel.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAMACAAAsAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-03-18T10:53:08.916Z",
"EditorCaption": ""
"WhenOpened": "2025-03-26T16:57:39.849Z",
"EditorCaption": " [Design]"
}
]
}

File diff suppressed because one or more lines are too long

View File

@ -431,11 +431,14 @@
<DependentUpon>frmSonar.cs</DependentUpon>
</Compile>
<Compile Include="Models\AlarmeModel.cs" />
<Compile Include="Models\AsyncTaskTimerModel.cs" />
<Compile Include="Models\Components\AsyncTaskTimerModel.cs" />
<Compile Include="Models\BLD300RModel.cs" />
<Compile Include="Models\CameraCaminhoModel.cs" />
<Compile Include="Models\CameraModel.cs" />
<Compile Include="Models\CameraSoloModel.cs" />
<Compile Include="Models\Components\CustomDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Models\DispositivosModel.cs" />
<Compile Include="Models\GPSModel.cs" />
<Compile Include="Models\GraficoInterativoModel.cs" />

View File

@ -1,4 +1,5 @@
using AgroBase.Models;
using AgroBase.Models.Components;
using AgroBase.Services;
using System;
using System.Collections.Generic;
@ -48,7 +49,15 @@ namespace AgroBase.Forms.IHM
KinectService.SalvarParametros();
}
MessageBox.Show("Configuração de câmeras salva com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
CustomDialog.ShowDialog(
"Sucesso",
"Configuração de câmeras salva com sucesso!",
MessageBoxIcon.Information,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } }
}
);
});
FuncoesGlobais.DefinirEventosPicBtn(picAtualizar, "Erro ao atualizar lista de câmeras!", async () =>
{
@ -62,7 +71,15 @@ namespace AgroBase.Forms.IHM
}
else
{
MessageBox.Show("Módulo LoRa de comunicação não está conectado ou não está no modo de parametrização!", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning);
CustomDialog.ShowDialog(
"Alerta",
"Módulo LoRa de comunicação não está conectado ou não está no modo de parametrização!",
MessageBoxIcon.Warning,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } }
}
);
}
});
FuncoesGlobais.DefinirEventosPicBtn(picGravar, "Erro ao salvar parâmetros de comunicação!", async () =>
@ -82,11 +99,27 @@ namespace AgroBase.Forms.IHM
await ConfigurarModulo(Parametros);
MessageBox.Show("Configuração de comunicação salva com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
CustomDialog.ShowDialog(
"Sucesso",
"Configuração de comunicação salva com sucesso!",
MessageBoxIcon.Information,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } }
}
);
}
else
{
MessageBox.Show("Módulo LoRa de comunicação não está conectado ou não está no modo de parametrização!", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning);
CustomDialog.ShowDialog(
"Alerta",
"Módulo LoRa de comunicação não está conectado ou não está no modo de parametrização!",
MessageBoxIcon.Warning,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } }
}
);
}
});
@ -120,7 +153,15 @@ namespace AgroBase.Forms.IHM
if (!sucesso)
{
MessageBox.Show("Erro ao requisitar parâmetros! Verifique o modo do módulo LoRa!");
CustomDialog.ShowDialog(
"Erro",
"Erro ao requisitar parâmetros! Verifique o modo do módulo LoRa!",
MessageBoxIcon.Error,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } }
}
);
}
Parametros = par;
@ -159,31 +200,71 @@ namespace AgroBase.Forms.IHM
{
if (Parametros.address == Variaveis.OperacaoEmAndamento.DispSen.Dados.LoRaParametrosBase.address)
{
MessageBox.Show("O endereço informado já está sendo usado pelo módulo de comunicação LoRa da base!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
CustomDialog.ShowDialog(
"Erro",
"O endereço informado já está sendo usado pelo módulo de comunicação LoRa da base!",
MessageBoxIcon.Error,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } }
}
);
return;
}
var Sucesso = await Variaveis.ConexaoLoRa.ConfigurarModuloAsync(Parametros);
if (Sucesso != null)
{
MessageBox.Show("Módulo de comunicação LoRa configurado com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
CustomDialog.ShowDialog(
"Sucesso",
"Módulo de comunicação LoRa configurado com sucesso!",
MessageBoxIcon.Information,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } }
}
);
}
else
{
MessageBox.Show("Erro ao configurar módulo de comunicação LoRa!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
CustomDialog.ShowDialog(
"Erro",
"Erro ao configurar módulo de comunicação LoRa!",
MessageBoxIcon.Error,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } }
}
);
}
}
else
{
if (Parametros.address == Variaveis.ConexaoLoRa.parametros.address)
{
MessageBox.Show("O endereço informado já está sendo usado pelo módulo de comunicação LoRa do equipamento!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
CustomDialog.ShowDialog(
"Erro",
"O endereço informado já está sendo usado pelo módulo de comunicação LoRa do equipamento!",
MessageBoxIcon.Error,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } }
}
);
return;
}
Variaveis.OperacaoEmAndamento.DispSen.Dados.LoRaParametrosBase = Parametros;
Variaveis.OperacaoEmAndamento.DispSen.SalvarParametros(Variaveis.OperacaoEmAndamento.DispSen.Dados);
MessageBox.Show("Configuração do módulo de comunicação LoRa da base realizado com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
CustomDialog.ShowDialog(
"Sucesso",
"Configuração do módulo de comunicação LoRa da base realizado com sucesso!",
MessageBoxIcon.Information,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } }
}
);
}
await AtualizarParametros();
}
@ -231,7 +312,15 @@ namespace AgroBase.Forms.IHM
if (CameraCaminho.combo.SelectedIndex > 0 && (Variaveis.OperacaoEmAndamento.CamerasSolo.Any(x => x.combo.SelectedIndex == CameraCaminho.combo.SelectedIndex)))
{
MessageBox.Show("Essa câmera já está sendo usada por outro processo!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning);
CustomDialog.ShowDialog(
"Erro",
"Essa câmera já está sendo usada por outro processo!",
MessageBoxIcon.Warning,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } }
}
);
CameraCaminho.combo.SelectedIndex = CameraCaminho.camera.cameraIndex;
return;
}
@ -313,7 +402,15 @@ namespace AgroBase.Forms.IHM
if (CameraSolo.combo.SelectedIndex > 0 && (cmbC.SelectedIndex == CameraSolo.combo.SelectedIndex || Variaveis.OperacaoEmAndamento.CamerasSolo.Any(x => x.Nome != CameraSolo.Nome && x.combo.SelectedIndex == CameraSolo.combo.SelectedIndex)))
{
MessageBox.Show("Essa câmera já está sendo usada por outro processo!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning);
CustomDialog.ShowDialog(
"Erro",
"Essa câmera já está sendo usada por outro processo!",
MessageBoxIcon.Warning,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } }
}
);
CameraSolo.combo.SelectedIndex = CameraSolo.camera.cameraIndex;
return;
}

View File

@ -2,6 +2,7 @@
using AForge.Video.DirectShow;
using AgroBase.Comum;
using AgroBase.Models;
using AgroBase.Models.Components;
using AgroBase.Models.Modules;
using AgroBase.Services;
using System;
@ -48,7 +49,18 @@ namespace AgroBase.Forms.IHM
return;
}
if (MessageBox.Show("Iniciar o diagnóstico completo do equipamento?", "Iniciar Diagnóstico", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
var res = CustomDialog.ShowDialog(
"Iniciar Diagnóstico",
"Iniciar o diagnóstico completo do equipamento?",
MessageBoxIcon.Question,
new Dictionary<(string, DialogResult?), Action>()
{
{ ("Sim", DialogResult.Yes), () => { } },
{ ("Não", DialogResult.No), () => { } },
}
);
if (res == DialogResult.Yes)
{
picLoading.Image = Properties.Resources.loading;
@ -72,7 +84,15 @@ namespace AgroBase.Forms.IHM
picLoading.Image = null;
MessageBox.Show($"Diagnóstico completo do equipamento concluído com sucesso!", "Diagnóstico Concluído", MessageBoxButtons.OK, MessageBoxIcon.Information);
CustomDialog.ShowDialog(
"Diagnóstico Concluído",
"Diagnóstico completo do equipamento concluído com sucesso!",
MessageBoxIcon.Information,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } },
}
);
}
});
FuncoesGlobais.DefinirEventosPicBtn(picIniciarDiagnostico, "Erro ao realizar diagnóstico do módulo " + tabControl1.SelectedTab.Text, async () =>
@ -83,7 +103,17 @@ namespace AgroBase.Forms.IHM
}
string ModuloSelecionado = tabControl1.SelectedTab.Text;
if (MessageBox.Show("Iniciar o diagnóstico do módulo " + ModuloSelecionado + "?", "Iniciar Diagnóstico", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
var res = CustomDialog.ShowDialog(
"Iniciar Diagnóstico",
$"Iniciar o diagnóstico do módulo {ModuloSelecionado}?",
MessageBoxIcon.Question,
new Dictionary<(string, DialogResult?), Action>()
{
{ ("Sim", DialogResult.Yes), () => { } },
{ ("Não", DialogResult.No), () => { } },
}
);
if (res == DialogResult.Yes)
{
picLoading.Image = Properties.Resources.loading;
@ -94,11 +124,27 @@ namespace AgroBase.Forms.IHM
if (Sucesso)
{
MessageBox.Show($"Diagnóstico do módulo {ModuloSelecionado} concluído com sucesso!", "Diagnóstico Concluído", MessageBoxButtons.OK, MessageBoxIcon.Information);
CustomDialog.ShowDialog(
"Diagnóstico Concluído",
$"Diagnóstico do módulo {ModuloSelecionado} concluído com sucesso!",
MessageBoxIcon.Information,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } },
}
);
}
else
{
MessageBox.Show($"Diagnóstico do módulo {ModuloSelecionado} concluído com erro!", "Diagnóstico Concluído", MessageBoxButtons.OK, MessageBoxIcon.Error);
CustomDialog.ShowDialog(
"Diagnóstico Concluído",
$"Diagnóstico do módulo {ModuloSelecionado} concluído com erro!",
MessageBoxIcon.Error,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } },
}
);
}
}
});

View File

@ -1,4 +1,5 @@
using AgroBase.Models;
using AgroBase.Models.Components;
using AgroBase.Services;
using System;
using System.Collections.Generic;
@ -41,7 +42,17 @@ namespace AgroBase.Forms.IHM
{
if (Variaveis.OperacaoEmAndamento.Iniciado)
{
if (MessageBox.Show("Tem certeza que deseja interromper a operação em andamento?", "Interromper Operação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
var res = CustomDialog.ShowDialog(
"Interromper Operação",
"Tem certeza que deseja interromper a operação em andamento?",
MessageBoxIcon.Question,
new Dictionary<(string, DialogResult?), Action>()
{
{ ("Sim", DialogResult.Yes), () => { } },
{ ("Não", DialogResult.No), () => { } },
}
);
if (res == DialogResult.Yes)
{
Variaveis.OperacaoEmAndamento.FinalizarOperacao();
if (Variaveis.OperacaoEmAndamento.Modo == Enums.ModoOperacao.Manual)
@ -526,7 +537,15 @@ namespace AgroBase.Forms.IHM
private void btnCodFalha_Click(object sender, EventArgs e)
{
string DescricaoFalha = OperacaoModel.DescricaoCodigoFalha(CodigoFalha);
MessageBox.Show($"{DescricaoFalha}", "Código de Falha", MessageBoxButtons.OK, MessageBoxIcon.Information);
CustomDialog.ShowDialog(
"Código de Falha",
$"{DescricaoFalha}",
MessageBoxIcon.Question,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } },
}
);
}
}

View File

@ -1,8 +1,10 @@
using AgroBase.Forms.Operacoes;
using AgroBase.Models;
using AgroBase.Models.Components;
using AgroBase.Properties;
using AgroBase.Services;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Drawing;
@ -48,12 +50,30 @@ namespace AgroBase.Forms.IHM
}
else
{
MessageBox.Show(Variaveis.OperacaoEmAndamento.ErroOperacaoLiberada, "Iniciar Operação Manual", MessageBoxButtons.OK, MessageBoxIcon.Error);
CustomDialog.ShowDialog(
"Iniciar Operação Manual",
$"{Variaveis.OperacaoEmAndamento.ErroOperacaoLiberada}",
MessageBoxIcon.Error,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } },
}
);
}
});
FuncoesGlobais.DefinirEventosPicBtn(picDesligar, "Erro ao desligar equipamento!", async () =>
{
if (MessageBox.Show("Deseja desligar o equipamento?", "Desligar", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
var res = CustomDialog.ShowDialog(
"Desligar",
"Deseja Desligar o Equipamento?",
MessageBoxIcon.Question,
new Dictionary<(string, DialogResult?), Action>()
{
{ ("Sim", DialogResult.Yes), () => { } },
{ ("Não", DialogResult.No), () => { } },
}
);
if (res == DialogResult.Yes)
{
if (frmInstancial.DebugMode)
{
@ -74,19 +94,30 @@ namespace AgroBase.Forms.IHM
var arquivosNaoEncontrados = VersionamentoService.ArquivosNaoEncontrados.ToList();
bool sucesso = !arquivosNaoEncontrados.Any();
MessageBox.Show(
CustomDialog.ShowDialog(
"Resultado",
"Atualização concluída com " + (sucesso ? "sucesso" : "falha") + "!\r\n\r\n" +
(!sucesso ?
(!sucesso ?
("Arquivos não encontrados:\r\n\r\n" + string.Join("\r\n", arquivosNaoEncontrados)) :
"Nenhum arquivo pendente!"),
"Resultado",
MessageBoxButtons.OK,
sucesso ? MessageBoxIcon.Asterisk : MessageBoxIcon.Error
"Nenhum arquivo pendente!"),
sucesso ? MessageBoxIcon.Asterisk : MessageBoxIcon.Error,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } },
}
);
}
else
{
MessageBox.Show("Impossível procurar por atualizações!", "Equipamento desconectado", MessageBoxButtons.OK, MessageBoxIcon.Warning);
CustomDialog.ShowDialog(
"Equipamento Desconectado",
"Impossível procurar por atualizações!",
MessageBoxIcon.Warning,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } },
}
);
}
});
}
@ -253,7 +284,15 @@ namespace AgroBase.Forms.IHM
private void LblCodigoFalha_Click(object sender, EventArgs e)
{
string DescricaoFalha = OperacaoModel.DescricaoCodigoFalha(CodFalha);
MessageBox.Show($"{DescricaoFalha}", "Código de Falha", MessageBoxButtons.OK, MessageBoxIcon.Information);
CustomDialog.ShowDialog(
"Código de Falha",
$"{DescricaoFalha}",
MessageBoxIcon.Information,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } },
}
);
}
private void lblModulo_Click(object sender, EventArgs e)
@ -278,11 +317,14 @@ namespace AgroBase.Forms.IHM
""
);
var res = MessageBox.Show(
msg,
CustomDialog.ShowDialog(
"Detalhes",
Modulo != null && Modulo.Conectado ? MessageBoxButtons.OK : MessageBoxButtons.RetryCancel,
Modulo != null && Modulo.Erro ? MessageBoxIcon.Error : Modulo != null && Modulo.Conectado ? MessageBoxIcon.Information : MessageBoxIcon.Exclamation
$"{msg}",
Modulo != null && Modulo.Erro ? MessageBoxIcon.Error : Modulo != null && Modulo.Conectado ? MessageBoxIcon.Information : MessageBoxIcon.Exclamation,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } },
}
);
}

View File

@ -1,5 +1,6 @@
using AgroBase.Forms.IHM;
using AgroBase.Models;
using AgroBase.Models.Components;
using System;
using System.Collections.Generic;
using System.Data;
@ -49,7 +50,17 @@ namespace AgroBase.Forms.Operacoes
{
if (Variaveis.OperacaoEmAndamento.OperacaoLiberada)
{
if (MessageBox.Show("Deseja iniciar a operação selecionada?", "Iniciar Operação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
var res = CustomDialog.ShowDialog(
"Iniciar Operação",
"Deseja iniciar a operação selecionada?",
MessageBoxIcon.Question,
new Dictionary<(string, DialogResult?), Action>()
{
{ ("Sim", DialogResult.Yes), () => { } },
{ ("Não", DialogResult.No), () => { } },
}
);
if (res == DialogResult.Yes)
{
frmDialogo.Show();
await frmDialogo.AtualizarRuasSelecionadas(ruasSelecionadas);
@ -58,18 +69,44 @@ namespace AgroBase.Forms.Operacoes
}
else
{
MessageBox.Show(Variaveis.OperacaoEmAndamento.ErroOperacaoLiberada, "Conexão de módulos pendentes", MessageBoxButtons.OK, MessageBoxIcon.Warning);
CustomDialog.ShowDialog(
"Conexão de módulos pendentes",
$"{Variaveis.OperacaoEmAndamento.ErroOperacaoLiberada}",
MessageBoxIcon.Warning,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } },
}
);
}
});
FuncoesGlobais.DefinirEventosPicBtn(picExcluir, "Erro ao excluir operação!", async () =>
{
if (pathOperacaoSelecionada.Contains(CaminhoOperacoesSistema))
{
if (MessageBox.Show("Tem certeza que deseja excluir a operação do sistema?", "Excluir Operação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
var res = CustomDialog.ShowDialog(
"Excluir Operação",
"Tem certeza que deseja excluir a operação do sistema?",
MessageBoxIcon.Question,
new Dictionary<(string, DialogResult?), Action>()
{
{ ("Sim", DialogResult.Yes), () => { } },
{ ("Não", DialogResult.No), () => { } },
}
);
if (res == DialogResult.Yes)
{
File.Delete(pathOperacaoSelecionada);
MessageBox.Show("Operação excluída da memória do equipamento com sucesso!", "Excluir Operação", MessageBoxButtons.OK, MessageBoxIcon.Information);
CustomDialog.ShowDialog(
"Excluir Operação",
"Operação excluída da memória do equipamento com sucesso!",
MessageBoxIcon.Information,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } },
}
);
LoadDirectoryFiles(txtCaminho.Text);
}
@ -88,7 +125,15 @@ namespace AgroBase.Forms.Operacoes
File.Copy(pathOperacaoSelecionada, CaminhoOperacoesSistema + fileName);
MessageBox.Show("Operação copiada da mídia para a memória do equipamento com sucesso!", "Copiar Operação", MessageBoxButtons.OK, MessageBoxIcon.Information);
CustomDialog.ShowDialog(
"Copiar Operação",
"Operação copiada da mídia para a memória do equipamento com sucesso!",
MessageBoxIcon.Information,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } },
}
);
}
});
@ -145,7 +190,15 @@ namespace AgroBase.Forms.Operacoes
}
catch (Exception ex)
{
MessageBox.Show($"Erro ao listar arquivos e pastas: {ex.Message}");
CustomDialog.ShowDialog(
"Erro",
$"Erro ao listar arquivos e pastas: {ex.Message}",
MessageBoxIcon.Error,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } },
}
);
}
}
@ -177,7 +230,15 @@ namespace AgroBase.Forms.Operacoes
}
catch (Exception ex)
{
MessageBox.Show("Erro ao carregar operação!");
CustomDialog.ShowDialog(
"Erro",
"Erro ao carregar operação!",
MessageBoxIcon.Error,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } },
}
);
}

View File

@ -34,7 +34,6 @@ namespace AgroBase.Forms
this.pnlOrientacaoGps = new System.Windows.Forms.Panel();
this.pnlBotoes = new System.Windows.Forms.Panel();
this.txtDescricao = new System.Windows.Forms.TextBox();
this.lblRuaAtual = new System.Windows.Forms.Label();
this.btnNovaRua = new System.Windows.Forms.Button();
this.btnGerarMapa = new System.Windows.Forms.Button();
this.btnLimpar = new System.Windows.Forms.Button();
@ -44,6 +43,7 @@ namespace AgroBase.Forms
this.btnCarregarMapa = new System.Windows.Forms.Button();
this.dgPontos = new System.Windows.Forms.DataGridView();
this.dgRuas = new System.Windows.Forms.DataGridView();
this.lblRuaAtual = new System.Windows.Forms.Label();
this.pnlMapa.SuspendLayout();
this.pnlBotoes.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgPontos)).BeginInit();
@ -59,7 +59,7 @@ namespace AgroBase.Forms
this.pnlMapa.Location = new System.Drawing.Point(700, 12);
this.pnlMapa.Margin = new System.Windows.Forms.Padding(2);
this.pnlMapa.Name = "pnlMapa";
this.pnlMapa.Size = new System.Drawing.Size(767, 462);
this.pnlMapa.Size = new System.Drawing.Size(767, 438);
this.pnlMapa.TabIndex = 1;
//
// pnlOrientacaoGps
@ -87,35 +87,22 @@ namespace AgroBase.Forms
this.pnlBotoes.Controls.Add(this.lblMapa);
this.pnlBotoes.Controls.Add(this.btnCarregarMapa);
this.pnlBotoes.Dock = System.Windows.Forms.DockStyle.Bottom;
this.pnlBotoes.Location = new System.Drawing.Point(0, 479);
this.pnlBotoes.Location = new System.Drawing.Point(0, 455);
this.pnlBotoes.Margin = new System.Windows.Forms.Padding(2);
this.pnlBotoes.Name = "pnlBotoes";
this.pnlBotoes.Size = new System.Drawing.Size(1476, 46);
this.pnlBotoes.Size = new System.Drawing.Size(1476, 79);
this.pnlBotoes.TabIndex = 2;
//
// txtDescricao
//
this.txtDescricao.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.txtDescricao.Location = new System.Drawing.Point(763, 15);
this.txtDescricao.Location = new System.Drawing.Point(556, 15);
this.txtDescricao.Name = "txtDescricao";
this.txtDescricao.Size = new System.Drawing.Size(100, 20);
this.txtDescricao.TabIndex = 7;
//
// lblRuaAtual
//
this.lblRuaAtual.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lblRuaAtual.AutoSize = true;
this.lblRuaAtual.Location = new System.Drawing.Point(868, 18);
this.lblRuaAtual.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblRuaAtual.Name = "lblRuaAtual";
this.lblRuaAtual.Size = new System.Drawing.Size(66, 13);
this.lblRuaAtual.TabIndex = 6;
this.lblRuaAtual.Text = "Rua Atual: 1";
//
// btnNovaRua
//
this.btnNovaRua.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnNovaRua.Location = new System.Drawing.Point(1058, 11);
this.btnNovaRua.Location = new System.Drawing.Point(556, 42);
this.btnNovaRua.Margin = new System.Windows.Forms.Padding(2);
this.btnNovaRua.Name = "btnNovaRua";
this.btnNovaRua.Size = new System.Drawing.Size(100, 26);
@ -126,8 +113,7 @@ namespace AgroBase.Forms
//
// btnGerarMapa
//
this.btnGerarMapa.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnGerarMapa.Location = new System.Drawing.Point(1266, 11);
this.btnGerarMapa.Location = new System.Drawing.Point(768, 11);
this.btnGerarMapa.Margin = new System.Windows.Forms.Padding(2);
this.btnGerarMapa.Name = "btnGerarMapa";
this.btnGerarMapa.Size = new System.Drawing.Size(100, 26);
@ -138,8 +124,7 @@ namespace AgroBase.Forms
//
// btnLimpar
//
this.btnLimpar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnLimpar.Location = new System.Drawing.Point(1162, 11);
this.btnLimpar.Location = new System.Drawing.Point(768, 42);
this.btnLimpar.Margin = new System.Windows.Forms.Padding(2);
this.btnLimpar.Name = "btnLimpar";
this.btnLimpar.Size = new System.Drawing.Size(100, 26);
@ -151,7 +136,7 @@ namespace AgroBase.Forms
// lblStatusGPS
//
this.lblStatusGPS.AutoSize = true;
this.lblStatusGPS.Location = new System.Drawing.Point(260, 17);
this.lblStatusGPS.Location = new System.Drawing.Point(9, 57);
this.lblStatusGPS.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblStatusGPS.Name = "lblStatusGPS";
this.lblStatusGPS.Size = new System.Drawing.Size(463, 13);
@ -161,8 +146,7 @@ namespace AgroBase.Forms
//
// btnRegistrarrPonto
//
this.btnRegistrarrPonto.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnRegistrarrPonto.Location = new System.Drawing.Point(954, 11);
this.btnRegistrarrPonto.Location = new System.Drawing.Point(664, 42);
this.btnRegistrarrPonto.Margin = new System.Windows.Forms.Padding(2);
this.btnRegistrarrPonto.Name = "btnRegistrarrPonto";
this.btnRegistrarrPonto.Size = new System.Drawing.Size(100, 26);
@ -184,12 +168,12 @@ namespace AgroBase.Forms
// btnCarregarMapa
//
this.btnCarregarMapa.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnCarregarMapa.Location = new System.Drawing.Point(1370, 11);
this.btnCarregarMapa.Location = new System.Drawing.Point(1367, 42);
this.btnCarregarMapa.Margin = new System.Windows.Forms.Padding(2);
this.btnCarregarMapa.Name = "btnCarregarMapa";
this.btnCarregarMapa.Size = new System.Drawing.Size(98, 26);
this.btnCarregarMapa.TabIndex = 0;
this.btnCarregarMapa.Text = "Carregar mapa";
this.btnCarregarMapa.Text = "Carregar Mapa";
this.btnCarregarMapa.UseVisualStyleBackColor = true;
this.btnCarregarMapa.Click += new System.EventHandler(this.btnCarregarMapa_Click);
//
@ -200,7 +184,7 @@ namespace AgroBase.Forms
this.dgPontos.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgPontos.Location = new System.Drawing.Point(12, 189);
this.dgPontos.Name = "dgPontos";
this.dgPontos.Size = new System.Drawing.Size(683, 285);
this.dgPontos.Size = new System.Drawing.Size(683, 261);
this.dgPontos.TabIndex = 4;
this.dgPontos.UserDeletedRow += new System.Windows.Forms.DataGridViewRowEventHandler(this.dgPontos_UserDeletedRow);
this.dgPontos.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.dgPontos_UserDeletingRow);
@ -216,11 +200,21 @@ namespace AgroBase.Forms
this.dgRuas.UserDeletedRow += new System.Windows.Forms.DataGridViewRowEventHandler(this.dgRuas_UserDeletedRow);
this.dgRuas.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.dgRuas_UserDeletingRow);
//
// lblRuaAtual
//
this.lblRuaAtual.AutoSize = true;
this.lblRuaAtual.Location = new System.Drawing.Point(661, 18);
this.lblRuaAtual.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblRuaAtual.Name = "lblRuaAtual";
this.lblRuaAtual.Size = new System.Drawing.Size(66, 13);
this.lblRuaAtual.TabIndex = 6;
this.lblRuaAtual.Text = "Rua Atual: 1";
//
// frmMapa
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1476, 525);
this.ClientSize = new System.Drawing.Size(1476, 534);
this.Controls.Add(this.dgRuas);
this.Controls.Add(this.dgPontos);
this.Controls.Add(this.pnlBotoes);
@ -253,8 +247,8 @@ namespace AgroBase.Forms
private System.Windows.Forms.DataGridView dgPontos;
private System.Windows.Forms.Button btnGerarMapa;
private System.Windows.Forms.Button btnNovaRua;
private System.Windows.Forms.Label lblRuaAtual;
private System.Windows.Forms.TextBox txtDescricao;
private System.Windows.Forms.DataGridView dgRuas;
private System.Windows.Forms.Label lblRuaAtual;
}
}

View File

@ -0,0 +1,166 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace AgroBase.Models.Components
{
public class CustomDialog : Form
{
private Label labelMensagem;
private PictureBox pictureBoxIcone;
private dynamic resultadoSelecionado = null;
private CustomDialog(string titulo, string mensagem, MessageBoxIcon icone, Dictionary<(string, dynamic), Action> botoes)
{
this.Text = titulo;
this.FormBorderStyle = FormBorderStyle.FixedDialog;
this.StartPosition = FormStartPosition.CenterScreen;
this.MinimizeBox = false;
this.MaximizeBox = false;
this.ShowInTaskbar = false;
this.Font = new Font("Segoe UI", 10);
this.Padding = new Padding(10);
this.TopMost = true;
this.AutoSize = true;
this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
// Layout principal (vertical)
var layoutPrincipal = new TableLayoutPanel
{
Dock = DockStyle.Fill,
AutoSize = true,
AutoSizeMode = AutoSizeMode.GrowAndShrink,
Padding = new Padding(10),
ColumnCount = 1,
RowCount = 2
};
// Layout conteúdo (ícone + mensagem)
var layoutConteudo = new TableLayoutPanel
{
ColumnCount = 2,
AutoSize = true,
AutoSizeMode = AutoSizeMode.GrowAndShrink,
Dock = DockStyle.Top,
Margin = new Padding(0, 0, 0, 10)
};
layoutConteudo.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
layoutConteudo.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
pictureBoxIcone = new PictureBox()
{
Size = new Size(48, 48),
SizeMode = PictureBoxSizeMode.StretchImage,
Image = ObterIcone(icone),
Anchor = AnchorStyles.Top
};
labelMensagem = new Label()
{
Text = mensagem,
AutoSize = true,
MaximumSize = new Size(320, 0),
TextAlign = ContentAlignment.TopLeft,
Anchor = AnchorStyles.Left | AnchorStyles.Top
};
layoutConteudo.Controls.Add(pictureBoxIcone, 0, 0);
layoutConteudo.Controls.Add(labelMensagem, 1, 0);
// Layout de botões
int colunas = 2;
var layoutBotoes = new TableLayoutPanel
{
ColumnCount = colunas,
AutoSize = true,
AutoSizeMode = AutoSizeMode.GrowAndShrink,
Dock = DockStyle.Bottom
};
for (int c = 0; c < colunas; c++)
layoutBotoes.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50));
int row = 0, col = 0;
layoutBotoes.RowCount = 0;
foreach (var botao in botoes)
{
var btn = new Button()
{
Text = botao.Key.Item1,
Anchor = AnchorStyles.None,
AutoSize = true,
Margin = new Padding(10),
Padding = new Padding(10, 5, 10, 5),
MinimumSize = new Size(140, 0)
};
btn.Click += (s, e) =>
{
resultadoSelecionado = botao.Key.Item2;
this.Close();
botao.Value?.Invoke();
};
if (col == 0)
{
layoutBotoes.RowCount++;
layoutBotoes.RowStyles.Add(new RowStyle(SizeType.AutoSize));
}
layoutBotoes.Controls.Add(btn, col, row);
col++;
if (col >= colunas)
{
col = 0;
row++;
}
}
// Adiciona nos painéis
layoutPrincipal.Controls.Add(layoutConteudo);
layoutPrincipal.Controls.Add(layoutBotoes);
this.Controls.Add(layoutPrincipal);
}
public static T ShowDialog<T>(string titulo, string mensagem, MessageBoxIcon icone, Dictionary<(string, T), Action> botoes)
{
T resultado = default(T);
var botoesConvertidos = new Dictionary<(string, dynamic), Action>();
foreach (var kv in botoes)
{
botoesConvertidos.Add((kv.Key.Item1, kv.Key.Item2), kv.Value);
}
using (var dialog = new CustomDialog(titulo, mensagem, icone, botoesConvertidos))
{
dialog.ShowDialog();
resultado = dialog.resultadoSelecionado;
}
return resultado;
}
private Image ObterIcone(MessageBoxIcon icone)
{
switch (icone)
{
case MessageBoxIcon.Information:
return SystemIcons.Information.ToBitmap();
case MessageBoxIcon.Warning:
return SystemIcons.Warning.ToBitmap();
case MessageBoxIcon.Error:
return SystemIcons.Error.ToBitmap();
case MessageBoxIcon.Question:
return SystemIcons.Question.ToBitmap();
default:
return null;
}
}
}
}

View File

@ -286,5 +286,13 @@ namespace AgroBase.Models
LimiteDireita = 5
}
public enum TipoMapaOperacao
{
Indefinido = 0,
GPS = 1,
RuasPlantacao = 2,
Corredores = 3
}
}
}

View File

@ -1,4 +1,5 @@
using AgroBase.Properties;
using AgroBase.Models.Components;
using AgroBase.Properties;
using AgroBase.Services;
using CefSharp.WinForms;
using Newtonsoft.Json;
@ -7,6 +8,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using static AgroBase.Models.Enums;
namespace AgroBase.Models
{
@ -19,12 +21,32 @@ namespace AgroBase.Models
public MapasService mapaService { get; set; } = new MapasService();
public List<List<GPSModel>> TrajetoriaMapa { get; set; } = new List<List<GPSModel>>();
public List<string> RuasPercorrer { get; set; } = new List<string>();
public TipoMapaOperacao TipoMapa { get; set; } = TipoMapaOperacao.Indefinido;
private AsyncTaskTimerModel tmrCarregamento;
public void btnCarregar_Click(object sender, EventArgs e, string caminhoArquivo = "", bool monitoramento = false)
{
var opcoes = Enum.GetValues(typeof(TipoMapaOperacao))
.Cast<TipoMapaOperacao>()
.ToDictionary(
valor => (valor.ToString(), (TipoMapaOperacao?)valor),
valor => (Action)null
);
var tipoMapa = CustomDialog.ShowDialog(
"Tipo de Mapa",
"Qual o tipo de mapa está sendo carregado?",
MessageBoxIcon.Question,
opcoes
);
if (tipoMapa == null)
{
return;
}
mapaService.Carregado = false;
string script = monitoramento ? PythonService.ScriptMapFollower : PythonService.ScriptMapConverter;
@ -46,6 +68,9 @@ namespace AgroBase.Models
{
pnlMapa.Controls.Add(picLoading);
}
TipoMapa = tipoMapa.Value;
tmrCarregamento?.Dispose();
tmrCarregamento = new AsyncTaskTimerModel("tmrCarregamento", tmrCarregamento_Tick, 500, pnlMapa);
tmrCarregamento.Start();
@ -66,6 +91,8 @@ namespace AgroBase.Models
}
mapaService.CarregarMapaGPS(MapasVariaveisModel.NomeArquivoMapaGPS);
TipoMapa = TipoMapaOperacao.GPS;
tmrCarregamento?.Dispose();
tmrCarregamento = new AsyncTaskTimerModel("tmrCarregamento", tmrCarregamento_Tick, 500, pnlMapa);
tmrCarregamento.Start();

View File

@ -558,6 +558,14 @@ namespace AgroBase.Models
double larguraTotal = VariaveisEquipamento.LarguraEsquerda + VariaveisEquipamento.LarguraDireita; // Largura total do robô
double deslocamentoLateralGPS = ((VariaveisEquipamento.LarguraEsquerda - VariaveisEquipamento.LarguraDireita) / larguraTotal) / 2.0;
if (Variaveis.OperacaoEmAndamento.Mapa.TipoMapa == TipoMapaOperacao.Corredores)
{
var ruasProjetadas = ProjetarRuasApartirDosCorredores(RuasPlantacao);
// Atualiza RuasPlantacao com as ruas projetadas
RuasPlantacao = ruasProjetadas;
}
for (int i = 0; i < RuasPlantacao.Count - 1; i++)
{
var rua1 = RuasPlantacao[i];
@ -640,9 +648,72 @@ namespace AgroBase.Models
larguras.Add(larguraCorredor);
}
return (corredores, larguras);
}
private List<List<GPSModel>> ProjetarRuasApartirDosCorredores(List<List<GPSModel>> corredores)
{
var ruasProjetadas = new List<List<GPSModel>>();
double larguraCorredor = LarguraCorredorPadrao;
if (corredores.Count > 1)
{
larguraCorredor = CalcularLarguraMediaDoCorredor(corredores[0], corredores[1]);
}
for (int i = 0; i < corredores.Count; i++)
{
var corredor = corredores[i];
double offset = larguraCorredor / 2.0;
// Calcular ruas apenas para o primeiro corredor
if (i == 0)
{
var ruaEsquerda = new List<GPSModel>();
for (int j = 0; j < corredor.Count - 1; j++)
{
var pontoAtual = corredor[j];
var pontoProximo = corredor[j + 1];
double angulo = GPSUtils.CalcularOrientacao(pontoAtual, pontoProximo);
var pontoEsquerda = GPSUtils.ProjetarPontoDeslocado(pontoAtual, offset, angulo + 90);
ruaEsquerda.Add(pontoEsquerda);
}
// Adiciona último ponto da rua esquerda
var ultimo = corredor[corredor.Count - 1];
var anterior = corredor[corredor.Count - 2];
double anguloFinal = GPSUtils.CalcularOrientacao(anterior, ultimo);
ruaEsquerda.Add(GPSUtils.ProjetarPontoDeslocado(ultimo, offset, anguloFinal + 90));
ruasProjetadas.Add(ruaEsquerda);
}
// Sempre criar a rua direita (inclusive para o último corredor)
var ruaDireita = new List<GPSModel>();
for (int j = 0; j < corredor.Count - 1; j++)
{
var pontoAtual = corredor[j];
var pontoProximo = corredor[j + 1];
double angulo = GPSUtils.CalcularOrientacao(pontoAtual, pontoProximo);
var pontoDireita = GPSUtils.ProjetarPontoDeslocado(pontoAtual, offset, angulo - 90);
ruaDireita.Add(pontoDireita);
}
var ultimoPonto = corredor[corredor.Count - 1];
var pontoAnterior = corredor[corredor.Count - 2];
double anguloUltimo = GPSUtils.CalcularOrientacao(pontoAnterior, ultimoPonto);
ruaDireita.Add(GPSUtils.ProjetarPontoDeslocado(ultimoPonto, offset, anguloUltimo - 90));
ruasProjetadas.Add(ruaDireita);
}
return ruasProjetadas;
}
// Método auxiliar para remover pontos muito próximos de forma balanceada
private List<GPSModel> RemoverPontosMuitoProximos(List<GPSModel> pontos, double distanciaMinima, double apartirDe, double distanciaMenor)

View File

@ -14,6 +14,7 @@ using System.Reflection;
using CefSharp.WinForms;
using System.IO;
using System.Threading;
using AgroBase.Models.Components;
namespace AgroBase.Models
{
@ -732,7 +733,15 @@ namespace AgroBase.Models
catch (Exception ex)
{
// Exibe uma mensagem de erro genérica para qualquer exceção
MessageBox.Show($"{mensagemErro}\nDetalhes: {ex.Message}", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
CustomDialog.ShowDialog(
"Erro",
$"{mensagemErro}\nDetalhes: {ex.Message}",
MessageBoxIcon.Error,
new Dictionary<(string, dynamic), Action>()
{
{ ("OK", null), () => { } },
}
);
}
}
public static void picBtn_MouseEnter(object sender, EventArgs e)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
07c6bb0653ed4366f0cd4e7c9a8e20d266183ca4b30de0ccc664981039497537
baee8a0ca18d340abe8739a630dc7cdec8260037bef83b42509798d9be128a31

View File

@ -482,4 +482,4 @@ C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.GenerateR
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.CoreCompileInputs.cache
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.exe
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.pdb
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.CopyComplete
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.Up2Date

View File

@ -1 +1 @@
{"RootPath":"C:\\ZendionInc\\agrobot_base\\AgroBase\\AgroMonitor","ProjectFileName":"AgroMonitor.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"Forms\\frmAjustesOperacao.cs"},{"SourceFile":"Forms\\frmAjustesOperacao.Designer.cs"},{"SourceFile":"Forms\\frmMonitoramento.cs"},{"SourceFile":"Forms\\frmMonitoramento.Designer.cs"},{"SourceFile":"Forms\\frmInicial.cs"},{"SourceFile":"Forms\\frmInicial.Designer.cs"},{"SourceFile":"Program.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"Properties\\Resources.Designer.cs"},{"SourceFile":"Properties\\Settings.Designer.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"}],"References":[{"Reference":"C:\\ZendionInc\\agrobot_base\\AgroBase\\AgroBase\\bin\\Debug\\AgroBase.exe","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":true,"ProjectPath":""},{"Reference":"C:\\ZendionInc\\agrobot_base\\AgroBase\\AgroMonitor\\bin\\Debug\\CefSharp.WinForms.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\ZendionInc\\agrobot_base\\AgroBase\\packages\\Newtonsoft.Json.13.0.3\\lib\\net45\\Newtonsoft.Json.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Deployment.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Drawing.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Net.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Windows.Forms.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\ZendionInc\\agrobot_base\\AgroBase\\AgroMonitor\\bin\\Debug\\AgroMonitor.exe","OutputItemRelativePath":"AgroMonitor.exe"},{"OutputItemFullPath":"C:\\ZendionInc\\agrobot_base\\AgroBase\\AgroMonitor\\bin\\Debug\\AgroMonitor.pdb","OutputItemRelativePath":"AgroMonitor.pdb"}],"CopyToOutputEntries":[]}
{"RootPath":"C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroMonitor","ProjectFileName":"AgroMonitor.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"Forms\\frmAjustesOperacao.cs"},{"SourceFile":"Forms\\frmAjustesOperacao.Designer.cs"},{"SourceFile":"Forms\\frmMonitoramento.cs"},{"SourceFile":"Forms\\frmMonitoramento.Designer.cs"},{"SourceFile":"Forms\\frmInicial.cs"},{"SourceFile":"Forms\\frmInicial.Designer.cs"},{"SourceFile":"Program.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"Properties\\Resources.Designer.cs"},{"SourceFile":"Properties\\Settings.Designer.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"}],"References":[{"Reference":"C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\bin\\Debug\\AgroBase.exe","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":true,"ProjectPath":""},{"Reference":"C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroMonitor\\bin\\Debug\\CefSharp.WinForms.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\ZendionINC\\agrobot_base\\AgroBase\\packages\\Newtonsoft.Json.13.0.3\\lib\\net45\\Newtonsoft.Json.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Deployment.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Drawing.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Net.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Windows.Forms.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroMonitor\\bin\\Debug\\AgroMonitor.exe","OutputItemRelativePath":"AgroMonitor.exe"},{"OutputItemFullPath":"C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroMonitor\\bin\\Debug\\AgroMonitor.pdb","OutputItemRelativePath":"AgroMonitor.pdb"}],"CopyToOutputEntries":[]}