using KGIS.Framework.Platform;
using KGIS.Framework.Utils;
using KGIS.Framework.Utils.Helper;
using Kingo.Plugin.MapView.Model;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace Kingo.Plugin.MapView.Views
{
///
/// FrmSelectQS.xaml 的交互逻辑
///
public partial class FrmSelectQS : UserControl
{
public event EditDicHandler EditDic;
public Action SelectedItemChanged;
private int SelectedLength = 0;
public FrmSelectQS(int pSelectedLength)
{
InitializeComponent();
this.SelectedLength = pSelectedLength;
Init();
}
private void TreeViewItem_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
var treeViewItem = VisualUpwardSearch(e.OriginalSource as DependencyObject) as TreeViewItem;
if (treeViewItem != null)
{
treeViewItem.Focus();
e.Handled = true;
}
}
DependencyObject VisualUpwardSearch(DependencyObject source)
{
while (source != null && source.GetType() != typeof(T))
source = VisualTreeHelper.GetParent(source);
return source;
}
public void Init()
{
try
{
//List dicList = DicAPI.GetDic(Enum.DicTypeEnum.QSDM, true);
//if (dicList == null)
// return;
//List treeList = GetTree(dicList);
//this.tvXZQ.ItemsSource = treeList;
}
catch (Exception ex)
{
LogAPI.Debug("加载数据字典失败 时异常,异常信息如下:");
LogAPI.Debug(ex);
LogAPI.Debug("加载数据字典失败 时异常信息结束");
MessageHelper.ShowTips("加载数据字典失败!");
//LogAPI.Debug("【按行政区划归】加载数据字典异常:" + ex);
}
}
private List GetTree(List dicList)
{
try
{
if (dicList == null)
return null;
List result = new List();
foreach (DataDicTionary dic in dicList)
{
var n1 = new TreeNode();
n1.Name = dic.NAME;
n1.Data = dic;
n1.Icon = "pack://application:,,,/KGIS.PlatformPlugin;component/Resources/zrz.png";
if (dic.CODE.Length > 6)
n1.IsExpanded = false;
else
n1.IsExpanded = true;
//n1.cMenu = "RouterMenu";
result.Add(n1);
if (dic.SubDic != null && dic.SubDic.Count > 0)
{
n1.Nodes = GetTree(dic.SubDic);
}
}
return result;
}
catch (Exception ex)
{
LogAPI.Debug("选择所要划归的行政区期间 获取信息树 时异常,异常信息如下:");
LogAPI.Debug(ex);
LogAPI.Debug("选择所要划归的行政区期间 获取信息树 时异常信息结束");
throw ex;
}
}
public object GetSelectedItem()
{
return tvXZQ.SelectedItem;
}
private void tvXZQ_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs