Hoy fatal, muy pocos avances

ConfiguracionSimplificada
Elena 2021-07-21 15:27:56 +02:00
parent de6303d9e3
commit 0bf952d7fb
11 changed files with 399 additions and 16 deletions

View File

@ -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<Geodatabase> 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<string> GetFields(FeatureClass fc)
{
ObservableCollection<string> fields = new ObservableCollection<string>();
return fields;
}
public static ObservableCollection<string> GetAttributes(FeatureClass fc, string fieldName)
{
ObservableCollection<string> attribs = new ObservableCollection<string>();
return attribs;
}
public static Geometry GetGeomSel(string pathLyr, string selField, ObservableCollection<string> 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;
}
}
}

24
Helper/HelperGlobal.cs Normal file
View File

@ -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();
}
}
}

View File

@ -131,6 +131,7 @@
<Compile Include="Button\ButtonMaq.cs" />
<Compile Include="Button\ButtonRec.cs" />
<Compile Include="Helper\HelperGdb.cs" />
<Compile Include="Helper\HelperGlobal.cs" />
<Compile Include="OptionsMenuItem.cs" />
<Compile Include="ViewModel\PaneLimpiezaSub4ViewModel.cs" />
<Compile Include="ViewModel\PaneLimpiezaSub3ViewModel.cs" />
@ -169,6 +170,10 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resource1.resx</DependentUpon>
</Compile>
<Compile Include="View\ProWndSelectFields.xaml.cs">
<DependentUpon>ProWndSelectFields.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModel\ShowProWndSelectFields.cs" />
</ItemGroup>
<ItemGroup>
<AddInContent Include="Images\GenericButtonBlue16.png" />
@ -218,6 +223,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\ProWndSelectFields.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<AddInContent Include="Images\GenericButtonPurple16.png" />
@ -273,6 +282,12 @@
<ItemGroup>
<Resource Include="View\openfolder.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="View\OliviaIconPro16.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="View\OliviaIconPro.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!--
PackageAction can be:

BIN
View/OliviaIconPro.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

BIN
View/OliviaIconPro16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 810 B

View File

@ -12,6 +12,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ArcGIS.Desktop.Core;
using OliviaAddInPro.Helper;
namespace OliviaAddInPro
@ -42,9 +43,9 @@ namespace OliviaAddInPro
private void Button_Click(object sender, RoutedEventArgs e)
{
string res=HelperGdb.OpenFileDialog(HelperGdb.TiposOpenFileDlg.OpenFtrClassLine | HelperGdb.TiposOpenFileDlg.OpenFtrClassPoint);
if (res.Length > 0)
label_capalimp.Content = System.IO.Path.GetFileName(res);
Item it=HelperGdb.OpenFileDialog(HelperGdb.TiposOpenFileDlg.OpenFtrClassLine | HelperGdb.TiposOpenFileDlg.OpenFtrClassPoint);
if(it!=null && it.Path.Length > 0)
label_capalimp.Content = it.Name;
else
label_capalimp.Content = Resource1.String_selec_capa;
}

View File

@ -24,12 +24,12 @@
<ColumnDefinition Width="45"/>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<Button Content="" HorizontalAlignment="Left" Margin="20,3,0,0" VerticalAlignment="Top" Width="16" Height="16" BorderThickness="0">
<Button x:Name="button_caparestr" Content="" HorizontalAlignment="Left" Margin="20,3,0,0" VerticalAlignment="Top" Width="16" Height="16" BorderThickness="0" Click="button_caparestr_Click">
<Button.Background>
<ImageBrush ImageSource="openfolder.png"/>
</Button.Background>
</Button>
<Label Content="{Binding Path=LblCapaRestr, Mode = TwoWay}" Grid.Column="1" HorizontalAlignment="Left" Margin="13,0,-33,0" VerticalAlignment="Top" Width="221" Height="30" Grid.ColumnSpan="2"/>
<Label x:Name="label_caparestr" Content="{Binding Path=LblCapaRestr, Mode = TwoWay}" Grid.Column="1" HorizontalAlignment="Left" Margin="13,0,-33,0" VerticalAlignment="Top" Width="221" Height="30" Grid.ColumnSpan="2"/>
</Grid>
<Label Margin="15,0,0,0" Content="Niveles" FontWeight="DemiBold"/>
<Grid Margin="0,0,0,0">
@ -37,12 +37,12 @@
<ColumnDefinition Width="45"/>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<Button Content="" HorizontalAlignment="Left" Margin="20,3,0,0" VerticalAlignment="Top" Width="16" Height="16" BorderThickness="0">
<Button x:Name="button_capaniv" Content="" HorizontalAlignment="Left" Margin="20,3,0,0" VerticalAlignment="Top" Width="16" Height="16" BorderThickness="0" Click="button_capaniv_Click">
<Button.Background>
<ImageBrush ImageSource="openfolder.png"/>
</Button.Background>
</Button>
<Label Content="{Binding Path=LblCapaNiv, Mode = TwoWay}" Grid.Column="1" HorizontalAlignment="Left" Margin="13,0,-33,0" VerticalAlignment="Top" Width="221" Height="30" Grid.ColumnSpan="2"/>
<Label x:Name="label_capaniv" Content="{Binding Path=LblCapaNiv, Mode = TwoWay}" Grid.Column="1" HorizontalAlignment="Left" Margin="13,0,-33,0" VerticalAlignment="Top" Width="221" Height="30" Grid.ColumnSpan="2"/>
</Grid>
<Label Margin="15,0,0,0" Content="Zonas" FontWeight="DemiBold"/>
<Grid Margin="0,0,0,0">
@ -50,12 +50,12 @@
<ColumnDefinition Width="45"/>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<Button Content="" HorizontalAlignment="Left" Margin="20,3,0,0" VerticalAlignment="Top" Width="16" Height="16" BorderThickness="0">
<Button x:Name="button_capazon" Content="" HorizontalAlignment="Left" Margin="20,3,0,0" VerticalAlignment="Top" Width="16" Height="16" BorderThickness="0" Click="button_capazon_Click">
<Button.Background>
<ImageBrush ImageSource="openfolder.png"/>
</Button.Background>
</Button>
<Label Content="{Binding Path=LblCapaZon, Mode = TwoWay}" Grid.Column="1" HorizontalAlignment="Left" Margin="13,0,-33,0" VerticalAlignment="Top" Width="221" Height="30" Grid.ColumnSpan="2"/>
<Label x:Name="label_capazon" Content="{Binding Path=LblCapaZon, Mode = TwoWay}" Grid.Column="1" HorizontalAlignment="Left" Margin="13,0,-33,0" VerticalAlignment="Top" Width="221" Height="30" Grid.ColumnSpan="2"/>
</Grid>
<Label Margin="15,0,0,0" Content="Instalación" FontWeight="DemiBold"/>
<Grid Margin="0,0,0,0">
@ -63,12 +63,12 @@
<ColumnDefinition Width="45"/>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<Button Content="" HorizontalAlignment="Left" Margin="20,3,0,0" VerticalAlignment="Top" Width="16" Height="16" BorderThickness="0">
<Button x:Name="button_capainst" Content="" HorizontalAlignment="Left" Margin="20,3,0,0" VerticalAlignment="Top" Width="16" Height="16" BorderThickness="0" Click="button_capainst_Click">
<Button.Background>
<ImageBrush ImageSource="openfolder.png"/>
</Button.Background>
</Button>
<Label Content="{Binding Path=LblCapaInst, Mode = TwoWay}" Grid.Column="1" HorizontalAlignment="Left" Margin="13,0,-33,0" VerticalAlignment="Top" Width="221" Height="30" Grid.ColumnSpan="2"/>
<Label x:Name="label_capainst" Content="{Binding Path=LblCapaInst, Mode = TwoWay}" Grid.Column="1" HorizontalAlignment="Left" Margin="13,0,-33,0" VerticalAlignment="Top" Width="221" Height="30" Grid.ColumnSpan="2"/>
</Grid>
<Grid Margin="0,5,0,0">
<Grid.ColumnDefinitions>

View File

@ -12,6 +12,10 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ArcGIS.Core.Data;
using ArcGIS.Desktop.Core;
using OliviaAddInPro.Helper;
using OliviaAddInPro.View;
namespace OliviaAddInPro
@ -31,5 +35,42 @@ namespace OliviaAddInPro
e.Handled = !PanelGlobal.IsValid(((TextBox)sender).Text + e.Text,0,9999);
}
private void button_caparestr_Click(object sender, RoutedEventArgs e)
{
FeatureClass fc = HelperGdb.OpenFtClassDialog(HelperGdb.TiposOpenFileDlg.OpenFtrClassPolygon);
bool ok = false;
string texto="";
if (fc != null)
{
texto = System.IO.Path.GetFileName(fc.GetName());
//saca la ventana de selección de campo
ShowProWndSelectFields selfwnd = new ShowProWndSelectFields(fc, true);
if(selfwnd.SelAttributes.Count>0)
{
ok = true;
//HelperGdb.GetGeomSel(it.Path, selfwnd.SelField, selfwnd.SelAttributes, out texto);
}
}
if(!ok)
texto= Resource1.String_selec_capa;
label_caparestr.Content = texto;
}
private void button_capaniv_Click(object sender, RoutedEventArgs e)
{
}
private void button_capazon_Click(object sender, RoutedEventArgs e)
{
}
private void button_capainst_Click(object sender, RoutedEventArgs e)
{
}
}
}

View File

@ -0,0 +1,28 @@
<controls:ProWindow x:Class="OliviaAddInPro.View.ProWndSelectFields"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:ArcGIS.Desktop.Framework.Controls;assembly=ArcGIS.Desktop.Framework"
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:extensions="clr-namespace:ArcGIS.Desktop.Extensions;assembly=ArcGIS.Desktop.Extensions"
mc:Ignorable="d" Height="300" Width="243.123"
WindowStartupLocation="CenterOwner" Icon="OliviaIconPro.ico" ResizeMode="NoResize" Closed="ProWindow_Closed" Closing="ProWindow_Closing"
>
<controls:ProWindow.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<extensions:DesignOnlyResourceDictionary Source="pack://application:,,,/ArcGIS.Desktop.Framework;component\Themes\Default.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</controls:ProWindow.Resources>
<StackPanel HorizontalAlignment="Left" Height="272" VerticalAlignment="Top" Width="233" Margin="0,0,0,-1.6">
<Label Margin="15,0,0,0" Content="Campo"/>
<ComboBox Margin="10,5,9.6,0"
ItemsSource="{Binding Path=Fields, Mode = TwoWay}" Name="comboBoxFields" SelectedItem="{Binding Path=SelField, Mode = TwoWay}" SelectionChanged="comboBoxFields_SelectionChanged"/>
<Label Margin="15,0,0,0" Content="Atributo"/>
<ListBox Margin="10,5,9.6,0" Height="127" ItemsSource="{Binding Path=Attributes, Mode = TwoWay}" Name="listBoxAttributes" SelectedItem="{Binding Path=SelAttributes, Mode = TwoWay}" SelectionMode="{Binding SelMode}"/>
<Button Margin="167,25,9.6,0" Content="Aceptar" Opacity="0.75" Click="Button_Click"/>
</StackPanel>
</controls:ProWindow>

View File

@ -0,0 +1,59 @@
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.Navigation;
using System.Windows.Shapes;
using OliviaAddInPro.Helper;
using ArcGIS.Core.Data;
namespace OliviaAddInPro.View
{
/// <summary>
/// Interaction logic for ProWndSelectFields.xaml
/// </summary>
public partial class ProWndSelectFields : ArcGIS.Desktop.Framework.Controls.ProWindow
{
private bool ok = false;
public FeatureClass fc = null;
public ProWndSelectFields()
{
InitializeComponent();
}
private void comboBoxFields_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if(comboBoxFields.SelectedIndex>0)
{
listBoxAttributes.ItemsSource = HelperGdb.GetAttributes(fc, comboBoxFields.SelectedItem.ToString());
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
ok = true;
Close();
}
private void ProWindow_Closed(object sender, EventArgs e)
{
}
private void ProWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (ok)
DialogResult = true;
else
DialogResult = false;
}
}
}

View File

@ -0,0 +1,121 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using ArcGIS.Desktop.Framework;
using ArcGIS.Desktop.Framework.Contracts;
using OliviaAddInPro.Helper;
using ArcGIS.Core.Data;
using System.Windows.Controls;
using ArcGIS.Desktop.Mapping;
using ArcGIS.Desktop.Core;
namespace OliviaAddInPro.View
{
internal class ShowProWndSelectFields : ArcGIS.Desktop.Framework.Contracts.Button
{
private ProWndSelectFields _prowndselectfields = null;
private ObservableCollection<string> fields = new ObservableCollection<string>();
private ObservableCollection<string> attributes = new ObservableCollection<string>();
private ObservableCollection<string> selAttributes = new ObservableCollection<string>();
private string selField = string.Empty;
private bool multiSelAtt = true;
private string pathLyr = string.Empty;
FeatureClass ftClass = null;
public bool res = false;
#region Methods
public ShowProWndSelectFields(FeatureClass fc, bool _multiSelAtt)
{
ftClass = fc;
//pathLyr = it.Path;
multiSelAtt = _multiSelAtt;
fields = HelperGdb.GetFields(fc);
attributes.Clear();
selAttributes.Clear();
selField = string.Empty;
muestra();
}
private void muestra()
{
//already open?
if (_prowndselectfields != null)
return;
_prowndselectfields = new ProWndSelectFields();
_prowndselectfields.Owner = FrameworkApplication.Current.MainWindow;
_prowndselectfields.fc = ftClass;
//_prowndselectfields.Closed += (o, e) => { _prowndselectfields = null; };
bool? res = _prowndselectfields.ShowDialog();
if (res ?? false)
{
selAttributes.Clear();
selField = string.Empty;
}
}
#endregion Methods
#region Properties
public ObservableCollection<string> Fields
{
get { return fields; }
set
{
fields = value;
base.NotifyPropertyChanged("Fields");
}
}
public ObservableCollection<string> Attributes
{
get { return attributes; }
set
{
attributes = value;
base.NotifyPropertyChanged("Attributes");
}
}
public ObservableCollection<string> SelAttributes
{
get { return selAttributes; }
set
{
selAttributes = value;
base.NotifyPropertyChanged("SelAttributes");
}
}
public string SelField
{
get { return selField; }
set
{
selField = value;
base.NotifyPropertyChanged("SelField");
}
}
public SelectionMode SelMode
{
get {
if (multiSelAtt)
return SelectionMode.Extended;
else
return SelectionMode.Single;
}
set
{
if (value== SelectionMode.Extended)
multiSelAtt= true;
else
multiSelAtt = false;
base.NotifyPropertyChanged("SelMode");
}
}
#endregion Properties
}
}