年度变更建库软件5.0版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
4.9 KiB

using KGIS.Framework.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
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;
namespace Kingo.Plugin.BGSetting.View.ViewSystemSetting
{
/// <summary>
/// 单图斑属性页面配置 的交互逻辑
/// </summary>
public partial class ViewAttributeShowSetting : UserControl
{
private System.Xml.XmlDocument doc = null;
private readonly string ArearNameCode = SysConfigsOprator.GetAppsetingValueByKey("ArearName");
private readonly string strPath = SysAppPath.GetConfigPath() + "AttributeShowConfigs.xml";
public ViewAttributeShowSetting()
{
InitializeComponent();
this.Loaded += InitData;
}
private void InitData(object sender, RoutedEventArgs e)
{
try
{
List<AttributeShowInfo> attributeShowInfos = new List<AttributeShowInfo>();
doc = new System.Xml.XmlDocument();
doc.Load(strPath);
System.Xml.XmlNode xmlSysNode = doc.SelectSingleNode("Attributes");
if (xmlSysNode.ChildNodes != null && xmlSysNode.ChildNodes.Count > 0)
{
foreach (System.Xml.XmlNode node in xmlSysNode.ChildNodes)
{
if (node.Attributes["Name"].Value.Contains(ArearNameCode))//绑定区域码
{
AttributeShowInfo attributeShow = new AttributeShowInfo();
foreach (System.Xml.XmlNode itemNode in node.ChildNodes)
{
if (itemNode.Attributes == null) return;//过滤注释项
attributeShow = new AttributeShowInfo
{
Name = itemNode.Attributes["Name"].Value,
ViewName = itemNode.Attributes["ViewName"].Value,
Type = itemNode.Attributes["Type"].Value,
IsShow = itemNode.Attributes["IsShow"].Value == "false" ? false : true
};
if (attributeShowInfos.FirstOrDefault(x => x.Name.Equals(attributeShow.Name)) == null)
attributeShowInfos.Add(attributeShow);
}
}
}
dgCtrl.ItemsSource = null;
dgCtrl.ItemsSource = attributeShowInfos;
}
}
catch (Exception ex)
{
LogAPI.Debug("属性页面配置异常:" + ex.Message);
}
}
/// <summary>
/// 单元格修改
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TableView_CellValueChanged(object sender, DevExpress.Xpf.Grid.CellValueChangedEventArgs e)
{
try
{
string AttributeName = (e.Source.FocusedRow as AttributeShowInfo).Name;
bool AttributeIsShow = (e.Source.FocusedRow as AttributeShowInfo).IsShow;
if (doc == null) return;
System.Xml.XmlNode xmlSysNode = doc.SelectSingleNode("Attributes");
if (xmlSysNode.ChildNodes != null && xmlSysNode.ChildNodes.Count > 0)
{
foreach (System.Xml.XmlNode node in xmlSysNode.ChildNodes)
{
if (node.Attributes["Name"].Value.Contains(ArearNameCode))//绑定区域码
{
foreach (System.Xml.XmlNode itemNode in node.ChildNodes)
{
if (itemNode.Attributes == null) return;//过滤注释项
if (itemNode.Attributes["Name"].Value.Equals(AttributeName))
{
itemNode.Attributes["IsShow"].Value = AttributeIsShow ? "false" : "True";
break;
}
}
}
}
doc.Save(strPath);
}
}
catch (Exception ex)
{
LogAPI.Debug("修改属性页面配置发生异常:" + ex);
}
}
}
public class AttributeShowInfo
{
public string Name { set; get; }
public string ViewName { set; get; }
public string Type { set; get; }
public bool IsShow { set; get; }
}
}