|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.Controls;
|
|
|
|
|
using ESRI.ArcGIS.Display;
|
|
|
|
|
using ESRI.ArcGIS.Geodatabase;
|
|
|
|
|
using ESRI.ArcGIS.Geometry;
|
|
|
|
|
using KGIS.Framework.AE;
|
|
|
|
|
using KGIS.Framework.AE.Enum;
|
|
|
|
|
using KGIS.Framework.DBOperator;
|
|
|
|
|
using KGIS.Framework.Maps;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using KGIS.Framework.Utils.Helper;
|
|
|
|
|
using KGIS.Framework.Views;
|
|
|
|
|
using Kingo.PluginServiceInterface;
|
|
|
|
|
using Kingo.PluginServiceInterface.Model;
|
|
|
|
|
using stdole;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.General.View
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// UCSHBZSketch.xaml 的交互逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class UCSHBZSketch : UserControl, IElementInfo
|
|
|
|
|
{
|
|
|
|
|
private IHookHelper hookHelper { get; set; }
|
|
|
|
|
private NYYSInfo NYYSInfo { get; set; }
|
|
|
|
|
private TaskPackage taskPackage { get; set; }
|
|
|
|
|
public UCSHBZSketch()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
Title = "审核标注草图";
|
|
|
|
|
DevExpress.Xpf.Core.ThemeManager.SetTheme(this, DevExpress.Xpf.Core.Theme.Office2013LightGray);
|
|
|
|
|
NYYSInfo = new NYYSInfo();
|
|
|
|
|
this.DataContext = NYYSInfo;
|
|
|
|
|
this.Loaded += (s, e) =>
|
|
|
|
|
{
|
|
|
|
|
hookHelper = new HookHelperClass();
|
|
|
|
|
hookHelper.Hook = MapsManager.Instance.MapService.getAxMapControl().Object;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public bool IsShow { get; set; }
|
|
|
|
|
public int ShowIndex { get; set; }
|
|
|
|
|
public bool ResetSize { get; set; }
|
|
|
|
|
public bool AllowEdit { 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 void BindData(object obj)
|
|
|
|
|
{
|
|
|
|
|
dgSHBZSketch.ItemsSource = null;
|
|
|
|
|
IWorkspaceAPI workspaceAPI = null;
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
NYYSInfo nYYSInfo = obj as NYYSInfo;
|
|
|
|
|
if (nYYSInfo == null) return;
|
|
|
|
|
this.NYYSInfo = nYYSInfo;
|
|
|
|
|
taskPackage = nYYSInfo.TaskPackages;
|
|
|
|
|
if (taskPackage == null || taskPackage.PackageTempPath == null || !System.IO.File.Exists(taskPackage.PackageTempPath)) return;
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper($"{taskPackage.PackageTempPath}{(MapsManager.Instance.CurrProjectInfo as ProjectInfo).Pathpassword}", DatabaseType.SQLite);
|
|
|
|
|
//审核标注
|
|
|
|
|
DataTable dataTable = rdbHelper.ExecuteDatatable("SJSHBZ", $"select * from SJSHBZ ", true);
|
|
|
|
|
if (dataTable == null || dataTable.Rows.Count <= 0)
|
|
|
|
|
nYYSInfo.SHBZSketch = new List<SHBZSketch>();
|
|
|
|
|
else
|
|
|
|
|
this.NYYSInfo.SHBZSketch = KGIS.Framework.Utils.Utility.TBToList.ToList<SHBZSketch>(dataTable);
|
|
|
|
|
|
|
|
|
|
dgSHBZSketch.ItemsSource = this.NYYSInfo.SHBZSketch;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("审核标注绑定数据异常:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("审核标注绑定数据异常:" + ex);
|
|
|
|
|
LogAPI.Debug("审核标注绑定数据异常:" + ex.StackTrace);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
if (workspaceAPI != null)
|
|
|
|
|
{
|
|
|
|
|
workspaceAPI.CloseWorkspace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveEdit()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public static IElement TextElement(IGeometry pGeometry, string textLabel)
|
|
|
|
|
{
|
|
|
|
|
IRgbColor pColor = new RgbColorClass()
|
|
|
|
|
{
|
|
|
|
|
Red = 0,
|
|
|
|
|
Blue = 255,
|
|
|
|
|
Green = 0
|
|
|
|
|
};
|
|
|
|
|
IFontDisp pFont = new StdFont()
|
|
|
|
|
{
|
|
|
|
|
Name = "宋体",
|
|
|
|
|
Size = 12
|
|
|
|
|
} as IFontDisp;
|
|
|
|
|
|
|
|
|
|
ITextSymbol pTextSymbol = new TextSymbolClass()
|
|
|
|
|
{
|
|
|
|
|
Color = pColor,
|
|
|
|
|
Font = pFont,
|
|
|
|
|
Size = 12
|
|
|
|
|
};
|
|
|
|
|
IGeometry geometry = pGeometry;
|
|
|
|
|
switch (geometry.GeometryType)
|
|
|
|
|
{
|
|
|
|
|
case esriGeometryType.esriGeometryPolygon:
|
|
|
|
|
geometry = (pGeometry as IArea).Centroid;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
IElement pTextElment = new TextElementClass()
|
|
|
|
|
{
|
|
|
|
|
Symbol = pTextSymbol,
|
|
|
|
|
ScaleText = true,
|
|
|
|
|
Text = textLabel,
|
|
|
|
|
Geometry = geometry
|
|
|
|
|
};
|
|
|
|
|
return pTextElment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IElement PolygonElement(IGeometry pGeometry)
|
|
|
|
|
{
|
|
|
|
|
IElement pElement = new PolygonElementClass();
|
|
|
|
|
//填充符号设置
|
|
|
|
|
ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();
|
|
|
|
|
//填充符号的边框设置
|
|
|
|
|
ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
|
|
|
|
|
IRgbColor pRgbColol = new RgbColorClass();
|
|
|
|
|
pRgbColol.Red = 0;
|
|
|
|
|
pRgbColol.Green = 0;
|
|
|
|
|
pRgbColol.Blue = 110;
|
|
|
|
|
pLineSymbol.Color = pRgbColol;
|
|
|
|
|
pLineSymbol.Width = 1;
|
|
|
|
|
pSimpleFillSymbol.Outline = pLineSymbol;
|
|
|
|
|
//填充符号颜色
|
|
|
|
|
pRgbColol = new RgbColorClass();
|
|
|
|
|
pRgbColol.Red = 229;
|
|
|
|
|
pRgbColol.Green = 103;
|
|
|
|
|
pRgbColol.Blue = 102;
|
|
|
|
|
pSimpleFillSymbol.Color = pRgbColol;
|
|
|
|
|
pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSCross; //.esriSFSBackwardDiagonal;
|
|
|
|
|
//面元素设置
|
|
|
|
|
IFillShapeElement pFillShapeElement = (IFillShapeElement)pElement;
|
|
|
|
|
pFillShapeElement.Symbol = pSimpleFillSymbol;
|
|
|
|
|
pElement.Geometry = pGeometry;
|
|
|
|
|
return pElement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LocationBZ(SHBZSketch wySketch)
|
|
|
|
|
{
|
|
|
|
|
IPointCollection poly2 = new PolygonClass();
|
|
|
|
|
IGeometry tempgeometry = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
MapsManager.Instance.MapService.ClearFeatureSelection(this.hookHelper.Hook as IMapControlDefault);
|
|
|
|
|
//this.hookHelper.ActiveView.GraphicsContainer.DeleteAllElements();
|
|
|
|
|
ESRI.ArcGIS.Geometry.IGeometry geometry = null;
|
|
|
|
|
switch (wySketch.BZLX)
|
|
|
|
|
{
|
|
|
|
|
case "1":// "点"
|
|
|
|
|
geometry = GeometryConvertHelper.ConverJsonToIGeoemtry(wySketch.Geometry, ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint);
|
|
|
|
|
using (ESRI.ArcGIS.ADF.ComReleaser comReleaser = new ESRI.ArcGIS.ADF.ComReleaser())
|
|
|
|
|
{
|
|
|
|
|
ESRI.ArcGIS.esriSystem.IJSONReader reader = new ESRI.ArcGIS.esriSystem.JSONReaderClass();
|
|
|
|
|
comReleaser.ManageLifetime(reader);
|
|
|
|
|
reader.ReadFromString(wySketch.Geometry);
|
|
|
|
|
ESRI.ArcGIS.Geometry.JSONConverterGeometryClass jsonConverter = new JSONConverterGeometryClass();
|
|
|
|
|
comReleaser.ManageLifetime(jsonConverter);
|
|
|
|
|
ISpatialReference spatialReference = jsonConverter.ReadSpatialReference(reader);
|
|
|
|
|
if (geometry.SpatialReference == null)
|
|
|
|
|
{
|
|
|
|
|
geometry.SpatialReference = spatialReference;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
geometry.Project(spatialReference);
|
|
|
|
|
}
|
|
|
|
|
MapsManager.Instance.MapService.DrawGraph(geometry, true);
|
|
|
|
|
MapsManager.Instance.MapService.Zoom(geometry);
|
|
|
|
|
//为了实现地图界面放大效果
|
|
|
|
|
if (geometry != null && !geometry.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
poly2.AddPoint(new PointClass() { X = geometry.Envelope.XMin - 10, Y = geometry.Envelope.YMax + 10 });
|
|
|
|
|
poly2.AddPoint(new PointClass() { X = geometry.Envelope.XMax + 10, Y = geometry.Envelope.YMax + 10 });
|
|
|
|
|
poly2.AddPoint(new PointClass() { X = geometry.Envelope.XMax + 10, Y = geometry.Envelope.YMin - 10 });
|
|
|
|
|
poly2.AddPoint(new PointClass() { X = geometry.Envelope.XMin - 10, Y = geometry.Envelope.YMin - 10 });
|
|
|
|
|
poly2.AddPoint(new PointClass() { X = geometry.Envelope.XMin - 10, Y = geometry.Envelope.YMax + 10 });
|
|
|
|
|
tempgeometry = poly2 as IGeometry;
|
|
|
|
|
MapsManager.Instance.MapService.Zoom(tempgeometry);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "2"://"线"
|
|
|
|
|
geometry = GeometryConvertHelper.ConverJsonToIGeoemtry(wySketch.Geometry, ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline);
|
|
|
|
|
geometry.Project(MapsManager.Instance.MapService.getAxMapControl().SpatialReference);
|
|
|
|
|
break;
|
|
|
|
|
case "3"://"面"
|
|
|
|
|
geometry = GeometryConvertHelper.ConverJsonToIGeoemtry(wySketch.Geometry);
|
|
|
|
|
geometry.Project(MapsManager.Instance.MapService.getAxMapControl().SpatialReference);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (wySketch.BZLX != "1" && geometry != null)
|
|
|
|
|
{
|
|
|
|
|
MapsManager.Instance.MapService.DrawGraph(geometry, true);
|
|
|
|
|
MapsManager.Instance.MapService.Zoom(geometry);
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(wySketch.BZMS) && geometry != null)
|
|
|
|
|
MapsManager.Instance.MapService.getAxMapControl().ActiveView.GraphicsContainer.AddElement(TextElement(geometry, wySketch.BZMS), 1);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("绘制图形失败:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("绘制图形失败:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("绘制图形失败:" + ex.StackTrace);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(poly2);
|
|
|
|
|
if (tempgeometry != null)
|
|
|
|
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(tempgeometry);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dgSHBZSketch_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if ((sender as KUI.PagingDataGrid) == null || (sender as KUI.PagingDataGrid).CurrentCell == null || (sender as KUI.PagingDataGrid).CurrentCell.Item == null || ((sender as KUI.PagingDataGrid).CurrentCell.Item as SHBZSketch) == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SHBZSketch wySketch = (SHBZSketch)(sender as KUI.PagingDataGrid).CurrentCell.Item;
|
|
|
|
|
LocationBZ(wySketch);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("定位失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|