From 0bf952d7fb82ee13fceb9242e6a4ab81507ccf3c Mon Sep 17 00:00:00 2001 From: Elena Date: Wed, 21 Jul 2021 15:27:56 +0200 Subject: [PATCH] Hoy fatal, muy pocos avances --- Helper/HelperGdb.cs | 102 ++++++++++++++++++++++- Helper/HelperGlobal.cs | 24 ++++++ OliviaAddInPro.csproj | 15 ++++ View/OliviaIconPro.ico | Bin 0 -> 144718 bytes View/OliviaIconPro16.png | Bin 0 -> 810 bytes View/PaneLimpiezaSub1.xaml.cs | 7 +- View/PaneLimpiezaSub2.xaml | 16 ++-- View/PaneLimpiezaSub2.xaml.cs | 43 +++++++++- View/ProWndSelectFields.xaml | 28 +++++++ View/ProWndSelectFields.xaml.cs | 59 ++++++++++++++ ViewModel/ShowProWndSelectFields.cs | 121 ++++++++++++++++++++++++++++ 11 files changed, 399 insertions(+), 16 deletions(-) create mode 100644 Helper/HelperGlobal.cs create mode 100644 View/OliviaIconPro.ico create mode 100644 View/OliviaIconPro16.png create mode 100644 View/ProWndSelectFields.xaml create mode 100644 View/ProWndSelectFields.xaml.cs create mode 100644 ViewModel/ShowProWndSelectFields.cs diff --git a/Helper/HelperGdb.cs b/Helper/HelperGdb.cs index 90bd3a9..8dd14d3 100644 --- a/Helper/HelperGdb.cs +++ b/Helper/HelperGdb.cs @@ -7,6 +7,10 @@ using System.Threading.Tasks; using ArcGIS.Desktop.Catalog; using ArcGIS.Desktop.Core; using ArcGIS.Desktop.Framework; +using System.Collections.ObjectModel; +using ArcGIS.Core.Geometry; +using ArcGIS.Core.Data; +using ArcGIS.Desktop.Mapping; namespace OliviaAddInPro.Helper { @@ -21,8 +25,37 @@ namespace OliviaAddInPro.Helper OpenGdb=8, } + public static FeatureClass OpenFtClassDialog(TiposOpenFileDlg tipo, string initialLoc = "") + { + Item it = OpenFileDialog( tipo, initialLoc); + FeatureClass fc = it as FeatureClass; + return fc; + } + + public static async Task OpenGdb(string path) + { + try + { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + // Opens a file geodatabase. This will open the geodatabase if the folder exists and contains a valid geodatabase. + using ( + Geodatabase geodatabase = + new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(path)))) + { + return geodatabase; + } + }); + } + catch (GeodatabaseNotFoundOrOpenedException exception) + { + // Handle Exception. + } + return null; + + } + //Devuelve el Path del archivo seleccionado o un string vacío si se ha cancelado - public static string OpenFileDialog(TiposOpenFileDlg tipo, string initialLoc="") + public static Item OpenFileDialog(TiposOpenFileDlg tipo, string initialLoc="") { string titulo; titulo = "Abrir Archivo"; @@ -65,10 +98,10 @@ namespace OliviaAddInPro.Helper BrowseFilter = filtro }; bool? ok = aNewFilter.ShowDialog(); - if (ok.Value) - return aNewFilter.Items.First().Path; + if ((ok ?? true) && aNewFilter.Items.Count() > 0) + return aNewFilter.Items.First(); else - return ""; + return null; } /*public static bool SelecPolig(string title, int wnd_handle, out string text_sal, out IGeometry geom_sal) @@ -79,5 +112,66 @@ namespace OliviaAddInPro.Helper { }*/ + + public static Table GetTable(string pathLyr) + { + Table tb=null; + Geodatabase fileGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(pathLyr))); + // FeatureLayer lyr = new FeatureLayer(); + + return tb; + } + + public static ObservableCollection GetFields(FeatureClass fc) + { + ObservableCollection fields = new ObservableCollection(); + + + return fields; + } + + public static ObservableCollection GetAttributes(FeatureClass fc, string fieldName) + { + ObservableCollection attribs = new ObservableCollection(); + + return attribs; + } + + public static Geometry GetGeomSel(string pathLyr, string selField, ObservableCollection selAttributes, out string textoSal) + { + string _textosal = ""; + Geometry geomsal = null; + + /*is_str = FunGDB.is_str_field(clase_path, selField); + nval = list.selec_valores_campo(selField, out val_ids, out val_st);//valores únicos + if (nval > 0) + { + //se embucla para unir las geoms + for (int i = 0; i < nval; i++) + { + if (is_str) + consulta = selField + " = '" + val_st[i] + "'"; + else + consulta = selField + " = " + val_st[i]; + ids = FunGDB.dame_ids_consulta(clase_path, consulta); + fc = FunGDB.abre_ftclass(clase_path); + if ((ids != null) && (fc != null)) + { + for (j = 0; j < ids.Length; j++) + { + f = fc.GetFeature(ids[j]); + geom = f.Shape; + geom_sal = FunGDB.une_geoms(geom_sal, geom); + FunGDB.libera(f); + } + } + FunGDB.libera(fc); + //Actualiza el texto de salida + _textosal = _textosal + HelperGlobal.RevisaText(val_st[i]); + } + }*/ + textoSal = _textosal; + return geomsal; + } } } diff --git a/Helper/HelperGlobal.cs b/Helper/HelperGlobal.cs new file mode 100644 index 0000000..108fba5 --- /dev/null +++ b/Helper/HelperGlobal.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OliviaAddInPro.Helper +{ + public static class HelperGlobal + { + public static string RevisaText(string text) + { + StringBuilder sb = new StringBuilder(); + foreach (char c in text) + { + if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_') + { + sb.Append(c); + } + } + return sb.ToString(); + } + } +} diff --git a/OliviaAddInPro.csproj b/OliviaAddInPro.csproj index f435d57..969e6da 100644 --- a/OliviaAddInPro.csproj +++ b/OliviaAddInPro.csproj @@ -131,6 +131,7 @@ + @@ -169,6 +170,10 @@ True Resource1.resx + + ProWndSelectFields.xaml + + @@ -218,6 +223,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + @@ -273,6 +282,12 @@ + + + + + +