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

244 lines
8.8 KiB

using System;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;
using DevExpress.Xpf.Core.Native;
using ESRI.ArcGIS.Controls;
using KGIS.Framework.Utils;
using KGIS.Framework.Utils.Interface;
using KGIS.Framework.Views;
using KGIS.Framework.Maps;
using KGIS.Framework.Platform;
using Kingo.Plugin.ResultsOfProof.ViewModel;
namespace Kingo.Plugin.ResultsOfProof.View.JZTBXX
{
/// <summary>
/// BGFrmJZTBList.xaml 的交互逻辑
/// </summary>
public partial class BGFrmJZTBList : UserControl, IDockPanel2
{
//用于定位
public IHookHelper m_hookHelper { 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 bool IsShowInMap { get; set; }
private bool IsReturn = false;
private IMapService _MapService;
public event EventHandler CloseViewHandler;
public BGJZTBListViewModel ViewModel = null;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="hook"></param>
/// <param name="pIsExportJZTBXXB">是否导出举证图斑信息表</param>
public BGFrmJZTBList(IHookHelper hookHelper)
{
try
{
DevExpress.Xpf.Core.ThemeManager.SetTheme(this, DevExpress.Xpf.Core.Theme.Office2013LightGray);
_MapService = MapsManager.Instance.MapService;// Platform.Instance.MapsManager.GetMapService();
InitializeComponent();
this.m_hookHelper = hookHelper;
Init();
_MapService.OnSelectionChanged += AxMapControl_OnSelectionChanged;
}
catch (Exception ex)
{
LogAPI.Debug(ex);
}
//TODO 周旺华 用于处理弹出筛选界面无法输入英文和字符问题
gcXJJZTB.View.FilterEditorCreated += (sender, e) =>
{
Window window;
Dispatcher.BeginInvoke(new Action(() =>
{
window = LayoutHelper.FindLayoutOrVisualParentObject<Window>(e.FilterControl);
window.Close();
window.ShowDialog();
}), DispatcherPriority.Render);
};
}
public void Init()
{
this.DockAreas = DockStyle.DockBottom | DockStyle.Float;
this.FloatSize = new System.Drawing.Size(600, 800);
this.DefaultArea = DockStyle.DockBottom;
this.ShowCloseButton = true;
this.ShowAutoHideButton = true;
this.Title = "举证图斑信息表";
this.DockHeight = 230;
this.IsShowInMap = true;
ViewModel = new BGJZTBListViewModel(m_hookHelper.Hook);
ViewModel.m_hookHelper = this.m_hookHelper;
DataContext = ViewModel;
CommandSubscribe();
ControlsZoomToSelectedCommandClass zoom = new ControlsZoomToSelectedCommandClass();
zoom.OnCreate(m_hookHelper.Hook);
zoom.OnClick();
IsReturn = false;
}
private void CommandSubscribe()
{
try
{
//上一条
ViewModel.PrevDataCmd.Subscribe(_ =>
{
int[] seleRows = gcXJJZTB.GetSelectedRowHandles();
if (seleRows == null || seleRows.Length == 0)
return;
if (seleRows.Min() > 0)
{
ViewModel.RowHandle = seleRows.Min() - 1;
gcXJJZTB.BeginSelection();
gcXJJZTB.UnselectAll();
gcXJJZTB.SelectItem(seleRows.Min() - 1);
tvXJJZTB.MoveFocusedRow(ViewModel.RowHandle);
gcXJJZTB.EndSelection();
}
});
//下一条
ViewModel.NextDataCmd.Subscribe(_ =>
{
int[] seleRows = gcXJJZTB.GetSelectedRowHandles();
if (seleRows == null || seleRows.Length == 0)
return;
if (seleRows.Max() < gcXJJZTB.VisibleRowCount - 1)
{
ViewModel.RowHandle = seleRows.Max() + 1;
gcXJJZTB.BeginSelection();
gcXJJZTB.UnselectAll();
gcXJJZTB.SelectItem(ViewModel.RowHandle);
tvXJJZTB.MoveFocusedRow(ViewModel.RowHandle);
gcXJJZTB.EndSelection();
}
});
ViewModel.RefreshDataCmd.Subscribe(_ =>
{
try
{
int[] seleRows = gcXJJZTB.GetSelectedRowHandles();
if (seleRows == null || seleRows.Length == 0)
return;
if (seleRows.Max() < gcXJJZTB.VisibleRowCount - 1)
{
ViewModel.RowHandle = seleRows.Max();
Thread.Sleep(500);
ViewModel.RefreshSource();
gcXJJZTB.BeginSelection();
gcXJJZTB.UnselectAll();
gcXJJZTB.SelectItem(ViewModel.RowHandle);
tvXJJZTB.MoveFocusedRow(ViewModel.RowHandle);
gcXJJZTB.EndSelection();
}
}
catch (Exception ex)
{
LogAPI.Debug("刷新举证图斑信息表失败:");
LogAPI.Debug(ex);
}
});
ViewModel.GridControlUnSelectAll.Subscribe(_ =>
{
gcXJJZTB.UnselectAll();
});
ViewModel.GridControlRefreshData.Subscribe(_ =>
{
gcXJJZTB.RefreshData();
});
ViewModel.GridControlFocusRow.Subscribe(_ =>
{
gcXJJZTB.BeginSelection();
gcXJJZTB.UnselectAll();
int cont = gcXJJZTB.VisibleRowCount;
int topRowIndex = 0;
//cont = cont > 200 ? 200 : cont;
for (int i = 0; i < cont; i++)
{
int rowHandle = gcXJJZTB.GetRowHandleByVisibleIndex(i);
if (!gcXJJZTB.IsGroupRowHandle(rowHandle))
{
int objId = int.Parse(gcXJJZTB.GetCellValue(rowHandle, gcXJJZTB.Columns["OBJECTID"]).ToString());
if (ViewModel.ObjectIDArray.Contains(objId))//选中集合是否和当前显示在DataView中的数据匹配
{
gcXJJZTB.SelectItem(rowHandle);
ViewModel.RowHandle = rowHandle;
if (topRowIndex <= 0)
{
topRowIndex = rowHandle;
}
}
}
}
gcXJJZTB.EndSelection();
});
}
catch (Exception ex)
{
throw ex;
}
}
private void AxMapControl_OnSelectionChanged(object sender, EventArgs e)
{
Dispatcher.Invoke(new Action(() =>
{
//ViewModel.RefreshSource();
}));
}
public event Action<NotifyMsgPackage> NotifyMsgEven;
public void SetNotifyMsg(NotifyMsgPackage msg)
{
if (NotifyMsgEven != null)
{
NotifyMsgEven(msg);
}
}
public void ShowPanel()
{
Platform.Instance.OpenView(this, false);
if (MapsManager.Instance.MapService != null)
{
MapsManager.Instance.MapService.ProjectClosed += (sender, e) =>
{
ClosePanel();
};
}
}
public void ClosePanel()
{
Platform.Instance.CloseView(this);
ViewModel = null;
}
public void ClosePanelInvoke()
{
CloseViewHandler?.Invoke(this, null);
}
}
}