|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.Geodatabase;
|
|
|
|
|
using ESRI.ArcGIS.Geometry;
|
|
|
|
|
using KGIS.Framework.Maps;
|
|
|
|
|
using KGIS.Framework.Platform;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using KGIS.Framework.Utils.ExtensionMethod;
|
|
|
|
|
using KGIS.Framework.Views;
|
|
|
|
|
using Kingo.PluginServiceInterface;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
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 UIShell.OSGi;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.BHTB_Extract.View
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// UcZYQMagr.xaml 的交互逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class UcZYQMagr : UserControl, IDockPanel3
|
|
|
|
|
{
|
|
|
|
|
private IFeatureLayer _Layer = null;
|
|
|
|
|
private DataTable _Data = new DataTable();
|
|
|
|
|
private string queryWhere = string.Empty;
|
|
|
|
|
|
|
|
|
|
public event EventHandler CloseViewHandler;
|
|
|
|
|
|
|
|
|
|
public bool IsDockToPanel { get; set; }
|
|
|
|
|
public DockStyle DockToPanelStyle { get; set; }
|
|
|
|
|
public bool IsShowInMap { get; set; }
|
|
|
|
|
public Guid ID { get; set; }
|
|
|
|
|
public DockStyle DockAreas { get; set; }
|
|
|
|
|
public System.Drawing.Size FloatSize { get; set; }
|
|
|
|
|
public int DockWidth { get; set; }
|
|
|
|
|
public int DockHeight { get; set; }
|
|
|
|
|
public DockStyle DefaultArea { get; set; }
|
|
|
|
|
public bool ShowCloseButton { get; set; }
|
|
|
|
|
public bool ShowAutoHideButton { get; set; }
|
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
|
|
|
|
|
public string packUri { get { return @"/KUI;component/Themes/Generic"; } }
|
|
|
|
|
|
|
|
|
|
private static UcZYQMagr instance;
|
|
|
|
|
public static UcZYQMagr Instance
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (instance == null)
|
|
|
|
|
{
|
|
|
|
|
instance = new UcZYQMagr();
|
|
|
|
|
}
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private UcZYQMagr()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom("KUI.dll");
|
|
|
|
|
//System.Windows.ResourceDictionary myResourceDictionary = System.Windows.Application.LoadComponent(new Uri(packUri + ".xaml", UriKind.Relative)) as System.Windows.ResourceDictionary;
|
|
|
|
|
//this.Resources.MergedDictionaries.Add(myResourceDictionary);
|
|
|
|
|
|
|
|
|
|
this.DockAreas = KGIS.Framework.Views.DockStyle.DockLeft;
|
|
|
|
|
|
|
|
|
|
this.FloatSize = new System.Drawing.Size(230, 160);
|
|
|
|
|
this.DefaultArea = KGIS.Framework.Views.DockStyle.DockLeft;
|
|
|
|
|
this.ShowCloseButton = false;
|
|
|
|
|
this.ShowAutoHideButton = true;
|
|
|
|
|
this.Title = "作业区管理";
|
|
|
|
|
this.IsShowInMap = false;
|
|
|
|
|
this.DockHeight = 160;
|
|
|
|
|
this.DockWidth = 230;
|
|
|
|
|
this.IsDockToPanel = false;
|
|
|
|
|
this.DockToPanelStyle = KGIS.Framework.Views.DockStyle.DockLeft | KGIS.Framework.Views.DockStyle.Document;
|
|
|
|
|
|
|
|
|
|
_Layer = MapsManager.Instance.MapService.GetFeatureLayerByName("ZYQ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ConstructColumn(IFields fields)
|
|
|
|
|
{
|
|
|
|
|
if (fields != null)
|
|
|
|
|
{
|
|
|
|
|
_Data.Clear();
|
|
|
|
|
_Data.PrimaryKey = null;
|
|
|
|
|
_Data.Columns.Clear();
|
|
|
|
|
|
|
|
|
|
AddInitFieldData(fields);
|
|
|
|
|
string oidField = "OBJECTID";
|
|
|
|
|
if (!_Data.Columns.Contains(oidField) && _Data.Columns.Contains("FID"))
|
|
|
|
|
{
|
|
|
|
|
oidField = "FID";
|
|
|
|
|
}
|
|
|
|
|
_Data.PrimaryKey = new DataColumn[] { _Data.Columns[oidField] };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void AddInitFieldData(IFields fields)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = fields.get_Field(i);
|
|
|
|
|
if (field.Name.ToUpper().EndsWith("SHAPE"))
|
|
|
|
|
continue;
|
|
|
|
|
DataColumn col = new DataColumn();
|
|
|
|
|
col.ExtendedProperties.Add("index", i);
|
|
|
|
|
col.ColumnName = field.Name;
|
|
|
|
|
col.Caption = field.AliasName;
|
|
|
|
|
switch (field.Type)
|
|
|
|
|
{
|
|
|
|
|
case esriFieldType.esriFieldTypeSmallInteger:
|
|
|
|
|
col.DataType = typeof(short);
|
|
|
|
|
break;
|
|
|
|
|
case esriFieldType.esriFieldTypeInteger:
|
|
|
|
|
col.DataType = typeof(int);
|
|
|
|
|
break;
|
|
|
|
|
case esriFieldType.esriFieldTypeSingle:
|
|
|
|
|
break;
|
|
|
|
|
case esriFieldType.esriFieldTypeDouble:
|
|
|
|
|
col.DataType = typeof(double);
|
|
|
|
|
break;
|
|
|
|
|
case esriFieldType.esriFieldTypeString:
|
|
|
|
|
col.DataType = typeof(string);
|
|
|
|
|
break;
|
|
|
|
|
case esriFieldType.esriFieldTypeDate:
|
|
|
|
|
col.DataType = typeof(DateTime);
|
|
|
|
|
break;
|
|
|
|
|
case esriFieldType.esriFieldTypeOID:
|
|
|
|
|
col.DataType = typeof(Int32);
|
|
|
|
|
break;
|
|
|
|
|
case esriFieldType.esriFieldTypeGeometry:
|
|
|
|
|
break;
|
|
|
|
|
case esriFieldType.esriFieldTypeBlob:
|
|
|
|
|
break;
|
|
|
|
|
case esriFieldType.esriFieldTypeRaster:
|
|
|
|
|
break;
|
|
|
|
|
case esriFieldType.esriFieldTypeGUID:
|
|
|
|
|
break;
|
|
|
|
|
case esriFieldType.esriFieldTypeGlobalID:
|
|
|
|
|
break;
|
|
|
|
|
case esriFieldType.esriFieldTypeXML:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
col.ReadOnly = !field.Editable;//编辑状态启用默认是否可以编辑
|
|
|
|
|
if (_Data.Columns.Contains(col.ColumnName) == false)//不存在则添加
|
|
|
|
|
{
|
|
|
|
|
_Data.Columns.Add(col);
|
|
|
|
|
}
|
|
|
|
|
Marshal.ReleaseComObject(field);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("加载表格数据失败!" + ex);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public TreeNode node = null;
|
|
|
|
|
public void InitTreeView()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_Layer = MapsManager.Instance.MapService.GetFeatureLayerByName("ZYQ");
|
|
|
|
|
if (_Layer == null) return;
|
|
|
|
|
ConstructColumn(this._Layer.FeatureClass.Fields);
|
|
|
|
|
|
|
|
|
|
IAttributeTable AttrTable = _Layer as IAttributeTable;
|
|
|
|
|
IQueryFilter queryfilter = new QueryFilterClass
|
|
|
|
|
{
|
|
|
|
|
WhereClause = queryWhere
|
|
|
|
|
};
|
|
|
|
|
//ITable table = SourceFeature as ITable;
|
|
|
|
|
ICursor cursor = AttrTable.AttributeTable.Search(queryfilter, true);
|
|
|
|
|
|
|
|
|
|
int count = AttrTable.AttributeTable.RowCount(queryfilter);
|
|
|
|
|
IRow row = null;
|
|
|
|
|
DataTable tempDt = _Data.Copy();
|
|
|
|
|
tempDt.Rows.Clear();
|
|
|
|
|
bool isExitFeatureXML = false;// JudgeExistsCurrentFeatureXML();
|
|
|
|
|
int columnCount = 0;
|
|
|
|
|
int fieldIndex = 0;
|
|
|
|
|
while ((row = cursor.NextRow()) != null)
|
|
|
|
|
{
|
|
|
|
|
DataRow dr = tempDt.NewRow();
|
|
|
|
|
if (isExitFeatureXML) columnCount = tempDt.Columns.Count - 1;
|
|
|
|
|
else columnCount = tempDt.Columns.Count;
|
|
|
|
|
for (int i = 0; i < columnCount; i++)
|
|
|
|
|
{
|
|
|
|
|
if (isExitFeatureXML)
|
|
|
|
|
fieldIndex = (int)tempDt.Columns[row.Fields.FindField(tempDt.Columns[i].ColumnName)].ExtendedProperties["index"];
|
|
|
|
|
else
|
|
|
|
|
fieldIndex = (int)tempDt.Columns[i].ExtendedProperties["index"];
|
|
|
|
|
object obj = row.get_Value(fieldIndex);
|
|
|
|
|
if (obj == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (obj.ToString().Contains("1899/12/30 0:00:00"))
|
|
|
|
|
{
|
|
|
|
|
obj = DBNull.Value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dr[i] = obj;
|
|
|
|
|
}
|
|
|
|
|
tempDt.Rows.Add(dr);
|
|
|
|
|
if (tempDt.Rows.Count == 10000)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_Data = tempDt.Copy();
|
|
|
|
|
Marshal.ReleaseComObject(AttrTable);
|
|
|
|
|
Marshal.ReleaseComObject(_Layer);
|
|
|
|
|
_Data = tempDt.Copy();
|
|
|
|
|
ObservableCollection<TreeNode> itemList = new ObservableCollection<TreeNode>();
|
|
|
|
|
node = new TreeNode()
|
|
|
|
|
{
|
|
|
|
|
Name = "作业区列表",
|
|
|
|
|
Paixu = 0,
|
|
|
|
|
IsExpanded = true,
|
|
|
|
|
Icon = "/Kingo.Plugin.BHTB_Extract;component/Resources/标记.png",
|
|
|
|
|
IsParent = true,
|
|
|
|
|
Data = null
|
|
|
|
|
};
|
|
|
|
|
node.Nodes = new ObservableCollection<TreeNode>();
|
|
|
|
|
foreach (DataRow _dr in _Data.Rows)
|
|
|
|
|
{
|
|
|
|
|
TreeNode zyqNode = new TreeNode()
|
|
|
|
|
{
|
|
|
|
|
Name = _dr["ZYQBH"] is DBNull ? _dr["ZYQMC"].ToTrim() : _dr["ZYQBH"].ToString(),
|
|
|
|
|
Paixu = 0,
|
|
|
|
|
IsExpanded = true,
|
|
|
|
|
Icon = "pack://application:,,,/Kingo.Plugin.DataDictionary;component/Resources/zrz.png",
|
|
|
|
|
IsParent = true,
|
|
|
|
|
Data = _dr["OBJECTID"]
|
|
|
|
|
};
|
|
|
|
|
switch (_dr["ZYQZT"].ToTrim())
|
|
|
|
|
{
|
|
|
|
|
case "0":
|
|
|
|
|
zyqNode.Icon = "/Kingo.Plugin.BHTB_Extract;component/Resources/未完成.png";
|
|
|
|
|
break;
|
|
|
|
|
case "1":
|
|
|
|
|
zyqNode.Icon = "/Kingo.Plugin.BHTB_Extract;component/Resources/进行中.png";
|
|
|
|
|
break;
|
|
|
|
|
case "2":
|
|
|
|
|
zyqNode.Icon = "/Kingo.Plugin.BHTB_Extract;component/Resources/已完成.png";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
zyqNode.cMenu = new ContextMenu();
|
|
|
|
|
MenuItem tmpitem = new MenuItem();
|
|
|
|
|
tmpitem.Tag = zyqNode;
|
|
|
|
|
tmpitem.Header = "已完成";
|
|
|
|
|
tmpitem.Click += (s, e) =>
|
|
|
|
|
{
|
|
|
|
|
MenuItem item = s as MenuItem;
|
|
|
|
|
if (item.Tag == null) return;
|
|
|
|
|
|
|
|
|
|
TreeNode tempNode = item.Tag as TreeNode;
|
|
|
|
|
int idx = _Layer.FeatureClass.FindField("ZYQZT");
|
|
|
|
|
if (idx == -1) return;
|
|
|
|
|
|
|
|
|
|
IFeature f = _Layer.FeatureClass.GetFeature(tempNode.Data.ToInt());
|
|
|
|
|
f.Value[idx] = 2;
|
|
|
|
|
f.Store();
|
|
|
|
|
tempNode.Icon = "/Kingo.Plugin.BHTB_Extract;component/Resources/已完成.png";
|
|
|
|
|
Marshal.ReleaseComObject(f);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
zyqNode.cMenu.Items.Add(tmpitem);
|
|
|
|
|
tmpitem = new MenuItem();
|
|
|
|
|
tmpitem.Tag = zyqNode;
|
|
|
|
|
tmpitem.Header = "进行中";
|
|
|
|
|
tmpitem.Click += (s, e) =>
|
|
|
|
|
{
|
|
|
|
|
MenuItem item = s as MenuItem;
|
|
|
|
|
if (item.Tag == null) return;
|
|
|
|
|
|
|
|
|
|
TreeNode tempNode = item.Tag as TreeNode;
|
|
|
|
|
int idx = _Layer.FeatureClass.FindField("ZYQZT");
|
|
|
|
|
if (idx == -1) return;
|
|
|
|
|
|
|
|
|
|
IFeature f = _Layer.FeatureClass.GetFeature(tempNode.Data.ToInt());
|
|
|
|
|
f.Value[idx] = 1;
|
|
|
|
|
f.Store();
|
|
|
|
|
tempNode.Icon = "/Kingo.Plugin.BHTB_Extract;component/Resources/进行中.png";
|
|
|
|
|
Marshal.ReleaseComObject(f);
|
|
|
|
|
};
|
|
|
|
|
zyqNode.cMenu.Items.Add(tmpitem);
|
|
|
|
|
tmpitem = new MenuItem();
|
|
|
|
|
tmpitem.Tag = zyqNode;
|
|
|
|
|
tmpitem.Header = "未开始";
|
|
|
|
|
tmpitem.Click += (s, e) =>
|
|
|
|
|
{
|
|
|
|
|
MenuItem item = s as MenuItem;
|
|
|
|
|
if (item.Tag == null) return;
|
|
|
|
|
|
|
|
|
|
TreeNode tempNode = item.Tag as TreeNode;
|
|
|
|
|
int idx = _Layer.FeatureClass.FindField("ZYQZT");
|
|
|
|
|
if (idx == -1) return;
|
|
|
|
|
|
|
|
|
|
IFeature f = _Layer.FeatureClass.GetFeature(tempNode.Data.ToInt());
|
|
|
|
|
f.Value[idx] = 0;
|
|
|
|
|
f.Store();
|
|
|
|
|
tempNode.Icon = "/Kingo.Plugin.BHTB_Extract;component/Resources/未完成.png";
|
|
|
|
|
Marshal.ReleaseComObject(f);
|
|
|
|
|
};
|
|
|
|
|
zyqNode.cMenu.Items.Add(tmpitem);
|
|
|
|
|
node.Nodes.Add(zyqNode);
|
|
|
|
|
//TreeNode subNode = new TreeNode();
|
|
|
|
|
//subNode.Text = _dr["ZYQBH"] is DBNull ? "" : _dr["ZYQBH"].ToString();
|
|
|
|
|
//subNode.Tag = _dr["OBJECTID"];
|
|
|
|
|
//node.Nodes.Add(subNode);
|
|
|
|
|
}
|
|
|
|
|
itemList.Add(node);
|
|
|
|
|
this.tvTypes.ItemsSource = null;
|
|
|
|
|
tvTypes.ItemsSource = itemList;
|
|
|
|
|
//tvDirectory.Nodes.Add(node);
|
|
|
|
|
if (node.Nodes.Count != 0)
|
|
|
|
|
node.Nodes[0].Checked = true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("初始化作业区列表时发生异常,异常信息如下:" + ex);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool isUpdatingSelection = false;
|
|
|
|
|
private void tvTypes_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!isUpdatingSelection)
|
|
|
|
|
{
|
|
|
|
|
// 标记正在更新选择
|
|
|
|
|
isUpdatingSelection = true;
|
|
|
|
|
|
|
|
|
|
TreeNode node = e.NewValue as TreeNode;
|
|
|
|
|
if (node == null || node.Data == null) return;
|
|
|
|
|
if (_Layer == null) return;
|
|
|
|
|
IGeometry currentGeo = _Layer.FeatureClass.GetFeature(node.Data.ToInt()).ShapeCopy;
|
|
|
|
|
MapsManager.Instance.MapService.Zoom(currentGeo);
|
|
|
|
|
//遮罩
|
|
|
|
|
//MaskRectangleHelper.ShowMask(node.Data.ToInt());
|
|
|
|
|
|
|
|
|
|
//有问题 列表选择 此执行两次
|
|
|
|
|
IUcMulitMapControlHelper ucMulitMapControlHelper = BundleRuntime.Instance.GetFirstOrDefaultService<IUcMulitMapControlHelper>();
|
|
|
|
|
if (ucMulitMapControlHelper != null)
|
|
|
|
|
{
|
|
|
|
|
ucMulitMapControlHelper.SetMask(currentGeo);
|
|
|
|
|
}
|
|
|
|
|
ShowMaskHelper showMaskForBHTBHelper = new ShowMaskHelper();
|
|
|
|
|
showMaskForBHTBHelper.axMapControl = MapsManager.Instance.MapService.getAxMapControl();
|
|
|
|
|
showMaskForBHTBHelper.ShowMask(currentGeo);
|
|
|
|
|
//showMaskForBHTBHelper.ShowAllMask(null, currentGeo);
|
|
|
|
|
|
|
|
|
|
// 取消标记更新选择
|
|
|
|
|
isUpdatingSelection = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("点击作业区列表刷新时发生异常,异常信息如下:" + ex);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tvTypes_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var treeViewItem = VisualUpwardSearch<TreeViewItem>(e.OriginalSource as DependencyObject) as TreeViewItem;
|
|
|
|
|
if (treeViewItem != null)
|
|
|
|
|
{
|
|
|
|
|
treeViewItem.Focus();
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tvTypes_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var treeViewItem = VisualUpwardSearch<TreeViewItem>(e.OriginalSource as DependencyObject) as TreeViewItem;
|
|
|
|
|
if (treeViewItem != null)
|
|
|
|
|
{
|
|
|
|
|
treeViewItem.Focus();
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
static DependencyObject VisualUpwardSearch<T>(DependencyObject source)
|
|
|
|
|
{
|
|
|
|
|
while (source != null && source.GetType() != typeof(T))
|
|
|
|
|
source = VisualTreeHelper.GetParent(source);
|
|
|
|
|
|
|
|
|
|
return source;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddMask(int selectIdZYQ)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (selectIdZYQ < 0) return;
|
|
|
|
|
_Layer = MapsManager.Instance.MapService.GetFeatureLayerByName("ZYQ");
|
|
|
|
|
if (_Layer == null) return;
|
|
|
|
|
selectIdZYQ++;
|
|
|
|
|
IGeometry currentGeo = _Layer.FeatureClass.GetFeature(selectIdZYQ).ShapeCopy;
|
|
|
|
|
if (currentGeo == null || currentGeo.IsEmpty) return;
|
|
|
|
|
ShowMaskHelper showMaskForBHTBHelper = new ShowMaskHelper();
|
|
|
|
|
showMaskForBHTBHelper.axMapControl = MapsManager.Instance.MapService.getAxMapControl();
|
|
|
|
|
showMaskForBHTBHelper.ShowMask(currentGeo, false);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ShowPanel()
|
|
|
|
|
{
|
|
|
|
|
Platform.Instance.OpenView(this, false);
|
|
|
|
|
//MapsManager.Instance.MapService.ProjectClosed += (s, e) =>
|
|
|
|
|
//{
|
|
|
|
|
// this.ClosePanel();
|
|
|
|
|
//};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ClosePanel()
|
|
|
|
|
{
|
|
|
|
|
Platform.Instance.CloseView(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ClosePanelInvoke()
|
|
|
|
|
{
|
|
|
|
|
CloseViewHandler?.Invoke(null, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ClearData()
|
|
|
|
|
{
|
|
|
|
|
this.tvTypes.ItemsSource = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int GetCheckedID()
|
|
|
|
|
{
|
|
|
|
|
if (tvTypes.ItemsSource != null)
|
|
|
|
|
{
|
|
|
|
|
ObservableCollection<TreeNode> tvTreeNode = tvTypes.ItemsSource as ObservableCollection<TreeNode>;
|
|
|
|
|
if (tvTreeNode != null)
|
|
|
|
|
return tvTreeNode[0].Nodes.FindIndex(a => a.Checked == true);
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public class TreeNode : System.ComponentModel.INotifyPropertyChanged
|
|
|
|
|
{
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
|
|
|
|
private void PropertyChange(string pProperty)
|
|
|
|
|
{
|
|
|
|
|
if (this.PropertyChanged != null)
|
|
|
|
|
{
|
|
|
|
|
this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(pProperty));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#region Property
|
|
|
|
|
|
|
|
|
|
private string _Text;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 显示的文本值
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return this._Text; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this._Text = value;
|
|
|
|
|
PropertyChange("Name");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ContextMenu _cMenu;
|
|
|
|
|
public ContextMenu cMenu
|
|
|
|
|
{
|
|
|
|
|
get { return this._cMenu; }
|
|
|
|
|
set { this._cMenu = value; }
|
|
|
|
|
}
|
|
|
|
|
private bool? _Checked;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否选中
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool? Checked
|
|
|
|
|
{
|
|
|
|
|
get { return this._Checked; }
|
|
|
|
|
set { this._Checked = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool _IsExpanded;
|
|
|
|
|
private string icon;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否展开
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsExpanded
|
|
|
|
|
{
|
|
|
|
|
get { return this._IsExpanded; }
|
|
|
|
|
set { this._IsExpanded = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 节点图标:相对路径
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Icon
|
|
|
|
|
{
|
|
|
|
|
get { return icon; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
icon = value;
|
|
|
|
|
|
|
|
|
|
PropertyChange("Icon");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 子节点,默认null
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IList<TreeNode> Nodes { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 该节点数据项,默认null
|
|
|
|
|
/// </summary>
|
|
|
|
|
public virtual object Data { get; set; }
|
|
|
|
|
|
|
|
|
|
public virtual bool IsOpenEdit { get; set; }
|
|
|
|
|
public object Paixu { get; internal set; }
|
|
|
|
|
public bool IsParent { get; internal set; }
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region NodeX-构造函数(初始化)
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// NodeX-构造函数(初始化)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public TreeNode()
|
|
|
|
|
{
|
|
|
|
|
this.Name = string.Empty;
|
|
|
|
|
this.Icon = string.Empty;
|
|
|
|
|
this.Checked = false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|