Merge branch 'Gerardo/MarchandoUnaDe' into develop
# Conflicts: # Model/Limpieza.cs # Model/Recogida.cs # Services/ProcesoEjecServ.cs # ViewModel/Limpieza/PaneLimpiezaViewModel.csElena/develop
commit
3110a03174
|
|
@ -21,6 +21,7 @@ using OliviaAddInPro.Model;
|
|||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using OliviaAddInPro.View;
|
||||
using OliviaAddInPro.Model.contract;
|
||||
|
||||
namespace OliviaAddInPro.Helper
|
||||
{
|
||||
|
|
@ -830,7 +831,7 @@ namespace OliviaAddInPro.Helper
|
|||
return res;
|
||||
}
|
||||
|
||||
public static bool ExportShp2(string pathLayerIn, SpatialQueryFilter filter, string nameShp, string outpath, CancelableProgressorSource cps, int incmax=100)
|
||||
public static bool ExportShp2(string pathLayerIn, SpatialQueryFilter filter, string nameShp, string outpath, IprocessManager cps, int incmax=100)
|
||||
{
|
||||
if (!System.IO.Directory.Exists(outpath))
|
||||
System.IO.Directory.CreateDirectory(outpath);
|
||||
|
|
@ -872,9 +873,9 @@ namespace OliviaAddInPro.Helper
|
|||
///Exporta
|
||||
string[] args = { pathLayerIn, outpath, nameShp, whereClause };
|
||||
// execute the tool
|
||||
uint valini = cps.Value;
|
||||
double valini = cps.GetProgress(); ;
|
||||
IGPResult gpResult = Geoprocessing.ExecuteToolAsync("FeatureClassToFeatureClass_conversion", args,
|
||||
null, cps.CancellationTokenSource.Token,
|
||||
null, null,
|
||||
|
||||
(event_name, o) => // implement delegate and handle events
|
||||
{
|
||||
|
|
@ -899,7 +900,7 @@ namespace OliviaAddInPro.Helper
|
|||
var av = (int)o;
|
||||
if (av > 0)
|
||||
{
|
||||
cps.Value += (uint)((float)av/100*Math.Min(incmax, cps.Max-valini));
|
||||
cps.SetProgress( cps.GetProgress()+ ((double)av/100*Math.Min(incmax, 100-valini)));
|
||||
}
|
||||
// if ((int)o < 0)
|
||||
//System.Windows.MessageBox.Show(msg2);
|
||||
|
|
@ -911,7 +912,7 @@ namespace OliviaAddInPro.Helper
|
|||
|
||||
if (gpResult.IsCanceled)
|
||||
{
|
||||
cps.CancellationTokenSource.Cancel();
|
||||
cps.Setcancelled();
|
||||
return false;
|
||||
}
|
||||
if(gpResult.IsFailed)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ using ArcGIS.Desktop.Framework.Dialogs;
|
|||
using System.Windows;
|
||||
using System.IO;
|
||||
using ArcGIS.Desktop.Framework.Threading.Tasks;
|
||||
using OliviaAddInPro.Model.contract;
|
||||
|
||||
namespace OliviaAddInPro.Helper
|
||||
{
|
||||
|
|
@ -85,22 +86,23 @@ namespace OliviaAddInPro.Helper
|
|||
|
||||
public class MyCancelableProgressorSource
|
||||
{
|
||||
public CancelableProgressorSource _ProgrSrc;
|
||||
public MyCancelableProgressorSource(ProgressDialog prodlg)
|
||||
public IprocessManager _ProgrSrc;
|
||||
public MyCancelableProgressorSource(IprocessManager prodlg)
|
||||
{
|
||||
_ProgrSrc = new CancelableProgressorSource(prodlg);
|
||||
_ProgrSrc.Max = 100;
|
||||
_ProgrSrc = prodlg;
|
||||
}
|
||||
public void Init(string stat)
|
||||
{
|
||||
_ProgrSrc.Value = 0;
|
||||
_ProgrSrc.Status = stat;
|
||||
_ProgrSrc.SetProgress(0);
|
||||
_ProgrSrc.SetProceso(stat);
|
||||
}
|
||||
public void IncMessage(uint inc, string mes)
|
||||
{
|
||||
if ((_ProgrSrc.Value + inc) < _ProgrSrc.Max)
|
||||
_ProgrSrc.Value += inc;
|
||||
_ProgrSrc.Message = mes;
|
||||
var prog = _ProgrSrc.GetProgress() + inc;
|
||||
if (prog > 100)
|
||||
prog = 100;
|
||||
_ProgrSrc.SetProgress(prog);
|
||||
_ProgrSrc.SetEstado(mes);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ namespace OliviaAddInPro.Model
|
|||
{
|
||||
Serv = new LimpiezaServ(this);
|
||||
LanzaSrv = new LanzaLimpSrv();
|
||||
ProceSrv = new ProcesoEjecServ();
|
||||
ProgrSrc = new MyCancelableProgressorSource(OliviaGlob.progrDialog.GetViewModel());
|
||||
}
|
||||
|
||||
public override Respuesta<TiposEjecucion> Ejecuta(ModosEjec modo)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ namespace OliviaAddInPro.Model
|
|||
//ya al menos una primera vez
|
||||
//se pone este estado cuando ha terminado ya la primera vez
|
||||
}
|
||||
|
||||
static class OliviaGlob
|
||||
{
|
||||
/**
|
||||
|
|
@ -101,7 +102,7 @@ namespace OliviaAddInPro.Model
|
|||
}
|
||||
public static EjecServ Serv { get; } = new EjecServ();
|
||||
public static SpatialReference SpatRef { get; set; } = null;
|
||||
public static ProgressDialog progrDialog { get; set; } = null;
|
||||
public static MarchandoUnaDe progrDialog { get; set; } = null;
|
||||
#endregion Properties
|
||||
|
||||
public static void Inicia()
|
||||
|
|
@ -110,7 +111,7 @@ namespace OliviaAddInPro.Model
|
|||
IniDefault();
|
||||
LimpiezaDef.iniciaLimpDef();
|
||||
RecogidaDef.iniciaRecoDef();
|
||||
progrDialog = new ProgressDialog("Procesando", Resource1.String_cancel_progreso, 100, false);
|
||||
progrDialog = new MarchandoUnaDe();
|
||||
limp = new Limpieza();
|
||||
reco = new Recogida();
|
||||
SpatRef = ArcGIS.Core.Geometry.SpatialReferenceBuilder.CreateSpatialReference(GeneralDef.SpatRefDef);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OliviaAddInPro.Model.contract
|
||||
{
|
||||
public interface IprocessManager
|
||||
{
|
||||
void SetProceso(string proceso);
|
||||
void SetEstado(string estado);//estado del proceso
|
||||
void SetProgress(double progresPorcent);
|
||||
double GetProgress();
|
||||
bool Getcancelled();
|
||||
void Setcancelled();
|
||||
}
|
||||
}
|
||||
|
|
@ -140,6 +140,7 @@
|
|||
<Compile Include="Helper\HelperGdb.cs" />
|
||||
<Compile Include="Helper\HelperGlobal.cs" />
|
||||
<Compile Include="Model\ComunDef.cs" />
|
||||
<Compile Include="Model\contract\IprocessManager.cs" />
|
||||
<Compile Include="Model\ESRI.ArcGIS.Geometry.esriSRProjCS4Type.cs" />
|
||||
<Compile Include="Model\Recogida.cs" />
|
||||
<Compile Include="Model\RecogidaDef.cs" />
|
||||
|
|
@ -158,6 +159,7 @@
|
|||
<Compile Include="Services\LimpiezaServ.cs" />
|
||||
<Compile Include="Services\ProcesoEjecServ.cs" />
|
||||
<Compile Include="Services\RecogidaServ.cs" />
|
||||
<Compile Include="ViewModel\Comun\MarchandoUnaDeViewModel.cs" />
|
||||
<Compile Include="ViewModel\Configuracion\DockpaneConfigViewModel.cs" />
|
||||
<Compile Include="ViewModel\Configuracion\PaneConfigViewModel.cs" />
|
||||
<Compile Include="ViewModel\OptionsMenuItem.cs" />
|
||||
|
|
@ -168,6 +170,9 @@
|
|||
<Compile Include="ViewModel\Limpieza\PaneLimpiezaViewModel.cs" />
|
||||
<Compile Include="ViewModel\PanelViewModelBase.cs" />
|
||||
<Compile Include="ViewModel\Recogida\PaneRecogidaSub1ViewModel.cs" />
|
||||
<Compile Include="View\Comun\MarchandoUnaDe.xaml.cs">
|
||||
<DependentUpon>MarchandoUnaDe.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\Configuracion\PropertyGridFilePickerLine.xaml.cs">
|
||||
<DependentUpon>PropertyGridFilePickerLine.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
|
@ -241,6 +246,10 @@
|
|||
<Resource Include="OliviaIconPro.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="View\Comun\MarchandoUnaDe.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="View\Configuracion\PropertyGridFilePickerLine.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ namespace OliviaAddInPro.Services
|
|||
ErrStr = "Error al exportar los ámbitos: " + HelperGdb.OutStr;
|
||||
return false;
|
||||
}
|
||||
if (com.ProgrSrc._ProgrSrc.CancellationTokenSource.IsCancellationRequested)
|
||||
if (com.ProgrSrc._ProgrSrc.Getcancelled())
|
||||
{
|
||||
ErrStr = Resource1.String_cancel_progreso;
|
||||
return false;
|
||||
|
|
@ -211,7 +211,7 @@ namespace OliviaAddInPro.Services
|
|||
}
|
||||
//guarda los nombres del shape
|
||||
OliviaGlob.Paths.PathNW = OliviaGlob.Paths.DirData + com.NombreShpExportNw;
|
||||
if (com.ProgrSrc._ProgrSrc.CancellationTokenSource.IsCancellationRequested)
|
||||
if (com.ProgrSrc._ProgrSrc.Getcancelled())
|
||||
{
|
||||
ErrStr = Resource1.String_cancel_progreso;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using ArcGIS.Desktop.Framework.Threading.Tasks;
|
||||
using OliviaAddIn;
|
||||
using OliviaAddInPro.Model;
|
||||
using OliviaAddInPro.Model.contract;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
@ -28,7 +29,7 @@ namespace OliviaAddInPro.Services
|
|||
string tarea = "";
|
||||
public string err_str = "";
|
||||
double x, y;
|
||||
CancelableProgressorSource cps;
|
||||
IprocessManager cps;
|
||||
enum TiposActu
|
||||
{
|
||||
ActuMal,
|
||||
|
|
@ -50,7 +51,7 @@ namespace OliviaAddInPro.Services
|
|||
{
|
||||
|
||||
}
|
||||
public Respuesta<TiposEjecucion> start(string cfg, CancelableProgressorSource cps)
|
||||
public Respuesta<bool> start(string cfg, CancelableProgressorSource cps)
|
||||
{
|
||||
this.cps = cps;
|
||||
soc = new Cstr_socket();
|
||||
|
|
@ -102,7 +103,7 @@ namespace OliviaAddInPro.Services
|
|||
}
|
||||
}
|
||||
|
||||
if (cps.Progressor.CancellationToken.IsCancellationRequested) //mira a ver si ha cancelado el usuario
|
||||
if (cps.Getcancelled()) //mira a ver si ha cancelado el usuario
|
||||
{
|
||||
//se ha cancelado, lo envía al OliviaTask
|
||||
envia_cancel();
|
||||
|
|
@ -454,7 +455,7 @@ namespace OliviaAddInPro.Services
|
|||
*/
|
||||
private void pon_texto(String txt)
|
||||
{
|
||||
cps.Message = txt;
|
||||
cps.SetEstado(txt);
|
||||
}
|
||||
/*
|
||||
* Para poder actualizar la barra de progreso hay que llamar a invoke
|
||||
|
|
@ -476,14 +477,14 @@ namespace OliviaAddInPro.Services
|
|||
|
||||
|
||||
if ((actu == TiposActu.ActuMal) || (actu == TiposActu.ActuFinNOk))
|
||||
cps.Status = "Proceso Finalizado con errores.";
|
||||
cps.SetProceso("Proceso Finalizado con errores.");
|
||||
else if(actu == TiposActu.ActuFinOk)
|
||||
cps.Status = "Proceso Finalizado.";
|
||||
cps.SetProceso("Proceso Finalizado.");
|
||||
|
||||
if (actu > TiposActu.ActuFinOk)
|
||||
cps.Status = "Calculando...";
|
||||
cps.SetEstado("Calculando...");
|
||||
if ((actu == TiposActu.ActuPermu) && !cancela)
|
||||
cps.Status = "Calculando Permutaciones..."; ;
|
||||
cps.SetEstado("Calculando Permutaciones...");
|
||||
}
|
||||
/*
|
||||
* Para poder actualizar la barra de progreso hay que llamar a invoke
|
||||
|
|
@ -492,8 +493,8 @@ namespace OliviaAddInPro.Services
|
|||
*/
|
||||
private void pon_progr(int pro)
|
||||
{
|
||||
cps.Value = (uint)pro;
|
||||
}
|
||||
cps.SetProgress( pro);
|
||||
}
|
||||
|
||||
//configura los parámetros de la conexión
|
||||
public void ConfigConex()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
<Window x:Class="OliviaAddInPro.MarchandoUnaDe"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="clr-namespace:OliviaAddInPro"
|
||||
xmlns:local="clr-namespace:OliviaAddInPro"
|
||||
mc:Ignorable="d"
|
||||
Title="MarchandoUnaDe" Height="165" Width="462"
|
||||
d:DataContext="{Binding Path=ui.MarchandoUnaDeViewModel}">
|
||||
|
||||
<Grid>
|
||||
<Label Content="{Binding TextProceso}" HorizontalAlignment="Left" Margin="76,24,0,0" VerticalAlignment="Top" Width="303" Height="26"/>
|
||||
<ProgressBar Minimum="0" Maximum="100" HorizontalAlignment="Left" Value="{Binding Progreso, UpdateSourceTrigger=PropertyChanged}" Height="20" Margin="76,66,0,0" VerticalAlignment="Top" Width="303"/>
|
||||
<Label Content="{Binding TextEstado}" HorizontalAlignment="Left" Margin="95,91,0,0" VerticalAlignment="Top" Width="265" Height="28"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace OliviaAddInPro
|
||||
{
|
||||
/// <summary>
|
||||
/// Lógica de interacción para MarchandoUnaDe.xaml
|
||||
/// </summary>
|
||||
public partial class MarchandoUnaDe : Window
|
||||
{
|
||||
public MarchandoUnaDe()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new MarchandoUnaDeViewModel();
|
||||
}
|
||||
|
||||
public MarchandoUnaDeViewModel GetViewModel()
|
||||
{
|
||||
if (DataContext is MarchandoUnaDeViewModel m)
|
||||
return m;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
using ArcGIS.Desktop.Framework.Contracts;
|
||||
using OliviaAddInPro.Model.contract;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OliviaAddInPro
|
||||
{
|
||||
public class MarchandoUnaDeViewModel : PropertyChangedBase, IprocessManager
|
||||
{
|
||||
|
||||
private string textProceso;
|
||||
public string TextProceso
|
||||
{
|
||||
get { return textProceso; }
|
||||
set { base.SetProperty(ref textProceso, value, () => TextProceso); }
|
||||
}
|
||||
|
||||
private string textEstado;
|
||||
public string TextEstado
|
||||
{
|
||||
get { return textEstado; }
|
||||
set { base.SetProperty(ref textEstado, value, () => TextEstado); }
|
||||
}
|
||||
private double progreso;
|
||||
|
||||
public double Progreso
|
||||
{
|
||||
get { return progreso; }
|
||||
set { base.SetProperty(ref progreso, value, () => Progreso); }
|
||||
}
|
||||
|
||||
void IprocessManager.SetProceso(string proceso)
|
||||
{
|
||||
TextProceso = proceso;
|
||||
}
|
||||
|
||||
void IprocessManager.SetEstado(string estado)
|
||||
{
|
||||
TextEstado = estado;
|
||||
}
|
||||
|
||||
void IprocessManager.SetProgress(double progresPorcent)
|
||||
{
|
||||
Progreso = progresPorcent;
|
||||
}
|
||||
|
||||
double IprocessManager.GetProgress()
|
||||
{
|
||||
return Progreso;
|
||||
}
|
||||
|
||||
bool IprocessManager.Getcancelled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void IprocessManager.Setcancelled()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,13 +10,14 @@ 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();
|
||||
|
|
@ -176,13 +177,24 @@ namespace OliviaAddInPro
|
|||
public void Ejecuta(OliviaAddInPro.Services.ModosEjec modo)
|
||||
{
|
||||
string err = "";
|
||||
//comprueba datos de la ventana
|
||||
//marchando
|
||||
|
||||
|
||||
OliviaGlob.Limp.ProgrSrc = new MyCancelableProgressorSource(OliviaGlob.progrDialog.GetViewModel());
|
||||
OliviaGlob.progrDialog.Show();
|
||||
|
||||
//oculta la ventana
|
||||
OliviaGlob.ShowHidePane(false);
|
||||
|
||||
if (!Lee(out err))
|
||||
{
|
||||
HelperGlobal.ponMsg(err);
|
||||
return;
|
||||
}
|
||||
OliviaGlob.Limp.ComienzaEjec(modo);
|
||||
|
||||
Action<TareaRes> ac = OliviaGlob.finEjecuta;
|
||||
OliviaGlob.Limp.EjecutaAsync(modo, ac);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue