From c88585690b90bde7fdcdfeca70de047b85c149c3 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Sat, 25 Sep 2021 21:18:47 +0200 Subject: [PATCH 1/2] Creaccion de ventana de propiedades y propiedades como tal. --- Button/ButtonConfig.cs | 5 +- Config.daml | 15 +- Model/OliviaConf.cs | 235 ++++++++++++++++++ OliviaAddInPro.csproj | 25 +- Resource1.Designer.cs | 18 ++ Resource1.resx | 6 + View/Configuracion/DockPaneConfig.xaml | 28 +++ View/Configuracion/DockPaneConfig.xaml.cs | 27 ++ View/Configuracion/PaneConfigView.xaml | 29 +++ View/Configuracion/PaneConfigView.xaml.cs | 52 ++++ .../Configuracion/DockpaneConfigViewModel.cs | 82 ++++++ .../Configuracion/PaneConfigViewModel.cs | 31 +++ 12 files changed, 543 insertions(+), 10 deletions(-) create mode 100644 Model/OliviaConf.cs create mode 100644 View/Configuracion/DockPaneConfig.xaml create mode 100644 View/Configuracion/DockPaneConfig.xaml.cs create mode 100644 View/Configuracion/PaneConfigView.xaml create mode 100644 View/Configuracion/PaneConfigView.xaml.cs create mode 100644 ViewModel/Configuracion/DockpaneConfigViewModel.cs create mode 100644 ViewModel/Configuracion/PaneConfigViewModel.cs diff --git a/Button/ButtonConfig.cs b/Button/ButtonConfig.cs index 7916eb9..74aee54 100644 --- a/Button/ButtonConfig.cs +++ b/Button/ButtonConfig.cs @@ -22,12 +22,13 @@ using OliviaAddInPro.Model; namespace OliviaAddInPro { internal class ButtonConfig : Button - { + { protected override void OnClick() { if (OliviaGlob.TipoEjec == TiposEjecucion.Ninguno) { - //OliviaGlob.tipEjec = TiposEjecucion.Config; + OliviaGlob.TipoEjec = TiposEjecucion.Config; + DockpaneConfigViewModel.Show(); } else { diff --git a/Config.daml b/Config.daml index 74e317f..504c947 100644 --- a/Config.daml +++ b/Config.daml @@ -1,5 +1,9 @@ - - + + OliviaAddInPro AddIn de Optimización de la Limpieza Viaria para ArcGIs Pro Images\AddinDesktop32.png @@ -50,8 +54,11 @@ - - + + + + + diff --git a/Model/OliviaConf.cs b/Model/OliviaConf.cs new file mode 100644 index 0000000..783e818 --- /dev/null +++ b/Model/OliviaConf.cs @@ -0,0 +1,235 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OliviaAddInPro.Model +{ + class OliviaConf + { + private static OliviaConf conf=null; + + private OliviaConf() + { + + } + + + static public OliviaConf Conf() + { + if (conf == null) + { + conf = new OliviaConf(); + conf.leerConfig(); + } + return conf; + } + + void leerConfig() + { + //leer ini + } + + + [Category("General")] + [DisplayName("Red de carreteras")] + [Description("Red de carreteras que se usara para la navegación")] + public string red_carreteras { get; set; } + + [Category("General")] + [DisplayName("Puerto")] + [Description("Puerto de conexión con el proceso olivia")] + public int puerto { get; set; } + + [Category("General")] + [DisplayName("Buffer de exportado (m)")] + [Description("Buuffer extra, en metros, que se va a exportar de la red de carreteras")] + public int buffer_export { get; set; } + + [Category("Capas Generales")] + [DisplayName("Eje de via")] + [Description("Capa de eje de via que se usara")] + public string eje_via { get; set; } + + [Category("Capas Generales")] + [DisplayName("Capa municipios")] + [Description("Capa municipios")] + public string municipios { get; set; } + + [Category("Campos Limpieza")] + [DisplayName("Tipo entidad")] + [Description("Nombre del campo tipo de entidad")] + public string cons_tip_ent { get; set; } + + [Category("Campos Limpieza")] + [DisplayName("Mecanizable")] + [Description("Nombre del campo que indica si es mecanizable")] + public string cons_mecaniz { get; set; } + + [Category("Campos Limpieza")] + [DisplayName("Observaciones")] + [Description("Nombre del campo de observaciones")] + public string cons_obser { get; set; } + + [Category("Campos Limpieza")] + [DisplayName("Ancho aceras")] + [Description("Nombre del campo que indica el ancho de las aceras")] + public string cons_anch_tip { get; set; } + + [Category("Campos Limpieza")] + [DisplayName("Tipo de aparcamiento")] + [Description("Nombre del campo que indica el tipo de aparcamiento")] + public string cons_tipolo { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Acera")] + [Description("Valor para el atributo acera")] + public string atr_acera { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Banda Aparcamiento")] + [Description("Valor para el atributo banda de aparcamiento")] + public int atr_aparc { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Bordillo libre")] + [Description("Valor para el atributo de bordillo libre")] + public string atr_bord { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Caída de hoja")] + [Description("Valor para el atributo caída hoja")] + public string atr_hoja { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Peatonales")] + [Description("Valor para el atributo calle peatonal")] + public string atr_peat { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Mecanizable")] + [Description("Valor para el atributo de si es mecanizable")] + public int atr_mec_s { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("No mecanizable")] + [Description("Valor para el atributo de si no es mecanizable")] + public string atr_mec_n { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Escaleras")] + [Description("Valor para el atributo escaleras")] + public string atr_esca { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Fuentes")] + [Description("Valor para el atributo fuentes")] + public string atr_fuent { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Juegos infantiles")] + [Description("Valor para el atributo juegos infantiles")] + public string atr_infan { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Papelera")] + [Description("Valor para el atributo papelera")] + public int atr_pape { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Paso a nivel")] + [Description("Valor para el atributo papelera para el atributo paso a nivel")] + public string atr_paso_niv { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Pipican")] + [Description("Valor para el atributo pipican")] + public string atr_pipi { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Sanecan")] + [Description("Valor para el atributo saneacan")] + public string atr_sane { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Areas Terrizas")] + [Description("Valor para el atributo areas terrizas")] + public int atr_terri { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Ocio")] + [Description("Valor para el atributo Ocio")] + public string atr_ocio { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Organismos oficiales")] + [Description("Valor para el atributo organismos oficiales")] + public string atr_org_ofi { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Organismos oficiales")] + [Description("Valor para el atributo parques")] + public string atr_parq { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Parquin")] + [Description("Valor para el atributo parquin")] + public string atr_park { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Playa")] + [Description("Valor para el atributo playa")] + public int atr_play { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Polideportivo")] + [Description("Valor para el atributo polideportivo")] + public string atr_polid { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("P. interes turistico")] + [Description("Valor para el atributo los puntos de interes turistico")] + public string atr_turis { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Solares")] + [Description("Valor para el atributo solares")] + public string atr_solar { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Suelo")] + [Description("Valor para el atributo uso del suelo")] + public string atr_suelo { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Aparcamiento en linea")] + [Description("Valor para el atributo aparcamiento en linea")] + public int atr_ap_lin { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("Aparacamiento en bateria")] + [Description("Valor para el atributo aparcamiento en bateria")] + public string atr_ap_bat { get; set; } + /* + [Category("Atributos limpieza")] + [DisplayName("")] + [Description("")] + public string puerto { get; set; } + + [Category("Atributos limpieza")] + [DisplayName("")] + [Description("")] + public string puerto { get; set; } + + /* + [Category("")] + [DisplayName("")] + [Description("")] + public string puerto { get; set; } + + }*/ + + } +} diff --git a/OliviaAddInPro.csproj b/OliviaAddInPro.csproj index deea6a8..936d906 100644 --- a/OliviaAddInPro.csproj +++ b/OliviaAddInPro.csproj @@ -137,8 +137,11 @@ + + + @@ -146,6 +149,12 @@ + + DockPaneConfig.xaml + + + PaneConfigView.xaml + PaneEjecutar.xaml @@ -206,6 +215,14 @@ + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -316,11 +333,11 @@ BuildDefault - - - + + + - + + + + + + + diff --git a/View/Configuracion/PaneConfigView.xaml.cs b/View/Configuracion/PaneConfigView.xaml.cs new file mode 100644 index 0000000..310d938 --- /dev/null +++ b/View/Configuracion/PaneConfigView.xaml.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +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.Navigation; +using System.Windows.Shapes; + +namespace OliviaAddInPro +{ + /// + /// Lógica de interacción para PaneConfigView.xaml + /// + public partial class PaneConfigView : UserControl + { + public PaneConfigView() + { + InitializeComponent(); + + } + private void OnGuardar(object sender, RoutedEventArgs e) + { + /* + if (DataContext is PaneLimpiezaSub1ViewModel mod) + { + mod.ComboTtoSel(i); + oldTtoSel = i; + } + */ + } + private void OnRefres(object sender, RoutedEventArgs e) + { + /* + if (DataContext is PaneLimpiezaSub1ViewModel mod) + { + mod.ComboTtoSel(i); + oldTtoSel = i; + } + */ + } + + + } +} diff --git a/ViewModel/Configuracion/DockpaneConfigViewModel.cs b/ViewModel/Configuracion/DockpaneConfigViewModel.cs new file mode 100644 index 0000000..50e0169 --- /dev/null +++ b/ViewModel/Configuracion/DockpaneConfigViewModel.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ArcGIS.Core.CIM; +using ArcGIS.Core.Data; +using ArcGIS.Core.Geometry; +using ArcGIS.Desktop.Catalog; +using ArcGIS.Desktop.Core; +using ArcGIS.Desktop.Editing; +using ArcGIS.Desktop.Extensions; +using ArcGIS.Desktop.Framework; +using ArcGIS.Desktop.Framework.Controls; +using ArcGIS.Desktop.Framework.Contracts; +using ArcGIS.Desktop.Framework.Dialogs; +using ArcGIS.Desktop.Framework.Threading.Tasks; +using ArcGIS.Desktop.Mapping; +using OliviaAddInPro.Model; +using OliviaAddInPro.View; + +namespace OliviaAddInPro +{ + internal class DockpaneConfigViewModel : DockPane + { + private bool firstTimeShow = true; + private const string _dockPaneID = "OliviaAddInPro_DockpaneConfig"; + protected DockpaneConfigViewModel() + { + _currentPage = new PaneConfigViewModel(); + + } + + /// + /// Show the DockPane. + /// + internal static void Show() + { + DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID); + if (pane == null) + return; + + pane.Activate(); + } + + //The parameter passed to this method will be true if the Dockpane is being opened and it is false when you close the dockpane + //also false the first time + protected override void OnShow(bool isVisible) + { + if (isVisible == false && !firstTimeShow) + { + //avisa de cerrar la ventana + OliviaGlob.TipoEjec = TiposEjecucion.Ninguno; + } + if (firstTimeShow) + firstTimeShow = false; + } + + /// + /// Text shown near the top of the DockPane. + /// + private string _heading = Resource1.String_header_Config; + public string Heading + { + get { return _heading; } + set + { + SetProperty(ref _heading, value, () => Heading); + } + } + + private PanelViewModelBase _currentPage; + public PanelViewModelBase CurrentPage + { + get { return _currentPage; } + set + { + SetProperty(ref _currentPage, value, () => CurrentPage); + } + } + } +} diff --git a/ViewModel/Configuracion/PaneConfigViewModel.cs b/ViewModel/Configuracion/PaneConfigViewModel.cs new file mode 100644 index 0000000..52ffeb1 --- /dev/null +++ b/ViewModel/Configuracion/PaneConfigViewModel.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using OliviaAddInPro.Model; +namespace OliviaAddInPro +{ + class PaneConfigViewModel : PanelViewModelBase + { + private OliviaConf conf; + public PaneConfigViewModel() + { + conf = OliviaConf.Conf(); + } + + + public override string DisplayName + { + get { return Resource1.String_ConfigGeneralView; } + } + + public OliviaConf Configuracion + { + get { return conf; } + set { base.SetProperty(ref conf, value, () => conf); } + } + } + +} From 3b05ca3a9fe32ac589b72af1bc102a1372a64c06 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Sat, 25 Sep 2021 21:53:17 +0200 Subject: [PATCH 2/2] Creaccion de servicio de configuracion --- Model/OliviaConf.cs | 28 +++++++-------- OliviaAddInPro.csproj | 1 + Services/ConfigServ.cs | 34 +++++++++++++++++++ View/Configuracion/PaneConfigView.xaml.cs | 20 ++++------- .../Configuracion/PaneConfigViewModel.cs | 22 ++++++++++-- 5 files changed, 74 insertions(+), 31 deletions(-) create mode 100644 Services/ConfigServ.cs diff --git a/Model/OliviaConf.cs b/Model/OliviaConf.cs index 783e818..4d0a576 100644 --- a/Model/OliviaConf.cs +++ b/Model/OliviaConf.cs @@ -11,28 +11,28 @@ namespace OliviaAddInPro.Model { private static OliviaConf conf=null; - private OliviaConf() + public OliviaConf() { } + #region PropiedadesOcultas + #region Paths + [Browsable(false)] + public string path_work { get; set; } - static public OliviaConf Conf() - { - if (conf == null) - { - conf = new OliviaConf(); - conf.leerConfig(); - } - return conf; - } + [Browsable(false)] + public string path_exe { get; set; } - void leerConfig() - { - //leer ini - } + [Browsable(false)] + public string path_temp { get; set; } + [Browsable(false)] + public string path_data { get; set; } + #endregion + + #endregion [Category("General")] [DisplayName("Red de carreteras")] [Description("Red de carreteras que se usara para la navegación")] diff --git a/OliviaAddInPro.csproj b/OliviaAddInPro.csproj index 936d906..fa92567 100644 --- a/OliviaAddInPro.csproj +++ b/OliviaAddInPro.csproj @@ -139,6 +139,7 @@ + diff --git a/Services/ConfigServ.cs b/Services/ConfigServ.cs new file mode 100644 index 0000000..6a1e92b --- /dev/null +++ b/Services/ConfigServ.cs @@ -0,0 +1,34 @@ +using OliviaAddInPro.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OliviaAddInPro.Services +{ + class ConfigServ + { + private static ConfigServ configServ=null; + + public static ConfigServ Serv + { + get { + if (configServ == null) + configServ = new ConfigServ(); + return configServ; + } + } + + public OliviaConf Leer() + { + return new OliviaConf(); + } + + public void Guardar(OliviaConf conf) + { + + } + + } +} diff --git a/View/Configuracion/PaneConfigView.xaml.cs b/View/Configuracion/PaneConfigView.xaml.cs index 310d938..e391b6d 100644 --- a/View/Configuracion/PaneConfigView.xaml.cs +++ b/View/Configuracion/PaneConfigView.xaml.cs @@ -28,23 +28,15 @@ namespace OliviaAddInPro } private void OnGuardar(object sender, RoutedEventArgs e) { - /* - if (DataContext is PaneLimpiezaSub1ViewModel mod) - { - mod.ComboTtoSel(i); - oldTtoSel = i; - } - */ + + if (DataContext is PaneConfigViewModel mod) + mod.OnGuardar(); } + private void OnRefres(object sender, RoutedEventArgs e) { - /* - if (DataContext is PaneLimpiezaSub1ViewModel mod) - { - mod.ComboTtoSel(i); - oldTtoSel = i; - } - */ + if (DataContext is PaneConfigViewModel mod) + mod.OnRefres(); } diff --git a/ViewModel/Configuracion/PaneConfigViewModel.cs b/ViewModel/Configuracion/PaneConfigViewModel.cs index 52ffeb1..225beea 100644 --- a/ViewModel/Configuracion/PaneConfigViewModel.cs +++ b/ViewModel/Configuracion/PaneConfigViewModel.cs @@ -5,14 +5,15 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using OliviaAddInPro.Model; +using OliviaAddInPro.Services; namespace OliviaAddInPro { class PaneConfigViewModel : PanelViewModelBase { - private OliviaConf conf; + private OliviaConf conf=null; public PaneConfigViewModel() { - conf = OliviaConf.Conf(); + OnRefres(); } @@ -24,7 +25,22 @@ namespace OliviaAddInPro public OliviaConf Configuracion { get { return conf; } - set { base.SetProperty(ref conf, value, () => conf); } + set + { + base.SetProperty(ref conf, value, () => conf); + ConfiguracioProperty.Update(); + } + + } + + public void OnGuardar() + { + ConfigServ.Serv.Guardar(Configuracion); + } + + public void OnRefres() + { + Configuracion = ConfigServ.Serv.Leer(); } }