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; using ArcGIS.Desktop.Internal.Framework.Controls; using System.Windows.Controls.Primitives; using ArcGIS.Desktop.Internal.Core; namespace OliviaAddInPro.View { public class ShowProWndSelectFields : ArcGIS.Desktop.Framework.Contracts.Button { private ProWndSelectFields _prowndselectfields = null; private ObservableCollection fields = new ObservableCollection(); private ObservableCollection attributes = new ObservableCollection(); private ObservableCollection selFieldVal = new ObservableCollection(); private int selIndx = -1; private string selField = string.Empty; private bool multiSelAtt = true; private FeatureClass ftClass = null; public string err_st=string.Empty; public bool res = false; #region Methods public ShowProWndSelectFields(FeatureClass fc, bool _multiSelAtt) { ftClass = fc; //pathLyr = it.Path; multiSelAtt = _multiSelAtt; fields = HelperGdb.GetFields(ftClass).Result; if (fields.Count == 0) { if (HelperGdb.OutStr.Length > 0) HelperGlobal.ponMsg(HelperGdb.OutStr, System.Windows.MessageBoxImage.Error); else HelperGlobal.ponMsg(Resource1.String_error_elems_tabla, System.Windows.MessageBoxImage.Warning); } else { attributes.Clear(); muestra(); } } private void muestra() { //already open? if (_prowndselectfields != null) return; _prowndselectfields = new ProWndSelectFields(ftClass, this); _prowndselectfields.Owner = FrameworkApplication.Current.MainWindow; bool? res = _prowndselectfields.ShowDialog(); if (res ?? true) { foreach (var it in _prowndselectfields.listBoxAttributes.SelectedItems) { SelFieldVals.Add(it.ToString()); } } } #endregion Methods #region Properties public ObservableCollection Fields { get { return fields; } set { fields = value; base.NotifyPropertyChanged("Fields"); } } public ObservableCollection Attributes { get { return attributes; } set { attributes = value; base.NotifyPropertyChanged("Attributes"); } } public ObservableCollection SelFieldVals { get { return selFieldVal; } set { selFieldVal = value; base.NotifyPropertyChanged("SelFieldVal"); } } public int SelIndx { get { return selIndx; } set { selIndx = value; base.NotifyPropertyChanged("SelIndx"); } } 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 } }