|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using KGIS.Framework.Views;
|
|
|
|
|
using KGIS.Framework.Maps;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using KGIS.Framework.Utils.ExtensionMethod;
|
|
|
|
|
using KGIS.Framework.Menus;
|
|
|
|
|
using KGIS.Framework.Core.Consts;
|
|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using KGIS.Framework.Menus.Entities;
|
|
|
|
|
using UIShell.OSGi;
|
|
|
|
|
using KGIS.Framework.Commands;
|
|
|
|
|
using DevExpress.XtraBars;
|
|
|
|
|
using ESRI.ArcGIS.SystemUI;
|
|
|
|
|
using KGIS.Framework.Platform;
|
|
|
|
|
using ESRI.ArcGIS.Geometry;
|
|
|
|
|
using KGIS.Framework.Utils.Helper;
|
|
|
|
|
using ESRI.ArcGIS.Controls;
|
|
|
|
|
using ESRI.ArcGIS.Display;
|
|
|
|
|
using Kingo.PluginServiceInterface;
|
|
|
|
|
using DevExpress.Xpf.Editors;
|
|
|
|
|
using KGIS.Framework.AE;
|
|
|
|
|
using KGIS.Framework.AE.Enum;
|
|
|
|
|
using ESRI.ArcGIS.Geodatabase;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using static Kingo.Plugin.BHTB_Extract.View.MulitMapCatalog;
|
|
|
|
|
using Kingo.Framework.LayerStyleConvert.XSDClass;
|
|
|
|
|
using Kingo.Framework.LayerStyleConvert.Common;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.BHTB_Extract.View
|
|
|
|
|
{
|
|
|
|
|
public partial class UcMapControl : UserControl, 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; }
|
|
|
|
|
ICommandManager _CmdManager = null;
|
|
|
|
|
private MenuGroupEntityManager _mapToolsGroupEntityManager;
|
|
|
|
|
private MenuItemEntityManager _mapToolsItemEntityManager;
|
|
|
|
|
private string StrTig { get; set; }
|
|
|
|
|
private List<ILayer> layer { get; set; } = new List<ILayer>();
|
|
|
|
|
public UcMapControl(/*List<ILayer> tempLayer*/)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
//layer = tempLayer;
|
|
|
|
|
//layer = MapsManager.Instance.MapService.GetAllLayerInMap<ILayer>();
|
|
|
|
|
|
|
|
|
|
Header = "前时相";
|
|
|
|
|
this.AllowClose = true;
|
|
|
|
|
this.IsActive = true;
|
|
|
|
|
this.AllowFloat = false;
|
|
|
|
|
InitMapTools();
|
|
|
|
|
axMapControl.OnExtentUpdated -= AxMapControl_OnExtentUpdated;
|
|
|
|
|
axMapControl.OnExtentUpdated += AxMapControl_OnExtentUpdated;
|
|
|
|
|
Platform.Instance.NotifyMsgEven2 += o =>
|
|
|
|
|
{
|
|
|
|
|
if (o.MsgType == "ExtentUpdated" && o.Content.ToTrim() == "MainMap")
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
StrTig = o.Content.ToTrim();
|
|
|
|
|
axMapControl.ActiveView.Extent = o.Extend as IEnvelope;// MapsManager.Instance.MapService.getAxMapControl().Extent;
|
|
|
|
|
axMapControl.ActiveView.Refresh();
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AxMapControl_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)
|
|
|
|
|
{
|
|
|
|
|
//MapsManager.Instance.MapService.getAxMapControl().Extent != (e.newEnvelope as IEnvelope) &&
|
|
|
|
|
if (StrTig != "MainMap")
|
|
|
|
|
{
|
|
|
|
|
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "ExtentUpdated", Content = "Map2", Extend = e.newEnvelope });
|
|
|
|
|
}
|
|
|
|
|
StrTig = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitMapTools()
|
|
|
|
|
{
|
|
|
|
|
InitData(ExtensionPointConst.MapTools);
|
|
|
|
|
var MenuPageData = GetMenuPageData();
|
|
|
|
|
InitMapTools(MenuPageData);
|
|
|
|
|
}
|
|
|
|
|
public void SetLayer()
|
|
|
|
|
{
|
|
|
|
|
layer = MapsManager.Instance.MapService.GetAllLayerInMap<ILayer>();
|
|
|
|
|
if (layer == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowWarning("获取多窗口操作图层失败!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "SaveProjectForNoEditor" });
|
|
|
|
|
InitLayerVisible();
|
|
|
|
|
layer.Reverse();
|
|
|
|
|
axMapControl.SpatialReference = MapsManager.Instance.MapService.getAxMapControl().SpatialReference;
|
|
|
|
|
foreach (ILayer item in layer)
|
|
|
|
|
{
|
|
|
|
|
if ((item as RasterLayer) != null)
|
|
|
|
|
{
|
|
|
|
|
IRasterLayer templayer = new RasterLayerClass();
|
|
|
|
|
templayer.CreateFromFilePath((item as IRasterLayer).FilePath);
|
|
|
|
|
templayer.Name = item.Name;
|
|
|
|
|
templayer.Visible = item.Visible == false ? false : GetParentIsChecked(nodes.Find(a=>a.LayerName == item.Name).PID);
|
|
|
|
|
axMapControl.Map.AddLayer(templayer);
|
|
|
|
|
}
|
|
|
|
|
else if ((item as KOTilesLayer) != null)
|
|
|
|
|
{
|
|
|
|
|
KOTilesLayer ko = KOTilesLayer.CreateInstance((item as KOTilesLayer).DBPath);
|
|
|
|
|
ko.Name = item.Name;
|
|
|
|
|
ko.Visible = item.Visible == false ? false : GetParentIsChecked(nodes.Find(a => a.LayerName == item.Name).PID);
|
|
|
|
|
axMapControl.Map.AddLayer(ko);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach (ILayer item in layer)
|
|
|
|
|
{
|
|
|
|
|
if ((item as IFeatureLayer) != null)
|
|
|
|
|
{
|
|
|
|
|
string FcPath = ((item as IFeatureLayer).FeatureClass as FeatureClass).Workspace.PathName;
|
|
|
|
|
WorkspaceTypeEnum workspaceType = WorkspaceTypeEnum.GDBFile;
|
|
|
|
|
if (FcPath.ToLower().EndsWith(".mdb"))
|
|
|
|
|
workspaceType = WorkspaceTypeEnum.MDBFile;
|
|
|
|
|
else if (FcPath.ToLower().EndsWith(".gdb"))
|
|
|
|
|
workspaceType = WorkspaceTypeEnum.GDBFile;
|
|
|
|
|
else
|
|
|
|
|
workspaceType = WorkspaceTypeEnum.ShapeFile;
|
|
|
|
|
|
|
|
|
|
IWorkspaceAPI wsAPI = new WorkspaceAPI(FcPath, workspaceType);
|
|
|
|
|
|
|
|
|
|
IFeatureClass fc = (item as IFeatureLayer).FeatureClass;
|
|
|
|
|
IFeatureClassAPI hrFcAPI = wsAPI.OpenFeatureClass((fc as FeatureClass).Name);
|
|
|
|
|
//IFeatureClassAPI hrFcAPI = wsAPI.OpenFeatureClass(item.BrowseName);
|
|
|
|
|
//IFeatureClass fc = wsAPI.OpenFeatureClass(item.Name).FeatureClass;
|
|
|
|
|
//ILayer tempLayer = new FeatureLayer() { Name = item.Name, FeatureClass = fc };
|
|
|
|
|
ILayer tempLayer = new FeatureLayerClass() { FeatureClass = hrFcAPI.FeatureClass };
|
|
|
|
|
tempLayer.Visible = item.Visible == false ? false : GetParentIsChecked(nodes.Find(a => a.LayerName == fc.AliasName).PID);
|
|
|
|
|
|
|
|
|
|
#region 图层样式
|
|
|
|
|
Renderer randerer = SymbolConvert.Instance().GetRenderer((item as IGeoFeatureLayer).Renderer);
|
|
|
|
|
LabelingInfo labelingInfo = null;
|
|
|
|
|
LabelStyleConvert styleConvert = new LabelStyleConvert();
|
|
|
|
|
List<LabelingInfo> labelInfo = styleConvert.EsriLabelToCustomLabels((item as IGeoFeatureLayer).AnnotationProperties);
|
|
|
|
|
if (labelInfo != null && labelInfo.Count > 0)
|
|
|
|
|
labelingInfo = labelInfo[0];
|
|
|
|
|
string symbol = null;
|
|
|
|
|
if (labelingInfo != null)
|
|
|
|
|
{
|
|
|
|
|
AdvancedDrawingInfo adi = new AdvancedDrawingInfo();
|
|
|
|
|
adi.DrawingInfo.Renderer = randerer;
|
|
|
|
|
adi.DrawingInfo.LabelingInfo = labelInfo;
|
|
|
|
|
symbol = adi.ToJson();
|
|
|
|
|
}
|
|
|
|
|
IFeatureRenderer render = GetSymbol(symbol);
|
|
|
|
|
if (render != null)
|
|
|
|
|
(tempLayer as IGeoFeatureLayer).Renderer = render;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
axMapControl.Map.AddLayer(tempLayer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//axMapControl.ActiveView.Extent = MapsManager.Instance.MapService.getAxMapControl().Extent;
|
|
|
|
|
axMapControl.Refresh();
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<MapTreeViewModel> nodes = new List<MapTreeViewModel>();
|
|
|
|
|
bool isFirst = true;
|
|
|
|
|
MapTreeViewModel treeViewModel = new MapTreeViewModel();
|
|
|
|
|
private void InitLayerVisible()
|
|
|
|
|
{
|
|
|
|
|
isFirst = true;
|
|
|
|
|
LayerCfg layerInfo = null;
|
|
|
|
|
treeViewModel = new MapTreeViewModel();
|
|
|
|
|
ProjectInfo ProInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo;
|
|
|
|
|
if (ProInfo != null)
|
|
|
|
|
{
|
|
|
|
|
ProInfo.MulitMapData = ProInfo.TempData;
|
|
|
|
|
byte[] contentArray = Convert.FromBase64String(ProInfo.MulitMapData);
|
|
|
|
|
string LayerCfg = System.Text.Encoding.Default.GetString(contentArray);
|
|
|
|
|
layerInfo = KGIS.Framework.Utils.SerializeAPI.DeserializeToObject<LayerCfg>(LayerCfg);
|
|
|
|
|
nodes.Clear();
|
|
|
|
|
AddNodeTree(treeViewModel, layerInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddNodeTree(MapTreeViewModel treeViewModel, LayerCfg layerInfo)
|
|
|
|
|
{
|
|
|
|
|
if (isFirst)
|
|
|
|
|
{
|
|
|
|
|
isFirst = false;
|
|
|
|
|
treeViewModel.PID = 0;
|
|
|
|
|
treeViewModel.ID = 1;
|
|
|
|
|
treeViewModel.IsChecked = layerInfo.Visible;
|
|
|
|
|
treeViewModel.LayerName = layerInfo.LayerName;
|
|
|
|
|
nodes.Add(treeViewModel);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < layerInfo.Layers.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
MapTreeViewModel childTreeViewModel = new MapTreeViewModel();
|
|
|
|
|
childTreeViewModel.PID = treeViewModel.ID;
|
|
|
|
|
childTreeViewModel.ID = treeViewModel.ID * 100 + i + 1;
|
|
|
|
|
childTreeViewModel.IsChecked = layerInfo.Layers[i].Visible;
|
|
|
|
|
childTreeViewModel.LayerName = layerInfo.Layers[i].LayerName;
|
|
|
|
|
treeViewModel.Children.Add(childTreeViewModel);
|
|
|
|
|
nodes.Add(childTreeViewModel);
|
|
|
|
|
AddNodeTree(childTreeViewModel, layerInfo.Layers[i]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private bool GetParentIsChecked(int PID)
|
|
|
|
|
{
|
|
|
|
|
if (!treeViewModel.IsChecked) return false;
|
|
|
|
|
MapTreeViewModel parent = nodes.FirstOrDefault(a => a.ID == PID);
|
|
|
|
|
if (parent == null)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (!parent.IsChecked)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return GetParentIsChecked(parent.PID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetMask(IGeometry currentGeo)
|
|
|
|
|
{
|
|
|
|
|
ShowMaskHelper showMaskForBHTBHelper = new ShowMaskHelper();
|
|
|
|
|
showMaskForBHTBHelper.axMapControl = axMapControl;
|
|
|
|
|
showMaskForBHTBHelper.ShowMask(currentGeo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void InitMapTools(IEnumerable<MenuPageEntity> pageDatas)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (barManager1 == null) return;
|
|
|
|
|
barManager1.BeginUpdate();
|
|
|
|
|
if (_CmdManager == null)
|
|
|
|
|
{
|
|
|
|
|
_CmdManager = BundleRuntime.Instance.GetFirstOrDefaultService<ICommandManager>();
|
|
|
|
|
}
|
|
|
|
|
//int num = 0;
|
|
|
|
|
foreach (var pageEntity in pageDatas)
|
|
|
|
|
{
|
|
|
|
|
var groupChilds = pageEntity.Childs;
|
|
|
|
|
if (groupChilds == null)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
foreach (var groupChild in groupChilds)
|
|
|
|
|
{
|
|
|
|
|
if (groupChild.Id != "MapTools.Group.MapOperation")
|
|
|
|
|
continue;
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
//if (num == 0)
|
|
|
|
|
//{
|
|
|
|
|
// MenuItemEntity menuItemEntity = new MenuItemEntity()
|
|
|
|
|
// {
|
|
|
|
|
// Name = "目录",
|
|
|
|
|
// ItemType = "ToolItem",
|
|
|
|
|
// Id = "MapTools.Tool.Calagon",
|
|
|
|
|
// Visible = true,
|
|
|
|
|
// ToolTip = "点击可查看地图目录列表。",
|
|
|
|
|
// //SmallImage = @"\Resources\维护数据字典.png",
|
|
|
|
|
// //LargeImage = @"\Resources\维护数据字典.png",
|
|
|
|
|
// //CommandId = "Kingo.Plugin.BHTB_Extract.Commands.CmdShowMulitMapCatalog"
|
|
|
|
|
// };
|
|
|
|
|
// var item1 = CreateItem(menuItemEntity, axMapControl.Object);
|
|
|
|
|
// subItem.LinksPersistInfo.Add(new LinkPersistInfo(item1));
|
|
|
|
|
//}
|
|
|
|
|
//num++;
|
|
|
|
|
var item = CreateItem(itemChild, axMapControl.Object);
|
|
|
|
|
//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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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.Caption == "目录")
|
|
|
|
|
//{
|
|
|
|
|
// System.Drawing.Point p = this.axMapControl.Location;
|
|
|
|
|
// System.Drawing.Point p2 = this.axMapControl.PointToScreen(p);
|
|
|
|
|
|
|
|
|
|
// List<ILayer> templayers = new List<ILayer>();
|
|
|
|
|
// int layerCount = this.axMapControl.LayerCount;
|
|
|
|
|
// for (int i = 0; i < layerCount; i++)
|
|
|
|
|
// {
|
|
|
|
|
// ILayer templayer = this.axMapControl.get_Layer(i);
|
|
|
|
|
// templayers.Add(templayer);
|
|
|
|
|
// }
|
|
|
|
|
// MulitMapCatalog.Getlnstance(p2, templayers, axMapControl).ShowWin();
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
public void SetCurrentTool(object tool)
|
|
|
|
|
{
|
|
|
|
|
if (tool is ITool)
|
|
|
|
|
{
|
|
|
|
|
axMapControl.CurrentTool = tool as ITool;
|
|
|
|
|
RefreshToolState(tool);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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 IEnumerable<MenuPageEntity> GetMenuPageData()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var pages = new List<MenuPageEntity>() { new MenuPageEntity() {
|
|
|
|
|
Id="DefaultToolBar",
|
|
|
|
|
LocationUri="",
|
|
|
|
|
LocationPosition=""
|
|
|
|
|
} };
|
|
|
|
|
|
|
|
|
|
var groups = _mapToolsGroupEntityManager.GetAll().ToList();
|
|
|
|
|
var items = _mapToolsItemEntityManager.GetAll().ToList();
|
|
|
|
|
|
|
|
|
|
var menuPageData = MenuExtensionParser.ArrangeMainMenuData(pages, groups, items);
|
|
|
|
|
pages.Clear();
|
|
|
|
|
groups.Clear();
|
|
|
|
|
items.Clear();
|
|
|
|
|
return menuPageData;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void InitData(string pExtensionPoint)
|
|
|
|
|
{
|
|
|
|
|
IBundle bundle = BundleRuntime.Instance.Framework.Bundles.Find(v => v.Context != null);
|
|
|
|
|
var menuExtensions = bundle.Context.GetExtensions(pExtensionPoint);
|
|
|
|
|
var GroupMenuEntities = MenuExtensionParser.GetMenuGroupEntities(menuExtensions);
|
|
|
|
|
var ItemMenuEntities = MenuExtensionParser.GetMenuItemEntities(menuExtensions);
|
|
|
|
|
|
|
|
|
|
if (_mapToolsGroupEntityManager == null)
|
|
|
|
|
_mapToolsGroupEntityManager = new MenuGroupEntityManager();
|
|
|
|
|
_mapToolsGroupEntityManager.Clear();
|
|
|
|
|
_mapToolsGroupEntityManager.AddRange(GroupMenuEntities);
|
|
|
|
|
|
|
|
|
|
if (_mapToolsItemEntityManager == null)
|
|
|
|
|
_mapToolsItemEntityManager = new MenuItemEntityManager();
|
|
|
|
|
_mapToolsItemEntityManager.Clear();
|
|
|
|
|
_mapToolsItemEntityManager.AddRange(ItemMenuEntities);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MarkLabelLayer()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IFeatureLayer pFeatureLayer = null;
|
|
|
|
|
int layerCount = axMapControl.LayerCount;
|
|
|
|
|
for (int i = 0; i < layerCount; i++)
|
|
|
|
|
{
|
|
|
|
|
ILayer templayer = axMapControl.get_Layer(i);
|
|
|
|
|
if ((templayer as RasterLayer) != null || (templayer as KOTilesLayer) != null) continue;
|
|
|
|
|
IFeatureLayer featureLayer = templayer as IFeatureLayer;
|
|
|
|
|
if (featureLayer == null) continue;
|
|
|
|
|
if (featureLayer.FeatureClass.AliasName == "ZYQ" || featureLayer.FeatureClass.AliasName == "作业区")
|
|
|
|
|
{
|
|
|
|
|
pFeatureLayer = templayer as IFeatureLayer;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (pFeatureLayer == null) return;
|
|
|
|
|
IGeoFeatureLayer pGeoLayer = pFeatureLayer as IGeoFeatureLayer;
|
|
|
|
|
IRgbColor pColor = new RgbColorClass() { Red = 85, Blue = 105, Green = 255 };
|
|
|
|
|
stdole.IFontDisp pFont = new stdole.StdFont()
|
|
|
|
|
{
|
|
|
|
|
Name = "宋体",
|
|
|
|
|
//Bold = true
|
|
|
|
|
} as stdole.IFontDisp;
|
|
|
|
|
|
|
|
|
|
ITextSymbol pTextSymbol = new TextSymbolClass()
|
|
|
|
|
{
|
|
|
|
|
Color = pColor,
|
|
|
|
|
Font = pFont,
|
|
|
|
|
Size = 8
|
|
|
|
|
};
|
|
|
|
|
IBasicOverposterLayerProperties pBasicOverLayerPro = new BasicOverposterLayerPropertiesClass();
|
|
|
|
|
pBasicOverLayerPro.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon;
|
|
|
|
|
pBasicOverLayerPro.GenerateUnplacedLabels = true;
|
|
|
|
|
pBasicOverLayerPro.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape;
|
|
|
|
|
|
|
|
|
|
ILabelEngineLayerProperties pLableEngine = new LabelEngineLayerPropertiesClass()
|
|
|
|
|
{
|
|
|
|
|
Symbol = pTextSymbol,
|
|
|
|
|
IsExpressionSimple = true
|
|
|
|
|
};
|
|
|
|
|
IOverposterLayerProperties2 pOverLayerProper = pBasicOverLayerPro as IOverposterLayerProperties2;
|
|
|
|
|
pOverLayerProper.TagUnplaced = true;//设置该属性,目的是不被其他element遮挡
|
|
|
|
|
pLableEngine.BasicOverposterLayerProperties = pBasicOverLayerPro;
|
|
|
|
|
IAnnotateLayerProperties pAnnoPros = pLableEngine as IAnnotateLayerProperties;
|
|
|
|
|
pGeoLayer.AnnotationProperties.Add(pAnnoPros);
|
|
|
|
|
pGeoLayer.DisplayAnnotation = true;
|
|
|
|
|
axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, axMapControl.Extent);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("设置标注时发生异常,异常信息如下:" + ex);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btMulitMapCatalog_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
System.Drawing.Point p = this.axMapControl.Location;
|
|
|
|
|
System.Drawing.Point p2 = this.axMapControl.PointToScreen(p);
|
|
|
|
|
|
|
|
|
|
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "SaveProjectForNoEditor" });
|
|
|
|
|
//记录多个多窗口图层勾选情况
|
|
|
|
|
if (axMapControl.DocumentMap == null)
|
|
|
|
|
{
|
|
|
|
|
ProjectInfo ProInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo;
|
|
|
|
|
if (ProInfo != null) axMapControl.DocumentMap = ProInfo.TempData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<ILayer> tempLayers = new List<ILayer>();
|
|
|
|
|
int layerCount = axMapControl.LayerCount;
|
|
|
|
|
for (int i = 0; i < layerCount; i++)
|
|
|
|
|
{
|
|
|
|
|
ILayer templayer = axMapControl.get_Layer(i);
|
|
|
|
|
tempLayers.Add(templayer);
|
|
|
|
|
}
|
|
|
|
|
MulitMapCatalog.Getlnstance(p2, axMapControl, tempLayers).ShowWin();
|
|
|
|
|
}
|
|
|
|
|
public void ClearPanelData()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ProjectInfo ProInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo;
|
|
|
|
|
if (ProInfo != null)
|
|
|
|
|
ProInfo.MulitMapData = null;
|
|
|
|
|
if (axMapControl != null)
|
|
|
|
|
{
|
|
|
|
|
axMapControl.Map.ClearLayers();
|
|
|
|
|
axMapControl.ClearLayers();
|
|
|
|
|
axMapControl.CurrentTool = null;
|
|
|
|
|
axMapControl.ActiveView.GraphicsContainer.DeleteAllElements();
|
|
|
|
|
axMapControl.Refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("清除多窗口图层数据时发生异常,异常信息如下:" + ex);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|