OliviaAddInPro/ViewModel/ShowProWndSelectFields.cs

145 lines
4.2 KiB
C#

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<string> fields = new ObservableCollection<string>();
private ObservableCollection<string> attributes = new ObservableCollection<string>();
private ObservableCollection<string> selFieldVal = new ObservableCollection<string>();
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<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> 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
}
}