Hi everyone
Good day Esri Community
Im coding an add-in (DockPane) that Subscribe to Events on start (SubscribeToStandaloneTablesAddedEvent and SubscribeToStandaloneTablesRemovedEvent) and them when it closed the DockPane Unsubscribe from the previous subscriptions (SubscribeToStandaloneTablesAddedEvent and SubscribeToStandaloneTablesRemovedEvent).
I have been using the Delegate Action and not the SubscriptionToken to call the subscriptions. Also when i Subscribe to an Event i execute some code to Update a List of OpenStandalone Tables in a ComboBox.
My methods are in the Xaml file and i call them with an instance from the ViewModel file to execute without any positive result.
Any suggestions or help.
My DockPane:
My ViewModel File:
using ArcGIS.Core.CIM;
using ArcGIS.Core.Data;
using ArcGIS.Core.Events;
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.Contracts;
using ArcGIS.Desktop.Framework.Events;
using ArcGIS.Desktop.Framework.Dialogs;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Layouts;
using ArcGIS.Desktop.Mapping;
using ArcGIS.Desktop.Mapping.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
namespace AppEstandarizaDirecciones
{
internal class Dockpane1ViewModel : DockPane
{
private const string _dockPaneID = "AppEstandarizaDirecciones_Dockpane1";
protected Dockpane1ViewModel() { }
/// <summary>
/// Show the DockPane.
/// </summary>
///
internal static void Show()
{
DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
if (pane == null)
return;
pane.Activate();
MessageBox.Show("was shown only once.");
}
protected override void OnShow(bool isVisible)
{
//base.OnShow(isVisible);
if (isVisible == true)
{
MessageBox.Show("was shown every time it was viewed");
}
}
protected override void OnHidden()
{
Dockpane1View ElmmiObject = new Dockpane1View();
ElmmiObject.QuitarsubscribeFromStandaloneTablesAddedEvent();
ElmmiObject.QuitarsubscribeFromStandaloneTablesRemovedEvent();
MessageBox.Show("DockPane Closed.");
}
/// <summary>
/// Text shown near the top of the DockPane.
/// </summary>
private string _heading = "My DockPane";
public string Heading
{
get { return _heading; }
set
{
SetProperty(ref _heading, value, () => Heading);
}
}
}
/// <summary>
/// Button implementation to show the DockPane.
/// </summary>
internal class Dockpane1_ShowButton : Button
{
protected override void OnClick()
{
Dockpane1ViewModel.Show();
}
}
}
My Xaml File:
using ArcGIS.Core.Data;
using ArcGIS.Desktop.Core.Geoprocessing;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Internal.Mapping.Locate;
using ArcGIS.Desktop.Mapping;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
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 ArcGIS.Desktop.Core.Events;
using ArcGIS.Desktop.Mapping.Events;
using ArcGIS.Desktop.Framework.Events;
using ArcGIS.Desktop.Framework.Contracts;
using ArcGIS.Desktop.Internal.Mapping.Georeference.Events;
using ArcGIS.Desktop.Framework;
namespace AppEstandarizaDirecciones
{
/// <summary>
/// Interaction logic for Dockpane1View.xaml
/// </summary>
public partial class Dockpane1View : UserControl
{
List<string> listaTablas = new List<string>();
List<string> listaCampos = new List<string>();
List<string> listaConsultas = new List<string>();
public Dockpane1View()
{
InitializeComponent();
var mv = MapView.Active;
if (mv != null)
{
var lyrs = mv.Map.GetStandaloneTablesAsFlattenedList();
int cantidadtablas = lyrs.Count();
MessageBox.Show("Number of Tables: " + cantidadtablas);
foreach (var lyr in lyrs)
{
this.MiComboBox1.Items.Add(lyr.Name);
listaTablas.Add(lyr.Name);
MessageBox.Show("Table: " + lyr.Name);
}
}
SubscribeToStandaloneTablesAddedEvent();
MessageBox.Show("ACTIVE Subscription ADD TABLE");
SubscribeToStandaloneTablesRemovedEvent();
MessageBox.Show("ACTIVE Subscription REMOVE TABLE");
}
public void SubscribeToStandaloneTablesAddedEvent()
{
StandaloneTablesAddedEvent.Subscribe(OnStandaloneTablesAdded);
MessageBox.Show("Subscription is ACTIVE ADD TABLE");
}
public void QuitarsubscribeFromStandaloneTablesAddedEvent()
{
StandaloneTablesAddedEvent.Unsubscribe(OnStandaloneTablesAdded);
MessageBox.Show("Subscription is REMOVED ADD TABLE");
}
public void OnStandaloneTablesAdded(StandaloneTableEventArgs obj)
{
foreach (var standaloneTable in obj.Tables)
{
string nombreTablaAdded;
nombreTablaAdded = standaloneTable.Name;
this.Dispatcher.Invoke(() => {
this.MiComboBox2.ItemsSource = null;
this.MiComboBox2.Items.Clear();
this.MiComboBox2.Items.Refresh();
this.MiComboBox1.ItemsSource = null;
this.MiComboBox1.Items.Clear();
this.MiComboBox1.Items.Refresh();
listaTablas.Add(nombreTablaAdded);
this.MiComboBox1.ItemsSource = listaTablas;
this.MiComboBox1.Items.Refresh();
MessageBox.Show("The table was ADDED" + nombreTablaAdded);
});
}
}
public void SubscribeToStandaloneTablesRemovedEvent()
{
StandaloneTablesRemovedEvent.Subscribe(OnStandaloneTablesRemoved);
MessageBox.Show("Be ACTIVE subscribe REMOVE TABLE");
}
public void QuitarsubscribeFromStandaloneTablesRemovedEvent()
{
StandaloneTablesRemovedEvent.Unsubscribe(OnStandaloneTablesRemoved);
MessageBox.Show("Subscription REMOVED REMOVE TABLE");
}
public void OnStandaloneTablesRemoved(StandaloneTableEventArgs obj)
{
foreach (var standaloneTable in obj.Tables)
{
string nombreTablaRemoved;
nombreTablaRemoved = standaloneTable.Name;
this.Dispatcher.Invoke(() => {
this.MiComboBox2.ItemsSource = null;
this.MiComboBox2.Items.Clear();
this.MiComboBox2.Items.Refresh();
this.MiComboBox1.ItemsSource = null;
this.MiComboBox1.Items.Clear();
this.MiComboBox1.Items.Refresh();
listaTablas.Remove(nombreTablaRemoved);
this.MiComboBox1.ItemsSource = listaTablas;
this.MiComboBox1.Items.Refresh();
MessageBox.Show("The table was REMOVED" + nombreTablaRemoved);
});
}
}
}
}
Hi,
There is no need to use coding for dockpane in code behind (*.xaml.cs). Look at the ArcGIS Pro SDK community WorkingWithQueryDefinitionFilters sample. Sample uses layers adding/removing events.
You're missing the URL for that sample: https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Exploration/WorkingWithQuer...
I still can't solve it. Any details in question?
Please share your updated code and cleanup empty lines
Here is my Update and Full code. I recently changed the code to use SubscriptionToken instead Delegate Action to call the subscriptions.
My ViewModel File (Dockpane1ViewModel.cs)
using ArcGIS.Core.CIM;
using ArcGIS.Core.Data;
using ArcGIS.Core.Events;
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.Contracts;
using ArcGIS.Desktop.Framework.Events;
using ArcGIS.Desktop.Framework.Dialogs;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Layouts;
using ArcGIS.Desktop.Mapping;
using ArcGIS.Desktop.Mapping.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
namespace AppEstandarizaDirecciones
{
internal class Dockpane1ViewModel : DockPane
{
private const string _dockPaneID = "AppEstandarizaDirecciones_Dockpane1";
protected Dockpane1ViewModel() { }
/// <summary>
/// Show the DockPane.
/// </summary>
///
internal static void Show()
{
DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
if (pane == null)
return;
pane.Activate();
MessageBox.Show("Se MOSTRO el DockPane SHOW-Una Sola vez.");
}
protected override void OnShow(bool isVisible)
{
if (isVisible == true)
{
MessageBox.Show("Se MOSTRO el DockPane en ONSHOW.");
}
}
protected override void OnHidden()
{
Dockpane1View miObjeto = new Dockpane1View();
if (miObjeto._standaloneTablesAddedToken != null)
{
miObjeto.QuitarsubscribeFromStandaloneTablesAddedEvent();
}
if (miObjeto._standaloneTablesRemovedToken != null)
{
miObjeto.QuitarsubscribeFromStandaloneTablesRemovedEvent();
}
MessageBox.Show("Se CERRO el DockPane");
}
/// <summary>
/// Text shown near the top of the DockPane.
/// </summary>
private string _heading = "My DockPane";
public string Heading
{
get { return _heading; }
set
{
SetProperty(ref _heading, value, () => Heading);
}
}
}
/// <summary>
/// Button implementation to show the DockPane.
/// </summary>
internal class Dockpane1_ShowButton : Button
{
protected override void OnClick()
{
Dockpane1ViewModel.Show();
}
}
}
My Xaml File (Dockpane1.xaml.cs)
using ArcGIS.Core.Data;
using ArcGIS.Desktop.Core.Geoprocessing;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Internal.Mapping.Locate;
using ArcGIS.Desktop.Mapping;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
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 ArcGIS.Desktop.Core.Events;
using ArcGIS.Desktop.Mapping.Events;
using ArcGIS.Desktop.Framework.Events;
using ArcGIS.Desktop.Framework.Contracts;
using ArcGIS.Desktop.Internal.Mapping.Georeference.Events;
using ArcGIS.Desktop.Framework;
namespace AppEstandarizaDirecciones
{
/// <summary>
/// Interaction logic for Dockpane1View.xaml
/// </summary>
public partial class Dockpane1View : UserControl
{
List<string> listaTablas = new List<string>();
List<string> listaCampos = new List<string>();
List<string> listaConsultas = new List<string>();
public ArcGIS.Core.Events.SubscriptionToken _standaloneTablesAddedToken; //suscripcion con token AGREGA TABLA
public ArcGIS.Core.Events.SubscriptionToken _standaloneTablesRemovedToken; //suscripcion con token QUITAR TABLA
public Dockpane1View()
{
InitializeComponent();
var mv = MapView.Active;
if (mv != null)
{
var lyrs = mv.Map.GetStandaloneTablesAsFlattenedList();
int cantidadtablas = lyrs.Count();
MessageBox.Show("Cantidad de Tablas: " + cantidadtablas);
foreach (var lyr in lyrs)
{
this.MiComboBox1.Items.Add(lyr.Name);
listaTablas.Add(lyr.Name);
MessageBox.Show("Tabla: " + lyr.Name);
}
}
SubscribeToStandaloneTablesAddedEvent();
MessageBox.Show("Subscripcion ACTIVA AGREGAR TABLA");
SubscribeToStandaloneTablesRemovedEvent();
MessageBox.Show("Subscripcion ACTIVA QUITAR TABLA");
}
//INICIA SUSCRIBE ADD TABLA EVENTO CON TOKEN
public void SubscribeToStandaloneTablesAddedEvent()
{
_standaloneTablesAddedToken=StandaloneTablesAddedEvent.Subscribe(OnStandaloneTablesAdded);
MessageBox.Show("Se ACTIVO subcribe AGREGAR TABLA");
}
public void QuitarsubscribeFromStandaloneTablesAddedEvent()
{
if (_standaloneTablesAddedToken != null)
{
StandaloneTablesAddedEvent.Unsubscribe(_standaloneTablesAddedToken);
MessageBox.Show("Se QUITO Unsubcribe AGREGAR TABLA");
}
}
public void OnStandaloneTablesAdded(StandaloneTableEventArgs obj)
{
foreach (var standaloneTable in obj.Tables)
{
string nombreTablaAdded;
nombreTablaAdded = standaloneTable.Name;
this.Dispatcher.Invoke(() => {
this.MiComboBox2.ItemsSource = null;
this.MiComboBox2.Items.Clear();
this.MiComboBox2.Items.Refresh();
this.MiComboBox1.ItemsSource = null;
this.MiComboBox1.Items.Clear();
this.MiComboBox1.Items.Refresh();
listaTablas.Add(nombreTablaAdded);
this.MiComboBox1.ItemsSource = listaTablas;
this.MiComboBox1.Items.Refresh();
MessageBox.Show("Se AGREGO la tabla " + nombreTablaAdded);
});
}
}
//FINALIZA SUSCRIBE ADD TABLA EVENTO CON TOKEN
//INICIA SUSCRIBE REMOVE TABLA EVENTO CON TOKEN
public void SubscribeToStandaloneTablesRemovedEvent()
{
_standaloneTablesRemovedToken = StandaloneTablesRemovedEvent.Subscribe(OnStandaloneTablesRemoved);
MessageBox.Show("Se ACTIVO subcribe QUITAR TABLA");
}
public void QuitarsubscribeFromStandaloneTablesRemovedEvent()
{
StandaloneTablesRemovedEvent.Unsubscribe(_standaloneTablesRemovedToken);
MessageBox.Show("Se QUITO Unsubcribe QUITAR TABLA");
}
public void OnStandaloneTablesRemoved(StandaloneTableEventArgs obj)
{
foreach (var standaloneTable in obj.Tables)
{
string nombreTablaRemoved;
nombreTablaRemoved = standaloneTable.Name;
this.Dispatcher.Invoke(() => {
this.MiComboBox2.ItemsSource = null;
this.MiComboBox2.Items.Clear();
this.MiComboBox2.Items.Refresh();
this.MiComboBox1.ItemsSource = null;
this.MiComboBox1.Items.Clear();
this.MiComboBox1.Items.Refresh();
listaTablas.Remove(nombreTablaRemoved);
this.MiComboBox1.ItemsSource = listaTablas;
this.MiComboBox1.Items.Refresh();
MessageBox.Show("Se QUITO la tabla " + nombreTablaRemoved);
});
}
}
//FINALIZA SUSCRIBE QUITAR TABLA EVENTO CON TOKEN
public async void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
listaCampos.Clear();
this.MiComboBox2.ItemsSource = null;
this.MiComboBox2.Items.Clear();
this.MiComboBox2.Items.Refresh();
string TablaElegidaPrimero = "";
if (this.MiComboBox1.SelectedItem is null)
{
TablaElegidaPrimero = this.MiComboBox1.SelectedIndex.ToString();
MessageBox.Show("Se selecciono automatico la tabla: " + TablaElegidaPrimero);
}
else
{
string TablaElegida = this.MiComboBox1.SelectedItem.ToString();
MessageBox.Show("Tabla definida: " + TablaElegida);
await QueuedTask.Run(() =>
{
var mvpr = MapView.Active.Map;
var tablaIngresoCambio = mvpr.GetStandaloneTablesAsFlattenedList().OfType<StandaloneTable>().Where(lyrd => lyrd.Name == TablaElegida).FirstOrDefault();
var table = tablaIngresoCambio.GetTable();
IReadOnlyList<Field> fieldList;
fieldList = table.GetDefinition().GetFields();
foreach (var field in fieldList)
{
string nombrecampo = field.Name;
listaCampos.Add(nombrecampo);
}
});
this.MiComboBox2.ItemsSource = listaCampos;
this.MiComboBox2.Items.Refresh();
}
}
private void ComboBox_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
var mvp = MapView.Active.Map;
string NameTablaIngreso = this.MiComboBox1.Text.ToString();
string NameCampoDireccion = this.MiComboBox2.Text.ToString();
var tablaIngreso = mvp.GetStandaloneTablesAsFlattenedList().OfType<StandaloneTable>().Where(lyrd => lyrd.Name == NameTablaIngreso).FirstOrDefault();
//string consulta = "!CAMPOTEST!.replace(\"Untexto\", \"UnTexto\")";
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"av calle\", \"CL\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"AV CALLE\", \"CL\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"calle\", \"CL\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CALLE\", \"CL\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"call\", \"CL\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CALL\", \"CL\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"clle\", \"CL\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CLLE\", \"CL\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"cll\", \"CL\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CLL\", \"CL\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"cal\", \"CL\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CAL\", \"CL\")");
listaConsultas.Add("!"+ NameCampoDireccion + "!.replace(\"Cl\", \"CL\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"cl\", \"CL\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"ac\", \"CL\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"AC\", \"CL\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"avenida carrera\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"AVENIDA CARRERA\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"carrera\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CARRERA\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"crra\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CRRA\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"car\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CAR\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"cra\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CRA\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"cre\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CRE\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"kra\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"KRA\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"crr\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CRR\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"cr\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CR\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"Kr\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"ak\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"AK\", \"KR\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"diagonal\", \"DG\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"DIAGONAL\", \"DG\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"diagnal\", \"DG\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"DIAGNAL\", \"DG\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"Diag\", \"DG\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"DIAG\", \"DG\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"dg\", \"DG\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"transversal\", \"TV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"TRANSVERSAL\", \"TV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"transv\", \"TV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"TRANSV\", \"TV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"trans\", \"TV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"TRANS\", \"TV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"tra\", \"TV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"TRA\", \"TV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"Tr\", \"TV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"TR\", \"TV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"tv\", \"TV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"tras\", \"TV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"TRAS\", \"TV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"trv\", \"TV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"TRV\", \"TV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"autopista\", \"AU\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"AUTOPISTA\", \"AU\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"autop\", \"AU\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"AUTOP\", \"AU\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"auto\", \"AU\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"AUTO\", \"AU\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"aut\", \"AU\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"AUT\", \"AU\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"au\", \"AU\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"circular\", \"CC\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CIRCULAR\", \"CC\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"Circ\", \"CC\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CIRC\", \"CC\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"cir\", \"CC\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CIR\", \"CC\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"avenida\", \"AV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"AVENIDA\", \"AV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"aven\", \"AV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"AVEN\", \"AV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"ave\", \"AV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"AVE\", \"AV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"av\", \"AV\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"Pasaje\", \"Pje\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"PASAJE\", \"Pje\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"Psj\", \"Pje\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"PSJ\", \"Pje\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"caljon\", \"CJ\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CALJON\", \"CJ\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"cljon\", \"CJ\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CLJON\", \"CJ\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"cjon\", \"CJ\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"CJON\", \"CJ\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"Cj\", \"CJ\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"NORTE\", \"N\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"Norte\", \"N\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"norte\", \"N\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"Nte\", \"N\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"NTE\", \"N\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"nt\", \"N\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"NT\", \"N\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"Nt\", \"N\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"SUR\", \"S\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"sur\", \"S\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"Sur\", \"S\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"ESTE\", \"E\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"Este\", \"E\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"este\", \"E\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"OESTE\", \"O\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"Oeste\", \"O\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"oeste\", \"O\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"OE\", \"O\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"Oe\", \"O\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"oe\", \"O\")");
listaConsultas.Add("!" + NameCampoDireccion + "!.replace(\"W\", \"O\")");
//ORGANIZAR PRIMERO LAS CONSULTAS LARGAS
//AGREGAR CONSULTA QUITAR APARTAMENTO-CASA-LOCAL-BLOQUE-TORRE-BODEGA-PISO-ENTRADA-KM-CALLEJON-CORREGIMIENTO
var comotabla = tablaIngreso as StandaloneTable;
using (var progDlg = new ProgressDialog("Procesando Direcciones.", "Cancelar", 100, false))
{
var progsrc=new CancelableProgressorSource(progDlg);
progSrc.Max = 100;
progDlg.Show();
await QueuedTask.Run(() =>
{
int TotalTablas = listaConsultas.Count();
uint PorcetajexTabla = (uint)(100 / TotalTablas);
for (int rdc = 0; rdc < listaConsultas.Count; rdc++)
{
var args = Geoprocessing.MakeValueArray(comotabla, NameCampoDireccion, listaConsultas[rdc], "PYTHON3");
var gp_result = Geoprocessing.ExecuteToolAsync("CalculateField_management", Geoprocessing.MakeValueArray(args.ToArray()));
comotabla.ClearSelection();
progSrc.Progressor.Value += PorcetajexTabla;
progSrc.Progressor.Status = progSrc.Progressor.Value + " % Completado de " + TotalTablas + " Consultas.";
}
}, progSrc.Progressor);
progDlg.Hide();
}
MessageBox.Show("Finalizado.");
}
private void MiComboBox1_MouseDown(object sender, MouseButtonEventArgs e)
{
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
listaCampos.Clear();
this.MiComboBox2.ItemsSource = null;
this.MiComboBox2.Items.Clear();
this.MiComboBox2.Items.Refresh();
List<string> listaCapas = new List<string>();
List<string> listaTempTablas = new List<string>();
this.MiComboBox1.ItemsSource = null;
this.MiComboBox1.Items.Clear();
this.MiComboBox1.Items.Refresh();
var mv2 = MapView.Active;
if (mv2 != null)
{
var lyrs2 = mv2.Map.GetStandaloneTablesAsFlattenedList();
MessageBox.Show("Cantidad tablas encontradas: " + lyrs2.Count);
String MiTablaSeleccionada = "";
foreach (var lyr2 in lyrs2)
{
listaCapas.Add(lyr2.Name);
MiTablaSeleccionada = lyr2.Name;
bool containsString = listaTablas.Contains(MiTablaSeleccionada);
if (containsString)
{
}
else
{
listaTablas.Add(MiTablaSeleccionada);
MessageBox.Show("Se agrego la tabla: " + MiTablaSeleccionada);
}
}
listaTempTablas = new List<string>(listaTablas);
foreach (string ListadoFinalTabla in listaTablas)
{
bool containsString2 = listaCapas.Contains(ListadoFinalTabla);
if (containsString2)
{
}
else
{
listaTempTablas.Remove(ListadoFinalTabla);
MessageBox.Show("Se Quito la tabla: " + ListadoFinalTabla);
}
}
listaTablas = new List<string>(listaTempTablas);
MiTablaSeleccionada = "";
}
MessageBox.Show("Antes de asignar lista de tablas");
string lasTablas="";
foreach (string ListadoFinalTabla in listaTablas)
{
lasTablas += ListadoFinalTabla+", ";
}
MessageBox.Show("Tablas Encontradas en la listaTablas: "+lasTablas);
this.MiComboBox1.ItemsSource = listaTablas;
this.MiComboBox1.Items.Refresh();
MessageBox.Show("Despues de asignar lista de tablas");
}
public void Button_Click_2(object sender, RoutedEventArgs e)
{
QuitarsubscribeFromStandaloneTablesAddedEvent();
MessageBox.Show("Se llama funcion Quitar suscripcion Monitorea AGREGAR TABLA.");
QuitarsubscribeFromStandaloneTablesRemovedEvent();
MessageBox.Show("Se llama funcion Quitar suscripcion Monitorea QUITAR TABLA.");
}
}
}
Thanks for the attention
The New (Dockpane1View.xaml)
Hi,
As I said earlier you don't need code in Dockpane1View.xaml.cs.
Delete all content from Dockpane1View.xaml.cs except constructor with one line InitializeComponent(); or create new dockpane from scratch.
Your comboboxes must be binded to Dovpane1ViewModel properties as in MetadataBrowserControl sample. Combobox selection event will update special property in Docpane1ViewModel.
Bind buttons to commands as in WorkingWithQueryDefinitionFilters sample.
All stable properties fill in Dockpane contructor or override InitializeAsync() method as in samples above.
In overriden OnShow method subscribe/unsubscribe to/from events and fill properties which can change content which depends on MapView or current application status.
If it's difficult to understand how it works, download mentioned samples, build and debug using Visual Studio. MVVM is WPF stuff, not ArcGIS Pro.