OliviaAddInPro/ViewModel/ShowProWndSelectFields.cs

131 lines
3.8 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;
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;
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)
{
OliviaGlob.ponMsg(HelperGdb.out_st, MessageType.Error);
}
else
{
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
}
}