年度变更建库软件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.
 
 

168 lines
6.4 KiB

using ESRI.ArcGIS.Carto;
using KGIS.Framework.Maps;
using KGIS.Framework.Platform;
using KGIS.Framework.Utils;
using KGIS.Framework.Utils.Helper;
using Kingo.KMapSDK;
using Kingo.PluginServiceInterface;
using Kingo.PluginServiceInterface.Helper;
using Kingo.PluginServiceInterface.Model;
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;
using UIShell.OSGi;
namespace Kingo.Plugin.DTBJK_XJ.View
{
/// <summary>
/// UCSetAllMapImageUrls.xaml 的交互逻辑
/// </summary>
public partial class UCSetAllMapImageUrls : BaseWindow
{
public UCSetAllMapImageUrls()
{
InitializeComponent();
Load();
}
private void Load()
{
List<ImageSlicing> keyAndValues = UserLoginHelper.GetAllYXGroupLayer();
dgTableMapping.ItemsSource = keyAndValues;
}
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
dgTableMapping.Items.Add(new ImageSlicing() { });
//tvAttrDTB.AddNewRow();
//tvAttrDTB.AllowEditing = true;
}
public List<ImageSlicing> AlllistTableMapping { get; set; }
private void btnDelete_Click(object sender, RoutedEventArgs e)
{
try
{
AlllistTableMapping = dgTableMapping.ItemsSource as List<ImageSlicing>;
//List<ImageSlicing> AlllistTableMapping = dgTableMapping.ItemsSource as List<ImageSlicing>;
List<ImageSlicing> listTableMapping = AlllistTableMapping;
if (listTableMapping == null || listTableMapping.Count == 0) return;
listTableMapping = AlllistTableMapping.FindAll(a => a.IsCheck);
if (listTableMapping == null || listTableMapping.Count == 0)
{
MessageHelper.ShowTips("请选择影响地址后删除!");
return;
}
foreach (ImageSlicing item in listTableMapping)
{
AlllistTableMapping.Remove(item);
UserLoginHelper.DeleteYXGroupLayerValueByName(item.Name);
}
dgTableMapping.ItemsSource = null;
dgTableMapping.ItemsSource = AlllistTableMapping;
}
catch (Exception ex)
{
LogAPI.Debug("UCSetAllMapImageUrls.btnDelete_Click异常:" + ex.Message);
LogAPI.Debug("UCSetAllMapImageUrls.btnDelete_Click异常:" + ex.StackTrace);
}
}
private void btnSave_Click(object sender, RoutedEventArgs e)
{
try
{
List<ImageSlicing> listTableMapping = dgTableMapping.ItemsSource as List<ImageSlicing>;
if (listTableMapping == null || listTableMapping.Count == 0) return;
foreach (ImageSlicing item in listTableMapping)
{
if (item == null || string.IsNullOrEmpty(item.Name) || string.IsNullOrEmpty(item.Alias) || string.IsNullOrEmpty(item.Path))
{
MessageHelper.ShowTips("图层名或路径不符合要求,请输入正确值后进行保存");
return;
}
UserLoginHelper.UpdateYXGroupLayerValueByName(item.Name, item.Alias, item.Path);
}
//加载图层
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "InitProject" });
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "SaveProjectForNoEditor" });
//刷新地图窗口
MapsManager.Instance.MapService.getAxMapControl().ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, MapsManager.Instance.MapService.getAxMapControl().Extent);
this.DialogResult = true;
this.Close();
}
catch (Exception ex)
{
LogAPI.Debug("UCSetAllMapImageUrls.btnSave_Click 异常:" + ex.Message);
LogAPI.Debug("UCSetAllMapImageUrls.btnSave_Click 异常:" + ex.StackTrace);
}
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void checkBox_Click(object sender, RoutedEventArgs e)
{
ImageSlicing value = dgTableMapping.SelectedItem as ImageSlicing;
if (value != null)
{
value.IsCheck = (bool)(sender as CheckBox).IsChecked;
}
}
private void AllCheckEidt_EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e)
{
try
{
if (this.dgTableMapping == null || (dgTableMapping.ItemsSource as List<ImageSlicing>) == null)
{
return;
}
List<ImageSlicing> listTableMapping = dgTableMapping.ItemsSource as List<ImageSlicing>;
bool check = (sender as DevExpress.Xpf.Editors.CheckEdit).IsChecked == null ? false : bool.Parse((sender as DevExpress.Xpf.Editors.CheckEdit).IsChecked.Value.ToString());
if (check)
{
listTableMapping.ForEach(a => a.IsCheck = true);
}
else
{
listTableMapping.ForEach(a => a.IsCheck = false);
}
//dgTableMapping.RefreshData();
dgTableMapping.ItemsSource = null;
dgTableMapping.ItemsSource = listTableMapping;
}
catch (Exception ex)
{
LogAPI.Debug("UCSetAllMapImageUrls.AllCheckEidt_EditValueChanged 异常:" + ex.Message);
LogAPI.Debug("UCSetAllMapImageUrls.AllCheckEidt_EditValueChanged 异常:" + ex.StackTrace);
MessageHelper.ShowTips("全选发生异常:" + ex.Message);
}
}
private void dgTableMapping_CustomColumnDisplayText(object sender, DevExpress.Xpf.Grid.CustomColumnDisplayTextEventArgs e)
{
}
}
}