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 { /// /// UCSetAllMapImageUrls.xaml 的交互逻辑 /// public partial class UCSetAllMapImageUrls : BaseWindow { public UCSetAllMapImageUrls() { InitializeComponent(); Load(); } private void Load() { List 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 AlllistTableMapping { get; set; } private void btnDelete_Click(object sender, RoutedEventArgs e) { try { AlllistTableMapping = dgTableMapping.ItemsSource as List; //List AlllistTableMapping = dgTableMapping.ItemsSource as List; List 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 listTableMapping = dgTableMapping.ItemsSource as List; 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) == null) { return; } List listTableMapping = dgTableMapping.ItemsSource as List; 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) { } } }