OliviaAddInPro/ViewModel/Limpieza/PaneLimpiezaViewModel.cs.bak

209 lines
8.4 KiB
C#
Raw Blame History

using OliviaAddInPro.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using OliviaAddInPro.Helper;
using static OliviaAddInPro.Model.ComunDef;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Framework.Contracts;
namespace OliviaAddInPro
{
class PaneLimpiezaViewModel : PanelViewModelBase
{
private PaneLimpiezaSub1ViewModel _subPanel1ViewModel;
Limpieza limp;
public MarchandoUnaDe marchando;
public PaneLimpiezaViewModel()
{
_subPanel1ViewModel = new PaneLimpiezaSub1ViewModel();
_subPanel2ViewModel = new PaneLimpiezaSub2ViewModel();
_subPanel3ViewModel = new PaneLimpiezaSub3ViewModel();
_subPanel4ViewModel = new PaneLimpiezaSub4ViewModel();
OptionsMenu = new ObservableCollection<OptionsMenuItem>
{
new OptionsMenuItem(new BitmapImage(new Uri("pack://application:,,,/OliviaAddInPro;component/Resources/inicio.png")), Resource1.String_tto, _subPanel1ViewModel),
new OptionsMenuItem(new BitmapImage(new Uri("pack://application:,,,/OliviaAddInPro;component/Resources/zonas.png")), Resource1.String_zonif, _subPanel2ViewModel),
new OptionsMenuItem(new BitmapImage(new Uri("pack://application:,,,/OliviaAddInPro;component/Resources/ptosctrl.png")), Resource1.String_ctrol, _subPanel3ViewModel),
new OptionsMenuItem(new BitmapImage(new Uri("pack://application:,,,/OliviaAddInPro;component/Resources/time.png")), Resource1.String_tiempos, _subPanel4ViewModel)
};
SelectedOption = OptionsMenu[0];
limp = OliviaGlob.Limp;
}
public override string DisplayName
{
get { return Resource1.String_header_limpieza; }
}
private ObservableCollection<OptionsMenuItem> _optionsMenu = new ObservableCollection<OptionsMenuItem>();
public ObservableCollection<OptionsMenuItem> OptionsMenu
{
get { return _optionsMenu; }
set { SetProperty(ref _optionsMenu, value, () => OptionsMenu); }
}
private PanelViewModelBase _currentSubPanelPage;
public PanelViewModelBase CurrentSubPanelPage
{
get { return _currentSubPanelPage; }
set { SetProperty(ref _currentSubPanelPage, value, () => CurrentSubPanelPage); }
}
private OptionsMenuItem _selectionOption;
public OptionsMenuItem SelectedOption
{
get { return _selectionOption; }
set {
SetProperty(ref _selectionOption, value, () => SelectedOption);
CurrentSubPanelPage = value.SubPanelViewModel;
}
}
public PaneLimpiezaSub1ViewModel PaneSub1
{
get { return _subPanel1ViewModel; }
}
public bool Lee(out string err_str)
{
err_str = "";
try
{
////////////////////////////////////////////////////////////
///Lee el panel 1
if(!_subPanel1ViewModel.CapaAbierta || string.IsNullOrEmpty(_subPanel1ViewModel.CapaElems))
{
err_str = "No se ha seleccionado ninguna Capa de Limpieza";
return false;
}
limp.CapaElems = _subPanel1ViewModel.CapaElems;
//pone que la capa de elementos es la red navegable, que es la que va a exportar
if (_subPanel1ViewModel.SelOpAmb == 1)
{
limp.CapaElems = OliviaGlob.Paths.PathGdbNw;
}
//lee el tipo tto
if (_subPanel1ViewModel.TipoTto == (int)LimpiezaDef.TiposTto.TtoNoDef)
{
err_str = "No se ha seleccionado ning<6E>n Tipo de Tratamiento";
return false;
}
limp.TipoTto = _subPanel1ViewModel.TipoTto;
limp.TipoTtoStr = LimpiezaDef.tto_gdb[_subPanel1ViewModel.TipoTto];
//lee el/los <20>mbito seleccionado
if (!_subPanel1ViewModel.lee_ambitos())
{
err_str = "No se ha seleccionado ning<6E>n <20>mbito de trabajo";
return false;
}
limp.AmbitosSel = _subPanel1ViewModel.AmbitosSel;
int i = 0;
for (i = 0; i < limp.AmbitosSel.Length; i++)
if (limp.AmbitosSel[i])
break;
if(i>= limp.AmbitosSel.Length)
{
err_str = "No se ha seleccionado ning<6E>n <20>mbito de trabajo";
return false;
}
//lee si respeta circulacion
limp.RespCirc = _subPanel1ViewModel.RespCirc;
//lee velo de desplazamiento
int vv = -1;
if((!HelperGlobal.Str2Int(_subPanel1ViewModel.TextVeloDespl, out vv)) && (_subPanel1ViewModel.TextVeloDespl!=Resource1.String_velo_nodef))
{
err_str = "Error al leer la velocidad de desplazamiento";
return false;
}
if ((vv == 0) || (vv > LimpiezaDef.Parametros.v_despM) || (vv < LimpiezaDef.Parametros.v_despm))
{
err_str = "La velocidad de desplazamiento no est<73> dentro de los l<>mites configurados";
return false;
}
limp.VDespl = vv;
//lee tiempo de tto
if ((_subPanel1ViewModel.TimeTto == 0) ||
(_subPanel1ViewModel.TimeTto > LimpiezaDef.Parametros.t_ttoM) || (_subPanel1ViewModel.TimeTto < LimpiezaDef.Parametros.t_ttom))
{
err_str = "El tiempo de tratamiento no est<73> dentro de los l<>mites configurados";
return false;
}
limp.Ttto = _subPanel1ViewModel.TimeTto;
limp.UdsTTto = _subPanel1ViewModel.UdsTTto;
//lee el ancho medio de la v<>a si est<73> visible (se ha seleccionado la opci<63>n gen<65>rica Eje de calles)
limp.AnchoVia = LimpiezaDef.Parametros.ancho_via;
if (_subPanel1ViewModel.VisTextAnchoVia == System.Windows.Visibility.Visible)
{
try
{
limp.AnchoVia = Convert.ToDouble(_subPanel1ViewModel.TextAnchoVia);
if ((limp.AnchoVia == 0) || (limp.AnchoVia > LimpiezaDef.Parametros.ancho_viaM) || (limp.AnchoVia < LimpiezaDef.Parametros.ancho_viam))
{
err_str = "El ancho de la v<>a no est<73> dentro de los l<>mites configurados";
return false;
}
}
catch (FormatException)
{
err_str = "El formato introducido para el ancho de la v<>a no es v<>lido.";
return false;
}
}
//lee las propiedades comunes a recogida
if (!LeeComun(limp,out err_str))
{
return false;
}
return true;
}
catch
{
return false;
}
}
/**
* Acciones para comenzar ejecuci<63>n
*/
public void Ejecuta(OliviaAddInPro.Services.ModosEjec modo)
{
string err = "";
<<<<<<< HEAD
//comprueba datos de la ventana
=======
//marchando
OliviaGlob.Limp.ProgrSrc = new MyCancelableProgressorSource(OliviaGlob.progrDialog.GetViewModel());
OliviaGlob.progrDialog.Show();
//oculta la ventana
OliviaGlob.ShowHidePane(false);
>>>>>>> Gerardo/MarchandoUnaDe
if (!Lee(out err))
{
HelperGlobal.ponMsg(err);
return;
}
<<<<<<< HEAD
OliviaGlob.Limp.ComienzaEjec(modo);
=======
Action<TareaRes> ac = OliviaGlob.finEjecuta;
OliviaGlob.Limp.EjecutaAsync(modo, ac);
>>>>>>> Gerardo/MarchandoUnaDe
}
}
}