|
|
|
|
using DevExpress.XtraBars;
|
|
|
|
|
using DevExpress.XtraBars.Docking;
|
|
|
|
|
using ESRI.ArcGIS.ADF;
|
|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.Controls;
|
|
|
|
|
using ESRI.ArcGIS.Display;
|
|
|
|
|
using ESRI.ArcGIS.esriSystem;
|
|
|
|
|
using ESRI.ArcGIS.Geodatabase;
|
|
|
|
|
using ESRI.ArcGIS.Geometry;
|
|
|
|
|
using ESRI.ArcGIS.SystemUI;
|
|
|
|
|
using KGIS.Framework.AE;
|
|
|
|
|
using KGIS.Framework.AE.Enum;
|
|
|
|
|
using KGIS.Framework.Commands;
|
|
|
|
|
using KGIS.Framework.Core.Services;
|
|
|
|
|
using KGIS.Framework.DBOperator;
|
|
|
|
|
using KGIS.Framework.Maps;
|
|
|
|
|
using KGIS.Framework.Maps.Handlers;
|
|
|
|
|
using KGIS.Framework.Menus;
|
|
|
|
|
using KGIS.Framework.Menus.Entities;
|
|
|
|
|
using KGIS.Framework.Platform;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using KGIS.Framework.Utils.ExtensionMethod;
|
|
|
|
|
using KGIS.Framework.Utils.Helper;
|
|
|
|
|
//using KGIS.Framework.Utils.Model;
|
|
|
|
|
using KGIS.Framework.Views;
|
|
|
|
|
using Kingo.Framework.LayerStyleConvert.Common;
|
|
|
|
|
using Kingo.Framework.LayerStyleConvert.XSDClass;
|
|
|
|
|
using Kingo.ImageViewForWebSocket;
|
|
|
|
|
using Kingo.KMapSDK;
|
|
|
|
|
using Kingo.Plugin.MapView.Common;
|
|
|
|
|
using Kingo.Plugin.MapView.Views.AppMenuView;
|
|
|
|
|
using Kingo.PluginServiceInterface;
|
|
|
|
|
using Kingo.PluginServiceInterface.Helper;
|
|
|
|
|
using KUI.Windows;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Security.AccessControl;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
using UIShell.OSGi;
|
|
|
|
|
using Path = System.IO.Path;
|
|
|
|
|
using PolygonElement = KGIS.Framework.Maps.PolygonElement;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.MapView
|
|
|
|
|
{
|
|
|
|
|
public partial class UcMapControl : UserControl, IMapService, IDocumentView2, ICameraPoint
|
|
|
|
|
{
|
|
|
|
|
public DockManager dockManager { get; private set; }
|
|
|
|
|
private ControlsSynchronizer _CtrlSynchronizer;
|
|
|
|
|
private object TocHook = null;
|
|
|
|
|
private EngineEditor editor;
|
|
|
|
|
private ControlsMapPanToolClass panTool = null;
|
|
|
|
|
private ProjectInfo projectInfo = null;
|
|
|
|
|
private ICommandManager _CmdManager;
|
|
|
|
|
|
|
|
|
|
public event OpenedProjectHandler ProjectOpened;
|
|
|
|
|
public event EventHandler ProjectClosed;
|
|
|
|
|
public event EventHandler OnSelectionChanged;
|
|
|
|
|
public event MouseEventHandler MapContainerMouseWheel;
|
|
|
|
|
private string m_FolderPath = string.Empty;
|
|
|
|
|
private bool m_IsLoad = true;
|
|
|
|
|
private string m_XmlPath = AppDomain.CurrentDomain.BaseDirectory + "\\" + "ProjectPath.xml";
|
|
|
|
|
private string StrTig { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工作目录服务接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
IDataCatalogService _DataCatalog = null;
|
|
|
|
|
IWorkCatalog _workCatalog = null;
|
|
|
|
|
//IEngineEditor m_EngineEditor = new EngineEditorClass();
|
|
|
|
|
private IElementInfo ucJCTBTree { get; set; }
|
|
|
|
|
LayerCfg allLayerInfo = null;
|
|
|
|
|
private UCProjectInfoSetting frmUserInfoSetting { get; set; }
|
|
|
|
|
|
|
|
|
|
public UcMapControl()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
allLayerInfo = null;
|
|
|
|
|
EnvironmentVariables.Instance.cameraPoint = this;
|
|
|
|
|
this.Header = "地图数据";
|
|
|
|
|
this.AllowClose = false;
|
|
|
|
|
this.IsActive = true;
|
|
|
|
|
this.AllowFloat = false;
|
|
|
|
|
axMapControl.AutoKeyboardScrolling = false;
|
|
|
|
|
axMapControl.OnMouseDown += AxMapControl_OnMouseDown;
|
|
|
|
|
axMapControl.OnMouseMove += AxMapControl_OnMouseMove;
|
|
|
|
|
axMapControl.OnMouseUp += AxMapControl_OnMouseUp;
|
|
|
|
|
axMapControl.OnSelectionChanged += PMapCtrl_OnSelectionChanged;
|
|
|
|
|
axMapControl.OnExtentUpdated += AxMapControl_OnExtentUpdated;
|
|
|
|
|
if (editor == null)
|
|
|
|
|
editor = new EngineEditorClass();
|
|
|
|
|
List<int> Listobjid_update = new List<int>();
|
|
|
|
|
List<int> Listobjid_insert = new List<int>();
|
|
|
|
|
editor.OnStopOperation += () =>
|
|
|
|
|
{
|
|
|
|
|
#region 变化图斑提取
|
|
|
|
|
//添加新的监测图斑时,自动维护相应的属性值
|
|
|
|
|
if (projectInfo != null && projectInfo.ProjType == EnumProjType.BHTBTQ)
|
|
|
|
|
{
|
|
|
|
|
IWorkspaceEdit2 workspaceEdit2 = (IWorkspaceEdit2)editor.EditWorkspace;
|
|
|
|
|
IDataChangesEx dataChangesEx = workspaceEdit2.get_EditDataChanges(esriEditDataChangesType.esriEditDataChangesWithinSession);
|
|
|
|
|
int featureOID = -1;
|
|
|
|
|
IFIDSet fids = dataChangesEx.ChangedIDs["JCTB", esriDifferenceType.esriDifferenceTypeInsert];
|
|
|
|
|
fids.Next(out featureOID);
|
|
|
|
|
while (featureOID != -1)
|
|
|
|
|
{
|
|
|
|
|
IFeatureLayer pFeatureLayer = MapsManager.Instance.MapService.GetFeatureLayerByName("JCTB");
|
|
|
|
|
IFeature feature = pFeatureLayer.FeatureClass.GetFeature(featureOID);
|
|
|
|
|
feature.Value[feature.Fields.FindField("XZQDM")] = projectInfo.CODE;
|
|
|
|
|
feature.Value[feature.Fields.FindField("XMC")] = GetXZQDic(projectInfo.CODE);
|
|
|
|
|
IArea area = feature.ShapeCopy as IArea;
|
|
|
|
|
IPoint point = new PointClass();
|
|
|
|
|
area.QueryCentroid(point);
|
|
|
|
|
if (area.Area > 0)
|
|
|
|
|
{
|
|
|
|
|
feature.Value[feature.Fields.FindField("XZB")] = point.X;
|
|
|
|
|
feature.Value[feature.Fields.FindField("YZB")] = point.Y;
|
|
|
|
|
feature.Value[feature.Fields.FindField("JCMJ")] = area.Area > 0 ? (area.Area / 666.7).ToDouble(2) : 0;
|
|
|
|
|
feature.Store();
|
|
|
|
|
}
|
|
|
|
|
Marshal.FinalReleaseComObject(feature);
|
|
|
|
|
feature = null;
|
|
|
|
|
fids.Next(out featureOID);
|
|
|
|
|
}
|
|
|
|
|
Marshal.FinalReleaseComObject(fids);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
};
|
|
|
|
|
panel1.MouseWheel += MapCtrlContainer_MouseWheel;
|
|
|
|
|
dockManager = dockManager1;
|
|
|
|
|
Platform.Instance.NotifyMsgEven2 += o =>
|
|
|
|
|
{
|
|
|
|
|
switch (o.MsgType)
|
|
|
|
|
{
|
|
|
|
|
case "InitProject":
|
|
|
|
|
LoadProject();
|
|
|
|
|
AddMask();
|
|
|
|
|
break;
|
|
|
|
|
case "SaveProject":
|
|
|
|
|
SaveProject();
|
|
|
|
|
break;
|
|
|
|
|
case "SaveProjectForNoEditor":
|
|
|
|
|
SaveProjectForNoEditor();
|
|
|
|
|
break;
|
|
|
|
|
case "LoadProject":
|
|
|
|
|
LoadProject(o.Content.ToTrim());
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (o.MsgType == "ExtentUpdated" && o.Content.ToTrim() == "Map2")
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
StrTig = o.Content.ToTrim();
|
|
|
|
|
axMapControl.ActiveView.Extent = o.Extend as IEnvelope;// MapsManager.Instance.MapService.getAxMapControl().Extent;
|
|
|
|
|
axMapControl.ActiveView.Refresh();
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据区划代码获取县级名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Codes"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public string GetXZQDic(string Codes)
|
|
|
|
|
{
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
string CodeName = string.Empty;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string systemPath = SysAppPath.GetDataBasePath() + "System.mdb";
|
|
|
|
|
if (File.Exists(systemPath))
|
|
|
|
|
{
|
|
|
|
|
string connStr = SysConfigsOprator.GetDBConnectionByName("MDBOledbConnection");
|
|
|
|
|
connStr = string.Format(connStr, systemPath);
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper(connStr, DatabaseType.MSAccess);
|
|
|
|
|
string strSQL = "select OBJECTID AS ID, XZQ AS CODE,XZQMC AS NAME from XZQ Where XZQ LIKE '" + Codes + "%'";
|
|
|
|
|
DataTable dt = rdbHelper.ExecuteDatatable("Dic", strSQL, true);
|
|
|
|
|
if (dt != null)
|
|
|
|
|
{
|
|
|
|
|
CodeName = dt.Rows[0]["NAME"].ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex.Message);
|
|
|
|
|
LogAPI.Debug(ex.StackTrace);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return CodeName;
|
|
|
|
|
}
|
|
|
|
|
private void AddMask()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (Platform.Instance.SystemType != SystemTypeEnum.BGFWCG) return;
|
|
|
|
|
IUcZYQMagrHelper ucZYQMagrHelper = BundleRuntime.Instance.GetFirstOrDefaultService<IUcZYQMagrHelper>();
|
|
|
|
|
if (ucZYQMagrHelper != null)
|
|
|
|
|
{
|
|
|
|
|
int selectIdZYQ = ucZYQMagrHelper.GetCheckedID();
|
|
|
|
|
if (selectIdZYQ < 0) return;
|
|
|
|
|
selectIdZYQ++;
|
|
|
|
|
IGeometry geometry = null;
|
|
|
|
|
IFeatureClass featureClass = MapsManager.Instance.MapService.GetFeatureClassByName("ZYQ");
|
|
|
|
|
if (featureClass != null)
|
|
|
|
|
{
|
|
|
|
|
IQueryFilter filter = new QueryFilterClass();
|
|
|
|
|
filter.WhereClause = string.Format("OBJECTID = {0}", selectIdZYQ);
|
|
|
|
|
IFeatureCursor pCursor = featureClass.Search(filter, true);
|
|
|
|
|
IFeature feature = null;
|
|
|
|
|
if ((feature = pCursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
geometry = feature.Shape;
|
|
|
|
|
}
|
|
|
|
|
if (geometry != null && !geometry.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
ShowMaskHelper showMaskForBHTBHelper = new ShowMaskHelper();
|
|
|
|
|
showMaskForBHTBHelper.axMapControl = MapsManager.Instance.MapService.getAxMapControl();
|
|
|
|
|
showMaskForBHTBHelper.ShowMask(geometry);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void AxMapControl_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
|
|
|
|
|
{
|
|
|
|
|
if (StrTig != "Map2")
|
|
|
|
|
{
|
|
|
|
|
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "ExtentUpdated", Content = "MainMap", Extend = e.newEnvelope });
|
|
|
|
|
}
|
|
|
|
|
StrTig = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MapCtrlContainer_MouseWheel(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MapContainerMouseWheel?.Invoke(sender, e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PMapCtrl_OnSelectionChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OnSelectionChanged?.Invoke(sender, e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AxMapControl_OnMouseUp(object sender, IMapControlEvents2_OnMouseUpEvent e)
|
|
|
|
|
{
|
|
|
|
|
//滚轮按下执行地图漫游工具,拖动地图
|
|
|
|
|
if (e.button == 4 && panTool != null && panTool.Enabled)
|
|
|
|
|
{
|
|
|
|
|
panTool.OnMouseUp(1, e.shift, e.x, e.y);
|
|
|
|
|
panTool.Deactivate();
|
|
|
|
|
axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, axMapControl.ActiveView.Extent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AxMapControl_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
|
|
|
|
|
{
|
|
|
|
|
//滚轮按下执行地图漫游工具,拖动地图
|
|
|
|
|
if (e.button == 4)
|
|
|
|
|
{
|
|
|
|
|
if (panTool != null && panTool.Enabled)
|
|
|
|
|
{
|
|
|
|
|
this.Cursor = global::System.Windows.Forms.Cursors.Hand;
|
|
|
|
|
panTool.OnMouseMove(1, e.shift, e.x, e.y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Platform.Instance.UpdateStateBar("", string.Format("X:{0:F3} Y:{1:F3} Unit {2}", e.mapX, e.mapY, axMapControl.Map.MapUnits));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AxMapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
|
|
|
|
|
{
|
|
|
|
|
if (editor == null)
|
|
|
|
|
editor = new EngineEditorClass();
|
|
|
|
|
if (e.button == 2)
|
|
|
|
|
{
|
|
|
|
|
//在未开启编辑状态下,地图控件上右键,则将当前工具切换至平移工具
|
|
|
|
|
if (this.axMapControl.CurrentTool == null || (this.axMapControl.CurrentTool.GetType() != typeof(ControlsMapPanToolClass) && editor.EditState != esriEngineEditState.esriEngineStateEditing))
|
|
|
|
|
{
|
|
|
|
|
ControlsMapPanToolClass tool = new ControlsMapPanToolClass();
|
|
|
|
|
tool.OnCreate(this.axMapControl.Object);
|
|
|
|
|
this.axMapControl.CurrentTool = tool;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (e.button == 4)
|
|
|
|
|
{
|
|
|
|
|
//鼠标滚轮键按下
|
|
|
|
|
if (panTool == null)
|
|
|
|
|
{
|
|
|
|
|
panTool = new ControlsMapPanToolClass();
|
|
|
|
|
panTool.OnCreate(axMapControl.Object);
|
|
|
|
|
}
|
|
|
|
|
this.Cursor = global::System.Windows.Forms.Cursors.Hand;
|
|
|
|
|
panTool.OnMouseDown(1, e.shift, e.x, e.y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#region ExecuteDataCheck
|
|
|
|
|
|
|
|
|
|
public void ExecuteDataCheck(IFeature feature)
|
|
|
|
|
{
|
|
|
|
|
IDataCheckHelper dataCheckHelper = UIShell.OSGi.BundleRuntime.Instance.GetFirstOrDefaultService<IDataCheckHelper>();
|
|
|
|
|
if (dataCheckHelper == null) return;
|
|
|
|
|
dataCheckHelper.DataCheckByThread(new CheckParametr()
|
|
|
|
|
{
|
|
|
|
|
CheckType = enumCheckType.Attribute | enumCheckType.Graphic,
|
|
|
|
|
DataSource = feature,
|
|
|
|
|
IDataCheckName = "BGQDataCheck"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public UcMapControl(IBundleContext pContext, object pTocHook = null) : this()
|
|
|
|
|
{
|
|
|
|
|
TocHook = pTocHook;
|
|
|
|
|
//CtlsSynchronizer.AddFrameworkControl(TocHook);
|
|
|
|
|
CtlsSynchronizer.ActivateMap();
|
|
|
|
|
InitService(pContext);
|
|
|
|
|
//object o = MapsManager.Instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void InitService(IBundleContext context)
|
|
|
|
|
{
|
|
|
|
|
context.AddService<IMapService>(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IWorkspace GetDefaultWorkspace(IMap pMap = null)
|
|
|
|
|
{
|
|
|
|
|
IWorkspace result = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IEnumLayer enumlayer = axMapControl.Map.Layers;
|
|
|
|
|
if (pMap != null)
|
|
|
|
|
enumlayer = pMap.Layers;
|
|
|
|
|
enumlayer.Reset();
|
|
|
|
|
ILayer layer = null;
|
|
|
|
|
while ((layer = enumlayer.Next()) != null)
|
|
|
|
|
{
|
|
|
|
|
if (!(layer is IFeatureLayer))
|
|
|
|
|
continue;
|
|
|
|
|
IFeatureLayer featureLayer = layer as IFeatureLayer;
|
|
|
|
|
if (!IsRemoteDatabase(featureLayer))
|
|
|
|
|
{
|
|
|
|
|
if (featureLayer.FeatureClass == null || !(featureLayer is IDataset))
|
|
|
|
|
continue;
|
|
|
|
|
if ((featureLayer as IDataset).Workspace == null)
|
|
|
|
|
continue;
|
|
|
|
|
if (featureLayer is IDataset)
|
|
|
|
|
{
|
|
|
|
|
string wsPath = (featureLayer as IDataset).Workspace.PathName;
|
|
|
|
|
if (projectInfo.GetDHZSDBPath().Equals(wsPath))
|
|
|
|
|
{
|
|
|
|
|
result = (featureLayer as IDataset).Workspace;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool IsRemoteDatabase(IFeatureLayer pLayer)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (pLayer != null && pLayer.FeatureClass != null && (pLayer.FeatureClass as FeatureClass).Workspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
|
|
|
|
|
{
|
|
|
|
|
result = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string GetClassShortName(IDataset paramDS)
|
|
|
|
|
{
|
|
|
|
|
if (paramDS == null)
|
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return GetClassShortName(paramDS.BrowseName.ToUpper());
|
|
|
|
|
}
|
|
|
|
|
private string GetClassShortName(string paramName)
|
|
|
|
|
{
|
|
|
|
|
string str = paramName;
|
|
|
|
|
int num = paramName.LastIndexOf(".");
|
|
|
|
|
if (num >= 0)
|
|
|
|
|
{
|
|
|
|
|
str = paramName.Substring(num + 1);
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<T> GetAllLayerInGroupLayer<T>(ICompositeLayer groupLayer)
|
|
|
|
|
{
|
|
|
|
|
List<T> allLayers = new List<T>();
|
|
|
|
|
if (groupLayer != null && groupLayer.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < groupLayer.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
ILayer layer = groupLayer.get_Layer(i);
|
|
|
|
|
if (layer is ICompositeLayer && !(layer is ESRI.ArcGIS.Carto.IAnnotationLayer))
|
|
|
|
|
{
|
|
|
|
|
List<T> list = GetAllLayerInGroupLayer<T>(layer as ICompositeLayer);
|
|
|
|
|
allLayers.AddRange(list);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (layer is T)
|
|
|
|
|
{
|
|
|
|
|
allLayers.Add((T)layer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return allLayers;
|
|
|
|
|
}
|
|
|
|
|
public List<T> GetAllVisibleLayerInGroupLayer<T>(ICompositeLayer groupLayer)
|
|
|
|
|
{
|
|
|
|
|
List<T> allLayers = new List<T>();
|
|
|
|
|
if (groupLayer != null && groupLayer.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < groupLayer.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
ILayer layer = groupLayer.get_Layer(i);
|
|
|
|
|
if (layer is ICompositeLayer && layer.Visible && !(layer is ESRI.ArcGIS.Carto.IAnnotationLayer))
|
|
|
|
|
{
|
|
|
|
|
allLayers.AddRange(GetAllVisibleLayerInGroupLayer<T>(layer as ICompositeLayer));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (layer is T && layer.Visible)
|
|
|
|
|
{
|
|
|
|
|
if ((layer.MinimumScale == 0 || layer.MinimumScale > axMapControl.MapScale) && (layer.MaximumScale == 0 || layer.MaximumScale < axMapControl.MapScale))
|
|
|
|
|
allLayers.Add((T)layer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return allLayers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> 创建菜单项
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="itemEntity"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private BarItem CreateItem(MenuItemEntity itemEntity, object pHook)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var itemType = itemEntity.ItemType;
|
|
|
|
|
var item = CreateItem(itemType);
|
|
|
|
|
item.Caption = itemEntity.Name;
|
|
|
|
|
item.Glyph = itemEntity.GetSmallImage();
|
|
|
|
|
item.LargeGlyph = itemEntity.GetLargeImage();
|
|
|
|
|
|
|
|
|
|
var type = item.GetType();
|
|
|
|
|
//设置文本信息
|
|
|
|
|
var propertyInfo = type.GetProperty("Text");
|
|
|
|
|
if (propertyInfo != null)
|
|
|
|
|
propertyInfo.SetValue(item, itemEntity.Name, null);
|
|
|
|
|
//注册快捷键
|
|
|
|
|
//propertyInfo = type.GetProperty("ShortcutKeys");
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(itemEntity.ShortcutKeys))
|
|
|
|
|
{
|
|
|
|
|
if (itemEntity.ShortcutKeys.Contains("+"))
|
|
|
|
|
{
|
|
|
|
|
if (itemEntity.ShortcutKeys.StartsWith("Shift"))
|
|
|
|
|
{
|
|
|
|
|
Keys key = GetObj<Keys>(itemEntity.ShortcutKeys.Replace("Shift+", ""));
|
|
|
|
|
item.ItemShortcut = new BarShortcut(Keys.Shift, key);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Shortcut shortcut = GetObj<Shortcut>(itemEntity.ShortcutKeys.Replace("+", "").Trim());
|
|
|
|
|
BarShortcut ishortcut = new BarShortcut(shortcut);
|
|
|
|
|
item.ItemShortcut = ishortcut;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Keys key = GetObj<Keys>(itemEntity.ShortcutKeys);
|
|
|
|
|
item.ItemShortcut = new BarShortcut(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
item.ItemClick += Item_ItemClick;
|
|
|
|
|
|
|
|
|
|
string commandId = itemEntity.CommandId;
|
|
|
|
|
if (!string.IsNullOrEmpty(commandId))
|
|
|
|
|
{
|
|
|
|
|
if (_CmdManager != null)
|
|
|
|
|
{
|
|
|
|
|
item.Tag = _CmdManager.AddCmd(itemEntity.CommandId, itemEntity.Bundle, pHook);
|
|
|
|
|
if (item.Tag is ICommand)
|
|
|
|
|
{
|
|
|
|
|
(item.Tag as ICommand).OnCreate(axMapControl.Object);
|
|
|
|
|
(item as BarItem).Enabled = (item.Tag as ESRI.ArcGIS.SystemUI.ICommand).Enabled;
|
|
|
|
|
}
|
|
|
|
|
else if (item.Tag is BaseMenuCommand)
|
|
|
|
|
{
|
|
|
|
|
(item.Tag as BaseMenuCommand).OnCreate(axMapControl.Object);
|
|
|
|
|
(item as BarItem).Enabled = (item.Tag as BaseMenuCommand).Enabled;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item is BarCheckItem && item.Tag is ESRI.ArcGIS.SystemUI.ICommand)
|
|
|
|
|
{
|
|
|
|
|
(item as BarCheckItem).Checked = (item.Tag as ESRI.ArcGIS.SystemUI.ICommand).Checked;
|
|
|
|
|
}
|
|
|
|
|
else if (item.Tag is ICombox)
|
|
|
|
|
{
|
|
|
|
|
ICombox combox = item.Tag as ICombox;
|
|
|
|
|
combox.SetBarEditItem(item);
|
|
|
|
|
}
|
|
|
|
|
//CreateChildItems(item, itemEntity);
|
|
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("创建菜单项 时异常,异常信息如下:");
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
LogAPI.Debug("创建菜单项 时异常信息结束");
|
|
|
|
|
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private T GetObj<T>(string pStr)
|
|
|
|
|
{
|
|
|
|
|
T t = default(T);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
t = (T)System.Enum.Parse(typeof(T), pStr);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
private void Item_ItemClick(object sender, ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
BarItem item = e.Item as BarItem;
|
|
|
|
|
if (item == null || item.Tag == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (item.Tag is ITool)
|
|
|
|
|
{
|
|
|
|
|
SetCurrentTool(item.Tag);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (item.Tag is ICommand)
|
|
|
|
|
{
|
|
|
|
|
(item.Tag as ICommand).OnClick();
|
|
|
|
|
if (item is BarCheckItem)
|
|
|
|
|
{
|
|
|
|
|
(item as BarCheckItem).Checked = (item.Tag as ICommand).Checked;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (item.Tag is IMenuCommand)
|
|
|
|
|
{
|
|
|
|
|
//if (item.Tag is IAppMenuCommand)
|
|
|
|
|
//{
|
|
|
|
|
// (item.Tag as IAppMenuCommand).CmdParameter = param;
|
|
|
|
|
//}
|
|
|
|
|
(item.Tag as IMenuCommand).OnClick();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//IMapService mapService = MapsManager.Instance.MapService;
|
|
|
|
|
//if (mapService != null)
|
|
|
|
|
//{
|
|
|
|
|
// mapService.SetCurrentTool(item.Tag);
|
|
|
|
|
// //if (mapService.Hook is IMapControlDefault)
|
|
|
|
|
// //{
|
|
|
|
|
// // (mapService.Hook as IMapControlDefault).CurrentTool = pCmd as ITool;
|
|
|
|
|
// //}
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(string.Format("执行【{0}】命令异常,异常信息如下:", item.Caption));
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
LogAPI.Debug("异常信息结束");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary> 创建菜单项
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="itemType">菜单项类型</param>
|
|
|
|
|
private BarItem CreateItem(string itemType)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(itemType))
|
|
|
|
|
return new BarButtonItem();
|
|
|
|
|
|
|
|
|
|
BarItem item = null;
|
|
|
|
|
switch (itemType.ToLower())
|
|
|
|
|
{
|
|
|
|
|
case "cmditem":
|
|
|
|
|
item = new BarButtonItem();
|
|
|
|
|
break;
|
|
|
|
|
case "toolitem":
|
|
|
|
|
item = new BarCheckItem();
|
|
|
|
|
break;
|
|
|
|
|
case "combobox":
|
|
|
|
|
item = new BarEditItem();
|
|
|
|
|
break;
|
|
|
|
|
case "labitem":
|
|
|
|
|
item = new BarHeaderItem();
|
|
|
|
|
item.PaintStyle = BarItemPaintStyle.Caption;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MoveToCenter(List<IFeature> pFeatures)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IEnvelope pEnvelope = new EnvelopeClass() as IEnvelope;
|
|
|
|
|
pEnvelope = pFeatures[0].ShapeCopy.Envelope;
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < pFeatures.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (pEnvelope.XMax < pFeatures[i].ShapeCopy.Envelope.XMax)
|
|
|
|
|
pEnvelope.XMax = pFeatures[i].ShapeCopy.Envelope.XMax;
|
|
|
|
|
if (pEnvelope.XMin > pFeatures[i].ShapeCopy.Envelope.XMin)
|
|
|
|
|
pEnvelope.XMin = pFeatures[i].ShapeCopy.Envelope.XMin;
|
|
|
|
|
|
|
|
|
|
if (pEnvelope.YMax < pFeatures[i].ShapeCopy.Envelope.YMax)
|
|
|
|
|
pEnvelope.YMax = pFeatures[i].ShapeCopy.Envelope.YMax;
|
|
|
|
|
if (pEnvelope.YMin > pFeatures[i].ShapeCopy.Envelope.YMin)
|
|
|
|
|
pEnvelope.YMin = pFeatures[i].ShapeCopy.Envelope.YMin;
|
|
|
|
|
}
|
|
|
|
|
////投影到当前地图坐标系定位缩放到当前要素
|
|
|
|
|
pEnvelope.Project((Hook as IMapControlDefault).SpatialReference);
|
|
|
|
|
IUnitConverter pUnitConverter = new UnitConverterClass();
|
|
|
|
|
double dScale = pUnitConverter.ConvertUnits(20, esriUnits.esriMeters, (Hook as IMapControlDefault).MapUnits);
|
|
|
|
|
pEnvelope.PutCoords(pEnvelope.XMin - dScale, pEnvelope.YMin - dScale, pEnvelope.XMax + dScale, pEnvelope.YMax + dScale);
|
|
|
|
|
(Hook as IMapControlDefault).ActiveView.Extent = pEnvelope;
|
|
|
|
|
(Hook as IMapControlDefault).ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, (Hook as IMapControlDefault).ActiveView.Extent);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("操作异常!异常信息:" + ex.Message);
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SwitchWorkspace(string pDirPath)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!Directory.Exists(pDirPath))
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.Show(string.Format("指定的工作目录{0}不存在,请重新选择!", pDirPath));
|
|
|
|
|
}
|
|
|
|
|
string templatePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "工作空间", "模板", "移动端数据制作");
|
|
|
|
|
ProjectInfo prj = new ProjectInfo();
|
|
|
|
|
prj.ProjDir = pDirPath;
|
|
|
|
|
prj.ProjSuffix = ".prj";
|
|
|
|
|
prj.ProjName = "数据制作";
|
|
|
|
|
string prjPath = System.IO.Path.Combine(prj.ProjDir, prj.ProjName + prj.ProjSuffix);
|
|
|
|
|
if (File.Exists(prjPath))
|
|
|
|
|
{
|
|
|
|
|
LoadProject(prjPath);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!Directory.Exists(prj.ProjDir + "数据制作.gdb") && File.Exists(prj.ProjDir + "\\~temp.mxd"))
|
|
|
|
|
{
|
|
|
|
|
File.Delete(prj.ProjDir + "\\~temp.mxd");
|
|
|
|
|
}
|
|
|
|
|
DirectoryCopy(templatePath + "\\数据制作.gdb", prj.ProjDir);
|
|
|
|
|
File.Copy(templatePath + "\\dic.mdb", prj.ProjDir + "\\dic.mdb", true);
|
|
|
|
|
|
|
|
|
|
//string dicPath = System.IO.Path.Combine(SysAppPath.GetCurrentAppPath(), "Database\\dic.kzd");
|
|
|
|
|
//if (System.IO.File.Exists(dicPath))
|
|
|
|
|
//{
|
|
|
|
|
// File.Copy(templatePath + "\\dic.mdb", prj.ProjDir + "\\dic.mdb", true);
|
|
|
|
|
//}
|
|
|
|
|
FileInfo file = new FileInfo(System.IO.Path.Combine(templatePath, "数据制作.MOD"));
|
|
|
|
|
|
|
|
|
|
System.IO.FileStream fileStream = file.Open(FileMode.Open, FileAccess.Read, FileShare.None);
|
|
|
|
|
byte[] bytes = new byte[fileStream.Length];
|
|
|
|
|
fileStream.Read(bytes, 0, bytes.Length);
|
|
|
|
|
fileStream.Close();
|
|
|
|
|
string strBase64 = Convert.ToBase64String(bytes);
|
|
|
|
|
prj.TempData = strBase64;
|
|
|
|
|
if (prj.Save())
|
|
|
|
|
{
|
|
|
|
|
LoadProject(prjPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.Show("切换目录异常:" + ex.Message);
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设置数据目录图层样式
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="layer"></param>
|
|
|
|
|
/// <param name="element"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private bool SetCatalogLayerStyle(ILayer layer, XElement element)
|
|
|
|
|
{
|
|
|
|
|
bool isSet = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ESRI.ArcGIS.Geometry.esriGeometryType geometryType;
|
|
|
|
|
IStyleGalleryClass symbologyStyleClass = null;
|
|
|
|
|
ISymbol symbol = null;
|
|
|
|
|
IFillSymbol fillSymbol = null;
|
|
|
|
|
string layerCaption = element.Attribute("LayerCaption").Value;
|
|
|
|
|
if (layerCaption == layer.Name)
|
|
|
|
|
{
|
|
|
|
|
isSet = true;
|
|
|
|
|
string layerLabelName = element.Attribute("LayerLableName").Value;
|
|
|
|
|
int layerBorderStyle = int.Parse(element.Attribute("LayerBorderStyle").Value);
|
|
|
|
|
double layerBorderWidth = double.Parse(element.Attribute("LayerBorderWidth").Value);
|
|
|
|
|
Color layerFillColor = ColorTranslator.FromHtml(element.Attribute("LayerFillColor").Value);
|
|
|
|
|
Color layerBorderColor = ColorTranslator.FromHtml(element.Attribute("LayerBorderColor").Value);
|
|
|
|
|
Color layerLableColor = ColorTranslator.FromHtml(element.Attribute("LayerLableColor").Value);
|
|
|
|
|
IFeatureLayer2 featureLayer = layer as IFeatureLayer2;
|
|
|
|
|
if (featureLayer != null)
|
|
|
|
|
{
|
|
|
|
|
geometryType = featureLayer.ShapeType;
|
|
|
|
|
switch (geometryType)
|
|
|
|
|
{
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
|
|
|
|
|
symbologyStyleClass = new MarkerSymbolStyleGalleryClassClass();
|
|
|
|
|
break;
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
|
|
|
|
|
symbologyStyleClass = new LineSymbolStyleGalleryClassClass();
|
|
|
|
|
break;
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
|
|
|
|
|
symbologyStyleClass = new FillSymbolStyleGalleryClassClass();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
ISimpleRenderer simpleRenderer = (featureLayer as IGeoFeatureLayer).Renderer as ISimpleRenderer;
|
|
|
|
|
if (simpleRenderer != null)
|
|
|
|
|
{
|
|
|
|
|
symbol = simpleRenderer.Symbol;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GetDefaultSymbol(geometryType);
|
|
|
|
|
}
|
|
|
|
|
fillSymbol = (symbol as IFillSymbol);
|
|
|
|
|
|
|
|
|
|
if (fillSymbol != null)
|
|
|
|
|
{
|
|
|
|
|
//填充颜色
|
|
|
|
|
IColor color = fillSymbol.Color;
|
|
|
|
|
System.Drawing.Color fillColor = System.Drawing.Color.FromArgb(layerFillColor.A, layerFillColor.R, layerFillColor.G, layerFillColor.B);
|
|
|
|
|
color = (IColor)Converter.ToRGBColor(fillColor);
|
|
|
|
|
color.Transparency = layerFillColor.A;
|
|
|
|
|
fillSymbol.Color = color;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置边框颜色、样式、宽度
|
|
|
|
|
ISimpleLineSymbol pMarkerLineSymbol = new SimpleLineSymbolClass();
|
|
|
|
|
System.Drawing.Color borderColor = System.Drawing.Color.FromArgb(layerBorderColor.A, layerBorderColor.R, layerBorderColor.G, layerBorderColor.B);
|
|
|
|
|
IColor outlineColor = (IColor)Converter.ToRGBColor(borderColor);
|
|
|
|
|
pMarkerLineSymbol.Width = Math.Abs(layerBorderWidth);
|
|
|
|
|
pMarkerLineSymbol.Color = outlineColor;
|
|
|
|
|
outlineColor.Transparency = layerBorderColor.A;
|
|
|
|
|
|
|
|
|
|
if (layerBorderStyle == 0)//实线
|
|
|
|
|
{
|
|
|
|
|
pMarkerLineSymbol.Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid;
|
|
|
|
|
}
|
|
|
|
|
else if (layerBorderStyle == 1)//虚线
|
|
|
|
|
{
|
|
|
|
|
pMarkerLineSymbol.Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSDash;
|
|
|
|
|
}
|
|
|
|
|
else if (layerBorderStyle == 2)//点
|
|
|
|
|
{
|
|
|
|
|
pMarkerLineSymbol.Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSDot;
|
|
|
|
|
}
|
|
|
|
|
else if (layerBorderStyle == 3)//点划线
|
|
|
|
|
{
|
|
|
|
|
pMarkerLineSymbol.Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSDashDot;
|
|
|
|
|
}
|
|
|
|
|
else if (layerBorderStyle == 4)//两点划线
|
|
|
|
|
{
|
|
|
|
|
pMarkerLineSymbol.Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSDashDotDot;
|
|
|
|
|
}
|
|
|
|
|
fillSymbol.Outline = pMarkerLineSymbol;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(layerLabelName))
|
|
|
|
|
{
|
|
|
|
|
IGeoFeatureLayer pGeoFeatureLayer = layer as IGeoFeatureLayer;
|
|
|
|
|
pGeoFeatureLayer.AnnotationProperties.Clear();//必须执行,因为里面有一个默认的
|
|
|
|
|
IBasicOverposterLayerProperties pBasic = new BasicOverposterLayerPropertiesClass();
|
|
|
|
|
ITextSymbol pTextSymbol = new TextSymbolClass();
|
|
|
|
|
Color textColor = System.Drawing.Color.FromArgb(layerLableColor.A, layerLableColor.R, layerLableColor.G, layerLableColor.B);
|
|
|
|
|
IColor lableColor = (IColor)Converter.ToRGBColor(textColor);
|
|
|
|
|
ILabelEngineLayerProperties pLableEngine = new LabelEngineLayerPropertiesClass();
|
|
|
|
|
pTextSymbol.Color = lableColor;//设置字体颜色
|
|
|
|
|
string pLable = "[" + layerLabelName + "]";
|
|
|
|
|
pLableEngine.Expression = pLable;
|
|
|
|
|
pLableEngine.IsExpressionSimple = true;
|
|
|
|
|
pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape;
|
|
|
|
|
pLableEngine.BasicOverposterLayerProperties = pBasic;
|
|
|
|
|
pLableEngine.Symbol = pTextSymbol;
|
|
|
|
|
pGeoFeatureLayer.AnnotationProperties.Add(pLableEngine as IAnnotateLayerProperties);
|
|
|
|
|
pGeoFeatureLayer.DisplayAnnotation = true;
|
|
|
|
|
pLableEngine.Symbol = pTextSymbol;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return isSet;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex.Message);
|
|
|
|
|
return isSet;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ISymbol GetDefaultSymbol(ESRI.ArcGIS.Geometry.esriGeometryType geometryType)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ISymbol result = null;
|
|
|
|
|
IRgbColor rgbColor = new RgbColorClass();
|
|
|
|
|
rgbColor.Red = 184;
|
|
|
|
|
rgbColor.Green = 242;
|
|
|
|
|
rgbColor.Blue = 200;
|
|
|
|
|
switch (geometryType)
|
|
|
|
|
{
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
|
|
|
|
|
result = (new SimpleMarkerSymbolClass
|
|
|
|
|
{
|
|
|
|
|
Color = rgbColor,
|
|
|
|
|
Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle
|
|
|
|
|
} as ISymbol);
|
|
|
|
|
goto IL_B3;
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultipoint:
|
|
|
|
|
goto IL_B3;
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
|
|
|
|
|
break;
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
|
|
|
|
|
result = (new SimpleFillSymbolClass
|
|
|
|
|
{
|
|
|
|
|
Color = rgbColor,
|
|
|
|
|
Style = ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSSolid
|
|
|
|
|
} as ISymbol);
|
|
|
|
|
goto IL_B3;
|
|
|
|
|
default:
|
|
|
|
|
if (geometryType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryLine)
|
|
|
|
|
{
|
|
|
|
|
goto IL_B3;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
result = (new SimpleLineSymbolClass
|
|
|
|
|
{
|
|
|
|
|
Color = rgbColor,
|
|
|
|
|
Width = 1.0,
|
|
|
|
|
Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid
|
|
|
|
|
} as ISymbol);
|
|
|
|
|
IL_B3:
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//RdbUtil.AddException(ex);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
public void LoadProject()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (_workCatalog == null)
|
|
|
|
|
{
|
|
|
|
|
_workCatalog = BundleRuntime.Instance.GetFirstOrDefaultService<IWorkCatalog>();
|
|
|
|
|
}
|
|
|
|
|
if (Platform.Instance.SystemType == SystemTypeEnum.WYZS || Platform.Instance.SystemType == SystemTypeEnum.DTBJK || Platform.Instance.SystemType == SystemTypeEnum.YCLJK)
|
|
|
|
|
{
|
|
|
|
|
string workCatalogPathTemp = null;
|
|
|
|
|
if (Platform.Instance.SystemType == SystemTypeEnum.DTBJK)
|
|
|
|
|
workCatalogPathTemp = SysAppPath.GetCurrentAppPath() + "DTBProject\\单图斑建库.KBG";
|
|
|
|
|
else if (Platform.Instance.SystemType == SystemTypeEnum.YCLJK)
|
|
|
|
|
workCatalogPathTemp = SysAppPath.GetCurrentAppPath() + "YCLProject\\图斑预处理.KBG";
|
|
|
|
|
else if (Platform.Instance.SystemType == SystemTypeEnum.WYZS)
|
|
|
|
|
workCatalogPathTemp = SysAppPath.GetCurrentAppPath() + "DTBZJProject\\单图斑质检.KBG";
|
|
|
|
|
if (!string.IsNullOrEmpty(workCatalogPathTemp))
|
|
|
|
|
{
|
|
|
|
|
if (File.Exists(workCatalogPathTemp))
|
|
|
|
|
{
|
|
|
|
|
LoadProject(workCatalogPathTemp);
|
|
|
|
|
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { Content = Platform.Instance.SystemType, MsgType = "LoadDTBViewData" });
|
|
|
|
|
//SetJCTBLayer();
|
|
|
|
|
//LoadDTBViewData();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
InitDTBProject();
|
|
|
|
|
//Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { Content = Platform.Instance.SystemType, MsgType = "LoadDTBViewData" });
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
string filePath = string.Empty;
|
|
|
|
|
#region 获取上次打开的工作目录
|
|
|
|
|
if (File.Exists(SysAppPath.GetRecentOpenProjectRecordConfigPath()))
|
|
|
|
|
{
|
|
|
|
|
XmlDocument xmlDoc = new XmlDocument();
|
|
|
|
|
xmlDoc.Load(SysAppPath.GetRecentOpenProjectRecordConfigPath());
|
|
|
|
|
string[,] RecentOpenProjectRecord_List = null;
|
|
|
|
|
SysConfigsOprator configOp = new SysConfigsOprator();
|
|
|
|
|
RecentOpenProjectRecord_List = configOp.GetRecentOpenProjectRecordList();
|
|
|
|
|
if (RecentOpenProjectRecord_List != null)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < RecentOpenProjectRecord_List.Length / 3; i++)
|
|
|
|
|
{
|
|
|
|
|
filePath = RecentOpenProjectRecord_List[i, 1].ToString();
|
|
|
|
|
if (Directory.Exists(filePath))
|
|
|
|
|
{
|
|
|
|
|
_workCatalog.SetWorksapce(filePath);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(string.Format("执行命令异常,异常信息如下:"));
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
LogAPI.Debug("异常信息结束");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化单图斑建库工程模板
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void InitDTBProject()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
this.ShowLoading("工程创建中……", 0, 0);
|
|
|
|
|
string path = null;
|
|
|
|
|
ProjectInfo pro = null;
|
|
|
|
|
if (Platform.Instance.SystemType == SystemTypeEnum.DTBJK)
|
|
|
|
|
{
|
|
|
|
|
path = SysAppPath.GetCurrentAppPath() + "DTBProject";
|
|
|
|
|
pro = new ProjectInfo
|
|
|
|
|
{
|
|
|
|
|
ProjType = EnumProjType.DTBJK,
|
|
|
|
|
ProjSuffix = ".KBG",
|
|
|
|
|
ProjDir = path,
|
|
|
|
|
ProjUserName = "今奥科技有限技术股份公司",
|
|
|
|
|
ProjName = "单图斑建库",
|
|
|
|
|
XYResolution = 0.0001 //默认值后续可动态配置
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else if (Platform.Instance.SystemType == SystemTypeEnum.YCLJK)
|
|
|
|
|
{
|
|
|
|
|
path = SysAppPath.GetCurrentAppPath() + "YCLProject";
|
|
|
|
|
pro = new ProjectInfo
|
|
|
|
|
{
|
|
|
|
|
ProjType = EnumProjType.YCLJK,
|
|
|
|
|
ProjSuffix = ".KBG",
|
|
|
|
|
ProjDir = path,
|
|
|
|
|
ProjUserName = "今奥科技有限技术股份公司",
|
|
|
|
|
ProjName = "图斑预处理",
|
|
|
|
|
XYResolution = 0.0001 //默认值后续可动态配置
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else if (Platform.Instance.SystemType == SystemTypeEnum.WYZS)
|
|
|
|
|
{
|
|
|
|
|
path = SysAppPath.GetCurrentAppPath() + "DTBZJProject";
|
|
|
|
|
pro = new ProjectInfo
|
|
|
|
|
{
|
|
|
|
|
ProjType = EnumProjType.WYZS,
|
|
|
|
|
ProjSuffix = ".KBG",
|
|
|
|
|
ProjDir = path,
|
|
|
|
|
ProjUserName = "今奥科技有限技术股份公司",
|
|
|
|
|
ProjName = "单图斑质检",
|
|
|
|
|
XYResolution = 0.0001 //默认值后续可动态配置
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
pro.UserName = PluginServiceInterface.CommonHelper.GetAppsetingValueByKey("UserName");
|
|
|
|
|
//验证同名工程是否存在
|
|
|
|
|
if (!Directory.Exists(pro.ProjDir))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(pro.ProjDir);
|
|
|
|
|
}
|
|
|
|
|
string strMxdPath = string.Empty;
|
|
|
|
|
//单图斑建库及单图斑质检
|
|
|
|
|
if (Platform.Instance.SystemType == SystemTypeEnum.DTBJK || Platform.Instance.SystemType == SystemTypeEnum.WYZS)
|
|
|
|
|
{
|
|
|
|
|
if (pro.ProjSuffix == ".KBG")
|
|
|
|
|
{
|
|
|
|
|
strMxdPath = SysAppPath.GetCurrentAppPath() + "工作空间DTBJK\\初始化工程模板\\LatersToXMLForDTBJK.xml";
|
|
|
|
|
File.Copy(SysAppPath.GetCurrentAppPath() + "工作空间DTBJK\\初始化工程模板\\dic.mdb", pro.ProjDir + "\\dic.mdb");
|
|
|
|
|
File.Copy(SysAppPath.GetCurrentAppPath() + "工作空间DTBJK\\初始化工程模板\\BGTJ.sqlite", pro.ProjDir + "\\BGTJ.sqlite");
|
|
|
|
|
DirectoryCopy(SysAppPath.GetCurrentAppPath() + string.Format("工作空间DTBJK\\DatabaseTemplate\\JCDB.gdb"), pro.ProjDir);
|
|
|
|
|
pro.JCDatabase = Path.Combine(pro.ProjDir, "JCDB.gdb");//监测数据图层
|
|
|
|
|
DirectoryCopy(SysAppPath.GetCurrentAppPath() + string.Format("工作空间DTBJK\\DatabaseTemplate\\BGDB.gdb"), pro.ProjDir);
|
|
|
|
|
pro.BGDatabase = Path.Combine(pro.ProjDir, "BGDB.gdb");
|
|
|
|
|
DirectoryCopy(SysAppPath.GetCurrentAppPath() + string.Format("工作空间DTBJK\\DatabaseTemplate\\Scheme-JK.gdb"), pro.ProjDir);
|
|
|
|
|
pro.DTBJKDatabase = Path.Combine(pro.ProjDir, "Scheme-JK.gdb");
|
|
|
|
|
DirectoryCopy(SysAppPath.GetCurrentAppPath() + string.Format("工作空间DTBJK\\DatabaseTemplate\\DTBDLTBBGGX.gdb"), pro.ProjDir);
|
|
|
|
|
pro.DTBBGGXDatabase = Path.Combine(pro.ProjDir, "DTBDLTBBGGX.gdb");
|
|
|
|
|
DirectoryCopy(SysAppPath.GetCurrentAppPath() + string.Format("工作空间DTBJK\\DatabaseTemplate\\Check.gdb"), pro.ProjDir);
|
|
|
|
|
pro.DTBCheckDatabase = Path.Combine(pro.ProjDir, "Check.gdb");
|
|
|
|
|
pro.LNGDFWPath = Path.Combine(pro.ProjDir, "Scheme-JK.gdb");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (Platform.Instance.SystemType == SystemTypeEnum.YCLJK)
|
|
|
|
|
{
|
|
|
|
|
if (pro.ProjSuffix == ".KBG")
|
|
|
|
|
{
|
|
|
|
|
strMxdPath = SysAppPath.GetCurrentAppPath() + "工作空间DTBJK\\初始化工程模板\\LatersToXMLForDTBYCL.xml";
|
|
|
|
|
File.Copy(SysAppPath.GetCurrentAppPath() + "工作空间DTBJK\\初始化工程模板\\dic.mdb", pro.ProjDir + "\\dic.mdb");
|
|
|
|
|
File.Copy(SysAppPath.GetCurrentAppPath() + "工作空间DTBJK\\初始化工程模板\\BGTJ.sqlite", pro.ProjDir + "\\BGTJ.sqlite");
|
|
|
|
|
DirectoryCopy(SysAppPath.GetCurrentAppPath() + string.Format("工作空间DTBJK\\DatabaseTemplate\\Scheme-YCL.gdb"), pro.ProjDir);
|
|
|
|
|
pro.DTBYCLDatabase = Path.Combine(pro.ProjDir, "Scheme-YCL.gdb");
|
|
|
|
|
DirectoryCopy(SysAppPath.GetCurrentAppPath() + string.Format("工作空间DTBJK\\DatabaseTemplate\\Scheme0.gdb"), pro.ProjDir);
|
|
|
|
|
pro.DTBYCLYHDatabase = Path.Combine(pro.ProjDir, "Scheme0.gdb");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LayerCfg StrLayerInfo = SerializeAPI.DeserializeToObject2<LayerCfg>(strMxdPath);
|
|
|
|
|
StrLayerInfo.LayerName = pro.ProjName;
|
|
|
|
|
SetLayerCfgPath(StrLayerInfo, pro);
|
|
|
|
|
Byte[] bytearr = Encoding.Default.GetBytes(SerializeAPI.SerializeToXML<LayerCfg>(StrLayerInfo));
|
|
|
|
|
string strBase64 = Convert.ToBase64String(bytearr);
|
|
|
|
|
pro.TempData = strBase64;
|
|
|
|
|
Platform.Instance.Progress.SetWorkPath(Path.GetDirectoryName(pro.ProjDir));
|
|
|
|
|
this.CloseLoading();
|
|
|
|
|
if (pro.Save())
|
|
|
|
|
{
|
|
|
|
|
IMapService mapService = MapsManager.Instance.MapService;
|
|
|
|
|
//设置工作目录时同时会加载
|
|
|
|
|
mapService.LoadProject(pro.ProjDir + "\\" + pro.ProjName + pro.ProjSuffix);
|
|
|
|
|
mapService.SetFolderPath(pro.ProjDir);
|
|
|
|
|
Platform.Instance.ViewManager.SetFilePath(pro.ProjDir);
|
|
|
|
|
Platform.Instance.AppMenuManager.HideAppMenu();
|
|
|
|
|
}
|
|
|
|
|
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "SaveProject" });
|
|
|
|
|
|
|
|
|
|
this.CloseLoading();
|
|
|
|
|
if (string.IsNullOrWhiteSpace(pro.UserName))
|
|
|
|
|
{ //设置单图斑工程用户信息
|
|
|
|
|
frmUserInfoSetting = new UCProjectInfoSetting
|
|
|
|
|
{
|
|
|
|
|
WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
|
|
|
|
|
};
|
|
|
|
|
frmUserInfoSetting.Closed += UserInfoSet_Closed;
|
|
|
|
|
frmUserInfoSetting.ShowInMainWindow(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("新建工程失败:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("新建工程时发生异常,异常信息如下:");
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
LogAPI.Debug("异常信息结束。");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
this.CloseLoading();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetILayerSymbol(IFeatureLayer tempLayer, string LayerAliseName)
|
|
|
|
|
{
|
|
|
|
|
IFeatureRenderer result = null;
|
|
|
|
|
ISystemCfg cfg2 = BundleRuntime.Instance.GetFirstOrDefaultService<ISystemCfg>();
|
|
|
|
|
SystemCfg = cfg2.Load();
|
|
|
|
|
if (SystemCfg.BGLayerLoadCfg == null)
|
|
|
|
|
{
|
|
|
|
|
SystemCfg.BGLayerLoadCfg = new List<LayerCfg>();
|
|
|
|
|
}
|
|
|
|
|
LayerCfg layerCfg = SystemCfg.BGLayerLoadCfg.FirstOrDefault(x => x.FcName == LayerAliseName);//默认配置默认不为NULL
|
|
|
|
|
if (layerCfg != null && !string.IsNullOrWhiteSpace(layerCfg.Symbol))
|
|
|
|
|
{
|
|
|
|
|
AdvancedDrawingInfo ad = AdvancedDrawingInfo.FromJson(layerCfg.Symbol);
|
|
|
|
|
if (ad != null)
|
|
|
|
|
{
|
|
|
|
|
if (ad.DrawingInfo.Renderer is Framework.LayerStyleConvert.XSDClass.SimpleRenderer)
|
|
|
|
|
{
|
|
|
|
|
Symbol symbol1 = (ad.DrawingInfo.Renderer as Framework.LayerStyleConvert.XSDClass.SimpleRenderer).Symbol;
|
|
|
|
|
ISimpleRenderer simpleRander2 = SymbolConvert.Instance().GetSimpleRenderer(symbol1, SymbolTypeEnum.Fill);
|
|
|
|
|
result = simpleRander2 as IFeatureRenderer;
|
|
|
|
|
}
|
|
|
|
|
else if (ad.DrawingInfo.Renderer is Framework.LayerStyleConvert.XSDClass.UniqueValueRenderer)
|
|
|
|
|
{
|
|
|
|
|
Renderer rander = ad.DrawingInfo.Renderer;
|
|
|
|
|
IUniqueValueRenderer uniqueValueRander = SymbolConvert.Instance().GetUniqueValueRenderer(rander, SymbolTypeEnum.Fill);
|
|
|
|
|
result = uniqueValueRander as IFeatureRenderer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#region 样式
|
|
|
|
|
if (result != null)
|
|
|
|
|
(tempLayer as IGeoFeatureLayer).Renderer = result;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 显示比例设置
|
|
|
|
|
tempLayer.MinimumScale = layerCfg.MinScale;
|
|
|
|
|
tempLayer.MaximumScale = layerCfg.MaxScale;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 图层透明度
|
|
|
|
|
if (tempLayer is ILayerEffects mLayerEffects)//透明度
|
|
|
|
|
mLayerEffects.Transparency = (short)layerCfg.Transparency;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 是否显示
|
|
|
|
|
tempLayer.Visible = layerCfg.Visible;//是否显示
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 是否可选择
|
|
|
|
|
tempLayer.Selectable = layerCfg.Selectable;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 过滤条件
|
|
|
|
|
IFeatureLayerDefinition pFLDefinition = tempLayer as IFeatureLayerDefinition;
|
|
|
|
|
if (pFLDefinition != null)
|
|
|
|
|
{
|
|
|
|
|
pFLDefinition.DefinitionExpression = layerCfg.DefinitionExpression;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设置默认数据库模板图层路径
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="StrLayerInfo"></param>
|
|
|
|
|
/// <param name="pro"></param>
|
|
|
|
|
private void SetLayerCfgPath(LayerCfg StrLayerInfo, ProjectInfo pro)
|
|
|
|
|
{
|
|
|
|
|
foreach (LayerCfg CfgItem in StrLayerInfo.Layers)//目录图层一级
|
|
|
|
|
{
|
|
|
|
|
if (CfgItem.LayerType == EnumLayerType.GroupLayer)
|
|
|
|
|
{
|
|
|
|
|
SetLayerCfgPath(CfgItem, pro);
|
|
|
|
|
}
|
|
|
|
|
else if (CfgItem.LayerType == EnumLayerType.FeatureLayer)
|
|
|
|
|
{
|
|
|
|
|
if (Platform.Instance.SystemType == SystemTypeEnum.YCLJK)
|
|
|
|
|
{
|
|
|
|
|
if ("标注点,标注线,标注面,自主图斑".Contains(CfgItem.LayerName))
|
|
|
|
|
CfgItem.FcPath = pro.DTBYCLYHDatabase;
|
|
|
|
|
else
|
|
|
|
|
CfgItem.FcPath = pro.DTBYCLDatabase;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ("单图斑地类图斑更新层,推土区更新".Contains(CfgItem.LayerName))
|
|
|
|
|
CfgItem.FcPath = pro.DTBBGGXDatabase;
|
|
|
|
|
else
|
|
|
|
|
CfgItem.FcPath = pro.DTBJKDatabase;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UserInfoSet_Closed(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ProjectInfo projectInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo;
|
|
|
|
|
if (frmUserInfoSetting != null)
|
|
|
|
|
{
|
|
|
|
|
frmUserInfoSetting.Close();
|
|
|
|
|
frmUserInfoSetting = null;
|
|
|
|
|
}
|
|
|
|
|
if (frmUserInfoSetting == null && string.IsNullOrWhiteSpace(projectInfo.UserName))
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.Show("请输入用户名!");
|
|
|
|
|
frmUserInfoSetting = new UCProjectInfoSetting
|
|
|
|
|
{
|
|
|
|
|
WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
|
|
|
|
|
};
|
|
|
|
|
frmUserInfoSetting.Closed += UserInfoSet_Closed;
|
|
|
|
|
frmUserInfoSetting.ShowInMainWindow(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 文件夹复制
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sourceDir">原文件夹</param>
|
|
|
|
|
/// <param name="targetDirPath">目标目录</param>
|
|
|
|
|
/// <returns>是否成功复制</returns>
|
|
|
|
|
public bool DirectoryCopy(string sourceDir, string targetDirPath)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!System.IO.Directory.Exists(sourceDir)) return false;
|
|
|
|
|
string targetDir = targetDirPath + "\\" + System.IO.Path.GetFileName(sourceDir);
|
|
|
|
|
if (!System.IO.Directory.Exists(targetDir)) System.IO.Directory.CreateDirectory(targetDir);
|
|
|
|
|
// 文件及文件夹名称数组
|
|
|
|
|
string[] dirColl = System.IO.Directory.GetDirectories(sourceDir);
|
|
|
|
|
string[] fileColl = System.IO.Directory.GetFiles(sourceDir);
|
|
|
|
|
// 便利所有文件
|
|
|
|
|
if (fileColl.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
string fileName;
|
|
|
|
|
foreach (string fileDir in fileColl)
|
|
|
|
|
{
|
|
|
|
|
fileName = System.IO.Path.GetFileName(fileDir);
|
|
|
|
|
System.IO.File.Copy(sourceDir + "\\" + fileName, targetDir + "\\" + fileName, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 遍历所有文件夹
|
|
|
|
|
if (dirColl.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
string folderName;
|
|
|
|
|
foreach (string dir in dirColl)
|
|
|
|
|
{
|
|
|
|
|
folderName = System.IO.Path.GetFileName(dir);
|
|
|
|
|
// 递归调用
|
|
|
|
|
System.IO.Directory.CreateDirectory(targetDir + "\\" + folderName);
|
|
|
|
|
DirectoryCopy(dir, targetDir + "\\" + folderName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("新建工程 页面 中 文件夹复制 时失败,异常原因: " + ex + " ; ");
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadMap(string filePath)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
axMapControl.CurrentTool = null;
|
|
|
|
|
projectInfo = new ProjectInfo();
|
|
|
|
|
projectInfo.ProjName = System.IO.Path.GetFileNameWithoutExtension(filePath);
|
|
|
|
|
projectInfo.ProjSuffix = System.IO.Path.GetExtension(filePath);
|
|
|
|
|
projectInfo.ProjDir = System.IO.Path.GetDirectoryName(filePath);
|
|
|
|
|
IMapDocument mDoc = new MapDocumentClass();
|
|
|
|
|
mDoc.Open(filePath);
|
|
|
|
|
|
|
|
|
|
IMap map = mDoc.get_Map(0);
|
|
|
|
|
if (map == null)
|
|
|
|
|
return;
|
|
|
|
|
map.Name = projectInfo.ProjName;
|
|
|
|
|
ISpatialReference reference = GeoDBAPI.GetGeoDatasetSpatialReference(GetDefaultWorkspace(map));
|
|
|
|
|
if (map.SpatialReference != reference && reference != null)
|
|
|
|
|
{
|
|
|
|
|
map.SpatialReference = reference;
|
|
|
|
|
}
|
|
|
|
|
IActiveView view = (IActiveView)map;
|
|
|
|
|
mDoc.SetActiveView(view);
|
|
|
|
|
CtlsSynchronizer.ReplaceMap(map);
|
|
|
|
|
axMapControl.DocumentFilename = filePath;
|
|
|
|
|
mDoc.Close();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CreateXml(string path)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
|
|
|
|
|
xmlDoc.AppendChild(xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null));
|
|
|
|
|
System.Xml.XmlElement root = xmlDoc.CreateElement("Root");
|
|
|
|
|
xmlDoc.AppendChild(root);
|
|
|
|
|
|
|
|
|
|
System.Xml.XmlElement roots = xmlDoc.CreateElement("File");
|
|
|
|
|
roots.SetAttribute("path", path);
|
|
|
|
|
root.AppendChild(roots);
|
|
|
|
|
xmlDoc.Save(m_XmlPath);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("在初始化 目录切换 命令时异常,异常信息如下:");
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
LogAPI.Debug("在初始化 目录切换 命令时异常信息结束");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 接口函数
|
|
|
|
|
public void InitMapTools(IEnumerable<MenuPageEntity> pageDatas)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (barManager1 == null) return;
|
|
|
|
|
barManager1.BeginUpdate();
|
|
|
|
|
if (_CmdManager == null)
|
|
|
|
|
{
|
|
|
|
|
_CmdManager = BundleRuntime.Instance.GetFirstOrDefaultService<ICommandManager>();
|
|
|
|
|
}
|
|
|
|
|
foreach (var pageEntity in pageDatas)
|
|
|
|
|
{
|
|
|
|
|
var groupChilds = pageEntity.Childs;
|
|
|
|
|
if (groupChilds == null)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
foreach (var groupChild in groupChilds)
|
|
|
|
|
{
|
|
|
|
|
Bar subItem = new Bar();
|
|
|
|
|
subItem.OptionsBar.AllowQuickCustomization = false;
|
|
|
|
|
subItem.BarName = groupChild.Name;
|
|
|
|
|
subItem.Visible = groupChild.Visible;
|
|
|
|
|
if (groupChild.Name == "地图操作")
|
|
|
|
|
{
|
|
|
|
|
subItem.DockStyle = BarDockStyle.Left;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
subItem.DockStyle = BarDockStyle.Top;
|
|
|
|
|
}
|
|
|
|
|
barManager1.Bars.Add(subItem);
|
|
|
|
|
|
|
|
|
|
var itemChilds = groupChild.Childs;
|
|
|
|
|
if (itemChilds == null)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
foreach (var itemChild in itemChilds)
|
|
|
|
|
{
|
|
|
|
|
var item = CreateItem(itemChild, Hook);
|
|
|
|
|
//item.PaintStyle = BarItemPaintStyle.Caption;
|
|
|
|
|
//subItem.LinksPersistInfo.Add(new LinkPersistInfo(DevExpress.XtraBars.BarLinkUserDefines.PaintStyle, item, "", false, true, true, 0, null, DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph));
|
|
|
|
|
subItem.LinksPersistInfo.Add(new LinkPersistInfo(item));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("加载主菜单异常,异常信息如下:");
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
LogAPI.Debug("异常信息结束");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
barManager1.EndUpdate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void RefreshToolState(object currentTool)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (barManager1 == null) return;
|
|
|
|
|
foreach (Bar bar in barManager1.Bars)
|
|
|
|
|
{
|
|
|
|
|
foreach (LinkPersistInfo linkPersist in bar.LinksPersistInfo)
|
|
|
|
|
{
|
|
|
|
|
BarItem item = linkPersist.Item;
|
|
|
|
|
if (item.Tag is ICommand)
|
|
|
|
|
{
|
|
|
|
|
item.Enabled = (item.Tag as ICommand).Enabled;
|
|
|
|
|
if (item is BarCheckItem)
|
|
|
|
|
{
|
|
|
|
|
(item as BarCheckItem).Checked = (item.Tag as ICommand).Checked;
|
|
|
|
|
|
|
|
|
|
if (currentTool == item.Tag)
|
|
|
|
|
{
|
|
|
|
|
(item as BarCheckItem).Checked = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (item.Tag is BaseMenuCommand)
|
|
|
|
|
{
|
|
|
|
|
item.Enabled = (item.Tag as BaseMenuCommand).Enabled;
|
|
|
|
|
if (item is BarCheckItem)
|
|
|
|
|
{
|
|
|
|
|
(item as BarCheckItem).Checked = (item.Tag as BaseMenuCommand).Checked;
|
|
|
|
|
|
|
|
|
|
if (currentTool == item.Tag)
|
|
|
|
|
{
|
|
|
|
|
(item as BarCheckItem).Checked = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("刷新工具条状态时发生异常,异常信息如下:");
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
LogAPI.Debug("异常信息结束");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private IFeatureRenderer GetSymbol(string pStrSymbol)
|
|
|
|
|
{
|
|
|
|
|
IFeatureRenderer result = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(pStrSymbol))
|
|
|
|
|
{
|
|
|
|
|
AdvancedDrawingInfo ad = AdvancedDrawingInfo.FromJson(pStrSymbol);
|
|
|
|
|
if (ad != null)
|
|
|
|
|
{
|
|
|
|
|
if (ad.DrawingInfo.Renderer is Framework.LayerStyleConvert.XSDClass.SimpleRenderer)
|
|
|
|
|
{
|
|
|
|
|
Symbol symbol1 = (ad.DrawingInfo.Renderer as Framework.LayerStyleConvert.XSDClass.SimpleRenderer).Symbol;
|
|
|
|
|
ISimpleRenderer simpleRander2 = SymbolConvert.Instance().GetSimpleRenderer(symbol1, SymbolTypeEnum.Fill);
|
|
|
|
|
result = simpleRander2 as IFeatureRenderer;
|
|
|
|
|
}
|
|
|
|
|
else if (ad.DrawingInfo.Renderer is Framework.LayerStyleConvert.XSDClass.UniqueValueRenderer)
|
|
|
|
|
{
|
|
|
|
|
Renderer rander = ad.DrawingInfo.Renderer;
|
|
|
|
|
IUniqueValueRenderer uniqueValueRander = SymbolConvert.Instance().GetUniqueValueRenderer(rander, SymbolTypeEnum.Fill);
|
|
|
|
|
result = uniqueValueRander as IFeatureRenderer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("获取图层样式失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
private void LaodLayersToMap(ILayer addLayerTemp, List<LayerCfg> layerInfo2s)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in layerInfo2s)
|
|
|
|
|
{
|
|
|
|
|
ILayer addLayer = null;
|
|
|
|
|
if (item.LayerType == EnumLayerType.GroupLayer)
|
|
|
|
|
{
|
|
|
|
|
addLayer = new GroupLayer() { Name = item.LayerName };
|
|
|
|
|
ILayerGeneralProperties layerGeneralProperties = addLayer as ILayerGeneralProperties;
|
|
|
|
|
layerGeneralProperties.LayerDescription = item.FcName;
|
|
|
|
|
}
|
|
|
|
|
foreach (LayerCfg subItem in item.Layers)
|
|
|
|
|
{
|
|
|
|
|
// LayerCfg GroupLayerInfo = null;
|
|
|
|
|
if (subItem.LayerType == EnumLayerType.GroupLayer)
|
|
|
|
|
{
|
|
|
|
|
ILayer groupLayer = new GroupLayer() { Name = subItem.LayerName };
|
|
|
|
|
ILayerGeneralProperties layerGeneralProperties = addLayer as ILayerGeneralProperties;
|
|
|
|
|
layerGeneralProperties.LayerDescription = subItem.FcName;
|
|
|
|
|
//GroupLayerInfo = _DataCatalog.AddLayer(groupLayer, addLayer as IGroupLayer) as LayerCfg;
|
|
|
|
|
//(addLayer as IGroupLayer).Add(addLayer);
|
|
|
|
|
subItem.Data = groupLayer;
|
|
|
|
|
LaodLayersToMap(groupLayer, item.Layers);//Group-Group
|
|
|
|
|
}
|
|
|
|
|
//工程文件夹或被移动-替换工作目录
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(subItem.FcPath) && projectInfo.ProWorkDir != null && _workCatalog.SaveWorkSapcePath != null)
|
|
|
|
|
{
|
|
|
|
|
subItem.FcPath = subItem.FcPath.ToString().Replace(projectInfo.ProWorkDir, _workCatalog.SaveWorkSapcePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (addLayer is IGroupLayer && subItem.LayerType == EnumLayerType.FeatureLayer)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(subItem.FcPath)) continue;
|
|
|
|
|
WorkspaceTypeEnum workspaceType = WorkspaceTypeEnum.GDBFile;
|
|
|
|
|
if (subItem.FcPath.ToLower().EndsWith(".mdb"))
|
|
|
|
|
{
|
|
|
|
|
if (!File.Exists(subItem.FcPath))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
workspaceType = WorkspaceTypeEnum.MDBFile;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!Directory.Exists(subItem.FcPath)) continue;
|
|
|
|
|
workspaceType = WorkspaceTypeEnum.ShapeFile;
|
|
|
|
|
if (subItem.FcPath.ToLower().EndsWith(".gdb"))
|
|
|
|
|
{
|
|
|
|
|
workspaceType = WorkspaceTypeEnum.GDBFile;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
IWorkspaceAPI wsAPI = new WorkspaceAPI(subItem.FcPath, workspaceType);
|
|
|
|
|
IFeatureClass fc = wsAPI.OpenFeatureClass(subItem.FcName).FeatureClass;
|
|
|
|
|
ILayer tempLayer = new FeatureLayer() { Name = subItem.LayerName, FeatureClass = fc };
|
|
|
|
|
IFeatureRenderer render = GetSymbol(subItem.Symbol);
|
|
|
|
|
if (render != null)
|
|
|
|
|
(tempLayer as IGeoFeatureLayer).Renderer = render;
|
|
|
|
|
//(addLayer as IGroupLayer).Add(tempLayer);
|
|
|
|
|
_DataCatalog.AddLayer(tempLayer, addLayer);
|
|
|
|
|
subItem.Data = tempLayer;
|
|
|
|
|
}
|
|
|
|
|
else if (addLayer is IGroupLayer && subItem.LayerType == EnumLayerType.RasterLayer)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(subItem.FcPath)) continue;
|
|
|
|
|
IRasterLayer layer = new RasterLayerClass();
|
|
|
|
|
layer.CreateFromFilePath(subItem.FcPath);
|
|
|
|
|
layer.Name = subItem.LayerName;
|
|
|
|
|
//(addLayer as IGroupLayer).Add(layer);
|
|
|
|
|
_DataCatalog.AddLayer(layer, addLayer);
|
|
|
|
|
subItem.Data = layer;
|
|
|
|
|
}
|
|
|
|
|
else if (addLayer is IGroupLayer && subItem.LayerType == EnumLayerType.KOTilesLayer)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(subItem.FcPath)) continue;
|
|
|
|
|
KOTilesLayer ko = KOTilesLayer.CreateInstance(subItem.FcPath);
|
|
|
|
|
ko.Name = subItem.LayerName;
|
|
|
|
|
//(addLayer as IGroupLayer).Add(ko);
|
|
|
|
|
_DataCatalog.AddLayer(ko, addLayer);
|
|
|
|
|
subItem.Data = ko;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (addLayer != null)
|
|
|
|
|
axMapControl.Map.AddLayer(addLayer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public SystemConfig2 SystemCfg { get; set; }
|
|
|
|
|
private void LoadLayerToMap(LayerCfg ParentGroup, List<LayerCfg> layerInfo2s)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < layerInfo2s.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
IGroupLayer rootGroupLayer = null;
|
|
|
|
|
LayerCfg GroupLayerInfo = null;
|
|
|
|
|
if (layerInfo2s[i].LayerType == EnumLayerType.GroupLayer)
|
|
|
|
|
{
|
|
|
|
|
rootGroupLayer = new GroupLayer() { Name = layerInfo2s[i].LayerName };
|
|
|
|
|
ILayerGeneralProperties layerGeneralProperties = rootGroupLayer as ILayerGeneralProperties;
|
|
|
|
|
layerGeneralProperties.LayerDescription = layerInfo2s[i].FcName;
|
|
|
|
|
GroupLayerInfo = _DataCatalog.AddLayer(rootGroupLayer, ParentGroup) as LayerCfg;
|
|
|
|
|
layerInfo2s[i].Symbol = GroupLayerInfo.Symbol;
|
|
|
|
|
layerInfo2s[i].SymbolImg = GroupLayerInfo.SymbolImg;
|
|
|
|
|
layerInfo2s[i].Data = GroupLayerInfo.Data;
|
|
|
|
|
LoadLayerToMap(GroupLayerInfo, layerInfo2s[i].Layers);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GroupLayerInfo = GroupLayerInfo ?? ParentGroup;
|
|
|
|
|
if (Platform.Instance.SystemType != SystemTypeEnum.WYZS && Platform.Instance.SystemType != SystemTypeEnum.DTBJK && Platform.Instance.SystemType != SystemTypeEnum.YCLJK)
|
|
|
|
|
{
|
|
|
|
|
layerInfo2s[i].FcPath = layerInfo2s[i].FcPath.Replace("{工程目录}", projectInfo.ProjDir);
|
|
|
|
|
layerInfo2s[i].FcPath = layerInfo2s[i].FcPath.Replace("{工作目录}", projectInfo.ProWorkDir);
|
|
|
|
|
//工程文件夹或被移动-替换工作目录 AddLayerWay-外部路径文件
|
|
|
|
|
if (projectInfo.ProjType != EnumProjType.BHTBTQ && layerInfo2s[i].AbsolutePathType != "AddLayerWay" && !string.IsNullOrWhiteSpace(layerInfo2s[i].FcPath) && projectInfo.ProWorkDir != null && _workCatalog.SaveWorkSapcePath != null)
|
|
|
|
|
{
|
|
|
|
|
if (layerInfo2s[i].FcPath.ToLower().EndsWith(".mdb") || layerInfo2s[i].FcPath.ToLower().EndsWith(".gdb"))
|
|
|
|
|
{
|
|
|
|
|
if (layerInfo2s[i].FcPath.Contains(projectInfo.ProWorkDir))
|
|
|
|
|
{
|
|
|
|
|
string Temppath = layerInfo2s[i].FcPath.ToString().Replace(projectInfo.ProWorkDir, "|");
|
|
|
|
|
layerInfo2s[i].FcPath = System.IO.Path.Combine(_workCatalog.SaveWorkSapcePath, projectInfo.ProWorkDir + Temppath.Split('|')[Temppath.Split('|').Length - 1].ToString());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string Temppath = layerInfo2s[i].FcPath.ToString().Replace("\\", "|");
|
|
|
|
|
layerInfo2s[i].FcPath = System.IO.Path.Combine(_workCatalog.SaveWorkSapcePath, projectInfo.ProWorkDir, "参考数据", Temppath.Split('|')[Temppath.Split('|').Length - 1].ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
LayerCfg layerInfo3 = new LayerCfg();
|
|
|
|
|
if (layerInfo2s[i].LayerType == EnumLayerType.FeatureLayer)
|
|
|
|
|
{
|
|
|
|
|
string sdf = layerInfo2s[i].LayerName;
|
|
|
|
|
ILayer tempLayer = null;
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(layerInfo2s[i].FcPath))
|
|
|
|
|
{
|
|
|
|
|
WorkspaceTypeEnum workspaceType = WorkspaceTypeEnum.GDBFile;
|
|
|
|
|
if (layerInfo2s[i].FcPath.ToLower().EndsWith(".mdb"))
|
|
|
|
|
{
|
|
|
|
|
if (!File.Exists(layerInfo2s[i].FcPath))
|
|
|
|
|
{
|
|
|
|
|
layerInfo2s.Remove(layerInfo2s[i]);
|
|
|
|
|
i--;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
workspaceType = WorkspaceTypeEnum.MDBFile;
|
|
|
|
|
}
|
|
|
|
|
else if (layerInfo2s[i].FcPath.ToLower().EndsWith(".gdb"))
|
|
|
|
|
{
|
|
|
|
|
if (!Directory.Exists(layerInfo2s[i].FcPath))
|
|
|
|
|
{
|
|
|
|
|
layerInfo2s.Remove(layerInfo2s[i]);
|
|
|
|
|
i--;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
workspaceType = WorkspaceTypeEnum.GDBFile;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
workspaceType = WorkspaceTypeEnum.ShapeFile;
|
|
|
|
|
}
|
|
|
|
|
IWorkspaceAPI wsAPI = null;
|
|
|
|
|
if (workspaceType == WorkspaceTypeEnum.GDBFile)
|
|
|
|
|
wsAPI = new WorkspaceAPI(layerInfo2s[i].FcPath, workspaceType, true);
|
|
|
|
|
else
|
|
|
|
|
wsAPI = new WorkspaceAPI(layerInfo2s[i].FcPath, workspaceType);
|
|
|
|
|
if (wsAPI.OpenFeatureClass2(layerInfo2s[i].FcName) != null)
|
|
|
|
|
{
|
|
|
|
|
IFeatureClass fc = wsAPI.OpenFeatureClass(layerInfo2s[i].FcName).FeatureClass;
|
|
|
|
|
tempLayer = new FeatureLayer() { Name = layerInfo2s[i].LayerName, FeatureClass = fc };
|
|
|
|
|
}
|
|
|
|
|
wsAPI.CloseWorkspace();
|
|
|
|
|
wsAPI = null;
|
|
|
|
|
}
|
|
|
|
|
else if (string.IsNullOrWhiteSpace(layerInfo2s[i].FcPath) && Platform.Instance.SystemType != SystemTypeEnum.DTBJK && Platform.Instance.SystemType != SystemTypeEnum.YCLJK)
|
|
|
|
|
continue;
|
|
|
|
|
if (tempLayer == null)
|
|
|
|
|
tempLayer = GetFeatureLayerByBasicPath(layerInfo2s[i]);// new FeatureLayer() { Name = layerInfo2s[i].LayerName };
|
|
|
|
|
#region 显示比例设置
|
|
|
|
|
sdf = tempLayer.Name;
|
|
|
|
|
tempLayer.MinimumScale = layerInfo2s[i].MinScale;
|
|
|
|
|
tempLayer.MaximumScale = layerInfo2s[i].MaxScale;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 图层透明度
|
|
|
|
|
if (tempLayer is ILayerEffects mLayerEffects)//透明度
|
|
|
|
|
mLayerEffects.Transparency = (short)layerInfo2s[i].Transparency;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 是否显示
|
|
|
|
|
tempLayer.Visible = layerInfo2s[i].Visible;//是否显示
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 过滤条件
|
|
|
|
|
IFeatureLayerDefinition pFLDefinition = tempLayer as IFeatureLayerDefinition;
|
|
|
|
|
if (pFLDefinition != null)
|
|
|
|
|
{
|
|
|
|
|
pFLDefinition.DefinitionExpression = layerInfo2s[i].DefinitionExpression;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 图层样式
|
|
|
|
|
IFeatureRenderer render = GetSymbol(layerInfo2s[i].Symbol);
|
|
|
|
|
if (render != null)
|
|
|
|
|
(tempLayer as IGeoFeatureLayer).Renderer = render;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 图层标注
|
|
|
|
|
SetLayerAnnotation(tempLayer, layerInfo2s[i]);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
layerInfo2s[i].Data = tempLayer;
|
|
|
|
|
tempLayer.Visible = layerInfo2s[i].Visible == false ? false : GetParentIsChecked(layerInfo2s[i]);
|
|
|
|
|
LayerCfg newLayerCfg = _DataCatalog.AddLayer(tempLayer, GroupLayerInfo) as LayerCfg;
|
|
|
|
|
layerInfo2s[i].Symbol = newLayerCfg.Symbol ?? layerInfo2s[i].Symbol;
|
|
|
|
|
layerInfo2s[i].SymbolImg = newLayerCfg.SymbolImg;
|
|
|
|
|
layerInfo2s[i].Data = newLayerCfg.Data;
|
|
|
|
|
var layerCfg = SystemCfg.ZLLayerLoadCfg.FirstOrDefault(x => x.LayerName == "增量成果");
|
|
|
|
|
if (layerCfg != null)
|
|
|
|
|
{
|
|
|
|
|
var ilayerCfg = layerCfg.Layers.FirstOrDefault(x => x.LayerName == tempLayer.Name);
|
|
|
|
|
if (ilayerCfg != null)
|
|
|
|
|
{
|
|
|
|
|
layerInfo2s[i].FieldEditCfg = ilayerCfg.FieldEditCfg;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
layerInfo3 = GroupLayerInfo.Layers.FirstOrDefault(x => x.FcName == tempLayer.Name);
|
|
|
|
|
}
|
|
|
|
|
else if (layerInfo2s[i].LayerType == EnumLayerType.RasterLayer)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(layerInfo2s[i].FcPath)) continue;
|
|
|
|
|
IRasterLayer layer = new RasterLayerClass();
|
|
|
|
|
layer.CreateFromFilePath(layerInfo2s[i].FcPath);
|
|
|
|
|
layer.Name = layerInfo2s[i].LayerName;
|
|
|
|
|
LayerCfg layerCfg = SystemCfg.JcLayerLoadCfg.FirstOrDefault(x => x.LayerName == layer.Name);
|
|
|
|
|
if (layerCfg != null)
|
|
|
|
|
{
|
|
|
|
|
layer.MinimumScale = layerCfg.MinScale;
|
|
|
|
|
layer.MaximumScale = layerCfg.MaxScale;
|
|
|
|
|
}
|
|
|
|
|
if (layer is ILayerEffects mLayerEffects)
|
|
|
|
|
mLayerEffects.Transparency = (short)layerInfo2s[i].Transparency;
|
|
|
|
|
layer.Visible = layerInfo2s[i].Visible;
|
|
|
|
|
layerInfo2s[i].Data = layer;
|
|
|
|
|
layer.Visible = layerInfo2s[i].Visible == false ? false : GetParentIsChecked(layerInfo2s[i]);
|
|
|
|
|
_DataCatalog.AddLayer(layer, GroupLayerInfo);
|
|
|
|
|
layerInfo3 = GroupLayerInfo.Layers.FirstOrDefault(x => x.FcName == layer.Name);
|
|
|
|
|
}
|
|
|
|
|
else if (layerInfo2s[i].LayerType == EnumLayerType.KOTilesLayer)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(layerInfo2s[i].FcPath)) continue;
|
|
|
|
|
KOTilesLayer ko = KOTilesLayer.CreateInstance(layerInfo2s[i].FcPath);
|
|
|
|
|
ko.Name = layerInfo2s[i].LayerName;
|
|
|
|
|
LayerCfg layerCfg = SystemCfg.JcLayerLoadCfg.FirstOrDefault(x => x.LayerName == ko.Name);
|
|
|
|
|
if (layerCfg != null)
|
|
|
|
|
{
|
|
|
|
|
ko.MinimumScale = layerCfg.MinScale;
|
|
|
|
|
ko.MaximumScale = layerCfg.MaxScale;
|
|
|
|
|
}
|
|
|
|
|
if (ko is ILayerEffects mLayerEffects)
|
|
|
|
|
mLayerEffects.Transparency = (short)layerInfo2s[i].Transparency;
|
|
|
|
|
ko.Visible = layerInfo2s[i].Visible;
|
|
|
|
|
layerInfo2s[i].Data = ko;
|
|
|
|
|
ko.Visible = layerInfo2s[i].Visible == false ? false : GetParentIsChecked(layerInfo2s[i]);
|
|
|
|
|
_DataCatalog.AddLayer(ko, GroupLayerInfo);
|
|
|
|
|
layerInfo3 = GroupLayerInfo.Layers.FirstOrDefault(x => x.FcName == ko.Name);
|
|
|
|
|
}
|
|
|
|
|
else if (layerInfo2s[i].LayerType == EnumLayerType.WMTSLayer)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
if (layerInfo3 != null)
|
|
|
|
|
{
|
|
|
|
|
layerInfo3.AbsolutePathType = layerInfo2s[i].AbsolutePathType;
|
|
|
|
|
layerInfo3.AbsolutePath = layerInfo2s[i].AbsolutePath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("LoadLayerToMap异常:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("LoadLayerToMap异常:" + ex.StackTrace);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 大数据影像相关
|
|
|
|
|
public Dictionary<ILayer, ILayer> GetAllLayerInGroupLayer(ICompositeLayer groupLayer, ILayer parentLayer)
|
|
|
|
|
{
|
|
|
|
|
Dictionary<ILayer, ILayer> allLayers = new Dictionary<ILayer, ILayer>();
|
|
|
|
|
if (groupLayer != null && groupLayer.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < groupLayer.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
ILayer layer = groupLayer.get_Layer(i);
|
|
|
|
|
if (layer is ICompositeLayer && !(layer is ESRI.ArcGIS.Carto.IAnnotationLayer))
|
|
|
|
|
{
|
|
|
|
|
if (!allLayers.Keys.Contains(layer))
|
|
|
|
|
allLayers.Add(layer, parentLayer);
|
|
|
|
|
Dictionary<ILayer, ILayer> list = GetChildLayerInGroupLayer(layer as ICompositeLayer, layer);
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
if (!allLayers.Keys.Contains(item.Key))
|
|
|
|
|
{
|
|
|
|
|
allLayers.Add(item.Key, item.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (layer is ILayer)
|
|
|
|
|
{
|
|
|
|
|
if (!allLayers.Keys.Contains(layer))
|
|
|
|
|
allLayers.Add(layer, parentLayer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return allLayers;
|
|
|
|
|
}
|
|
|
|
|
public Dictionary<ILayer, ILayer> GetChildLayerInGroupLayer(ICompositeLayer groupLayer, ILayer parentLayer)
|
|
|
|
|
{
|
|
|
|
|
Dictionary<ILayer, ILayer> allLayers = new Dictionary<ILayer, ILayer>();
|
|
|
|
|
if (groupLayer != null && groupLayer.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < groupLayer.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
ILayer layer = groupLayer.get_Layer(i);
|
|
|
|
|
if (layer is ICompositeLayer && !(layer is ESRI.ArcGIS.Carto.IAnnotationLayer))
|
|
|
|
|
{
|
|
|
|
|
if (!allLayers.Keys.Contains(layer))
|
|
|
|
|
allLayers.Add(layer, parentLayer);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (layer is ILayer)
|
|
|
|
|
{
|
|
|
|
|
if (!allLayers.Keys.Contains(layer))
|
|
|
|
|
allLayers.Add(layer, parentLayer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return allLayers;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取模版数据库要素类
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="layerCfg"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private IFeatureLayer GetFeatureLayerByBasicPath(LayerCfg layerCfg)
|
|
|
|
|
{
|
|
|
|
|
IFeatureLayer featureLayer = null;
|
|
|
|
|
IWorkspaceAPI wsAPI = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (projectInfo == null)
|
|
|
|
|
projectInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo;
|
|
|
|
|
string BasicPath = string.Empty;
|
|
|
|
|
switch (layerCfg.LayerName)
|
|
|
|
|
{
|
|
|
|
|
case "质检结果":
|
|
|
|
|
BasicPath = projectInfo.DTBCheckDatabase;
|
|
|
|
|
break;
|
|
|
|
|
case "基础_历年耕地":
|
|
|
|
|
BasicPath = projectInfo.DTBJKDatabase;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrWhiteSpace(BasicPath))
|
|
|
|
|
return featureLayer ?? new FeatureLayer() { Name = layerCfg.LayerName };
|
|
|
|
|
wsAPI = new WorkspaceAPI(BasicPath, WorkspaceTypeEnum.GDBFile, true);
|
|
|
|
|
if (wsAPI.ExistFeatureClass(layerCfg.FcName))
|
|
|
|
|
{
|
|
|
|
|
IFeatureClass fc = wsAPI.OpenFeatureClass(layerCfg.FcName).FeatureClass;
|
|
|
|
|
featureLayer = new FeatureLayer() { Name = layerCfg.LayerName, FeatureClass = fc };
|
|
|
|
|
}
|
|
|
|
|
return featureLayer ?? new FeatureLayer() { Name = layerCfg.LayerName };
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("获取模版数据库要素类失败:" + ex);
|
|
|
|
|
return featureLayer ?? new FeatureLayer() { Name = layerCfg.LayerName };
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (wsAPI != null)
|
|
|
|
|
wsAPI.CloseWorkspace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool GetParentIsChecked(LayerCfg layer)
|
|
|
|
|
{
|
|
|
|
|
if (allLayerInfo == null) return true;
|
|
|
|
|
LayerCfg parent = allLayerInfo.GetAllItem().Find(a => a.Layers.Contains(layer));
|
|
|
|
|
if (parent == null)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (!parent.Visible)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return GetParentIsChecked(parent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadProject(string pPrjFile)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
EngineEditor engineEditor = new EngineEditor();
|
|
|
|
|
if (engineEditor.EditState == esriEngineEditState.esriEngineStateEditing)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("当前处于编辑状态,请关闭后打开工程!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (_DataCatalog == null)
|
|
|
|
|
_DataCatalog = BundleRuntime.Instance.GetFirstOrDefaultService<IDataCatalogService>();
|
|
|
|
|
CloseProject();
|
|
|
|
|
projectInfo = ProjectInfo.OpenProject(pPrjFile);
|
|
|
|
|
if (projectInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("加载工程失败!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
axMapControl.CurrentTool = null;
|
|
|
|
|
if (projectInfo != null && !string.IsNullOrWhiteSpace(projectInfo.TempData))
|
|
|
|
|
{
|
|
|
|
|
#region 将文件流转换成文件存储到本地
|
|
|
|
|
byte[] contentArray = Convert.FromBase64String(projectInfo.TempData);
|
|
|
|
|
string LayerCfgd = Encoding.Default.GetString(contentArray);
|
|
|
|
|
LayerCfg layerInfo = SerializeAPI.DeserializeToObject<LayerCfg>(LayerCfgd);
|
|
|
|
|
//string strMxdPath = @"C:\Users\Administrator\Desktop\临时文档\新建文件夹\LatersSymbolToXML.xml";
|
|
|
|
|
//LayerCfg layerInfo = SerializeAPI.DeserializeToObject2<LayerCfg>(strMxdPath);
|
|
|
|
|
allLayerInfo = layerInfo;
|
|
|
|
|
axMapControl.Map.ClearLayers();
|
|
|
|
|
if (layerInfo != null)
|
|
|
|
|
{
|
|
|
|
|
if (layerInfo.LayerType == EnumLayerType.Map)
|
|
|
|
|
{
|
|
|
|
|
axMapControl.Map.Name = layerInfo.LayerName;
|
|
|
|
|
Bitmap groupImg = new Bitmap(Image.FromFile(System.IO.Path.Combine(Application.StartupPath, @"images\menu", "MxtFile" + ".png")), 22, 16);
|
|
|
|
|
//string asd = System.IO.Path.Combine(Application.StartupPath, @"images\menu", "MxdFile" + ".png");
|
|
|
|
|
layerInfo.SymbolImg = groupImg;
|
|
|
|
|
}
|
|
|
|
|
if (layerInfo.Layers.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ISystemCfg cfg2 = BundleRuntime.Instance.GetFirstOrDefaultService<ISystemCfg>();
|
|
|
|
|
SystemCfg = cfg2.Load();
|
|
|
|
|
if (SystemCfg.JcLayerLoadCfg == null)
|
|
|
|
|
{
|
|
|
|
|
SystemCfg.JcLayerLoadCfg = new List<LayerCfg>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//重新加载大数据影像
|
|
|
|
|
#region 大数据影像
|
|
|
|
|
LayerCfg tempSJYX = layerInfo.Layers.FirstOrDefault(a => a.LayerName == "影像底图");
|
|
|
|
|
LayerCfg tempSJYXWMTSLayer = null;
|
|
|
|
|
List<LayerCfg> SJYXAllItem = null;
|
|
|
|
|
if (tempSJYX != null && tempSJYX.GetAllItem() != null)
|
|
|
|
|
{
|
|
|
|
|
SJYXAllItem = tempSJYX.GetAllItem();
|
|
|
|
|
if (SJYXAllItem != null)
|
|
|
|
|
tempSJYXWMTSLayer = SJYXAllItem.FirstOrDefault(b => b.LayerType == EnumLayerType.WMTSLayer);
|
|
|
|
|
}
|
|
|
|
|
if (tempSJYX != null && tempSJYX.Layers != null) tempSJYX.Layers.Clear();
|
|
|
|
|
|
|
|
|
|
List<ImageSlicing> keyAndValues = UserLoginHelper.GetAllYXGroupLayer();
|
|
|
|
|
if (keyAndValues != null && keyAndValues.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
IGroupLayer groupLayer = Kingo.KMapSDK.Common.CommonAPI.GetGroupLayerByName<IGroupLayer>(MapsManager.Instance.MapService.getAxMapControl().Map, Kingo.KMapSDK.Common.GlobalConfig.Instance.GroupName);
|
|
|
|
|
IDataCatalogService _DataCatalog = BundleRuntime.Instance.GetFirstOrDefaultService<IDataCatalogService>();
|
|
|
|
|
if (_DataCatalog == null) return;
|
|
|
|
|
if (groupLayer != null)
|
|
|
|
|
{
|
|
|
|
|
ILayer parent = MapsManager.Instance.MapService.GetGroupLayer(Kingo.KMapSDK.KMap.Instance.KMapGroupLayer.Name);
|
|
|
|
|
if (parent != null)
|
|
|
|
|
{
|
|
|
|
|
_DataCatalog.RemoveLayer(parent);
|
|
|
|
|
_DataCatalog.UpdateTree();
|
|
|
|
|
MapsManager.Instance.MapService.getAxMapControl().Map.DeleteLayer(Kingo.KMapSDK.KMap.Instance.KMapGroupLayer);
|
|
|
|
|
MapsManager.Instance.MapService.getAxMapControl().ActiveView.Refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SystemCfg.SJYXLayerLoadCfg.Clear();
|
|
|
|
|
layerInfo.Layers.Remove(tempSJYX);
|
|
|
|
|
//初始化时间轴底图服务
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Kingo.KMapSDK.KMap.Instance.InitKMaps(keyAndValues);
|
|
|
|
|
//加载时间轴底图服务到地图窗口
|
|
|
|
|
if (Kingo.KMapSDK.KMap.Instance.KMapGroupLayer != null)
|
|
|
|
|
{
|
|
|
|
|
IGroupLayer group = Kingo.KMapSDK.KMap.Instance.KMapGroupLayer as IGroupLayer;
|
|
|
|
|
ILayerGeneralProperties layerGeneralProperties = group as ILayerGeneralProperties;
|
|
|
|
|
layerGeneralProperties.LayerDescription = group.Name;
|
|
|
|
|
|
|
|
|
|
if (tempSJYXWMTSLayer != null)
|
|
|
|
|
{
|
|
|
|
|
group.MinimumScale = tempSJYXWMTSLayer.MinScale;
|
|
|
|
|
group.MaximumScale = tempSJYXWMTSLayer.MaxScale;
|
|
|
|
|
if (group is ILayerEffects mLayerEffects)
|
|
|
|
|
mLayerEffects.Transparency = (short)tempSJYXWMTSLayer.Transparency;
|
|
|
|
|
group.Visible = tempSJYXWMTSLayer.Visible;
|
|
|
|
|
tempSJYXWMTSLayer.Data = group;
|
|
|
|
|
group.Visible = tempSJYXWMTSLayer.Visible == false ? false : GetParentIsChecked(tempSJYXWMTSLayer);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
group.Visible = false;
|
|
|
|
|
//影像底图 第一层级
|
|
|
|
|
LayerCfg GroupLayerInfo = _DataCatalog.AddLayer(group) as LayerCfg;
|
|
|
|
|
LayerCfg node = new LayerCfg()
|
|
|
|
|
{
|
|
|
|
|
Visible = false,
|
|
|
|
|
IsChecked = false,
|
|
|
|
|
LayerName = group.Name,
|
|
|
|
|
FcPath = UserLoginHelper.GetYXGroupLayerValueByAliasName(group.Name),
|
|
|
|
|
LayerType = EnumLayerType.GroupLayer
|
|
|
|
|
};
|
|
|
|
|
SystemCfg.SJYXLayerLoadCfg.Add(node);
|
|
|
|
|
|
|
|
|
|
Dictionary<ILayer, ILayer> layers = new Dictionary<ILayer, ILayer>();
|
|
|
|
|
if (Kingo.KMapSDK.KMap.Instance.KMapGroupLayer is ICompositeLayer)
|
|
|
|
|
{
|
|
|
|
|
layers = GetAllLayerInGroupLayer(Kingo.KMapSDK.KMap.Instance.KMapGroupLayer as ICompositeLayer, Kingo.KMapSDK.KMap.Instance.KMapGroupLayer);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
layers.Add(Kingo.KMapSDK.KMap.Instance.KMapGroupLayer, null);
|
|
|
|
|
|
|
|
|
|
// 遍历字典输出键与值
|
|
|
|
|
var fristChilds = layers.Where(a => a.Value == Kingo.KMapSDK.KMap.Instance.KMapGroupLayer).ToList();
|
|
|
|
|
foreach (var fristChild in fristChilds)
|
|
|
|
|
{
|
|
|
|
|
LayerCfg fristChildLayerCfg = null;
|
|
|
|
|
object tempGroupLayerInfo = GroupLayerInfo;
|
|
|
|
|
var secondChilds = layers.Where(a => a.Value == fristChild.Key).ToList();
|
|
|
|
|
if (secondChilds != null && secondChilds.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ILayer fristChildGroupLayer = new GroupLayer() { Name = fristChild.Key.Name };
|
|
|
|
|
ILayerGeneralProperties fristChildLayerGeneralProperties = fristChildGroupLayer as ILayerGeneralProperties;
|
|
|
|
|
fristChildLayerGeneralProperties.LayerDescription = fristChild.Key.Name;
|
|
|
|
|
|
|
|
|
|
if (tempSJYXWMTSLayer != null)
|
|
|
|
|
{
|
|
|
|
|
fristChildGroupLayer.MinimumScale = tempSJYXWMTSLayer.MinScale;
|
|
|
|
|
fristChildGroupLayer.MaximumScale = tempSJYXWMTSLayer.MaxScale;
|
|
|
|
|
if (fristChildGroupLayer is ILayerEffects mLayerEffectsfristChild)
|
|
|
|
|
mLayerEffectsfristChild.Transparency = (short)tempSJYXWMTSLayer.Transparency;
|
|
|
|
|
fristChildGroupLayer.Visible = tempSJYXWMTSLayer.Visible;
|
|
|
|
|
tempSJYXWMTSLayer.Data = fristChildGroupLayer;
|
|
|
|
|
fristChildGroupLayer.Visible = tempSJYXWMTSLayer.Visible == false ? false : GetParentIsChecked(tempSJYXWMTSLayer);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
fristChildGroupLayer.Visible = false;
|
|
|
|
|
tempGroupLayerInfo = _DataCatalog.AddLayer(fristChildGroupLayer, GroupLayerInfo);
|
|
|
|
|
fristChildLayerCfg = new LayerCfg(node)
|
|
|
|
|
{
|
|
|
|
|
Visible = false,
|
|
|
|
|
IsChecked = false,
|
|
|
|
|
LayerName = fristChild.Key.Name,
|
|
|
|
|
FcPath = UserLoginHelper.GetYXGroupLayerValueByAliasName(fristChild.Key.Name),
|
|
|
|
|
LayerType = EnumLayerType.WMTSLayer
|
|
|
|
|
};
|
|
|
|
|
SystemCfg.SJYXLayerLoadCfg.Add(fristChildLayerCfg);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (tempSJYXWMTSLayer != null)
|
|
|
|
|
{
|
|
|
|
|
fristChild.Key.MinimumScale = tempSJYXWMTSLayer.MinScale;
|
|
|
|
|
fristChild.Key.MaximumScale = tempSJYXWMTSLayer.MaxScale;
|
|
|
|
|
if (fristChild.Key is ILayerEffects mLayerEffectsfristChild)
|
|
|
|
|
mLayerEffectsfristChild.Transparency = (short)tempSJYXWMTSLayer.Transparency;
|
|
|
|
|
fristChild.Key.Visible = tempSJYXWMTSLayer.Visible;
|
|
|
|
|
tempSJYXWMTSLayer.Data = fristChild.Key;
|
|
|
|
|
fristChild.Key.Visible = tempSJYXWMTSLayer.Visible == false ? false : GetParentIsChecked(tempSJYXWMTSLayer);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
fristChild.Key.Visible = false;
|
|
|
|
|
tempGroupLayerInfo = _DataCatalog.AddLayer(fristChild.Key, GroupLayerInfo);
|
|
|
|
|
fristChildLayerCfg = new LayerCfg(node)
|
|
|
|
|
{
|
|
|
|
|
Visible = false,
|
|
|
|
|
IsChecked = false,
|
|
|
|
|
LayerName = fristChild.Key.Name,
|
|
|
|
|
FcPath = UserLoginHelper.GetYXGroupLayerValueByAliasName(fristChild.Key.Name),
|
|
|
|
|
LayerType = EnumLayerType.WMTSLayer
|
|
|
|
|
};
|
|
|
|
|
SystemCfg.SJYXLayerLoadCfg.Add(fristChildLayerCfg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var secondChild in secondChilds)
|
|
|
|
|
{
|
|
|
|
|
if (tempSJYXWMTSLayer != null)
|
|
|
|
|
{
|
|
|
|
|
secondChild.Key.MinimumScale = tempSJYXWMTSLayer.MinScale;
|
|
|
|
|
secondChild.Key.MaximumScale = tempSJYXWMTSLayer.MaxScale;
|
|
|
|
|
if (secondChild.Key is ILayerEffects mLayerEffectssecondChild)
|
|
|
|
|
mLayerEffectssecondChild.Transparency = (short)tempSJYXWMTSLayer.Transparency;
|
|
|
|
|
secondChild.Key.Visible = tempSJYXWMTSLayer.Visible;
|
|
|
|
|
tempSJYXWMTSLayer.Data = secondChild.Key;
|
|
|
|
|
secondChild.Key.Visible = tempSJYXWMTSLayer.Visible == false ? false : GetParentIsChecked(tempSJYXWMTSLayer);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
secondChild.Key.Visible = false;
|
|
|
|
|
_DataCatalog.AddLayer(secondChild.Key, tempGroupLayerInfo);
|
|
|
|
|
LayerCfg secondLayerCfg = new LayerCfg(fristChildLayerCfg)
|
|
|
|
|
{
|
|
|
|
|
Visible = false,
|
|
|
|
|
IsChecked = false,
|
|
|
|
|
LayerName = secondChild.Key.Name,
|
|
|
|
|
FcPath = UserLoginHelper.GetYXGroupLayerValueByAliasName(secondChild.Key.Name),
|
|
|
|
|
LayerType = EnumLayerType.WMTSLayer
|
|
|
|
|
};
|
|
|
|
|
SystemCfg.SJYXLayerLoadCfg.Add(secondLayerCfg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
layerInfo.Layers.Add(GroupLayerInfo);
|
|
|
|
|
tempSJYX = layerInfo.Layers.FirstOrDefault(a => a.LayerName == "影像底图");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exce)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("加载大数据影像 异常:" + exce.Message);
|
|
|
|
|
LogAPI.Debug("加载大数据影像 异常:" + exce.StackTrace);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
layerInfo.Layers.Remove(tempSJYX);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
layerInfo.Layers.Reverse();
|
|
|
|
|
foreach (var item in layerInfo.Layers)
|
|
|
|
|
{
|
|
|
|
|
if (item.LayerName == "影像底图" && tempSJYX != null && tempSJYX.GetAllItem() != null && tempSJYX.GetAllItem().FirstOrDefault(b => b.LayerType == EnumLayerType.WMTSLayer) != null) continue;
|
|
|
|
|
IGroupLayer rootGroupLayer = new GroupLayer() { Name = item.LayerName, Visible = item.Visible };
|
|
|
|
|
ILayerGeneralProperties layerGeneralProperties = rootGroupLayer as ILayerGeneralProperties;
|
|
|
|
|
layerGeneralProperties.LayerDescription = item.FcName;
|
|
|
|
|
LayerCfg GroupLayerInfo = _DataCatalog.AddLayer(rootGroupLayer) as LayerCfg;
|
|
|
|
|
item.Symbol = GroupLayerInfo.Symbol;
|
|
|
|
|
item.SymbolImg = GroupLayerInfo.SymbolImg;
|
|
|
|
|
item.Data = GroupLayerInfo.Data;
|
|
|
|
|
LoadLayerToMap(GroupLayerInfo, item.Layers);
|
|
|
|
|
}
|
|
|
|
|
layerInfo.Layers.Reverse();
|
|
|
|
|
}
|
|
|
|
|
if (_DataCatalog != null)
|
|
|
|
|
{
|
|
|
|
|
_DataCatalog.CurrentLayers = layerInfo;
|
|
|
|
|
_DataCatalog.UpdateTree();
|
|
|
|
|
}
|
|
|
|
|
Byte[] bytearr = System.Text.Encoding.Default.GetBytes(SerializeAPI.SerializeToXML<LayerCfg>(layerInfo));
|
|
|
|
|
string strBase64 = Convert.ToBase64String(bytearr);
|
|
|
|
|
projectInfo.TempData = strBase64;
|
|
|
|
|
projectInfo.Save();
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
#region 装载地图
|
|
|
|
|
IWorkspaceAPI wsAPI = new WorkspaceAPI(projectInfo.JCKPath, WorkspaceTypeEnum.GDBFile);
|
|
|
|
|
ISpatialReference reference = GeoDBAPI.GetGeoDatasetSpatialReference(wsAPI.CurrentWorkspace);
|
|
|
|
|
if (reference == null)
|
|
|
|
|
{
|
|
|
|
|
reference = GetCurentProjectedCoordinate(projectInfo.PrjFileStr);
|
|
|
|
|
}
|
|
|
|
|
if (axMapControl.Map.SpatialReference != reference && reference != null)
|
|
|
|
|
{
|
|
|
|
|
axMapControl.Map.SpatialReference = reference;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
if (projectInfo.MapExtent != null && projectInfo.MapExtent.XMax > 0 && projectInfo.MapExtent.YMax > 0 && projectInfo.MapExtent.XMin > 0 && projectInfo.MapExtent.YMin > 0)
|
|
|
|
|
{
|
|
|
|
|
IEnvelope env = axMapControl.ActiveView.Extent;
|
|
|
|
|
env.XMax = projectInfo.MapExtent.XMax;
|
|
|
|
|
env.YMax = projectInfo.MapExtent.YMax;
|
|
|
|
|
env.XMin = projectInfo.MapExtent.XMin;
|
|
|
|
|
env.YMin = projectInfo.MapExtent.YMin;
|
|
|
|
|
axMapControl.ActiveView.Extent = env;
|
|
|
|
|
}
|
|
|
|
|
//axMapControl.Map = axMapControl.Map.Copy<IMap>();
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{ }
|
|
|
|
|
SetFolderPath(projectInfo.ProjDir);
|
|
|
|
|
|
|
|
|
|
#region 记录最近打开的工程
|
|
|
|
|
//使用接口调用不确定是否为当前工作目录
|
|
|
|
|
string workCatalogPath = SplitWorkCatalogPath(pPrjFile);
|
|
|
|
|
string workCatalogPathTemp = workCatalogPath + "\\RecentWorkCatalogRecord.xml";
|
|
|
|
|
XmlDocument docWork = new XmlDocument();
|
|
|
|
|
if (File.Exists(workCatalogPathTemp) == false)
|
|
|
|
|
{
|
|
|
|
|
XmlDeclaration dec = docWork.CreateXmlDeclaration("1.0", "utf-8", null);
|
|
|
|
|
docWork.AppendChild(dec);
|
|
|
|
|
XmlElement projectmessage = docWork.CreateElement("projectmessage");
|
|
|
|
|
docWork.AppendChild(projectmessage);
|
|
|
|
|
docWork.Save(workCatalogPathTemp);
|
|
|
|
|
}
|
|
|
|
|
UpDataFileAttribute(workCatalogPathTemp);
|
|
|
|
|
SysConfigsOprator configOp = new SysConfigsOprator();
|
|
|
|
|
//记录不存在,可以加
|
|
|
|
|
if (configOp.JudgeRecentOpenProjectRecordXmlMsgIsExist(workCatalogPathTemp, pPrjFile) == false)
|
|
|
|
|
{
|
|
|
|
|
docWork.Load(workCatalogPathTemp);
|
|
|
|
|
XmlElement projectrecord = docWork.DocumentElement;
|
|
|
|
|
XmlElement project = docWork.CreateElement("project");
|
|
|
|
|
|
|
|
|
|
project.SetAttribute("ProjectPath", pPrjFile);
|
|
|
|
|
projectrecord.AppendChild(project);
|
|
|
|
|
|
|
|
|
|
project.SetAttribute("LastOpenTime", DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);
|
|
|
|
|
projectrecord.AppendChild(project);
|
|
|
|
|
|
|
|
|
|
//加上工程唯一标识码---2020-6-12
|
|
|
|
|
string sProjectUniqueID_Now = System.Guid.NewGuid().ToString("N");
|
|
|
|
|
sProjectUniqueID_Now += DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
|
|
|
|
|
project.SetAttribute("ProjectUniqueID", sProjectUniqueID_Now);
|
|
|
|
|
projectrecord.AppendChild(project);
|
|
|
|
|
|
|
|
|
|
project.SetAttribute("ProjType", Platform.Instance.SystemType.ToTrim());
|
|
|
|
|
projectrecord.AppendChild(project);
|
|
|
|
|
|
|
|
|
|
docWork.Save(workCatalogPathTemp);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//更新打开记录的时间
|
|
|
|
|
configOp.UpdateProjectFileOpenTime(workCatalogPathTemp, pPrjFile);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
ProjectOpened?.Invoke(null, new ProjectArgs(projectInfo));
|
|
|
|
|
}
|
|
|
|
|
string ring = SysConfigsOprator.GetAppsetingValueByKey("Ring");
|
|
|
|
|
#region 单图斑建库不需要授权验证
|
|
|
|
|
if (RunIDService2.Instance.Secretkey is null) return;
|
|
|
|
|
#endregion
|
|
|
|
|
ring = Decrypt(ring, RunIDService2.Instance.Secretkey);
|
|
|
|
|
IPointCollection py = new PolygonClass();
|
|
|
|
|
ring = ring.Replace("POLYGON((", "").Replace("))", "");
|
|
|
|
|
string[] points = ring.Split(',');
|
|
|
|
|
foreach (var item in points)
|
|
|
|
|
{
|
|
|
|
|
string[] xy = item.Split(' ');
|
|
|
|
|
if (!string.IsNullOrEmpty(xy[0]))
|
|
|
|
|
py.AddPoint(new PointClass() { X = xy[0].ToDouble(), Y = xy[1].ToDouble() });
|
|
|
|
|
}
|
|
|
|
|
IGeometry geo = py as IPolygon;
|
|
|
|
|
|
|
|
|
|
ISpatialReferenceFactory NewSpatialReference = new SpatialReferenceEnvironmentClass();
|
|
|
|
|
geo.SpatialReference = NewSpatialReference.CreateGeographicCoordinateSystem(4490);
|
|
|
|
|
geo.Project(axMapControl.Map.SpatialReference);
|
|
|
|
|
ITopologicalOperator topo = geo as ITopologicalOperator;
|
|
|
|
|
geo = topo.Buffer(2000);
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(RunIDService2.Instance.Area))
|
|
|
|
|
return;
|
|
|
|
|
//RunIDService2.Instance.Area = "113.672189445838,29.5445025464221;113.674780898419,29.5538753998546;113.701036907537,29.5619667292916;113.703271032312,29.5737472305565;113.728065241476,29.5814296430658;113.730506236069,29.5882305110216;113.72180845195,29.5981916415709;113.714908315116,29.6115914363939;113.700369113137,29.6099134436897;113.6953225086,29.6348894093267;113.672875331586,29.6354090935205;113.663931638311,29.6396170811324;113.662126446635,29.6633090724344;113.652666745806,29.6818636464943;113.64199627008,29.6726730250061;113.602871647016,29.6668273654561;113.554668258905,29.6728419265816;113.535555299977,29.6854613645623;113.528957441395,29.7007731081284;113.545355979903,29.7486616021041;113.542229089153,29.7712650559793;113.556918366136,29.7984533689952;113.561973187234,29.8065616278606;113.562697175743,29.8100010824577;113.559731900403,29.8121393968801;113.556377748795,29.8156353469605;113.572431727121,29.8351352257007;113.56391902912,29.8526500772604;113.603278403139,29.8775300941483;113.620968979039,29.8987163161281;113.646176590223,29.9198835060142;113.669368914261,29.9251254215999;113.690165507591,29.9256276003578;113.659227355269,29.9031459113497;113.667075910438,29.8935207769548;113.661490078874,29.8814927630501;113.670407089747,29.85787047763;113.7100824322,29.8409276157232;113.711286111745,29.8304365301236;113.738815122822,29.8041364810043;113.740939250502,29.8165538490895;113.762089741447,29.8262406132185;113.78816387954,29.8174971479217;113.785953750843,29.8098836804694;113.795360816635,29.8030080534899;113.799160891553,29.7948756763448;113.807430116224,29.7952919449776;113.813280933787,29.8072339778784;113.831126362636,29.7938128483825;113.855127904827,29.8129356819566;113.86739213361,29.8057059081432;113.87648535357,29.8202414643093;113.895647196403,29.8255658007337;113.903588539662,29.8341265134432;113.910424087836,29.8335183420794;113.912052354168,29.8393529063506;113.919092467777,29.8487576999041;113.904372002384,29.864215412778;113.923502111859,29.8848707414145;113.937916080263,29.8852587922305;113.937731326637,29.8717281510483;113.947920394616,29.8690742492733;113.95295374687,29.8734275299451;113.956896952155,29.8747177792446;113.959381324924,29.8740283049994;113.960676849402,29.8736687426157;113.962319512292,29.8751968097791;113.960883499039,29.8815093827451;113.958697774393,29.8911160382025;113.961988632386,29.8953943781068;113.963215307708,29.8969890246439;113.967172740952,29.8974616312853;113.972830172899,29.8981370423029;113.993204963744,29.8936752666882;114.023300475456,29.9146075574597;114.0390605966,29.9074327317217;114.037699759084,29.9340572650935;114.051792059689,29.9447039519426;114.05295775514,29.9713141417686;114.07129721007,29.9910854084222;114.094008487758,29.9866259538265;114.116757550228,29.9666043498142;114.134074796786,29.9255096904288;114.147111232515,29.9176035592078;114.152069654698,29.8873811991018;114.159686864605,29.8827777725355;114.166380158647,29.8757235219821;114.170503085988,29.8699346619422;114.172659810995,29.866371990232;114.17567626303,29.8542297850871;114.172371968494,29.8522078144413;114.171115703486,29.84367356524;114.176451793087,29.8350163773508;114.172680733594,29.8334408152698;114.167715583789,29.824697387795;114.159875104255,29.8109869549732;114.167788411704,29.8027380589187;114.174570918831,29.7792351891774;114.167807837268,29.7605632620057;114.176232577057,29.7496548280721;114.1578888375,29.7410165459216;114.155933396733,29.7314039064953;114.184218966974,29.7201329498954;114.209467520814,29.7291582613439;114.218111903101,29.7243626898426;114.236012639636,29.7014228176329;114.225781028504,29.6930146897363;114.228854219987,29.6805189355768;114.221355193287,29.6720530401913;114.189646676224,29.6674027775449;114.174831006201,29.6545404768989;114.166710418725,29.6439133045843;114.122674315467,29.6520613634896;114.056341451424,29.6313613844561;114.048526665701,29.6376586384469;114.035814946605,29.6351734806015;114.016976116019,29.6369195412727;114.004117368051,29.6292767183716;113.980866116356,29.6546241574212;113.950556093013,29.64127
|
|
|
|
|
string SQstring = RunIDService2.Instance.Area.Replace('\r', ' ').ToTrim();
|
|
|
|
|
string[] rings = SQstring.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
string coord = string.Empty;
|
|
|
|
|
if (rings.Length > 500) return;
|
|
|
|
|
if (rings.Length > 1)
|
|
|
|
|
{
|
|
|
|
|
coord = "MULTIPOLYGON(";
|
|
|
|
|
foreach (var r in rings)
|
|
|
|
|
{
|
|
|
|
|
string Temp_Coordinate = string.Empty;
|
|
|
|
|
string[] ps = r.TrimEnd(';').Split(';');
|
|
|
|
|
string strRing = "((";
|
|
|
|
|
if (ps.Length == 1)
|
|
|
|
|
{
|
|
|
|
|
strRing += ps[0];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in ps)
|
|
|
|
|
{
|
|
|
|
|
strRing += item.Replace('\n', ' ').Replace(',', ' ') + ",";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
char[] charsToTrim = { ',' };
|
|
|
|
|
strRing = strRing.TrimEnd(charsToTrim);
|
|
|
|
|
strRing = strRing.ToTrim();
|
|
|
|
|
strRing = strRing.TrimEnd(charsToTrim);
|
|
|
|
|
strRing += ")),";
|
|
|
|
|
coord += strRing;
|
|
|
|
|
}
|
|
|
|
|
coord = coord.TrimEnd(',');
|
|
|
|
|
coord += ")";
|
|
|
|
|
IGeometry geo2 = GetPolygonFromWkt(coord);
|
|
|
|
|
geo2.SpatialReference = NewSpatialReference.CreateGeographicCoordinateSystem(4490);
|
|
|
|
|
geo2.Project(axMapControl.Map.SpatialReference);
|
|
|
|
|
//GeometryBag ExterGeometryBag = (geo2 as ESRI.ArcGIS.Geometry.IPolygon4).ExteriorRingBag as GeometryBag;
|
|
|
|
|
if (geo2 == null) return;
|
|
|
|
|
//IGeometry firstGeo = null;
|
|
|
|
|
IGeometryCollection ExterRingGeometryCollection = geo2 as IGeometryCollection;
|
|
|
|
|
if (ExterRingGeometryCollection == null) return;
|
|
|
|
|
IGeometryCollection geometry = new ESRI.ArcGIS.Geometry.PolygonClass() as IGeometryCollection;
|
|
|
|
|
for (int i = 0; i < ExterRingGeometryCollection.GeometryCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IGeometry ExterGeometry = ExterRingGeometryCollection.get_Geometry(i);
|
|
|
|
|
if (ExterGeometry != null && !ExterGeometry.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
geometry.AddGeometry(ExterGeometry);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ITopologicalOperator topo2 = geometry as ITopologicalOperator;
|
|
|
|
|
IGeometry buf = topo2.Buffer(2000);
|
|
|
|
|
GeometryBag ExterGeometryBag = (buf as ESRI.ArcGIS.Geometry.IPolygon4).ExteriorRingBag as GeometryBag;
|
|
|
|
|
ExterRingGeometryCollection = ExterGeometryBag as IGeometryCollection;
|
|
|
|
|
geometry = new ESRI.ArcGIS.Geometry.PolygonClass() as IGeometryCollection;
|
|
|
|
|
for (int i = 0; i < ExterRingGeometryCollection.GeometryCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IGeometry ExterGeometry = ExterRingGeometryCollection.get_Geometry(i);
|
|
|
|
|
if (ExterGeometry != null && !ExterGeometry.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
geometry.AddGeometry(ExterGeometry);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
topo = geo as ITopologicalOperator;
|
|
|
|
|
geo = topo.Difference(geometry as IGeometry);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
foreach (var geoRing in rings)
|
|
|
|
|
{
|
|
|
|
|
string strGeo = geoRing.Replace('\r', ' ').ToTrim();
|
|
|
|
|
if (strGeo.Split(new char[] { ';' }).Length < 10)
|
|
|
|
|
strGeo = geoRing.Replace(";", ",");
|
|
|
|
|
if (strGeo.Contains(";"))
|
|
|
|
|
{
|
|
|
|
|
coord = string.Format("POLYGON((");
|
|
|
|
|
string[] ps = strGeo.TrimEnd(';').Split(';');
|
|
|
|
|
foreach (var item in ps)
|
|
|
|
|
{
|
|
|
|
|
coord += item.Replace('\r', ' ').Replace(',', ' ') + ",";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
coord = string.Format("POLYGON((");
|
|
|
|
|
coord += strGeo;
|
|
|
|
|
}
|
|
|
|
|
coord = coord.TrimEnd(',');
|
|
|
|
|
coord += "))";
|
|
|
|
|
IGeometry geo2 = GetPolygonFromWkt(coord);
|
|
|
|
|
IArea area = geo2 as IArea;
|
|
|
|
|
if (area.Area < 0)
|
|
|
|
|
{
|
|
|
|
|
(geo2 as IPolygon).ReverseOrientation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
geo2.SpatialReference = NewSpatialReference.CreateGeographicCoordinateSystem(4490);
|
|
|
|
|
geo2.Project(axMapControl.Map.SpatialReference);
|
|
|
|
|
ITopologicalOperator topo2 = geo2 as ITopologicalOperator;
|
|
|
|
|
IGeometry buf = topo2.Buffer(2000);
|
|
|
|
|
topo = geo as ITopologicalOperator;
|
|
|
|
|
GeometryBag ExterGeometryBag = (buf as ESRI.ArcGIS.Geometry.IPolygon4).ExteriorRingBag as GeometryBag;
|
|
|
|
|
if (ExterGeometryBag == null) continue;
|
|
|
|
|
//IGeometry firstGeo = null;
|
|
|
|
|
IGeometryCollection ExterRingGeometryCollection = ExterGeometryBag as IGeometryCollection;
|
|
|
|
|
IGeometryCollection geometry = new ESRI.ArcGIS.Geometry.PolygonClass() as IGeometryCollection;
|
|
|
|
|
for (int i = 0; i < ExterRingGeometryCollection.GeometryCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IGeometry ExterGeometry = ExterRingGeometryCollection.get_Geometry(i);
|
|
|
|
|
if (ExterGeometry != null && !ExterGeometry.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
geometry.AddGeometry(ExterGeometry);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
geo = topo.Difference(geometry as IGeometry);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (geo != null && !geo.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
MapsManager.Instance.MapService.DrawGraph(geo, true);
|
|
|
|
|
MapsManager.Instance.MapService.Zoom(geo);
|
|
|
|
|
DrawBaseGraph(geo, 150, 150, 150);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("加载工程异常:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("加载工程异常:" + ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
this.CloseLoading();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IGeometry GetPolygonFromWkt(string pointsStr)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//OSGeo.OGR.Ogr.RegisterAll();
|
|
|
|
|
IGeometry geometry = new PolygonClass();
|
|
|
|
|
OSGeo.OGR.Geometry rstGeometry = OSGeo.OGR.Geometry.CreateFromWkt(pointsStr);
|
|
|
|
|
byte[] geometryBytes = new byte[rstGeometry.WkbSize()];
|
|
|
|
|
rstGeometry.ExportToWkb(geometryBytes);
|
|
|
|
|
IGeometryFactory3 factory = new GeometryEnvironment() as IGeometryFactory3;
|
|
|
|
|
int bytesLen = geometryBytes.Length;
|
|
|
|
|
factory.CreateGeometryFromWkbVariant(geometryBytes, out geometry, out bytesLen);
|
|
|
|
|
IPolygon polygon = geometry as IPolygon;
|
|
|
|
|
polygon.Close();
|
|
|
|
|
ITopologicalOperator pBoundaryTop = polygon as ITopologicalOperator;
|
|
|
|
|
pBoundaryTop.Simplify();
|
|
|
|
|
return geometry;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("GetPolygonFromWkt获取图形异常:" + ex);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Decrypt(string content, string strKey)
|
|
|
|
|
{
|
|
|
|
|
string result = string.Empty;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(content))
|
|
|
|
|
return string.Empty;
|
|
|
|
|
System.Security.Cryptography.RijndaelManaged rm = new System.Security.Cryptography.RijndaelManaged
|
|
|
|
|
{
|
|
|
|
|
Key = Encoding.UTF8.GetBytes(strKey),
|
|
|
|
|
Mode = System.Security.Cryptography.CipherMode.ECB,
|
|
|
|
|
Padding = System.Security.Cryptography.PaddingMode.PKCS7
|
|
|
|
|
};
|
|
|
|
|
//将base64字符串转换成byte数组
|
|
|
|
|
byte[] contentArray = Convert.FromBase64String(content);
|
|
|
|
|
//创建解密转换器
|
|
|
|
|
System.Security.Cryptography.ICryptoTransform cDecryptTransform = rm.CreateDecryptor();
|
|
|
|
|
//对byte数组进行解密转换
|
|
|
|
|
Byte[] DecryptArray = cDecryptTransform.TransformFinalBlock(contentArray, 0, contentArray.Length);
|
|
|
|
|
//将解密后的byte[]转换成字符串(base64)
|
|
|
|
|
string strDecrypt = Encoding.UTF8.GetString(DecryptArray);
|
|
|
|
|
//将base64字符串转换成8位无符号整数数组
|
|
|
|
|
byte[] base64ToByte = Convert.FromBase64String(strDecrypt);
|
|
|
|
|
//string s = Encoding.UTF8.GetString(base64ToByte);
|
|
|
|
|
//将8位无符号整数数组转换成等效字符串,并返回
|
|
|
|
|
return Encoding.UTF8.GetString(base64ToByte);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("解密工程文件异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
GC.Collect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public ISpatialReference GetCurentProjectedCoordinate(string pPrjFileStr)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(pPrjFileStr))
|
|
|
|
|
{
|
|
|
|
|
//创建一个要素集创建一个投影
|
|
|
|
|
ISpatialReferenceFactory pSpatialRefFac = new SpatialReferenceEnvironmentClass();
|
|
|
|
|
ISpatialReference pSpatialReference;
|
|
|
|
|
pPrjFileStr = pPrjFileStr.Replace("'", "\"");
|
|
|
|
|
pSpatialRefFac.CreateESRISpatialReference(pPrjFileStr, out pSpatialReference, out int s);
|
|
|
|
|
return pSpatialReference;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("创建投影坐标系失败:" + ex.Message);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///为文件夹添加users,everyone,Administrator用户组的完全控制权限
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dirPath"></param>
|
|
|
|
|
static void AddSecurityControll2Folder(string dirPath)
|
|
|
|
|
{
|
|
|
|
|
//获取文件夹信息
|
|
|
|
|
DirectoryInfo dir = new DirectoryInfo(dirPath);
|
|
|
|
|
//获得该文件夹的所有访问权限
|
|
|
|
|
System.Security.AccessControl.DirectorySecurity dirSecurity = dir.GetAccessControl(AccessControlSections.All);
|
|
|
|
|
//设定文件ACL继承
|
|
|
|
|
InheritanceFlags inherits = InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit;
|
|
|
|
|
//添加ereryone用户组的访问权限规则 完全控制权限
|
|
|
|
|
FileSystemAccessRule everyoneFileSystemAccessRule = new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, inherits, PropagationFlags.None, AccessControlType.Allow);
|
|
|
|
|
//添加Users用户组的访问权限规则 完全控制权限
|
|
|
|
|
FileSystemAccessRule usersFileSystemAccessRule = new FileSystemAccessRule("Users", FileSystemRights.FullControl, inherits, PropagationFlags.None, AccessControlType.Allow);
|
|
|
|
|
//添加Administrator用户组的访问权限规则 完全控制权限
|
|
|
|
|
FileSystemAccessRule AdministratorFileSystemAccessRule = new FileSystemAccessRule("Administrator", FileSystemRights.FullControl, inherits, PropagationFlags.None, AccessControlType.Allow);
|
|
|
|
|
bool isModified = false;
|
|
|
|
|
dirSecurity.ModifyAccessRule(AccessControlModification.Add, everyoneFileSystemAccessRule, out isModified);
|
|
|
|
|
dirSecurity.ModifyAccessRule(AccessControlModification.Add, usersFileSystemAccessRule, out isModified);
|
|
|
|
|
//设置访问权限
|
|
|
|
|
dir.SetAccessControl(dirSecurity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 修改文件的可读写
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="T_Path"></param>
|
|
|
|
|
private void UpDataFileAttribute(string T_Path)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DirectoryInfo dirInfo = new DirectoryInfo(T_Path);
|
|
|
|
|
dirInfo.Attributes = FileAttributes.Normal | FileAttributes.Directory;
|
|
|
|
|
FileInfo fileInfo = new FileInfo(T_Path);
|
|
|
|
|
if (fileInfo.IsReadOnly)
|
|
|
|
|
{
|
|
|
|
|
File.SetAttributes(T_Path, FileAttributes.Normal);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据工程文件路径获取工作目录路径
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pPrjFile"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public string SplitWorkCatalogPath(string pPrjFile)
|
|
|
|
|
{
|
|
|
|
|
string TempPath = string.Empty;
|
|
|
|
|
string pathshba = System.IO.Path.GetFileName(pPrjFile);
|
|
|
|
|
//单图斑建库三套系统历史工程记录
|
|
|
|
|
if ((pPrjFile.Contains("DTBZJProject") && pathshba.Equals("单图斑质检.KBG")) || (pPrjFile.Contains("DTBProject") && pathshba.Equals("单图斑建库.KBG")) || (pPrjFile.Contains("YCLProject") && pathshba.Equals("图斑预处理.KBG")))
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < pPrjFile.Split('\\').Length - 1; i++)
|
|
|
|
|
{
|
|
|
|
|
TempPath += pPrjFile.Split('\\')[i] + "\\";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (Path.GetFileName(pPrjFile).EndsWith(".KBG"))//建库软件向上循环获取工作目录
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < pPrjFile.Split('\\').Length - 4; i++)
|
|
|
|
|
{
|
|
|
|
|
TempPath += pPrjFile.Split('\\')[i] + "\\";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (Path.GetFileName(pPrjFile) == "工作目录")
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < pPrjFile.Split('\\').Length - 2; i++)
|
|
|
|
|
{
|
|
|
|
|
TempPath += pPrjFile.Split('\\')[i] + "\\";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TempPath.TrimEnd('\\');
|
|
|
|
|
}
|
|
|
|
|
private IGroupLayer GetGroupLayer(IMap map, string Description, bool IsClear = true)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IGroupLayer pgpLayer = null;
|
|
|
|
|
if (map != null && !string.IsNullOrEmpty(Description))
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < map.LayerCount; i++)
|
|
|
|
|
{
|
|
|
|
|
if (map.get_Layer(i) is IGroupLayer)
|
|
|
|
|
{
|
|
|
|
|
ILayerGeneralProperties lp = map.get_Layer(i) as ILayerGeneralProperties;
|
|
|
|
|
if (lp != null && lp.LayerDescription.ToUpper().Equals(Description.ToUpper()))
|
|
|
|
|
{
|
|
|
|
|
pgpLayer = map.get_Layer(i) as IGroupLayer;
|
|
|
|
|
//if (IsClear)
|
|
|
|
|
// pgpLayer.Clear();
|
|
|
|
|
return pgpLayer;
|
|
|
|
|
}
|
|
|
|
|
ICompositeLayer pComLayer = map.get_Layer(i) as ICompositeLayer;
|
|
|
|
|
for (int j = 0; j < pComLayer.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
if (pComLayer.get_Layer(j) is IGroupLayer)
|
|
|
|
|
{
|
|
|
|
|
ILayerGeneralProperties lgp = pComLayer.get_Layer(j) as ILayerGeneralProperties;
|
|
|
|
|
if (lgp != null && lgp.LayerDescription.ToUpper().Equals(Description.ToUpper()))
|
|
|
|
|
{
|
|
|
|
|
pgpLayer = pComLayer.get_Layer(j) as IGroupLayer;
|
|
|
|
|
//if (IsClear)
|
|
|
|
|
// pgpLayer.Clear();
|
|
|
|
|
return pgpLayer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return pgpLayer;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void LoadProjectByMxd(string filePath)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (true == string.IsNullOrEmpty(filePath) || false == File.Exists(filePath))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
axMapControl.CurrentTool = null;
|
|
|
|
|
projectInfo = new ProjectInfo();
|
|
|
|
|
projectInfo.ProjName = System.IO.Path.GetFileNameWithoutExtension(filePath);
|
|
|
|
|
projectInfo.ProjSuffix = System.IO.Path.GetExtension(filePath);
|
|
|
|
|
projectInfo.ProjDir = System.IO.Path.GetDirectoryName(filePath);
|
|
|
|
|
(MapsManager.Instance.CurrProjectInfo as ProjectInfo).ProjName = System.IO.Path.GetFileNameWithoutExtension(filePath);
|
|
|
|
|
(MapsManager.Instance.CurrProjectInfo as ProjectInfo).ProjSuffix = System.IO.Path.GetExtension(filePath);
|
|
|
|
|
(MapsManager.Instance.CurrProjectInfo as ProjectInfo).ProjDir = System.IO.Path.GetDirectoryName(filePath);
|
|
|
|
|
|
|
|
|
|
ESRI.ArcGIS.Carto.IMapDocument mDoc = new ESRI.ArcGIS.Carto.MapDocumentClass();
|
|
|
|
|
mDoc.Open(filePath);
|
|
|
|
|
|
|
|
|
|
ESRI.ArcGIS.Carto.IMap map = mDoc.get_Map(0);
|
|
|
|
|
if (map == null)
|
|
|
|
|
return;
|
|
|
|
|
map.Name = projectInfo.ProjName;
|
|
|
|
|
ISpatialReference reference = GeoDBAPI.GetGeoDatasetSpatialReference(GetDefaultWorkspace(map));
|
|
|
|
|
if (map.SpatialReference != reference && reference != null)
|
|
|
|
|
{
|
|
|
|
|
map.SpatialReference = reference;
|
|
|
|
|
}
|
|
|
|
|
IActiveView view = (IActiveView)map;
|
|
|
|
|
mDoc.SetActiveView(view);
|
|
|
|
|
CtlsSynchronizer.ReplaceMap(map);
|
|
|
|
|
axMapControl.DocumentFilename = filePath;
|
|
|
|
|
mDoc.Close();
|
|
|
|
|
ProjectClosed?.Invoke(null, null);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetFolderPath(string folderPath)
|
|
|
|
|
{
|
|
|
|
|
m_FolderPath = folderPath;
|
|
|
|
|
Platform.Instance.ViewManager.SetFilePath(m_FolderPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetFolderPath()
|
|
|
|
|
{
|
|
|
|
|
return m_FolderPath;
|
|
|
|
|
}
|
|
|
|
|
public bool DeleteTheDir(string strPath)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
strPath = @strPath.Trim();
|
|
|
|
|
if (Directory.Exists(strPath))
|
|
|
|
|
{
|
|
|
|
|
string[] strDirs = Directory.GetDirectories(strPath);
|
|
|
|
|
string[] strFiles = Directory.GetFiles(strPath);
|
|
|
|
|
|
|
|
|
|
int iCountDirs = strDirs.Count();
|
|
|
|
|
int iFileDirs = strFiles.Count();
|
|
|
|
|
|
|
|
|
|
foreach (string strFile in strFiles)
|
|
|
|
|
{
|
|
|
|
|
File.Delete(strFile);
|
|
|
|
|
}
|
|
|
|
|
foreach (string strdir in strDirs)
|
|
|
|
|
{
|
|
|
|
|
Directory.Delete(strdir, true);
|
|
|
|
|
}
|
|
|
|
|
//LogAPI.Debug("清空变更统计信息文件夹 。文件夹数量=" + iCountDirs + " ; 文件数量=" + iFileDirs + " ; ");
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("清空文件目录(" + strPath + ") 时失败,异常原因: " + ex + " ; ");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CloseProject()
|
|
|
|
|
{
|
|
|
|
|
IMapDocument mDoc = new MapDocumentClass();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
EngineEditor editor = new EngineEditorClass();
|
|
|
|
|
#region 修改在编辑状态时,快捷键保存工程不提示信息;修改人:白明雅;修改时间:2018-09-04
|
|
|
|
|
if (editor.EditState == esriEngineEditState.esriEngineStateEditing)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("当前工程正处于编辑状态,保存之前请先结束编辑!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
if (projectInfo != null)
|
|
|
|
|
SaveProject();
|
|
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
projectInfo = null;
|
|
|
|
|
axMapControl.Map.Name = "地图文档";
|
|
|
|
|
axMapControl.ClearLayers();
|
|
|
|
|
axMapControl.CurrentTool = null;
|
|
|
|
|
ProjectClosed?.Invoke(null, null);
|
|
|
|
|
axMapControl.ActiveView.GraphicsContainer.DeleteAllElements();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
mDoc.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void FlashShape(IMapControlDefault mapControl, IGeometry geo, int nflashes = 3, int flashInterval = 300)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IRgbColor pRgbColor = new RgbColorClass();
|
|
|
|
|
pRgbColor.Red = 0;
|
|
|
|
|
pRgbColor.Green = 105;
|
|
|
|
|
pRgbColor.Blue = 0;
|
|
|
|
|
ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
|
|
|
|
|
pLineSymbol.Color = Converter.ToRGBColor(Color.Black) as IColor;
|
|
|
|
|
pLineSymbol.Width = 5;
|
|
|
|
|
ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();
|
|
|
|
|
pSimpleFillSymbol.Color = pRgbColor;
|
|
|
|
|
pSimpleFillSymbol.Outline = pLineSymbol;
|
|
|
|
|
|
|
|
|
|
ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();
|
|
|
|
|
pSimpleLineSymbol.Color = pRgbColor;
|
|
|
|
|
pSimpleLineSymbol.Width = 8;
|
|
|
|
|
|
|
|
|
|
ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();
|
|
|
|
|
pSimpleMarkerSymbol.Color = pRgbColor;
|
|
|
|
|
pSimpleMarkerSymbol.Size = 14;
|
|
|
|
|
pSimpleMarkerSymbol.Outline = true;
|
|
|
|
|
pSimpleMarkerSymbol.OutlineSize = 2;
|
|
|
|
|
pSimpleMarkerSymbol.OutlineColor = Converter.ToRGBColor(Color.Black) as IColor;
|
|
|
|
|
|
|
|
|
|
if (geo.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
|
|
|
|
|
mapControl.FlashShape(geo, nflashes, flashInterval, pSimpleMarkerSymbol);
|
|
|
|
|
else if (geo.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
|
|
|
|
|
mapControl.FlashShape(geo, nflashes, flashInterval, pSimpleLineSymbol);
|
|
|
|
|
else if (geo.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon)
|
|
|
|
|
mapControl.FlashShape(geo, nflashes, flashInterval, pSimpleFillSymbol);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("执行 FlashShape 时异常,异常信息如下:");
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
LogAPI.Debug("执行 FlashShape 时异常信息结束");
|
|
|
|
|
|
|
|
|
|
MessageHelper.ShowError("操作异常!异常信息:" + ex.Message);
|
|
|
|
|
//LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据名称获取当前工程中的图层
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pName"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public IFeatureLayer GetFeatureLayerByName(string pName)
|
|
|
|
|
{
|
|
|
|
|
IFeatureLayer result = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IEnumLayer enumlayer = axMapControl.Map.Layers;
|
|
|
|
|
ILayer layer = null;
|
|
|
|
|
while ((layer = enumlayer.Next()) != null)
|
|
|
|
|
{
|
|
|
|
|
if (!(layer is IFeatureLayer))
|
|
|
|
|
continue;
|
|
|
|
|
IFeatureLayer featureLayer = layer as IFeatureLayer;
|
|
|
|
|
if (featureLayer.FeatureClass == null || (featureLayer as IDataset) == null || (featureLayer as IDataset).Workspace == null)
|
|
|
|
|
continue;
|
|
|
|
|
if (featureLayer is IDataset && GetClassShortName(featureLayer as IDataset).ToUpper() == pName.ToUpper())
|
|
|
|
|
{
|
|
|
|
|
result = featureLayer;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if (featureLayer is IDataset && GetClassShortName(featureLayer as IDataset).ToUpper() == pName.ToUpper() && (featureLayer as IDataset).Workspace.PathName == Env.Instance.Project.GetProjMDBPath())
|
|
|
|
|
//{
|
|
|
|
|
// result = featureLayer;
|
|
|
|
|
// break;
|
|
|
|
|
//}
|
|
|
|
|
//if (IsRemoteDatabase(featureLayer))
|
|
|
|
|
//{
|
|
|
|
|
// if (featureLayer is IDataset && GetClassShortName(featureLayer as IDataset).ToUpper() == pName.ToUpper())
|
|
|
|
|
// result = featureLayer;
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// if (featureLayer is IDataset && GetClassShortName(featureLayer as IDataset).ToUpper() == pName.ToUpper() && (featureLayer as IDataset).Workspace.PathName == Env.Instance.Project.GetProjMDBPath())
|
|
|
|
|
// result = featureLayer;
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IFeatureLayer GetFeatureLayerByLayerName(string layerName)
|
|
|
|
|
{
|
|
|
|
|
IFeatureLayer result = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IEnumLayer enumlayer = axMapControl.Map.Layers;
|
|
|
|
|
ILayer layer = null;
|
|
|
|
|
while ((layer = enumlayer.Next()) != null)
|
|
|
|
|
{
|
|
|
|
|
if (!(layer is IFeatureLayer))
|
|
|
|
|
continue;
|
|
|
|
|
IFeatureLayer featureLayer = layer as IFeatureLayer;
|
|
|
|
|
|
|
|
|
|
if (featureLayer.Name.ToUpper().Equals(layerName))
|
|
|
|
|
{
|
|
|
|
|
result = featureLayer;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IRasterLayer GetRasterLayerByLayerName(string layerName)
|
|
|
|
|
{
|
|
|
|
|
IRasterLayer result = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IEnumLayer enumlayer = axMapControl.Map.Layers;
|
|
|
|
|
ILayer layer = null;
|
|
|
|
|
while ((layer = enumlayer.Next()) != null)
|
|
|
|
|
{
|
|
|
|
|
if (!(layer is IRasterLayer))
|
|
|
|
|
continue;
|
|
|
|
|
IRasterLayer rasterLayer = layer as IRasterLayer;
|
|
|
|
|
|
|
|
|
|
if (rasterLayer.Name.ToUpper().Equals(layerName))
|
|
|
|
|
{
|
|
|
|
|
result = rasterLayer;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IRasterLayer GetRasterLayerByLayerName(string groupName, string layerName)
|
|
|
|
|
{
|
|
|
|
|
IRasterLayer result = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IEnumLayer enumlayer = axMapControl.Map.Layers;
|
|
|
|
|
ILayer layer = null;
|
|
|
|
|
while ((layer = enumlayer.Next()) != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (layer is IGroupLayer)
|
|
|
|
|
{
|
|
|
|
|
IGroupLayer grlayer = layer as IGroupLayer;
|
|
|
|
|
if (grlayer.Name.Equals(groupName))
|
|
|
|
|
{
|
|
|
|
|
ICompositeLayer pComLayer = layer as ICompositeLayer;
|
|
|
|
|
for (int j = 0; j < pComLayer.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
ILayer newLayer = pComLayer.get_Layer(j);
|
|
|
|
|
|
|
|
|
|
if (!(newLayer is IRasterLayer))
|
|
|
|
|
continue;
|
|
|
|
|
IRasterLayer rasterLayer = newLayer as IRasterLayer;
|
|
|
|
|
if (rasterLayer.Name.ToUpper().Equals(layerName.ToUpper()))
|
|
|
|
|
{
|
|
|
|
|
result = rasterLayer;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过图层名称获取图层
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pName">图层名称</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public IFeatureClass GetFeatureClassByName(string pName)
|
|
|
|
|
{
|
|
|
|
|
IFeatureClass result = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IEnumLayer enumlayer = axMapControl.Map.Layers;
|
|
|
|
|
ILayer layer = null;
|
|
|
|
|
while ((layer = enumlayer.Next()) != null)
|
|
|
|
|
{
|
|
|
|
|
if (!(layer is IFeatureLayer))
|
|
|
|
|
continue;
|
|
|
|
|
IFeatureLayer featureLayer = layer as IFeatureLayer;
|
|
|
|
|
if (featureLayer.FeatureClass == null || (featureLayer as IDataset) == null || (featureLayer as IDataset).Workspace == null)
|
|
|
|
|
continue;
|
|
|
|
|
if (featureLayer is IDataset && GetClassShortName(featureLayer as IDataset).ToUpper() == pName.ToUpper())
|
|
|
|
|
result = featureLayer.FeatureClass;
|
|
|
|
|
//if (featureLayer is IDataset && GetClassShortName(featureLayer as IDataset).ToUpper() == pName.ToUpper() && (featureLayer as IDataset).Workspace.PathName == Env.Instance.Project.GetProjMDBPath())
|
|
|
|
|
//{
|
|
|
|
|
// result = featureLayer.FeatureClass;
|
|
|
|
|
// break;
|
|
|
|
|
//}
|
|
|
|
|
//if (IsRemoteDatabase(featureLayer))
|
|
|
|
|
//{
|
|
|
|
|
// if (featureLayer is IDataset && GetClassShortName(featureLayer as IDataset).ToUpper() == pName.ToUpper())
|
|
|
|
|
// result = featureLayer.FeatureClass;
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// if (featureLayer is IDataset && GetClassShortName(featureLayer as IDataset).ToUpper() == pName.ToUpper() && (featureLayer as IDataset).Workspace.PathName == Env.Instance.Project.GetProjMDBPath())
|
|
|
|
|
// result = featureLayer.FeatureClass;
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SelectFeature(string layerName, string OIDs, bool IsMoveToCenter = true)
|
|
|
|
|
{
|
|
|
|
|
List<IFeature> featureList = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IMapControlDefault mapControl = Hook as IMapControlDefault;
|
|
|
|
|
string[] oidArr = OIDs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
ILayer layer = GetFeatureLayerByName(layerName) != null ? GetFeatureLayerByName(layerName) : GetFeatureLayerByLayerName(layerName);//GetLayerByTableName(Env.Instance.KMap.GetMap(), layerName);
|
|
|
|
|
if (!(layer is IFeatureLayer))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
featureList = new List<IFeature>();
|
|
|
|
|
//ClearFeatureSelection(mapControl);
|
|
|
|
|
ISelectionSet pSelectionSetes = (layer as IFeatureSelection).SelectionSet;
|
|
|
|
|
if (pSelectionSetes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
int unSeleID = pSelectionSetes.IDs.Next();
|
|
|
|
|
pSelectionSetes.RemoveList(pSelectionSetes.Count, ref unSeleID);
|
|
|
|
|
mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, featureList, mapControl.ActiveView.Extent);
|
|
|
|
|
}
|
|
|
|
|
foreach (string oid in oidArr)
|
|
|
|
|
{
|
|
|
|
|
IFeature feature = (layer as IFeatureLayer).FeatureClass.GetFeature(Convert.ToInt32(oid));
|
|
|
|
|
if (feature != null && feature.Shape != null && !feature.Shape.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
featureList.Add(feature);
|
|
|
|
|
(Hook as IMapControlDefault).Map.SelectFeature(layer, feature);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (IsMoveToCenter && featureList.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
MoveToCenter(featureList);
|
|
|
|
|
}
|
|
|
|
|
if (featureList.Count != 0)
|
|
|
|
|
mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, featureList, mapControl.ActiveView.Extent);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug($"{layerName}图斑{OIDs}高亮显示失败:" + ex);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (featureList != null)
|
|
|
|
|
{
|
|
|
|
|
featureList.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IElement DrawGraph(ESRI.ArcGIS.Geometry.IGeometry geoDraw, bool pIsDel = true, int R = 255, int G = 0, int B = 0)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IElement result = null;
|
|
|
|
|
IGraphicsContainer iGraphicsContainer = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IElement CameraPointElm = null; // axMapControl.ActiveView.GraphicsContainer.Next();
|
|
|
|
|
while ((CameraPointElm = axMapControl.ActiveView.GraphicsContainer.Next()) != null)
|
|
|
|
|
{
|
|
|
|
|
if ((CameraPointElm as IElementProperties).Name == "TempElem")
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (CameraPointElm == null)
|
|
|
|
|
{
|
|
|
|
|
CameraPointElm = new GroupElementClass();
|
|
|
|
|
(CameraPointElm as IElementProperties).Name = "TempElem";
|
|
|
|
|
(Hook as IMapControlDefault).ActiveView.GraphicsContainer.AddElement(CameraPointElm, 0);
|
|
|
|
|
}
|
|
|
|
|
if (pIsDel == true)
|
|
|
|
|
{
|
|
|
|
|
////替换Env改动
|
|
|
|
|
////IGraphicsContainer graphics = Env.Instance.KMap.HookHelper.ActiveView.GraphicsContainer;
|
|
|
|
|
//IGraphicsContainer graphics = (Hook as IMapControlDefault).ActiveView.GraphicsContainer;
|
|
|
|
|
//graphics.DeleteAllElements();
|
|
|
|
|
(CameraPointElm as IGroupElement).ClearElements();
|
|
|
|
|
}
|
|
|
|
|
if (geoDraw == null) return null;
|
|
|
|
|
|
|
|
|
|
//替换Env改动---无用
|
|
|
|
|
//IMapControl2 axMapDraw = Env.Instance.KMap.HookHelper.Hook as IMapControl2;
|
|
|
|
|
|
|
|
|
|
// 获取IRGBColor接口
|
|
|
|
|
IRgbColor color = new RgbColor();
|
|
|
|
|
// 设置颜色属性
|
|
|
|
|
color.Red = R;
|
|
|
|
|
color.Green = G;
|
|
|
|
|
color.Blue = B;
|
|
|
|
|
switch (geoDraw.GeometryType)
|
|
|
|
|
{
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
|
|
|
|
|
result = new MarkerElementClass();
|
|
|
|
|
IMarkerSymbol symbol = new SimpleMarkerSymbolClass();
|
|
|
|
|
symbol.Color = color;
|
|
|
|
|
symbol.Size = 10;
|
|
|
|
|
(result as IMarkerElement).Symbol = symbol;
|
|
|
|
|
result.Geometry = geoDraw;
|
|
|
|
|
break;
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
|
|
|
|
|
result = new PolygonElement() { Opacity = 40 };
|
|
|
|
|
// 获取ILine符号接口
|
|
|
|
|
ILineSymbol lineSymbol = new SimpleLineSymbol();
|
|
|
|
|
// 设置线符号属
|
|
|
|
|
lineSymbol.Width = 2;
|
|
|
|
|
ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
|
|
|
|
|
simpleFillSymbol.Color = color;
|
|
|
|
|
IRgbColor colorLine = new RgbColor();
|
|
|
|
|
colorLine.Red = 255;
|
|
|
|
|
colorLine.Green = 0;
|
|
|
|
|
colorLine.Blue = 0;
|
|
|
|
|
lineSymbol.Color = colorLine;
|
|
|
|
|
// 设置填充符号属性
|
|
|
|
|
simpleFillSymbol.Outline = lineSymbol;
|
|
|
|
|
simpleFillSymbol.Style = ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSCross;//esriSimpleFillStyle.esriSFSSolid;
|
|
|
|
|
(result as IFillShapeElement).Symbol = simpleFillSymbol;
|
|
|
|
|
result.Geometry = geoDraw;
|
|
|
|
|
break;
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
|
|
|
|
|
result = new LineElementClass();
|
|
|
|
|
// 获取ILine符号接口
|
|
|
|
|
ILineSymbol outline = new SimpleLineSymbol();
|
|
|
|
|
// 设置线符号属
|
|
|
|
|
outline.Width = 3;
|
|
|
|
|
outline.Color = color;
|
|
|
|
|
(outline as SimpleLineSymbol).Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid;
|
|
|
|
|
(result as ILineElement).Symbol = outline;
|
|
|
|
|
result.Geometry = geoDraw;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (!pIsDel)
|
|
|
|
|
{
|
|
|
|
|
result.Locked = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//替换Env改动
|
|
|
|
|
//Env.Instance.KMap.HookHelper.ActiveView.GraphicsContainer.AddElement(result, 0);
|
|
|
|
|
//(Hook as IMapControlDefault).ActiveView.GraphicsContainer.AddElement(result, 0);
|
|
|
|
|
(CameraPointElm as IGroupElement).AddElement(result);
|
|
|
|
|
|
|
|
|
|
if (iGraphicsContainer != null)
|
|
|
|
|
{
|
|
|
|
|
iGraphicsContainer.AddElement(result, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("执行DrawGraph方法时异常:" + ex);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IElement DrawBaseGraph(ESRI.ArcGIS.Geometry.IGeometry geoDraw, int R = 255, int G = 0, int B = 0)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IElement result = null;
|
|
|
|
|
IGraphicsContainer iGraphicsContainer = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IElement CameraPointElm = null; // axMapControl.ActiveView.GraphicsContainer.Next();
|
|
|
|
|
while ((CameraPointElm = axMapControl.ActiveView.GraphicsContainer.Next()) != null)
|
|
|
|
|
{
|
|
|
|
|
if ((CameraPointElm as IElementProperties).Name == "BaseElement")
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (CameraPointElm == null)
|
|
|
|
|
{
|
|
|
|
|
CameraPointElm = new GroupElementClass();
|
|
|
|
|
(CameraPointElm as IElementProperties).Name = "BaseElement";
|
|
|
|
|
(Hook as IMapControlDefault).ActiveView.GraphicsContainer.AddElement(CameraPointElm, 2);
|
|
|
|
|
}
|
|
|
|
|
(CameraPointElm as IGroupElement).ClearElements();
|
|
|
|
|
if (geoDraw == null) return null;
|
|
|
|
|
|
|
|
|
|
//替换Env改动---无用
|
|
|
|
|
//IMapControl2 axMapDraw = Env.Instance.KMap.HookHelper.Hook as IMapControl2;
|
|
|
|
|
|
|
|
|
|
// 获取IRGBColor接口
|
|
|
|
|
IRgbColor color = new RgbColor();
|
|
|
|
|
// 设置颜色属性
|
|
|
|
|
color.Red = R;
|
|
|
|
|
color.Green = G;
|
|
|
|
|
color.Blue = B;
|
|
|
|
|
switch (geoDraw.GeometryType)
|
|
|
|
|
{
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
|
|
|
|
|
result = new MarkerElementClass();
|
|
|
|
|
IMarkerSymbol symbol = new SimpleMarkerSymbolClass();
|
|
|
|
|
symbol.Color = color;
|
|
|
|
|
symbol.Size = 10;
|
|
|
|
|
(result as IMarkerElement).Symbol = symbol;
|
|
|
|
|
result.Geometry = geoDraw;
|
|
|
|
|
break;
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
|
|
|
|
|
result = new PolygonElement() { Opacity = 100 };
|
|
|
|
|
// 获取ILine符号接口
|
|
|
|
|
ILineSymbol lineSymbol = new SimpleLineSymbol();
|
|
|
|
|
// 设置线符号属
|
|
|
|
|
lineSymbol.Width = 2;
|
|
|
|
|
ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
|
|
|
|
|
simpleFillSymbol.Color = color;
|
|
|
|
|
IRgbColor colorLine = new RgbColor();
|
|
|
|
|
colorLine.Red = 0;
|
|
|
|
|
colorLine.Green = 0;
|
|
|
|
|
colorLine.Blue = 0;
|
|
|
|
|
lineSymbol.Color = colorLine;
|
|
|
|
|
// 设置填充符号属性
|
|
|
|
|
simpleFillSymbol.Outline = lineSymbol;
|
|
|
|
|
simpleFillSymbol.Style = ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSSolid;//esriSimpleFillStyle.esriSFSSolid;
|
|
|
|
|
(result as IFillShapeElement).Symbol = simpleFillSymbol;
|
|
|
|
|
result.Geometry = geoDraw;
|
|
|
|
|
break;
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
|
|
|
|
|
result = new LineElementClass();
|
|
|
|
|
// 获取ILine符号接口
|
|
|
|
|
ILineSymbol outline = new SimpleLineSymbol();
|
|
|
|
|
// 设置线符号属
|
|
|
|
|
outline.Width = 3;
|
|
|
|
|
outline.Color = color;
|
|
|
|
|
(outline as SimpleLineSymbol).Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid;
|
|
|
|
|
(result as ILineElement).Symbol = outline;
|
|
|
|
|
result.Geometry = geoDraw;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
(CameraPointElm as IGroupElement).AddElement(result);
|
|
|
|
|
|
|
|
|
|
if (iGraphicsContainer != null)
|
|
|
|
|
{
|
|
|
|
|
iGraphicsContainer.AddElement(result, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
axMapControl.ActiveView.Refresh();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("执行DrawGraph方法时异常:" + ex);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取特定样式的图形元素
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="geoDraw"></param>
|
|
|
|
|
/// <param name="R"></param>
|
|
|
|
|
/// <param name="G"></param>
|
|
|
|
|
/// <param name="B"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public IElement GetGraphicsElement(ESRI.ArcGIS.Geometry.IGeometry geoDraw, int R = 255, int G = 0, int B = 0)
|
|
|
|
|
{
|
|
|
|
|
IElement result = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (geoDraw == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IRgbColor color = new RgbColor();//获取IRGBColor接口,并设置颜色属性
|
|
|
|
|
color.Red = R;
|
|
|
|
|
color.Green = G;
|
|
|
|
|
color.Blue = B;
|
|
|
|
|
|
|
|
|
|
switch (geoDraw.GeometryType)
|
|
|
|
|
{
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
|
|
|
|
|
result = new MarkerElementClass();
|
|
|
|
|
IMarkerSymbol symbol = new SimpleMarkerSymbolClass();
|
|
|
|
|
symbol.Color = color;
|
|
|
|
|
symbol.Size = 10;
|
|
|
|
|
(result as IMarkerElement).Symbol = symbol;
|
|
|
|
|
result.Geometry = geoDraw;
|
|
|
|
|
break;
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
|
|
|
|
|
result = new LineElementClass();
|
|
|
|
|
ILineSymbol outline = new SimpleLineSymbol();//获取ILine符号接口,并设置线符号属
|
|
|
|
|
outline.Width = 3;
|
|
|
|
|
outline.Color = color;
|
|
|
|
|
(outline as SimpleLineSymbol).Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid;
|
|
|
|
|
(result as ILineElement).Symbol = outline;
|
|
|
|
|
result.Geometry = geoDraw;
|
|
|
|
|
break;
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
|
|
|
|
|
result = new PolygonElement() { Opacity = 40 };
|
|
|
|
|
|
|
|
|
|
IRgbColor colorLine = new RgbColor();
|
|
|
|
|
colorLine.Red = 255;
|
|
|
|
|
colorLine.Green = 0;
|
|
|
|
|
colorLine.Blue = 0;
|
|
|
|
|
|
|
|
|
|
ILineSymbol lineSymbol = new SimpleLineSymbol();//获取ILine符号接口,并设置线符号属性
|
|
|
|
|
lineSymbol.Color = colorLine;
|
|
|
|
|
lineSymbol.Width = 5;
|
|
|
|
|
|
|
|
|
|
ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
|
|
|
|
|
simpleFillSymbol.Color = color;
|
|
|
|
|
simpleFillSymbol.Outline = lineSymbol;//设置填充符号属性
|
|
|
|
|
//simpleFillSymbol.Outline = new SimpleLineSymbol() { Color = new RgbColor() { Red = 255, Green = 0, Blue = 0 }, Width = 5 };//设置填充符号属性
|
|
|
|
|
simpleFillSymbol.Style = ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSCross;//esriSimpleFillStyle.esriSFSSolid;
|
|
|
|
|
(result as IFillShapeElement).Symbol = simpleFillSymbol;
|
|
|
|
|
result.Geometry = geoDraw;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("获取特定样式的图形元素 时失败,异常原因: " + ex + " ; ");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Zoom(ESRI.ArcGIS.Geometry.IGeometry geo)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (geo == null) return;
|
|
|
|
|
//替换Env改动
|
|
|
|
|
//-----------解决问题图斑处理工具查出的问题图斑双击定位异常,原因axmap为空
|
|
|
|
|
//IMap map = Env.Instance.KMap.HookHelper.FocusMap;
|
|
|
|
|
IMap map = (Hook as IMapControlDefault).Map;
|
|
|
|
|
|
|
|
|
|
IActiveView axMap = map as IActiveView;
|
|
|
|
|
//------------------------------------
|
|
|
|
|
IEnvelope NewExtent = geo.Envelope;
|
|
|
|
|
if (geo.Envelope.Width <= 0 || geo.Envelope.Height <= 0)
|
|
|
|
|
{
|
|
|
|
|
NewExtent.XMax = geo.Envelope.XMax + 800 / 2;
|
|
|
|
|
NewExtent.XMin = geo.Envelope.XMin - 800 / 2;
|
|
|
|
|
NewExtent.YMax = geo.Envelope.YMax + 500 / 2;
|
|
|
|
|
NewExtent.YMin = geo.Envelope.YMin - 500 / 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NewExtent.XMax = geo.Envelope.XMax + geo.Envelope.Width / 2;
|
|
|
|
|
NewExtent.YMax = geo.Envelope.YMax + geo.Envelope.Height / 2;
|
|
|
|
|
NewExtent.XMin = geo.Envelope.XMin - geo.Envelope.Width / 2;
|
|
|
|
|
NewExtent.YMin = geo.Envelope.YMin - geo.Envelope.Height / 2;
|
|
|
|
|
}
|
|
|
|
|
axMap.Extent = NewExtent;
|
|
|
|
|
if (axMap.FocusMap.MapScale < 2)
|
|
|
|
|
axMap.FocusMap.MapScale = 2;
|
|
|
|
|
axMap.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, axMap.Extent);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("执行Zoom方法时异常:" + ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 清除选中的要素
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="mapControl"></param>
|
|
|
|
|
/// <param name="layerName"></param>
|
|
|
|
|
public void ClearFeatureSelection(IMapControlDefault mapControl, string layerName = "")
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(layerName))
|
|
|
|
|
{
|
|
|
|
|
ILayer clearLy = GetFeatureLayerByName(layerName);
|
|
|
|
|
|
|
|
|
|
if (!(clearLy is IFeatureLayer)) return;
|
|
|
|
|
IFeatureSelection pFeatureSelection = clearLy as IFeatureSelection;
|
|
|
|
|
mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, pFeatureSelection, null);
|
|
|
|
|
pFeatureSelection.Clear();
|
|
|
|
|
mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, pFeatureSelection, null);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ISelection pSelection = mapControl.Map.FeatureSelection as ISelection;
|
|
|
|
|
mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, pSelection, null);
|
|
|
|
|
|
|
|
|
|
ControlsClearSelectionCommand cmd = new ControlsClearSelectionCommandClass();
|
|
|
|
|
cmd.OnCreate(mapControl);
|
|
|
|
|
cmd.OnClick();
|
|
|
|
|
|
|
|
|
|
mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("操作异常!异常信息:" + ex.Message);
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object GetProjectInfo()
|
|
|
|
|
{
|
|
|
|
|
return projectInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetCustomProperty(object pProperty)
|
|
|
|
|
{
|
|
|
|
|
if (axMapControl != null)
|
|
|
|
|
axMapControl.CustomProperty = pProperty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetLayerPathByLayer(ILayer pLayer)
|
|
|
|
|
{
|
|
|
|
|
if (pLayer is IFeatureLayer)
|
|
|
|
|
{
|
|
|
|
|
IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
|
|
|
|
|
|
|
|
|
|
if (pFeatureLayer.FeatureClass == null || (pFeatureLayer as IDataset) == null || (pFeatureLayer as IDataset).Workspace == null)
|
|
|
|
|
return "";
|
|
|
|
|
FeatureClass fc = pFeatureLayer.FeatureClass as FeatureClass;
|
|
|
|
|
if (pFeatureLayer.FeatureClass.FeatureDataset != null)
|
|
|
|
|
{
|
|
|
|
|
//if (fc.Workspace.WorkspaceFactory.WorkspaceType == esriWorkspaceType.esriRemoteDatabaseWorkspace
|
|
|
|
|
// && (string.IsNullOrWhiteSpace(fc.Workspace.PathName) || !System.IO.File.Exists(fc.Workspace.PathName)))
|
|
|
|
|
//{
|
|
|
|
|
// return System.IO.Path.Combine(fc.Workspace.PathName, pFeatureLayer.FeatureClass.FeatureDataset.BrowseName, fc.BrowseName);
|
|
|
|
|
//}
|
|
|
|
|
return global::System.IO.Path.Combine(fc.Workspace.PathName, pFeatureLayer.FeatureClass.FeatureDataset.BrowseName, fc.BrowseName);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return global::System.IO.Path.Combine(fc.Workspace.PathName, fc.BrowseName);
|
|
|
|
|
}
|
|
|
|
|
////return (pFeatureLayer as IDataset).Workspace.PathName;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<T> GetAllLayerInMap<T>()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
List<T> allLayers = new List<T>();
|
|
|
|
|
for (int i = 0; i < axMapControl.Map.LayerCount; i++)
|
|
|
|
|
{
|
|
|
|
|
ILayer layer = axMapControl.Map.get_Layer(i);
|
|
|
|
|
if (layer is ICompositeLayer)
|
|
|
|
|
{
|
|
|
|
|
List<T> list = GetAllLayerInGroupLayer<T>(layer as ICompositeLayer);
|
|
|
|
|
allLayers.AddRange(list);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (layer is T)
|
|
|
|
|
{
|
|
|
|
|
allLayers.Add((T)layer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return allLayers;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public List<IGroupLayer> GetAllRasterGroupLayerInMap<T>()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
List<IGroupLayer> allLayers = new List<IGroupLayer>();
|
|
|
|
|
for (int i = 0; i < axMapControl.Map.LayerCount; i++)
|
|
|
|
|
{
|
|
|
|
|
ILayer layer = axMapControl.Map.get_Layer(i);
|
|
|
|
|
if (layer is ICompositeLayer)
|
|
|
|
|
{
|
|
|
|
|
List<T> list = GetAllLayerInGroupLayer<T>(layer as ICompositeLayer);
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
allLayers.Add(layer as IGroupLayer);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//if (layer is T)
|
|
|
|
|
//{
|
|
|
|
|
// allLayers.Add((T)layer);
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return allLayers;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AxMapControl getAxMapControl()
|
|
|
|
|
{
|
|
|
|
|
//throw new NotImplementedException();
|
|
|
|
|
return this.axMapControl;
|
|
|
|
|
}
|
|
|
|
|
public List<T> GetAllDisplayLayerInMap<T>()
|
|
|
|
|
{
|
|
|
|
|
List<T> allLayers = new List<T>();
|
|
|
|
|
for (int i = 0; i < axMapControl.Map.LayerCount; i++)
|
|
|
|
|
{
|
|
|
|
|
ILayer layer = axMapControl.Map.get_Layer(i);
|
|
|
|
|
if (layer is ICompositeLayer)
|
|
|
|
|
{
|
|
|
|
|
if (!layer.Visible)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
allLayers.AddRange(GetAllDisplayLayerInGroupLayer<T>(layer as ICompositeLayer));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (layer is T)
|
|
|
|
|
{
|
|
|
|
|
if (layer.Visible)
|
|
|
|
|
{
|
|
|
|
|
allLayers.Add((T)layer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return allLayers;
|
|
|
|
|
}
|
|
|
|
|
public List<T> GetAllDisplayLayerInGroupLayer<T>(ICompositeLayer pCompLayer)
|
|
|
|
|
{
|
|
|
|
|
List<T> allLayers = new List<T>();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IFeatureLayer layer = null;
|
|
|
|
|
for (int j = 0; j < pCompLayer.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
if (pCompLayer.get_Layer(j) is IFeatureLayer)
|
|
|
|
|
{
|
|
|
|
|
layer = pCompLayer.get_Layer(j) as IFeatureLayer;
|
|
|
|
|
if (layer.Visible)
|
|
|
|
|
{
|
|
|
|
|
allLayers.Add((T)layer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (pCompLayer.get_Layer(j) is IGroupLayer)
|
|
|
|
|
{
|
|
|
|
|
if (!pCompLayer.get_Layer(j).Visible)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
allLayers.AddRange(GetAllDisplayLayerInGroupLayer<T>(pCompLayer.get_Layer(j) as ICompositeLayer));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return allLayers;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
return allLayers;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据索引获得地图上显示的图层
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pMap">地图</param>
|
|
|
|
|
/// <param name="index">索引</param>
|
|
|
|
|
/// <returns>检索到的图层</returns>
|
|
|
|
|
public IFeatureLayer GetMapDisLayer(IMap pMap, int index)
|
|
|
|
|
{
|
|
|
|
|
IFeatureLayer layer = null;
|
|
|
|
|
int ind = -1;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//IEnumLayer enumLayer= KGIS.Framework.Platform.Platform.Instance.MapsService.getAxMapControl().Map.Layers;
|
|
|
|
|
ICompositeLayer pCompLayer;
|
|
|
|
|
//遍历地图
|
|
|
|
|
for (int i = 0; i < pMap.LayerCount; i++)
|
|
|
|
|
{
|
|
|
|
|
if (pMap.get_Layer(i) is IFeatureLayer)
|
|
|
|
|
{
|
|
|
|
|
//获得图层要素
|
|
|
|
|
layer = pMap.get_Layer(i) as IFeatureLayer;
|
|
|
|
|
if (layer.Visible)
|
|
|
|
|
{
|
|
|
|
|
ind++;
|
|
|
|
|
}
|
|
|
|
|
if (ind == index)
|
|
|
|
|
{
|
|
|
|
|
return layer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (pMap.get_Layer(i) is IGroupLayer)
|
|
|
|
|
{
|
|
|
|
|
if (!pMap.get_Layer(i).Visible)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//遍历图层组
|
|
|
|
|
pCompLayer = pMap.get_Layer(i) as ICompositeLayer;
|
|
|
|
|
GetMapDisLayer(pCompLayer, index, ref layer, ref ind);
|
|
|
|
|
if (layer != null)
|
|
|
|
|
{
|
|
|
|
|
return layer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return layer;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
return layer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GetMapDisLayer(ICompositeLayer pCompLayer, int index, ref IFeatureLayer getLayer, ref int retIndex)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IFeatureLayer layer = null;
|
|
|
|
|
for (int j = 0; j < pCompLayer.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
if (pCompLayer.get_Layer(j) is IFeatureLayer)
|
|
|
|
|
{
|
|
|
|
|
layer = pCompLayer.get_Layer(j) as IFeatureLayer;
|
|
|
|
|
if (layer.Visible)
|
|
|
|
|
{
|
|
|
|
|
retIndex++;
|
|
|
|
|
}
|
|
|
|
|
if (retIndex == index)
|
|
|
|
|
{
|
|
|
|
|
getLayer = layer;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (pCompLayer.get_Layer(j) is IGroupLayer)
|
|
|
|
|
{
|
|
|
|
|
if (!pCompLayer.get_Layer(j).Visible)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
GetMapDisLayer(pCompLayer.get_Layer(j) as ICompositeLayer, index, ref getLayer, ref retIndex);
|
|
|
|
|
if (getLayer != null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取当前地图控件在屏幕上的位置
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public System.Drawing.Point GetMapInScreenLocation(int pIndex)
|
|
|
|
|
{
|
|
|
|
|
System.Drawing.Point result = new System.Drawing.Point();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
result = axMapControl.Parent.PointToScreen(new System.Drawing.Point(0, 0));
|
|
|
|
|
|
|
|
|
|
switch (pIndex)
|
|
|
|
|
{
|
|
|
|
|
case 2:
|
|
|
|
|
result.X += axMapControl.Width;//x为地图x坐标
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
result.X += axMapControl.Width;//x为地图x坐标
|
|
|
|
|
result.Y += axMapControl.Height;//y为地图y坐标
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
result.Y += axMapControl.Height;//y为地图y坐标
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("获取屏幕坐标时发生异常!异常信息如下:");
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
LogAPI.Debug("异常信息结束。");
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetIsLoad(bool isLoad)
|
|
|
|
|
{
|
|
|
|
|
m_IsLoad = isLoad;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool GetIsLoad()
|
|
|
|
|
{
|
|
|
|
|
return m_IsLoad;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveProject()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
EngineEditor editor = new EngineEditorClass();
|
|
|
|
|
#region 修改在编辑状态时,快捷键保存工程不提示信息;修改人:白明雅;修改时间:2018-09-04
|
|
|
|
|
if (editor.EditState == esriEngineEditState.esriEngineStateEditing)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("当前工程正处于编辑状态,保存之前请先结束编辑!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
ProjectInfo ProInfo = (MapsManager.Instance.CurrProjectInfo as ProjectInfo);
|
|
|
|
|
if (ProInfo == null) return;
|
|
|
|
|
//保存地图文档
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IDataCatalogService _DataCatalog = BundleRuntime.Instance.GetFirstOrDefaultService<IDataCatalogService>();
|
|
|
|
|
if (_DataCatalog == null || _DataCatalog.CurrentLayers == null) return;
|
|
|
|
|
GetLayersState();
|
|
|
|
|
//Xml数据
|
|
|
|
|
string Str = SerializeAPI.SerializeToXML<LayerCfg>(_DataCatalog.CurrentLayers as LayerCfg);
|
|
|
|
|
Byte[] bytearr = Encoding.Default.GetBytes(Str);
|
|
|
|
|
string strBase64 = Convert.ToBase64String(bytearr);
|
|
|
|
|
ProInfo.TempData = strBase64;
|
|
|
|
|
//当前地图范围
|
|
|
|
|
ProInfo.MapExtent = new PluginServiceInterface.MapExtent();
|
|
|
|
|
if (!axMapControl.ActiveView.Extent.IsEmpty)//添加图形非空判断 王欢 2019-03-21
|
|
|
|
|
{
|
|
|
|
|
ProInfo.MapExtent.XMax = axMapControl.ActiveView.Extent.XMax;
|
|
|
|
|
ProInfo.MapExtent.YMax = axMapControl.ActiveView.Extent.YMax;
|
|
|
|
|
ProInfo.MapExtent.XMin = axMapControl.ActiveView.Extent.XMin;
|
|
|
|
|
ProInfo.MapExtent.YMin = axMapControl.ActiveView.Extent.YMin;
|
|
|
|
|
}
|
|
|
|
|
if (ProInfo.Save())
|
|
|
|
|
{
|
|
|
|
|
//MessageHelper.ShowTips("保存成功!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex1)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("在保存工程时发生异常,异常信息如下:");
|
|
|
|
|
LogAPI.Debug(ex1);
|
|
|
|
|
LogAPI.Debug(" 异常信息结束");
|
|
|
|
|
MessageHelper.ShowError("保存失败!" + ex1.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("保存工程时发生异常,异常信息如下:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void SaveProjectForNoEditor()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ProjectInfo ProInfo = (MapsManager.Instance.CurrProjectInfo as ProjectInfo);
|
|
|
|
|
if (ProInfo == null) return;
|
|
|
|
|
//保存地图文档
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IDataCatalogService _DataCatalog = BundleRuntime.Instance.GetFirstOrDefaultService<IDataCatalogService>();
|
|
|
|
|
if (_DataCatalog == null || _DataCatalog.CurrentLayers == null) return;
|
|
|
|
|
GetLayersState();
|
|
|
|
|
//Xml数据
|
|
|
|
|
string Str = SerializeAPI.SerializeToXML<LayerCfg>(_DataCatalog.CurrentLayers as LayerCfg);
|
|
|
|
|
Byte[] bytearr = Encoding.Default.GetBytes(Str);
|
|
|
|
|
string strBase64 = Convert.ToBase64String(bytearr);
|
|
|
|
|
ProInfo.TempData = strBase64;
|
|
|
|
|
//当前地图范围
|
|
|
|
|
ProInfo.MapExtent = new PluginServiceInterface.MapExtent();
|
|
|
|
|
if (!axMapControl.ActiveView.Extent.IsEmpty)//添加图形非空判断 王欢 2019-03-21
|
|
|
|
|
{
|
|
|
|
|
ProInfo.MapExtent.XMax = axMapControl.ActiveView.Extent.XMax;
|
|
|
|
|
ProInfo.MapExtent.YMax = axMapControl.ActiveView.Extent.YMax;
|
|
|
|
|
ProInfo.MapExtent.XMin = axMapControl.ActiveView.Extent.XMin;
|
|
|
|
|
ProInfo.MapExtent.YMin = axMapControl.ActiveView.Extent.YMin;
|
|
|
|
|
}
|
|
|
|
|
if (ProInfo.Save())
|
|
|
|
|
{
|
|
|
|
|
//MessageHelper.ShowTips("保存成功!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex1)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("在保存工程时发生异常,异常信息如下:");
|
|
|
|
|
LogAPI.Debug(ex1);
|
|
|
|
|
LogAPI.Debug(" 异常信息结束");
|
|
|
|
|
MessageHelper.ShowError("保存失败!" + ex1.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("保存工程时发生异常,异常信息如下:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存图层状态(透明度-比例尺-样式)
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void GetLayersState()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (_DataCatalog == null)
|
|
|
|
|
_DataCatalog = BundleRuntime.Instance.GetFirstOrDefaultService<IDataCatalogService>();
|
|
|
|
|
//随时保存-重新获取
|
|
|
|
|
ISystemCfg cfg2 = BundleRuntime.Instance.GetFirstOrDefaultService<ISystemCfg>();
|
|
|
|
|
SystemCfg = cfg2.Load();
|
|
|
|
|
if (SystemCfg.JcLayerLoadCfg == null)
|
|
|
|
|
{
|
|
|
|
|
SystemCfg.JcLayerLoadCfg = new List<LayerCfg>();
|
|
|
|
|
}
|
|
|
|
|
ProjectInfo projectInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo;
|
|
|
|
|
if (projectInfo == null || _DataCatalog.CurrentLayers == null) return;
|
|
|
|
|
|
|
|
|
|
//获取图层样式
|
|
|
|
|
LayerCfg layerInfo = _DataCatalog.CurrentLayers as LayerCfg;
|
|
|
|
|
List<LayerCfg> list = layerInfo.GetAllItem();
|
|
|
|
|
if (list != null && list.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
if (item.Data is ILayer layer)
|
|
|
|
|
{
|
|
|
|
|
if (layer is IFeatureLayer)
|
|
|
|
|
{
|
|
|
|
|
#region 图层是否可选
|
|
|
|
|
item.Selectable = (layer as IFeatureLayer).Selectable;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 图层显示
|
|
|
|
|
item.Visible = layer.Visible;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 透明度
|
|
|
|
|
if (layer is ILayerEffects mLayerEffects)
|
|
|
|
|
item.Transparency = mLayerEffects.Transparency;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 比例尺
|
|
|
|
|
LayerCfg layerCfg = SystemCfg.JcLayerLoadCfg.FirstOrDefault(x => x.LayerName == item.LayerName);
|
|
|
|
|
if (layerCfg != null)
|
|
|
|
|
{
|
|
|
|
|
item.MinScale = layer.MinimumScale.ToInt();
|
|
|
|
|
item.MaxScale = layer.MaximumScale.ToInt();//.MaxScale;
|
|
|
|
|
layerCfg.MinScale = item.MinScale;
|
|
|
|
|
layerCfg.MaxScale = item.MaxScale;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 样式
|
|
|
|
|
Renderer randerer = SymbolConvert.Instance().GetRenderer((layer as IGeoFeatureLayer).Renderer);
|
|
|
|
|
LabelingInfo labelingInfo = null;
|
|
|
|
|
LabelStyleConvert styleConvert = new LabelStyleConvert();
|
|
|
|
|
List<LabelingInfo> labelInfo = styleConvert.EsriLabelToCustomLabels((layer as IGeoFeatureLayer).AnnotationProperties);
|
|
|
|
|
if (labelInfo != null && labelInfo.Count > 0)
|
|
|
|
|
labelingInfo = labelInfo[0];
|
|
|
|
|
if (labelingInfo != null)
|
|
|
|
|
{
|
|
|
|
|
AdvancedDrawingInfo adi = new AdvancedDrawingInfo();
|
|
|
|
|
adi.DrawingInfo.Renderer = randerer;
|
|
|
|
|
adi.DrawingInfo.LabelingInfo = labelInfo;
|
|
|
|
|
item.Symbol = adi.ToJson();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
IGeoFeatureLayer pGeoFeatureLayer = layer as IGeoFeatureLayer;
|
|
|
|
|
#region 标注-测试
|
|
|
|
|
if (pGeoFeatureLayer != null && pGeoFeatureLayer.DisplayAnnotation == true && item != null)
|
|
|
|
|
{
|
|
|
|
|
IAnnotateLayerPropertiesCollection m_AnnotateLayerPropertiesCollection = (layer as IGeoFeatureLayer).AnnotationProperties;
|
|
|
|
|
if (m_AnnotateLayerPropertiesCollection != null)
|
|
|
|
|
{
|
|
|
|
|
IAnnotateLayerProperties annotateLayerProperties = null;
|
|
|
|
|
IElementCollection elementCollection = null;
|
|
|
|
|
IElementCollection elementCollection2 = null;
|
|
|
|
|
#region 实体化
|
|
|
|
|
for (int i = 0; i < m_AnnotateLayerPropertiesCollection.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
m_AnnotateLayerPropertiesCollection.QueryItem(i, out annotateLayerProperties, out elementCollection2, out elementCollection);
|
|
|
|
|
if (annotateLayerProperties == null) continue;
|
|
|
|
|
ILabelEngineLayerProperties labelEngineLayer = (annotateLayerProperties as IClone).Clone() as ILabelEngineLayerProperties;
|
|
|
|
|
AdvancedAnnotationInfo annotationInfo = new AdvancedAnnotationInfo();
|
|
|
|
|
if (labelEngineLayer == null) continue;
|
|
|
|
|
SimpleTextSymbol txtSymbol = AnnotationConvret.Instance().GetTextSymbol(labelEngineLayer.Symbol);
|
|
|
|
|
if (txtSymbol != null)
|
|
|
|
|
{
|
|
|
|
|
annotationInfo.AnnotationInfos.Symbol = txtSymbol;
|
|
|
|
|
annotationInfo.AnnotationInfos.Expression = labelEngineLayer.Expression;
|
|
|
|
|
annotationInfo.AnnotationInfos.DisplayAnnotation = true;
|
|
|
|
|
item.Annotation = annotationInfo.ToJson();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SystemCfg.Save();
|
|
|
|
|
if (false)//测试数据提取
|
|
|
|
|
{
|
|
|
|
|
string Str = SerializeAPI.SerializeToXML<LayerCfg>(_DataCatalog.CurrentLayers as LayerCfg);
|
|
|
|
|
Byte[] bytearr = Encoding.Default.GetBytes(Str);//Encoding.UTF8.GetBytes(Str);
|
|
|
|
|
using (Stream stream = new System.IO.FileStream(@"C:\Users\Administrator\Desktop\临时文档" + "\\" + "LatersSymbolToXML简单绘制2.xml", FileMode.Create, FileAccess.Write, FileShare.None))
|
|
|
|
|
{
|
|
|
|
|
stream.Write(bytearr, 0, bytearr.Length);
|
|
|
|
|
stream.Close();
|
|
|
|
|
MessageHelper.ShowTips("提取成功!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("UcMapControl.GetLayersState() 异常:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("UcMapControl.GetLayersState() 异常:" + ex.StackTrace);
|
|
|
|
|
LogAPI.Debug("UcMapControl.GetLayersState() 异常:" + ex);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 图层标注设置
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="layer"></param>
|
|
|
|
|
/// <param name="layerCfg"></param>
|
|
|
|
|
private void SetLayerAnnotation(ILayer layer, LayerCfg layerCfg)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(layerCfg.Annotation)) return;
|
|
|
|
|
AdvancedAnnotationInfo advanced = new AdvancedAnnotationInfo();
|
|
|
|
|
advanced = AdvancedAnnotationInfo.FromJson(layerCfg.Annotation);
|
|
|
|
|
ITextSymbol pTextSymbol = AnnotationConvret.Instance().GetSimpleTextSymbol(advanced.AnnotationInfos.Symbol);
|
|
|
|
|
IGeoFeatureLayer pGeoFeatureLayer = layer as IGeoFeatureLayer;
|
|
|
|
|
|
|
|
|
|
pGeoFeatureLayer.DisplayAnnotation = advanced.AnnotationInfos.DisplayAnnotation;//开启标注图层内要素
|
|
|
|
|
IBasicOverposterLayerProperties pBasicOverposterLayerProprties = new BasicOverposterLayerProperties
|
|
|
|
|
{
|
|
|
|
|
FeatureType = advanced.AnnotationInfos.FeatureType
|
|
|
|
|
};
|
|
|
|
|
ILabelEngineLayerProperties pLabelEngineLayerProperties = new LabelEngineLayerProperties() as ILabelEngineLayerProperties;
|
|
|
|
|
pLabelEngineLayerProperties.Expression = advanced.AnnotationInfos.Expression;
|
|
|
|
|
pLabelEngineLayerProperties.Symbol = pTextSymbol;
|
|
|
|
|
pLabelEngineLayerProperties.BasicOverposterLayerProperties = pBasicOverposterLayerProprties;
|
|
|
|
|
|
|
|
|
|
// 刷新地图
|
|
|
|
|
IAnnotateLayerProperties pAnnotateLayerProperties = pLabelEngineLayerProperties as IAnnotateLayerProperties;
|
|
|
|
|
IAnnotateLayerPropertiesCollection pAnnotateLayerPropertiesCollection = pGeoFeatureLayer.AnnotationProperties;
|
|
|
|
|
pAnnotateLayerPropertiesCollection.Clear();
|
|
|
|
|
pAnnotateLayerPropertiesCollection.Add(pAnnotateLayerProperties);
|
|
|
|
|
axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("图层标注设置异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<T> GetAllVisibleLayerInMap<T>()
|
|
|
|
|
{
|
|
|
|
|
List<T> allLayers = new List<T>();
|
|
|
|
|
for (int i = 0; i < axMapControl.Map.LayerCount; i++)
|
|
|
|
|
{
|
|
|
|
|
ILayer layer = axMapControl.Map.get_Layer(i);
|
|
|
|
|
if (layer is ICompositeLayer)
|
|
|
|
|
{
|
|
|
|
|
if (!layer.Visible) continue;
|
|
|
|
|
allLayers.AddRange(GetAllVisibleLayerInGroupLayer<T>(layer as ICompositeLayer));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (layer is T && layer.Visible)
|
|
|
|
|
{
|
|
|
|
|
if ((layer.MinimumScale == 0 || layer.MinimumScale > axMapControl.MapScale) && (layer.MaximumScale == 0 || layer.MaximumScale < axMapControl.MapScale))
|
|
|
|
|
allLayers.Add((T)layer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return allLayers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RefreshToolState()
|
|
|
|
|
{
|
|
|
|
|
if (!axMapControl.IsDisposed)
|
|
|
|
|
RefreshToolState(axMapControl.CurrentTool);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetCurrentTool(object tool)
|
|
|
|
|
{
|
|
|
|
|
if (tool is ITool)
|
|
|
|
|
{
|
|
|
|
|
axMapControl.CurrentTool = tool as ITool;
|
|
|
|
|
RefreshToolState(tool);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ILayer GetGroupLayer(string strSearch)
|
|
|
|
|
{
|
|
|
|
|
return GetGroupLayer(axMapControl.Map, strSearch);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region IKMap
|
|
|
|
|
public object Hook => axMapControl.Object;
|
|
|
|
|
|
|
|
|
|
public object MapCtrl => axMapControl;
|
|
|
|
|
public ControlsSynchronizer CtlsSynchronizer
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (_CtrlSynchronizer == null)
|
|
|
|
|
_CtrlSynchronizer = new ControlsSynchronizer(Hook as IMapControl3, null);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
return _CtrlSynchronizer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public Control MapCtrlContainer => axMapControl.ContainingControl.ActiveControl;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region IDocumentView
|
|
|
|
|
public string Header { get; set; }
|
|
|
|
|
public bool IsOpened { get; set; }
|
|
|
|
|
public bool AllowClose { get; set; }
|
|
|
|
|
public bool IsFloat { get; set; }
|
|
|
|
|
public bool IsActive { get; set; }
|
|
|
|
|
public bool AllowFloat { get; set; }
|
|
|
|
|
#endregion
|
|
|
|
|
private void hoverButton1_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void hoverButton1_MouseDown(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
popupCtrl.Show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 图片方位角
|
|
|
|
|
Dictionary<string, ESRI.ArcGIS.Geometry.IPoint> dicPic = new Dictionary<string, ESRI.ArcGIS.Geometry.IPoint>();
|
|
|
|
|
public void AddCameraPoint(object pCameraParams)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!(pCameraParams is List<AttachEntity>)) return;
|
|
|
|
|
dicPic = new Dictionary<string, IPoint>();
|
|
|
|
|
currentEl = null;
|
|
|
|
|
axMapControl.ActiveView.GraphicsContainer.Reset();
|
|
|
|
|
|
|
|
|
|
IElement CameraPointElm = null; // axMapControl.ActiveView.GraphicsContainer.Next();
|
|
|
|
|
while ((CameraPointElm = axMapControl.ActiveView.GraphicsContainer.Next()) != null)
|
|
|
|
|
{
|
|
|
|
|
if ((CameraPointElm as IElementProperties).Name == "CameraPoint")
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (CameraPointElm == null)
|
|
|
|
|
{
|
|
|
|
|
CameraPointElm = new GroupElementClass();
|
|
|
|
|
(CameraPointElm as IElementProperties).Name = "CameraPoint";
|
|
|
|
|
axMapControl.ActiveView.GraphicsContainer.AddElement(CameraPointElm, 1);
|
|
|
|
|
}
|
|
|
|
|
(CameraPointElm as IGroupElement).ClearElements();//.DeleteAllElements();
|
|
|
|
|
//if (pCameraParams != null)
|
|
|
|
|
//{
|
|
|
|
|
List<AttachEntity> list = pCameraParams as List<AttachEntity>;
|
|
|
|
|
foreach (AttachEntity item in list)
|
|
|
|
|
{
|
|
|
|
|
IPoint point = new PointClass() { X = item.X, Y = item.Y };
|
|
|
|
|
if (!dicPic.ContainsKey(item.FJMC))
|
|
|
|
|
{
|
|
|
|
|
DrawAnglePoint(CameraPointElm as IGroupElement, point, item.Angle, item.FJMC, axMapControl, item.isCheck);
|
|
|
|
|
dicPic.Add(item.FJMC, point);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
axMapControl.ActiveView.GraphicsContainer.Reset();
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("方位角异常:" + ex.Message);
|
|
|
|
|
MessageHelper.ShowError("方位角出现异常,请查看日志!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 绘制带方向点
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pt"></param>
|
|
|
|
|
/// <param name="angle"></param>
|
|
|
|
|
private void DrawAnglePoint(IGroupElement pGroupEle, IPoint point, double angle, string picName, object objmapcontrol, bool IsCheck)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
PictureMarkerSymbolClass picMarkerSymbol = new PictureMarkerSymbolClass();
|
|
|
|
|
picMarkerSymbol.Angle = -angle;
|
|
|
|
|
picMarkerSymbol.Size = 28;
|
|
|
|
|
if (IsCheck)
|
|
|
|
|
{
|
|
|
|
|
picMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, Application.StartupPath + "\\Plugins\\KGIS.Plugin.MapView\\Resources\\近景.png");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
picMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, Application.StartupPath + "\\Plugins\\KGIS.Plugin.MapView\\Resources\\arrow_unselect.png");
|
|
|
|
|
}
|
|
|
|
|
MarkerElementClass pMarkerAngleElement = new MarkerElementClass();
|
|
|
|
|
pMarkerAngleElement.Symbol = picMarkerSymbol;
|
|
|
|
|
pMarkerAngleElement.Name = "ShowPicElement&" + picName;
|
|
|
|
|
IElement pElement;
|
|
|
|
|
pElement = pMarkerAngleElement as IElement;
|
|
|
|
|
|
|
|
|
|
pElement.Geometry = point;
|
|
|
|
|
pGroupEle.AddElement((IElement)pMarkerAngleElement);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("绘制带方向点异常:" + ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
IElement currentEl = null;
|
|
|
|
|
|
|
|
|
|
public void ChangedPointSymbol(string elementName, bool ischeck)
|
|
|
|
|
{
|
|
|
|
|
string elementNamePic = "ShowPicElement&" + elementName;
|
|
|
|
|
|
|
|
|
|
axMapControl.ActiveView.GraphicsContainer.Reset();
|
|
|
|
|
IElement CameraPointElm = null; // axMapControl.ActiveView.GraphicsContainer.Next();
|
|
|
|
|
while ((CameraPointElm = axMapControl.ActiveView.GraphicsContainer.Next()) != null)
|
|
|
|
|
{
|
|
|
|
|
if ((CameraPointElm as IElementProperties).Name == "CameraPoint")
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (CameraPointElm == null)
|
|
|
|
|
{
|
|
|
|
|
CameraPointElm = new GroupElementClass();
|
|
|
|
|
(CameraPointElm as IElementProperties).Name = "CameraPoint";
|
|
|
|
|
}
|
|
|
|
|
//(CameraPointElm as IGroupElement).Elements.Reset();
|
|
|
|
|
IEnumElement Elements = (CameraPointElm as IGroupElement).Elements;
|
|
|
|
|
//Elements.Reset();
|
|
|
|
|
IElement el = Elements.Next();
|
|
|
|
|
//int num = (CameraPointElm as IGroupElement).ElementCount;
|
|
|
|
|
if (el == null)
|
|
|
|
|
{
|
|
|
|
|
Elements.Reset();
|
|
|
|
|
el = Elements.Next();
|
|
|
|
|
}
|
|
|
|
|
if (currentEl is IMarkerElement)
|
|
|
|
|
{
|
|
|
|
|
IMarkerElement elMarker = currentEl as IMarkerElement;
|
|
|
|
|
if (elMarker.Symbol is IPictureMarkerSymbol)
|
|
|
|
|
{
|
|
|
|
|
IPictureMarkerSymbol picSymbol = elMarker.Symbol as IPictureMarkerSymbol;
|
|
|
|
|
if (ischeck)
|
|
|
|
|
{
|
|
|
|
|
picSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, System.Windows.Forms.Application.StartupPath + "\\Plugins\\KGIS.Plugin.MapView\\Resources\\近景.png");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
picSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, System.Windows.Forms.Application.StartupPath + "\\Plugins\\KGIS.Plugin.MapView\\Resources\\arrow_unselect.png");
|
|
|
|
|
}
|
|
|
|
|
elMarker.Symbol = picSymbol;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (el != null)
|
|
|
|
|
{
|
|
|
|
|
if (el == null) return;
|
|
|
|
|
if (el is IMarkerElement)
|
|
|
|
|
{
|
|
|
|
|
IElementProperties elementPro = el as IElementProperties;
|
|
|
|
|
if (!elementPro.Name.StartsWith("ShowPicElement")) continue;
|
|
|
|
|
if (elementPro.Name == elementNamePic)
|
|
|
|
|
{
|
|
|
|
|
IMarkerElement elMarker = el as IMarkerElement;
|
|
|
|
|
if (elMarker == null) continue;
|
|
|
|
|
IPictureMarkerSymbol picSymbol = elMarker.Symbol as IPictureMarkerSymbol;
|
|
|
|
|
if (picSymbol == null) continue;
|
|
|
|
|
picSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, System.Windows.Forms.Application.StartupPath + "\\Plugins\\KGIS.Plugin.MapView\\Resources\\arrow_select.png");
|
|
|
|
|
elMarker.Symbol = picSymbol;
|
|
|
|
|
currentEl = el;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
el = Elements.Next();
|
|
|
|
|
}
|
|
|
|
|
axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
public object GetAllEditOID()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IWorkspaceEdit2 workspaceEdit2 = (IWorkspaceEdit2)editor.EditWorkspace;
|
|
|
|
|
IDataChangesEx dataChangesEx = workspaceEdit2.get_EditDataChanges(esriEditDataChangesType.esriEditDataChangesWithinSession);
|
|
|
|
|
//获取所有变化的要素集
|
|
|
|
|
//String modifiedClass = null;
|
|
|
|
|
//ESRI.ArcGIS.esriSystem.IEnumBSTR modifiedClasses = dataChangesEx.ModifiedClasses;
|
|
|
|
|
//if (modifiedClasses == null)
|
|
|
|
|
// return null;
|
|
|
|
|
Dictionary<string, List<int>> objids = new Dictionary<string, List<int>>();
|
|
|
|
|
objids.Add("修改", new List<int>());
|
|
|
|
|
objids.Add("新增", new List<int>());
|
|
|
|
|
objids.Add("删除", new List<int>());
|
|
|
|
|
//图层名称
|
|
|
|
|
//while ((modifiedClass = modifiedClasses.Next()) != null)
|
|
|
|
|
//{
|
|
|
|
|
//获取当前要素类所有变化图形信息
|
|
|
|
|
IFIDSet fids = dataChangesEx.ChangedIDs["DLTBBG", esriDifferenceType.esriDifferenceTypeUpdateNoChange];
|
|
|
|
|
#region 参数
|
|
|
|
|
//准备输入参数
|
|
|
|
|
int featureOID = -1;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
fids.Next(out featureOID);
|
|
|
|
|
while (featureOID != -1)
|
|
|
|
|
{
|
|
|
|
|
if (!objids["修改"].Contains(featureOID))
|
|
|
|
|
objids["修改"].Add(featureOID);
|
|
|
|
|
fids.Next(out featureOID);
|
|
|
|
|
}
|
|
|
|
|
//获取删除图形信息
|
|
|
|
|
fids = dataChangesEx.ChangedIDs["DLTBBG", esriDifferenceType.esriDifferenceTypeDeleteNoChange];
|
|
|
|
|
fids.Next(out featureOID);
|
|
|
|
|
while (featureOID != -1)
|
|
|
|
|
{
|
|
|
|
|
if (!objids["删除"].Contains(featureOID))
|
|
|
|
|
objids["删除"].Add(featureOID);
|
|
|
|
|
fids.Next(out featureOID);
|
|
|
|
|
}
|
|
|
|
|
//获取插入图形信息
|
|
|
|
|
fids = dataChangesEx.ChangedIDs["DLTBBG", esriDifferenceType.esriDifferenceTypeInsert];
|
|
|
|
|
fids.Next(out featureOID);
|
|
|
|
|
while (featureOID != -1)
|
|
|
|
|
{
|
|
|
|
|
if (!objids["新增"].Contains(featureOID))
|
|
|
|
|
objids["新增"].Add(featureOID);
|
|
|
|
|
fids.Next(out featureOID);
|
|
|
|
|
}
|
|
|
|
|
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(fids);
|
|
|
|
|
//}
|
|
|
|
|
return objids;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
public class WorkCatalogPaths
|
|
|
|
|
{
|
|
|
|
|
public override string ToString() { return WorkCatalogPath; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工作目录路径
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string WorkCatalogPath { get; set; }
|
|
|
|
|
public string CODE { get; set; }
|
|
|
|
|
public string DisplayName { get; set; }
|
|
|
|
|
public DateTime UpdateTime { get; set; }
|
|
|
|
|
}
|
|
|
|
|
}
|