/// <summary> /// ����һ���µ�ͼ��������ӵ�Map������ /// </summary> /// <returns></returns> public IMap Create() { IMap newMap = new MapClass(); _mapList.Add(newMap); return newMap; }
/// <summary> /// Create a new Map, add it to the collection and return it to the caller /// </summary> /// <returns></returns> public IMap Create() { IMap newMap = new MapClass(); m_array.Add(newMap); return newMap; }
public static string ExportLayerImage(IRaster pRaster, string[] bbox, string[] size,string outputUrl,string serveroutDir) { //判断栅格文件是否已经存在,存在删除,原因是如果存在,不删除的话,保存图片出错 //创建rasterlayer IRasterLayer pRasterLayer = new RasterLayerClass(); //获取mapServer中所有的图层 IMap pMap = new MapClass(); pRasterLayer.CreateFromRaster(pRaster); pMap.AddLayer(pRasterLayer as ILayer); // // Size pSize = new Size(); pSize.Width = Convert.ToInt32(size[0]); pSize.Height = Convert.ToInt32(size[1]); // IEnvelope pEnvelop = new EnvelopeClass(); pEnvelop.PutCoords(Convert.ToDouble(bbox[0]), Convert.ToDouble(bbox[1]), Convert.ToDouble(bbox[2]), Convert.ToDouble(bbox[3])); Image pImage = SaveCurrentToImage(pMap, pSize, pEnvelop); string imageName = System.DateTime.Now.ToString().Replace("/", "").Replace(":", "").Replace(" ", "") + ".png"; //outputUrl="http://localhost:6080/arcgis/rest/directories/arcgisoutput/imageserver/miyunspot_ImageServer/" // serveroutDir="D:\arcgisserver\directories\arcgisoutput\imageserver\miyunspot_ImageServer"; string url = outputUrl + imageName; string path = System.IO.Path.Combine(serveroutDir, imageName); pImage.Save(path); return url; }
public void SetImage(string mapType, string src,byte[] data) { if (dbDic.ContainsKey(mapType)) { IObjectContainer db0 = dbDic[mapType]; string key = mapType + src; MapClass obj = new MapClass(key, data); db0.Set(obj); db0.Commit(); } }
public frmMain() { InitializeComponent(); m_MapControl = (IMapControl4)this.axMapControl1.Object; m_MapControltop = (IMapControl4)this.axMapControl2.Object; m_MapControlbase = (IMapControl4)this.axMapControl3.Object; IMap map = new MapClass(); map.Name = "Map"; m_MapControl.DocumentFilename = string.Empty; m_MapControl.Map = map; //test if it's necessary m_MapControl.ActiveView.Refresh(); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { //ask the user whether he'd like to save th ecurrent doc DialogResult res = MessageBox.Show("��ǰ�ĵ��Ƿ���Ҫ����?", "��Ϣ", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { //if yes, launch the SaveAs command ICommand command = new ControlsSaveAsDocCommandClass(); command.OnCreate(m_hookHelper.Hook); command.OnClick(); } //create a new Map instance IMap map = new MapClass(); map.Name = "��ͼ"; m_mapControl.Map = map; }
public static string CreateJPEGFromActiveView(IRaster pRaster,IEnvelope pEnv,string outurl, System.String pathFileName) { //创建rasterlayer IRasterLayer pRasterLayer = new RasterLayerClass(); //获取mapServer中所有的图层 IMap pMap = new MapClass(); pRasterLayer.CreateFromRaster(pRaster); pMap.AddLayer(pRasterLayer as ILayer); IActiveView activeView = pMap as IActiveView; activeView.Extent = pEnv; //parameter check if (activeView == null) { return null; } string imageName = System.DateTime.Now.ToString().Replace("/", "").Replace(":", "").Replace(" ", "") + ".png"; pathFileName = System.IO.Path.Combine(pathFileName, imageName); ESRI.ArcGIS.Output.IExport export = new ESRI.ArcGIS.Output.ExportPNGClass(); export.ExportFileName = pathFileName; // Microsoft Windows default DPI resolution ESRI.ArcGIS.esriSystem.tagRECT exportRECT = new ESRI.ArcGIS.esriSystem.tagRECT(); exportRECT.top = 0; exportRECT.left = 0; exportRECT.right = 800; exportRECT.bottom = 600; ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass(); envelope.PutCoords(exportRECT.top,exportRECT.left,exportRECT.right,exportRECT.bottom); export.PixelBounds = envelope; System.Int32 hDC = export.StartExporting(); activeView.Output(hDC, (System.Int16)export.Resolution, ref exportRECT, null, null); // Finish writing the export file and cleanup any intermediate files export.FinishExporting(); export.Cleanup(); return outurl + "/" + imageName; }
//点击事件响应函数 public override void OnClick() { IMapControl3 mapControl = null; //如果容器是ToolbatControl,通过hook(钩)获取到MapControl if (m_hookHelper.Hook is IToolbarControl) { mapControl = (IMapControl3)((IToolbarControl)m_hookHelper.Hook).Buddy; } //如果容器是MapControl else if (m_hookHelper.Hook is IMapControl3) { mapControl = (IMapControl3)m_hookHelper.Hook; } else { MessageBox.Show("当前控件必须是MapControl!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //提示用户是否保存当前地图文档 DialogResult res = MessageBox.Show("是否保存当前地图文档?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { //启动保存命令 ICommand command = new ControlsSaveAsDocCommandClass(); command.OnCreate(m_hookHelper.Hook); command.OnClick(); } //创建新Map IMap map = new MapClass(); map.Name = "Map"; //加载新地图 mapControl.DocumentFilename = string.Empty; mapControl.Map = map; }
private void SortLayersByShapeType(ref MapClass map) { }
public static CombatAnimaController GetOrAdd(GameObject gameObject, MapClass role0, MapClass role1) { CombatAnimaController combat = GetOrAdd(gameObject); return(combat == null || !combat.LoadCombatUnit(role0, role1) ? null : combat); }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { if (e.button == 2) { IBasicMap map = new MapClass(); ILayer layer = new FeatureLayerClass(); object other = new object(); object index = new object(); esriTOCControlItem item = new esriTOCControlItem(); try { axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); } catch (Exception eX) { MessageBox.Show(eX.Message); } if (item == esriTOCControlItem.esriTOCControlItemLayer) { if (layer != null) { this.setCurrentLayer(layer); } } } }
public void Reset() { map = new MapClass(); MakeMap(); StartCoroutine(AddPlayer()); }
private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e) { if (e.button == 2) { //鼠标右键按下 if (axMapControl1.LayerCount > 0)//主视图中要有地理数据 { esriTOCControlItem mItem = new esriTOCControlItem(); IBasicMap pMap = new MapClass(); ILayer pLayer = new FeatureLayerClass(); object pOther = new object(); object pIndex = new object(); axTOCControl1.HitTest(e.x, e.y, ref mItem, ref pMap, ref pLayer, ref pOther, ref pIndex); IGeoFeatureLayer pGeoFeatureLayer; pGeoFeatureLayer = pLayer as IGeoFeatureLayer; //添加显示属性表的代码 string layerPath; string layerDatafileName; IWorkspaceName pWorkspaceName; IDatasetName pDatasetName; IDataLayer pDataLayer; pDataLayer = pGeoFeatureLayer as IDataLayer; pDatasetName = pDataLayer.DataSourceName as IDatasetName; pWorkspaceName = pDatasetName.WorkspaceName; layerPath = pWorkspaceName.PathName; layerDatafileName = pLayer.Name.Trim() + ".dbf"; string dbfFilePath = layerPath;; string dbfFileName = layerDatafileName;; IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass(); IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(dbfFilePath, 0); IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace; if (pFeatureWorkspace != null) { IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass(dbfFileName); if (pFeatureClass != null) { DataTable dt = new DataTable(); DataColumn dc; for (int i = 0; i <= pFeatureClass.Fields.FieldCount - 1; i++) { dc = new DataColumn(pFeatureClass.Fields.get_Field(i).Name); dt.Columns.Add(dc); } IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false); IFeature pFeature = pFeatureCursor.NextFeature(); DataRow dr; while (pFeature != null) { dr = dt.NewRow(); for (int j = 0; j <= pFeatureClass.Fields.FieldCount - 1; j++) { if (pFeatureClass.FindField(pFeatureClass.ShapeFieldName) == j) { dr[j] = pFeatureClass.ShapeType.ToString(); } else { dr[j] = pFeature.get_Value(j).ToString(); } } dt.Rows.Add(dr); pFeature = pFeatureCursor.NextFeature(); } GeoMapAttribute frmTable = new GeoMapAttribute(); frmTable.Show(); frmTable.dataGridView1.DataSource = dt; } } } } }
/// <summary> /// 初始化战斗双方 /// </summary> /// <param name="mapClass0"></param> /// <param name="mapClass1"></param> /// <returns></returns> public bool LoadCombatUnit(MapClass mapClass0, MapClass mapClass1) { return(combat.LoadCombatUnit(mapClass0, mapClass1)); }
public override void OnClick() { if (m_Hook == null) { return; } //LogFile log = new LogFile(m_Hook.tipRichBox, m_Hook.strLogFilePath); //if (log != null) //{ // log.Writelog("导入范围出图"); //} if (m_Hook.ArcGisMapControl.Map.LayerCount == 0) { MessageBox.Show("当前没有调阅数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } try { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "个人数据库(*.mdb)|*.mdb|shp数据|*.shp|文本文件|*.txt"; if (dlg.ShowDialog() == DialogResult.Cancel) { return; } IPolygon pGon = new PolygonClass(); pGon = GetPolyGonFromFile(dlg.FileName); if (pGon == null) { return; } if (this.WriteLog) { Plugin.LogTable.Writelog("总体规划图"); } IFeatureClass xzq_xianFC = ModGetData.GetXZQFC("//City"); if (xzq_xianFC == null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未找到相应的行政区图层!"); return; } string xzqdmFD = ModGetData.GetXZQFd("//City"); if (xzqdmFD == null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未找到相应的行政区配置文件的行政区代码字段名称!"); return; } List <string> lstName = getXZQMC(pGon as IGeometry, xzq_xianFC, xzqdmFD); if (lstName == null || lstName.Count == 0) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "行政区配置无效或导入的范围非本地范围。"); return; } IMap pMap = null; bool isSpecial = ModGetData.IsMapSpecial(); if (isSpecial) { pMap = new MapClass(); foreach (string xzq in lstName) { ModGetData.AddMapOfByXZQ(pMap, "ZTGH", "", m_Hook.ArcGisMapControl.Map, xzq); } if (pMap.LayerCount == 0) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未找到总体规划专题!请加载改专题图层。"); return; } ModuleMap.LayersComposeEx(pMap);//图层排序 } else { IObjectCopy pOC = new ObjectCopyClass(); pMap = pOC.Copy(m_Hook.ArcGisMapControl.Map) as IMap; //复制地图 } pGon.SpatialReference = pMap.SpatialReference; //须赋给一致的空间参考 ITopologicalOperator pTopo = pGon as ITopologicalOperator; if (pTopo != null) { pTopo.Simplify(); } drawgeometryXOR(pGon, m_pScreenDisplay); //addGeometryEle(pGon); //GeoDataCenterFunLib.CProgress pgss = new GeoDataCenterFunLib.CProgress("正在加载制图界面,请稍候..."); //pgss.EnableCancel = false; //pgss.ShowDescription = false; //pgss.FakeProgress = true; //pgss.TopMost = true; //pgss.ShowProgress(); //Application.DoEvents(); fmPageLayout = new FrmPageLayout(pMap, pGon as IGeometry, false); //pgss.Close(); fmPageLayout.WriteLog = WriteLog;//ygc 2012-9-12 是否写日志 fmPageLayout.FormClosed += new FormClosedEventHandler(fmPageLayout_FormClosed); fmPageLayout.Show(); Application.DoEvents(); } catch (Exception ex) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", ex.Message); } //gpl = new GeoPageLayout.GeoPageLayout(pMap, pGon as ESRI.ArcGIS.Geometry.IGeometry); //gpl.typePageLayout = 2; //gpl.MapOut(); //gpl = null; //m_Hook.MapControl.ActiveView.Refresh(); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { if (m_hookHelper.Hook == null) { return; } //IFeatureLayer tmpFeatureLayer = layerCurSeleted(); //if (tmpFeatureLayer == null) //{ // MessageBox.Show("请在地图目录设置当前选择图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} try { IMap pMap = null; bool isSpecial = ModGetData.IsMapSpecial(); if (isSpecial)//如果找特定专题 { pMap = new MapClass(); pMap.SpatialReference = m_hookHelper.FocusMap.SpatialReference; ModGetData.AddMapOfNoneXZQ(pMap, "CZDJ", m_hookHelper.FocusMap); ModGetData.AddMapOfNoneXZQ(pMap, "DLGK", m_hookHelper.FocusMap); if (pMap.LayerCount == 0) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未找到图层。"); return; } ModuleMap.LayersComposeEx(pMap);//图层排序 } else { IObjectCopy pOC = new ObjectCopyClass(); pMap = pOC.Copy(m_hookHelper.FocusMap) as IMap;//复制地图 } pMap.Name = "宗地图"; ILayer ZD = getLayer(pMap, "CZDJ_ZD"); ILayer JZD = getLayer(pMap, "CZDJ_JZD"); ILayer JZX = getLayer(pMap, "CZDJ_JZX"); //IMap JZDXmap = new MapClass();//界址点线地图 //pMap.DeleteLayer(JZD); //pMap.DeleteLayer(JZX); //JZDXmap.AddLayer(JZX); //JZDXmap.AddLayer(JZD); //JZDXmap.Name ="界址数据"; //IMaps newMaps = new Maps(); //newMaps.Add(pMap); //newMaps.Add(JZDXmap); IFeatureLayer pFL = ZD as IFeatureLayer; if (pFL == null || pFL.FeatureClass == null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未找到图层!请加载宗地图层。"); return; } //获得选择要素的图形 List <IGeometry> vTemp = GetDataGeometry(ZD as IFeatureLayer); if (vTemp == null || vTemp.Count == 0) { return; } IFeatureClass zdFC = pFL.FeatureClass; string OID = zdFC.OIDFieldName; IFeatureLayerDefinition pFLD = pFL as IFeatureLayerDefinition; pFLD.DefinitionExpression = OID + " = " + pZD.OID; delSelOfLyr(ZD); pMap.ClearSelection(); //清楚选择集 try //空间过滤显示 { filterLyrBySpatial(JZD, pZD.ShapeCopy); filterLyrBySpatial(JZX, pZD.ShapeCopy); } catch { } //if (m_hookHelper.FocusMap.SelectionCount > 100) //int ooo = m_hookHelper.FocusMap.SelectionCount; SysCommon.CProgress pgss = new SysCommon.CProgress("正在加载制图界面,请稍候..."); pgss.EnableCancel = false; pgss.ShowDescription = false; pgss.FakeProgress = true; pgss.TopMost = true; pgss.ShowProgress(); //ITopologicalOperator pTO = GetUnion(vTemp) as ITopologicalOperator; ESRI.ArcGIS.Geometry.IGeometry pGeometry = GetUnion(vTemp); IEnvelope extent = pGeometry.Envelope; //if (extent.Width > extent.Height) //extent.Expand((2 *extent.Width*0.8)/extent.Height, 2, false); extent.Expand(2, 2, true);//出图范围暂设为宗地的2倍 //m_hookHelper.ActiveView.Extent=pGeometry.Envelope; //m_hookHelper.ActiveView.Refresh(); pgss.Close(); Application.DoEvents(); drawgeometryXOR(extent, m_pScreenDisplay); frm = new FrmPageLayout(pMap, extent, pZD); frm.WriteLog = WriteLog;//ygc 2012-9-12 是否写日志 frm.FormClosed += new FormClosedEventHandler(frm_FormClosed); frm.typeZHT = 2; frm.Show(); Application.DoEvents(); } catch (Exception exError) { ErrorHandle.ShowFrmErrorHandle("提示", exError.Message); } }
private void btnOK_Click(object sender, EventArgs e) { if (txtMapNo.Text == "" || cBoxScale.Text == "") { return; } this.Hide(); if (this.WriteLog) { Plugin.LogTable.Writelog("选择比例尺为:" + cBoxScale.Text + ",图幅号为:" + txtMapNo.Text); } MapNo = txtMapNo.Text; Scale = Convert.ToInt32(cBoxScale.Text.Split(':')[1]); string scaleDM = ModGetData.GetDMofScale("1:" + Scale.ToString()); if (scaleDM == "") { return; } IMap pMap = null; int type = 0; bool isSpecial = ModGetData.IsMapSpecial(); if (sheetType == SheetType.foundationTerrain) { type = 0; if (isSpecial)//如果找特定专题 { pMap = new MapClass(); pMap.SpatialReference = pAxMapControl.Map.SpatialReference; ModGetData.AddMapOfNoneXZQ(pMap, "DLG" + scaleDM, pAxMapControl.Map); if (pMap.LayerCount == 0) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未找到图层。"); goto CloseFrm; } ModuleMap.LayersComposeEx(pMap);//图层排序 } else { IObjectCopy pOC = new ObjectCopyClass(); pMap = pOC.Copy(pAxMapControl.Map) as IMap;//复制地图 } GeoPageLayout pPageLayout = new GeoPageLayout(pMap, MapNo, Scale, pPt, type); pPageLayout.WriteLog = WriteLog;//ygc 2012-9-12 是否写日志 pPageLayout.typePageLayout = 3; pPageLayout.MapOut(); pPageLayout = null; } else if (sheetType == SheetType.urbanCadastre) { type = 2; if (isSpecial)//如果找特定专题 { pMap = new MapClass(); pMap.SpatialReference = pAxMapControl.Map.SpatialReference; ModGetData.AddMapOfNoneXZQ(pMap, "CZDJ", pAxMapControl.Map);//寻找专题 ModGetData.AddMapOfNoneXZQ(pMap, "DLG" + scaleDM, pAxMapControl.Map); if (pMap.LayerCount == 0) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未找到图层。"); goto CloseFrm; } ModuleMap.LayersComposeEx(pMap);//图层排序 } else { IObjectCopy pOC = new ObjectCopyClass(); pMap = pOC.Copy(pAxMapControl.Map) as IMap; //复制地图 } ModuleMap.LayersComposeEx(pMap); //图层排序 GeoPageLayout pPageLayout = new GeoPageLayout(pMap, MapNo, Scale, pPt, type); pPageLayout.WriteLog = WriteLog;//ygc 2012-9-12 是否写日志 pPageLayout.typePageLayout = 3; pPageLayout.MapOut(); pPageLayout = null; } //BzffOutMap cmdBZTF = new BzffOutMap(MapNo, Scale,pPt);// //cmdBZTF.OnCreate(hook); //cmdBZTF.OnClick(); CloseFrm: this.Close(); }
private void GeneratePageLayout() { IPageLayout pageLayout = axPageLayoutControl1.PageLayout; IGraphicsContainer pGraphicsContainer = pageLayout as IGraphicsContainer; pGraphicsContainer.DeleteAllElements(); IPage pPage = new PageClass(); pPage = pageLayout.Page; pPage.PutCustomSize(36, 24); IActiveView pActiveView = pageLayout as IActiveView; IMap pMap = pActiveView.FocusMap; IMapFrame mapFrame1 = pGraphicsContainer.FindFrame(pMap) as IMapFrame; IEnvelope pEnvelope = new EnvelopeClass(); pEnvelope.PutCoords(1.5, 3, 17.5, 20); IElement pElement = mapFrame1 as IElement; pElement.Geometry = pEnvelope; //Map frame 2 IMap mapDF1 = new MapClass(); IMapFrame mapFrame2 = new MapFrameClass(); mapFrame2.Map = mapDF1; IElement element1 = mapFrame2 as IElement; IEnvelope envelope1 = new EnvelopeClass(); envelope1.PutCoords(18.5, 3, 34.5, 20); element1.Geometry = envelope1; //?????element 1 or bot map always hide??? pGraphicsContainer.AddElement(element1, 0); //# //////add map---problem shot //mapFrame1.Map = m_MapControltop.ActiveView.FocusMap; //mapFrame2.Map = m_MapControlbase.ActiveView.FocusMap; //# //TRY to use ObjectCopy //copy map to top mapframe of pagelayoutcontrol IObjectCopy objectCopy1 = new ObjectCopyClass(); object toCopyMap1 = m_MapControltop.ActiveView.FocusMap; //IMap map1 = toCopyMap1 as IMap; //map1.IsFramed = true; object copiedMap1 = objectCopy1.Copy(toCopyMap1); object toOverwriteMap1 = mapFrame1.Map; objectCopy1.Overwrite(copiedMap1, ref toOverwriteMap1); //SetMapExtent1(); //copy map to bot mapframe of pagelayoutcontrol IObjectCopy objectCopy2 = new ObjectCopyClass(); object toCopyMap2 = m_MapControlbase.ActiveView.FocusMap; object copiedMap2 = objectCopy2.Copy(toCopyMap2); object toOverwriteMap2 = mapFrame2.Map; objectCopy2.Overwrite(copiedMap2, ref toOverwriteMap2); mapFrame1.Map.Name = "MapTop"; mapFrame2.Map.Name = "MapBot"; //try to change scale IGraphicsContainer container = this.axPageLayoutControl1.GraphicsContainer; container.Reset(); IElement element = container.Next(); int index = 0; while (element != null) { if (element is IMapFrame) { IMapFrame mapFrame = (IMapFrame)element; string sMapName = mapFrame.Map.Name; IElementProperties elementProperties = (IElementProperties)element; string slementName = elementProperties.Name; index += 1; } element = container.Next(); } //add title ITextElement teTitle = new TextElementClass(); IPoint ptTitle = new PointClass(); ptTitle.PutCoords(18, 22.5); IElement eleTitle = teTitle as IElement; eleTitle = MakeATextElement(ptTitle, tbStNum.Text + " " + tbStNa.Text + " Historical Aerial Comparison", 80); pGraphicsContainer.AddElement(eleTitle, 0); string topYear = cboTopYear.Text; string botYear = cboBotYear.Text; //Add subtitle ITextElement teSubTitle1 = new TextElementClass(); IPoint ptSubTitle1 = new PointClass(); ptSubTitle1.PutCoords(9.5, 21); IElement eleSubTitle1 = teSubTitle1 as IElement; eleSubTitle1 = MakeATextElement(ptSubTitle1, topYear, 45); pGraphicsContainer.AddElement(eleSubTitle1, 0); //Add Subtitle2 ITextElement teSubTitle2 = new TextElementClass(); IPoint ptSubTitle2 = new PointClass(); ptSubTitle2.PutCoords(26.5, 21); IElement eleSubTitle2 = teSubTitle2 as IElement; eleSubTitle2 = MakeATextElement(ptSubTitle2, botYear, 45); pGraphicsContainer.AddElement(eleSubTitle2, 0); //Add Scale Bar AddScaleBar(mapFrame1.Map); //Add North Arrow AddNorthArrow(axPageLayoutControl1.PageLayout, mapFrame1.Map); axPageLayoutControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); MessageBox.Show("Done!"); }
private void Start() { if (m_Map == null) { m_Map = GameObject.FindObjectOfType <MapGraph>(); } if (m_Map == null) { Debug.LogError("EditorTestCombat -> Map was not found."); return; } //m_Combat = m_Map.gameObject.GetComponent<Combat>(); //if (m_Combat == null) //{ // m_Combat = m_Map.gameObject.AddComponent<Combat>(); //} m_CombatAnimaController = Combat.GetOrAdd(m_Map.gameObject); m_CombatAnimaController.onPlay.AddListener(CombatAnimaController_onPlay); m_CombatAnimaController.onStop.AddListener(CombatAnimaController_onStop); m_CombatAnimaController.onStep.AddListener(CombatAnimaController_onStep); m_Map.InitMap(); if (m_TestClassPrefab == null) { Debug.LogError("EditorTestCombat -> Class Prefab is null."); return; } m_TestClass1 = m_Map.CreateMapObject(m_TestClassPrefab, new Vector3Int(5, 5, 0)) as MapClass; m_TestClass2 = m_Map.CreateMapObject(m_TestClassPrefab, new Vector3Int(6, 5, 0)) as MapClass; if (!m_TestClass1.Load(0, RoleType.Unique) || !m_TestClass2.Load(1, RoleType.Unique)) { Debug.LogError("EditorTestCombat -> Load role Error."); return; } ItemModel model = ModelManager.models.Get <ItemModel>(); m_TestClass1.role.AddItem(model.CreateItem(0)); m_TestClass2.role.AddItem(model.CreateItem(1)); //Debug.LogFormat("{0}.hp = {1}, {0}.atk = {4}, {2}.hp = {3}, {2}.atk = {5}", // m_TestClass1.role.character.info.name, // m_TestClass1.role.hp, // m_TestClass2.role.character.info.name, // m_TestClass2.role.hp, // m_TestClass1.role.attack, // m_TestClass2.role.attack); //m_Combat.LoadCombatUnit(m_TestClass1, m_TestClass2); //m_Combat.BattleBegin(); //for (int i = 0; i < m_Combat.stepCount; i++) //{ // CombatVariable var0 = m_Combat.steps[i].atkVal; // CombatVariable var1 = m_Combat.steps[i].defVal; // Debug.LogFormat("({4}) -> Animation Type: ({0}, {1}), ({2}, {3})", // var0.position.ToString(), // var0.animaType.ToString(), // var1.position.ToString(), // var1.animaType.ToString(), // i); //} //m_Combat.BattleEnd(); //Debug.LogFormat("{0}.hp = {1}, {2}.hp = {3}", // m_TestClass1.role.character.info.name, // m_TestClass1.role.hp, // m_TestClass2.role.character.info.name, // m_TestClass2.role.hp); ReloadCombat(); }
public void OnClick() { // TODO: Add CreateNewDocument.OnClick implementation DialogResult res = MessageBox.Show("Would you like to save the current document?", "AoView", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { //launch the save command (why work hard!?) cmd = new ControlsSaveAsDocCommandClass(); cmd.OnCreate(this.hk.MapControl); cmd.OnClick(); } //craete a new Map IMap map = new MapClass(); map.Name = "Map"; //assign the new map to the MapControl m_mapControl.DocumentFilename = string.Empty; m_mapControl.Map = map; }
/// <summary> /// Create a new Map, add it to the collection and return it to the caller /// </summary> /// <returns></returns> public IMap Create() { IMap newMap = new MapClass(); m_array.Add(newMap); return(newMap); }
public static MapClass Read(BinaryReader reader) { MapClass result = new MapClass(); result.ClassId = Utilities.Read7BitEncodedInt(reader); result.IsValueType = Utilities.Read7BitEncodedInt(reader) != 0; result.Name = reader.ReadString(); return result; }
private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e) { //Exit if not right mouse button if (e.button != 2) return; IBasicMap map = new MapClass(); ILayer layer = new FeatureLayerClass(); object other = new Object(); object index = new Object(); esriTOCControlItem item = new esriTOCControlItem(); //Determine what kind of item has been clicked on axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //QI to IFeatureLayer and IGeoFeatuerLayer interface if (layer == null) return; IFeatureLayer featureLayer = layer as IFeatureLayer; if (featureLayer == null) return; IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer) featureLayer; ISimpleRenderer simpleRenderer = (ISimpleRenderer) geoFeatureLayer.Renderer; //Create the form with the SymbologyControl frmSymbol symbolForm = new frmSymbol(); //Get the IStyleGalleryItem IStyleGalleryItem styleGalleryItem = null; //Select SymbologyStyleClass based upon feature type switch (featureLayer.FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassMarkerSymbols, simpleRenderer.Symbol); break; case esriGeometryType.esriGeometryPolyline: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassLineSymbols, simpleRenderer.Symbol); break; case esriGeometryType.esriGeometryPolygon: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassFillSymbols, simpleRenderer.Symbol); break; } //Release the form symbolForm.Dispose(); this.Activate(); if (styleGalleryItem == null) return; //Create a new renderer simpleRenderer = new SimpleRendererClass(); //Set its symbol from the styleGalleryItem simpleRenderer.Symbol = (ISymbol) styleGalleryItem.Item; //Set the renderer into the geoFeatureLayer geoFeatureLayer.Renderer = (IFeatureRenderer) simpleRenderer; //Fire contents changed event that the TOCControl listens to axPageLayoutControl1.ActiveView.ContentsChanged(); //Refresh the display axPageLayoutControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null); }
/// <summary> /// bind the MapControl and PageLayoutControl together by assigning a new joint focus map /// </summary> /// <param name="activateMapFirst">true if the MapControl supposed to be activated first</param> public void BindControls(bool activateMapFirst) { if (m_pageLayoutControl == null || m_mapControl == null) throw new Exception("ControlsSynchronizer::BindControls:\r\nEither MapControl or PageLayoutControl are not initialized!"); //create a new instance of IMap IMap newMap = new MapClass(); newMap.Name = "Map"; //create a new instance of IMaps collection which is needed by the PageLayout IMaps maps = new Maps(); //add the new Map instance to the Maps collection maps.Add(newMap); //call replace map on the PageLayout in order to replace the focus map m_pageLayoutControl.PageLayout.ReplaceMaps(maps); //assign the new map to the MapControl m_mapControl.Map = newMap; //reset the active tools m_pageLayoutActiveTool = null; m_mapActiveTool = null; //make sure that the last active control is activated if (activateMapFirst) this.ActivateMap(); else this.ActivatePageLayout(); }
private void btnOK_Click(object sender, EventArgs e) { if (txtMapNo.Text == "" || cBoxScale.Text == "") { return; } this.Hide(); try { if (this.WriteLog) { Plugin.LogTable.Writelog("选择比例尺为:" + cBoxScale.Text + ",图幅号为:" + txtMapNo.Text); } MapNo = txtMapNo.Text; Scale = Convert.ToInt32(cBoxScale.Text.Split(':')[1]); IMap pMap = null; bool isSpecial = ModGetData.IsMapSpecial(); if (isSpecial) { pMap = new MapClass(); List <string> lstName = getXZQMC(); if (lstName == null || lstName.Count == 0) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "行政区配置无效或图幅号非本地范围。"); return; } foreach (string xzq in lstName) { string resXzq = xzq; ModGetData.AddMapOfByXZQ(pMap, "TDLY", cBoxZT.Text, pAxMapControl.Map, resXzq); } if (pMap.LayerCount == 0) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未找到图层。"); return; } ModuleMap.LayersComposeEx(pMap);//图层排序 } else { IObjectCopy pOC = new ObjectCopyClass(); pMap = pOC.Copy(pAxMapControl.Map) as IMap;//复制地图 } //BzffOutMap_ZT cmdBZTF = new BzffOutMap_ZT(MapNo, Scale,pPt,pMap);// GeoPageLayout pPageLayout = new GeoPageLayout(pMap, MapNo, Scale, pPt, 1); pPageLayout.WriteLog = WriteLog;//ygc 2012-9-12 是否写日志 pPageLayout.typePageLayout = 3; pPageLayout.MapOut(); pPageLayout = null; } catch { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请输入正确的图幅号,如G49G077090."); } finally { this.Close(); } }
IEnumerator LoadBattle() { Debug.Log("Loading..."); // Sort the load order for the game to ensure systems load in correct order // TODO: Find more elegant and comprehensive solution // // Find Scene-inbetweener-thing TeamSO playerTeam = null; MissionClassSO thisMission = null; if (GameObject.FindWithTag("GameStatus") != null) { if (GameStatus.playerTeam != null) { playerTeam = GameStatus.playerTeam; } if (GameStatus.mission != null) { thisMission = GameStatus.mission; } if (thisMission != null) { mission = thisMission; } if (playerTeam != null) { UnitManager.instance.teamA = playerTeam; } Debug.Log("Test Success! Loaded from memory"); } // Mission if (mission != null) { if (mission.map != null) { testMap = mission.map; } if (mission.enemies != null) { UnitManager.instance.teamB = mission.enemies; } } // Grid if (testMap != null) { Debug.Log("Test Success! Map loading..."); yield return(StartCoroutine(GridClass.instance.LoadGrid(testMap))); } else { yield return(StartCoroutine(GridClass.instance.LoadGrid())); } // Units Debug.Log("Units: loading..."); yield return(StartCoroutine(UnitManager.instance.Load())); // Intro // This section is for making some cool battle intro. Naturally, this will likely go unused yield return(StartCoroutine(UIManager.instance.Intro())); //TODO: animation //UI yield return(null); UIManager.instance.Load(); // Controller settings StartSettings(); }
/* * OnMouseDown(): called when the sector is clicked. * It handles the logic behind selecting which action to be taken (Attack, Movement or sector Highlighting) * depending on if another sector is selected, whether the turn is on an Attacking or Movement phase, * and the ownership of the current sector compared to the original. */ void OnMouseDown() { if (Input.GetMouseButtonDown(0)) { MapClass map = GameObject.Find("Map").GetComponent <MapClass> (); GameObject originalSector = map.getSelectedSector(); if (originalSector != null) { if (this.adjacent_sectors.Contains(originalSector)) { Sector originalSectorClass = originalSector.GetComponent <Sector> (); if (this.owner == originalSectorClass.Owner && GameClass.GameState == GameClass.MOVEMENT) { //Move Gang members from originalSector to currentSector (this). print("Move gang members from " + originalSector.name + " to " + name); map.deselectAll(); } else if (this.owner != originalSectorClass.Owner && GameClass.GameState == GameClass.ATTACK) { //Attack from originalSector to currentSector (this). print("Attack " + name + " from " + originalSector.name); map.Combat(originalSector, this.gameObject); map.deselectAll(); } } } else { if (this.owner == GameClass.CurrentPlayer) { int sectorsHighlighted = 0; foreach (GameObject adjSect in adjacent_sectors) { if (GameClass.GameState == GameClass.MOVEMENT) { if (adjSect.GetComponent <Sector> ().Owner == this.owner) { adjSect.GetComponent <SpriteRenderer> ().color = new Color(1, 1, 1, 1); sectorsHighlighted++; } } else { if (adjSect.GetComponent <Sector> ().Owner != this.owner) { adjSect.GetComponent <SpriteRenderer> ().color = new Color(1, 0, 0, 1); sectorsHighlighted++; } } } if (sectorsHighlighted > 0) { SpriteRenderer sprite = GetComponent <SpriteRenderer> (); sprite.color = new Color(0, 0, 0, 1); this.selected = true; } else { // No valid moves from clicked sector //print("No valid moves from clicked sector"); } } } } }
/// <summary> /// Create Bitmap From ESRI Dataset /// </summary> /// <param name="dataset">Dataset to generate an image from</param> /// <param name="imageFormat">Output image format</param> /// <param name="size">Size of output image</param> /// <param name="resolution">Resolution of output image (dpi)</param> /// <param name="background">Background color</param> /// <param name="filename">Ouput filename</param> public static void CreateBitmap(IDataset dataset, esriImageFormat imageFormat, Size size, ushort resolution, Color background, string filename) { ILayer layer = null; switch (dataset.Type) { case esriDatasetType.esriDTFeatureClass: IFeatureClass featureClass = (IFeatureClass)dataset; switch (featureClass.FeatureType) { case esriFeatureType.esriFTDimension: layer = new DimensionLayerClass(); break; case esriFeatureType.esriFTAnnotation: layer = new FeatureLayerClass(); IGeoFeatureLayer geoFeaureLayer = (IGeoFeatureLayer)layer; geoFeaureLayer.DisplayAnnotation = true; break; case esriFeatureType.esriFTComplexEdge: case esriFeatureType.esriFTComplexJunction: case esriFeatureType.esriFTSimple: case esriFeatureType.esriFTSimpleEdge: case esriFeatureType.esriFTSimpleJunction: layer = new FeatureLayerClass(); break; } if (layer == null) { return; } IFeatureLayer featureLayer = (IFeatureLayer)layer; featureLayer.FeatureClass = featureClass; break; case esriDatasetType.esriDTRasterDataset: layer = new RasterLayerClass(); IRasterLayer rasterLayer = (IRasterLayer)layer; rasterLayer.CreateFromDataset((IRasterDataset)dataset); break; default: string message = string.Format("[{0}] is not supported", dataset.Type.ToString()); throw new Exception(message); } if (layer == null) { return; } // Create In-memory Map IMap map = new MapClass(); map.AddLayer(layer); IActiveView activeView = (IActiveView)map; IExport export = null; tagRECT rect = new tagRECT(); // Set Format Specific Properties switch (imageFormat) { case esriImageFormat.esriImageJPG: export = new ExportJPEGClass(); IExportJPEG exportJpeg = (IExportJPEG)export; exportJpeg.ProgressiveMode = false; exportJpeg.Quality = 100; break; default: throw new Exception("[" + imageFormat.ToString() + "] is not supported"); } if (export == null) { throw new Exception("Failed to Created Exporter"); } // Set Background if ((export is IExportBMP) || (export is IExportGIF) || (export is IExportJPEG) || (export is IExportPNG) || (export is IExportTIFF)) { IExportImage exportImage = (IExportImage)export; exportImage.ImageType = esriExportImageType.esriExportImageTypeTrueColor; exportImage.BackgroundColor = GeodatabaseUtility.ToESRIColor(background); } // Set Export Frame rect = activeView.ExportFrame; rect.left = 0; rect.top = 0; rect.right = size.Width; rect.bottom = size.Height; // Set Output Extent IEnvelope envelope = new EnvelopeClass(); envelope.PutCoords(rect.left, rect.top, rect.right, rect.bottom); export.PixelBounds = envelope; export.Resolution = resolution; export.ExportFileName = filename; // Export map to image int intHdc = export.StartExporting(); activeView.Output(intHdc, resolution, ref rect, null, null); export.FinishExporting(); export.Cleanup(); // Clear Layers map.ClearLayers(); // Release COM Objects GeodatabaseUtility.ReleaseComObject(layer); GeodatabaseUtility.ReleaseComObject(envelope); GeodatabaseUtility.ReleaseComObject(map); GeodatabaseUtility.ReleaseComObject(activeView); GeodatabaseUtility.ReleaseComObject(export); GC.Collect(); GC.WaitForPendingFinalizers(); }
/// <summary> /// ��MapControl��PageLayoutControlͨ��ͬһ������Map���а� /// </summary> /// <param name="activateMapFirst">���MapControl��ΪĬ�ϻ�ؼ�����ΪTrue</param> public void BindControls(bool activateMapFirst) { if (m_pageLayoutControl == null || m_mapControl == null) throw new Exception("ControlsSynchronizer::BindControls:\r\nMapControl��PageLayoutControlû�г�ʼ��!"); if (m_mapControl.Map.LayerCount == 0) { //����һ��Map���� IMap newMap = new MapClass(); newMap.Name = "��ͼ"; //����һ����ͼ����IMaps���� IMaps maps = new Maps(); maps.Add(newMap); m_pageLayoutControl.PageLayout.ReplaceMaps(maps); m_mapControl.Map = newMap; if (activateMapFirst) this.ActivateMap(); else this.ActivatePageLayout(); } else { //����һ��Map���� IMap newMap = new MapClass(); newMap.Name = "��ͼ"; for (int i = 0; i < m_mapControl.Map.LayerCount; i++) { newMap.AddLayer(m_mapControl.Map.get_Layer(i)); } //m_mapControl.Map = null; //����һ����ͼ����IMaps���� IMaps maps = new Maps(); maps.Add(newMap); m_pageLayoutControl.PageLayout.ReplaceMaps(maps); m_mapControl.Map = newMap; if (activateMapFirst) this.ActivateMap(); else this.ActivatePageLayout(); } }
/// <summary> /// bind the MapControl and PageLayoutControl together by assigning a new joint focus map /// 指定共同的Map来把MapControl和PageLayoutControl绑在一起 /// </summary> /// <param name="activateMapFirst">true if the MapControl supposed to be activated first,如果MapControl被首先激活,则为true</param> public void BindControls(bool activateMapFirst) { if (m_pageLayoutControl == null || m_mapControl == null) { throw new Exception("ControlsSynchronizer::BindControls:\r\nEither MapControl or PageLayoutControl are not initialized!"); } //create a new instance of IMap //创造IMap的一个实例 IMap newMap = new MapClass(); newMap.Name = "Map"; //create a new instance of IMaps collection which is needed by the PageLayout //创造一个新的IMaps collection的实例,这是PageLayout所需要的 IMaps maps = new Maps(); //add the new Map instance to the Maps collection //把新的Map实例赋给Maps collection maps.Add(newMap); //call replace map on the PageLayout in order to replace the focus map //调用PageLayout的replace map来置换focus map m_pageLayoutControl.PageLayout.ReplaceMaps(maps); //assign the new map to the MapControl //把新的map赋给MapControl m_mapControl.Map = newMap; //reset the active tools //重设active tools m_pageLayoutActiveTool = null; m_mapActiveTool = null; //make sure that the last active control is activated //确定最后活动的control被激活 if (activateMapFirst) { this.ActivateMap(); } else { this.ActivatePageLayout(); } }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { //Exit if not right mouse button if (e.button != 2) { return; } IBasicMap map = new MapClass(); ILayer layer = new FeatureLayerClass(); object other = new object(); object index = new object(); esriTOCControlItem item = new esriTOCControlItem(); //Determine what kind of item has been clicked on axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //QI to IFeatureLayer and IGeoFeatuerLayer interface if (layer == null) { return; } IFeatureLayer featureLayer = layer as IFeatureLayer; if (featureLayer == null) { return; } IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)featureLayer; ISimpleRenderer simpleRenderer = (ISimpleRenderer)geoFeatureLayer.Renderer; //Create the form with the SymbologyControl frmSymbol symbolForm = new frmSymbol(); //Get the IStyleGalleryItem IStyleGalleryItem styleGalleryItem = null; //Select SymbologyStyleClass based upon feature type switch (featureLayer.FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassMarkerSymbols, simpleRenderer.Symbol); break; case esriGeometryType.esriGeometryPolyline: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassLineSymbols, simpleRenderer.Symbol); break; case esriGeometryType.esriGeometryPolygon: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassFillSymbols, simpleRenderer.Symbol); break; case esriGeometryType.esriGeometryMultipoint: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassMarkerSymbols, simpleRenderer.Symbol); break; } //Release the form symbolForm.Dispose(); this.Activate(); if (styleGalleryItem == null) { return; } //Create a new renderer simpleRenderer = new SimpleRendererClass(); //Set its symbol from the styleGalleryItem simpleRenderer.Symbol = (ISymbol)styleGalleryItem.Item; //Set the renderer into the geoFeatureLayer geoFeatureLayer.Renderer = (IFeatureRenderer)simpleRenderer; //Fire contents changed event that the TOCControl listens to axPageLayoutControl1.ActiveView.ContentsChanged(); //Refresh the display axPageLayoutControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null); }
private void createDataFrame(string sMapName) { try { IMxDocument pMxDoc = (IMxDocument)ArcMap.Document; IMap pMap = new MapClass(); pMap.Name = sMapName; //Dictionary<string, string> dctMapLayers = Dictionary <string, string> dctMapLayers = new Dictionary <string, string>(); switch (sMapName.ToUpper()) { case "ECONOMIC DEVELOPMENT": dctMapLayers = SConst.EconDevLayers; this.loadLayers(ref pMap, dctMapLayers, this.m_EconOnLayers); break; case "FIRE": dctMapLayers = SConst.FireLayers; this.loadLayers(ref pMap, dctMapLayers, this.m_FireOnLayers); break; case "PLANNING": dctMapLayers = SConst.PlanningLayers; this.loadLayers(ref pMap, dctMapLayers, this.m_PlanOnLayers); break; case "POLICE": dctMapLayers = SConst.PoliceLayers; this.loadLayers(ref pMap, dctMapLayers, this.m_PoliceOnLayers); break; case "PUBLIC WORKS": dctMapLayers = SConst.PublicWorksLayers; this.loadLayers(ref pMap, dctMapLayers, this.m_PWOnLayers); break; default: return; } //addMapLayers(ref pMap, sMapName); IEnvelope pEnv = new EnvelopeClass(); pEnv.PutCoords(1, 1, 5, 4); // page units pMxDoc.Maps.Add(pMap); IMapFrame pMapFrame = this.MakeMapFrame(pEnv, pMap); pMapFrame.Map.MapUnits = esriUnits.esriFeet; IGraphicsContainer pGC = (IGraphicsContainer)pMxDoc.PageLayout; pGC.AddElement((IElement)pMapFrame, 0); pMxDoc.CurrentContentsView.Refresh(null); pMxDoc.UpdateContents(); Application.DoEvents(); // activate the frame and zoom to the extent of the UGB for (int i = 0; i < pMxDoc.Maps.Count; i++) { IMap map = pMxDoc.Maps.get_Item(i); if (map.Name == sMapName) { pMxDoc.ActiveView = (IActiveView)map; //Set the query filter. use the arguements passed into the function ESRI.ArcGIS.Geodatabase.IQueryFilter pQueryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); pQueryFilter.WhereClause = "CITY = 'Medford'"; using (CSpatialSubs oSpatialSubs = new CSpatialSubs()) { oSpatialSubs.selectFeatures(pQueryFilter, this.App, (IFeatureLayer)oSpatialSubs.returnFeatureLayer(pMap, "MEDSDE.DBO.Urban_Growth_Boundary"), true); } pMxDoc.FocusMap.ClearSelection(); } } pMxDoc.UpdateContents(); Application.DoEvents(); } catch (Exception ex) { string s = ex.Message; s += ex.InnerException.Message; s += " "; } }
public bool LoadCombatUnit(MapClass mapClass0, MapClass mapClass1) { return(Unit0.Load(mapClass0) && Unit1.Load(mapClass1)); }
/// <summary> /// New Map document menu event handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void menuNewDoc_Click(object sender, System.EventArgs e) { //ask the user whether he'd like to save the current doc DialogResult res = MessageBox.Show("Would you like to save the current document?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { //if yes, launch the SaveAs command ICommand command = new ControlsSaveAsDocCommandClass(); command.OnCreate(m_controlsSynchronizer.PageLayoutControl.Object); command.OnClick(); } // switch to map view tabControl1.SelectedTab = (TabPage)tabControl1.Controls[0]; //create a new Map instance IMap map = new MapClass(); map.Name = "Map"; //replace the shared map with the new Map instance m_controlsSynchronizer.ReplaceMap(map); m_documentFileName = string.Empty; }
void form_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { if (e.Data.GetDataPresent(System.Windows.Forms.DataFormats.FileDrop)) { string[] files = (string[])e.Data.GetData(System.Windows.Forms.DataFormats.FileDrop); if (files != null) { lock (plock) { var file = files[0]; var ext = Path.GetExtension(file).ToUpper(); switch (ext) { //case ".PAL": // MousePalette = new PAL(file); // break; //case ".SHP": //case ".SHA": // MouseFrame = -1; // MouseTextures = new SHP(file); // if (MousePalette == null) { // MousePalette = PAL.GrayscalePalette; // } // MouseTextures.ApplyPalette(MousePalette); // break; //case ".INI": // INIFile = new INI(file); // break; //case ".HVA": // var H = new HVA(file); // Console.WriteLine("Loaded HVA with {0} sections", H.Sections.Count); // break; //case ".VXL": // LoadedVoxels.Clear(); // VoxelFrame = 0; // var body = VoxLib.Create(file); // if (body != null) { // var turname = file.Replace(Path.GetExtension(file), "tur.vxl"); // var turret = VoxLib.Create(turname); // var barlname = file.Replace(Path.GetExtension(file), "barl.vxl"); // var barrel = VoxLib.Create(barlname); // VoxelChanged = true; // LoadedVoxels.Add(body); // if (turret != null) { // LoadedVoxels.Add(turret); // } // if (barrel != null) { // LoadedVoxels.Add(barrel); // } // Console.WriteLine("Loaded VXL with {0} sections", LoadedVoxels.Sum(v => v.Voxel.Sections.Count)); // } // break; case ".YRM": case ".MAP": Map = new MapClass(file); LoadMap(); if (MapTexture != null) { MapTexture.Dispose(); MapTexture = null; } break; //case ".CSF": // var lbl = new CSF(file); // Console.WriteLine("Loaded string table with {0} entries", lbl.Labels.Count); // break; //case ".IDX": // var idx = new IDX(file); // Console.WriteLine("Loaded IDX with {0} samples", idx.Samples.Count); // var bagFile = file.Replace(Path.GetExtension(file), ".BAG"); // if (File.Exists(bagFile)) { // var Bag = new BAG(bagFile); // idx.ReadBAG(Bag); // var soundPlayer = new libZPlay.ZPlay(); // var samplesToExtract = new List<String>() { /*"ichratc", */"ichratta" }; // foreach (var s in samplesToExtract) { // var sample = idx.Samples[s]; // if (sample != null) { // var output = sample.GetWaveHeader().Compile(); // var outFile = Path.GetDirectoryName(file) + Path.DirectorySeparatorChar + sample.Name + ".WAV"; // using (var outWav = File.OpenWrite(outFile)) { // using (var writer = new BinaryWriter(outWav)) { // writer.Write(output); // writer.Flush(); // } // } // if (!soundPlayer.OpenStream(false, false, ref output, (uint)output.Length, libZPlay.TStreamFormat.sfWav)) { // Console.WriteLine("Sound failed: {0}.", soundPlayer.GetError()); // break; // } // if (!soundPlayer.StartPlayback()) { // Console.WriteLine("Sound failed: {0}.", soundPlayer.GetError()); // break; // } // } // } // } // break; } } } } }
public static ILayer GetLayerFromTOCControl(AxTOCControl _axTOCControl) { IBasicMap map = new MapClass(); ILayer layer = new FeatureLayerClass(); object legendGroup = new object(); object index = new object(); esriTOCControlItem item = new esriTOCControlItem(); _axTOCControl.GetSelectedItem(ref item, ref map, ref layer, ref legendGroup, ref index); return layer; }
/// <summary> /// 写入当前切片级别地理坐标系切片 /// </summary> /// <param name="i"></param> /// <param name="tileFileInfo"></param> /// <param name="outPutDir"></param> public static void WriteGeoLevel(int i, TileFileInfo tileFileInfo, string outPutDir) { IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactory(); IWorkspace pWs = workspaceFactory.OpenFromFile(System.IO.Path.GetDirectoryName(tileFileInfo.filePath), 0); IFeatureClass pFeatureClass = (pWs as IFeatureWorkspace).OpenFeatureClass(System.IO.Path.GetFileNameWithoutExtension(tileFileInfo.filePath)); IFeatureLayer featureLayer = new FeatureLayerClass { FeatureClass = pFeatureClass }; IDataset dataSet = (IDataset)pFeatureClass; featureLayer.Name = dataSet.Name; IMap map = new MapClass(); map.AddLayer(featureLayer); IMapControlDefault pMapControl = new MapControlClass(); pMapControl.Map = map; IActiveView pActiveView = pMapControl.ActiveView; tagRECT rect = new tagRECT(); rect.left = rect.top = 0; rect.right = 256; rect.bottom = 256; IExport pExport = null; IEnvelope pEnvelope = new EnvelopeClass(); string temp = i.ToString(); if (temp.Length < 2) { temp = "0" + temp; } System.IO.DirectoryInfo LevelDir = new System.IO.DirectoryInfo(outPutDir).CreateSubdirectory($"L{temp}"); pMapControl.MapScale = TileParam.TileParamProjCoordinateSystem.TileScales[i]; pMapControl.Refresh(); Console.WriteLine($"Level:L{temp}:分辨率{TileParam.TileParamGeoCoordinateSystem.TileResolutions[i]}"); double imageHeighy = TileParam.TileParamGeoCoordinateSystem.TileResolutions[i] * TileParam.TileParamGeoCoordinateSystem.TileSize; for (int dy = 1, iRnum = 0; TileParam.TileOriginGeo.OriginY - imageHeighy * dy > tileFileInfo.MinY - imageHeighy; dy++, iRnum++) { if (TileParam.TileOriginGeo.OriginY - imageHeighy * dy > tileFileInfo.MaxY) { continue; } string tmpy = iRnum.ToString("X"); while (tmpy.Length < 8) { tmpy = "0" + tmpy; } Console.WriteLine($"--行号:R{tmpy}"); System.IO.DirectoryInfo RowDir = LevelDir.CreateSubdirectory($"R{tmpy}"); for (int dx = 1, iCnum = 0; TileParam.TileOriginGeo.OriginX + imageHeighy * dx < tileFileInfo.MaxX + imageHeighy; dx++, iCnum++) { if (TileParam.TileOriginGeo.OriginX + imageHeighy * dx < tileFileInfo.MinX) { continue; } string tmpx = iCnum.ToString("X"); while (tmpx.Length < 8) { tmpx = "0" + tmpx; } try { pEnvelope.PutCoords(TileParam.TileOriginGeo.OriginX + imageHeighy * (dx - 1), TileParam.TileOriginGeo.OriginY - imageHeighy * dy, TileParam.TileOriginGeo.OriginX + imageHeighy * dx, TileParam.TileOriginGeo.OriginY - imageHeighy * (dy - 1)); pExport = ToExporter("PNG"); pExport.ExportFileName = RowDir.FullName + "\\C" + tmpx + ".png"; Console.WriteLine($"----列号:C{tmpx} {pExport.ExportFileName}"); pExport.Resolution = 96; IEnvelope pPixelBoundsEnv = new EnvelopeClass(); pPixelBoundsEnv.PutCoords(rect.left, rect.top, rect.right, rect.bottom); pExport.PixelBounds = pPixelBoundsEnv; //开始导出,获取DC int hDC = pExport.StartExporting(); //导出 pActiveView.Output(hDC, 96, ref rect, pEnvelope, null); //结束导出 pExport.FinishExporting(); //清理导出类 pExport.Cleanup(); RealeaseAO(pExport); RealeaseAO(pPixelBoundsEnv); } catch (Exception ex) { Helpers.ErrorHelper.PrintException(ex); } } } RealeaseAO(workspaceFactory); RealeaseAO(pWs); RealeaseAO(pFeatureClass); RealeaseAO(featureLayer); RealeaseAO(map); RealeaseAO(pMapControl); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { if (m_hookHelper != null) { //TODO: Add Map/PageLayout related logic object hook = null; if (m_hookHelper.Hook is IToolbarControl2) hook = ((IToolbarControl2)m_hookHelper.Hook).Buddy; else hook = m_hookHelper.Hook; IMapControl3 mapControl = hook as IMapControl3; if (mapControl == null) return; // Save the current document DialogResult res = MessageBox.Show("Would you want to save the current document?", "AoView", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if(res==DialogResult.Yes) { ICommand command = new ControlsSaveAsDocCommandClass(); command.OnCreate(m_hookHelper.Hook); command.OnClick(); } // Create a new map IMap map = new MapClass(); map.Name = "map"; mapControl.DocumentFilename = string.Empty; mapControl.Map = map; } else if (m_sceneHookHelper != null) { //TODO: Add Scene related logic } else if (m_globeHookHelper != null) { //TODO: Add Globe related logic } }
//保存 public static void Save(AxMapControl axMapControl) { DialogResult res = MessageBox.Show("是否保存当前地图?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { ICommand pCommand = new ControlsSaveAsDocCommandClass(); if(axMapControl!=null) pCommand.OnCreate(axMapControl.Object); IMap map = new MapClass(); map.Name = "Map"; axMapControl.DocumentFilename = string.Empty; pCommand.OnClick(); } if (axMapControl == null) { return; } }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { IBasicMap map = new MapClass(); ILayer layer = new FeatureLayerClass(); object other = new object(); object index = new object(); esriTOCControlItem item = new esriTOCControlItem(); //Determine what kind of item has been clicked on axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); if (e.button == 1) { //QI to IFeatureLayer and IGeoFeatuerLayer interface if (layer == null) { return; } IFeatureLayer featureLayer = layer as IFeatureLayer; if (featureLayer == null) { return; } IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)featureLayer; ILegendClass legendClass = new LegendClassClass(); ISymbol symbol = null; if (other is ILegendGroup && (int)index != -1) { legendClass = ((ILegendGroup)other).get_Class((int)index); symbol = legendClass.Symbol; } if (symbol == null) { return; } symbol = GetSymbolByControl(symbol); //symbol = GetSymbolBySymbolSelector(symbol); if (symbol == null) { return; } legendClass.Symbol = symbol; this.Activate(); //Fire contents changed event that the TOCControl listens to axMapControl1.ActiveView.ContentsChanged(); //Refresh the display axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null); axTOCControl1.Update(); } if (e.button == 2) { if (item == esriTOCControlItem.esriTOCControlItemMap) { m_mapControl.CustomProperty = map; m_TocMapMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd); } else if (layer is IFeatureLayer) { m_mapControl.CustomProperty = layer; m_TocLayerMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd); } else if (layer is INALayer) { m_mapControl.CustomProperty = layer; if (item == esriTOCControlItem.esriTOCControlItemLayer) { m_menuLayer.PopupMenu(e.x, e.y, axMapControl1.hWnd); ITOCControl toc = axTOCControl1.Object as ITOCControl; toc.Update(); } } } }
void itemopenattribution_Click(object sender, EventArgs e) { IMap pMap = new MapClass(); IFeatureLayer pFeatureLayer = (IFeatureLayer)Global.mainmap.get_Layer(0); IFields pFields = pFeatureLayer.FeatureClass.Fields; DataTable pDataTable = new DataTable(); for (int i = 0; i < pFields.FieldCount; i++) { string fldName; fldName = pFields.get_Field(i).AliasName; pDataTable.Columns.Add(fldName); } IFeatureCursor pFeatureCursor; pFeatureCursor = pFeatureLayer.FeatureClass.Search(null, false); IFeature pFeature; pFeature = pFeatureCursor.NextFeature(); while (pFeature != null) { string fldValue = null; DataRow dr = pDataTable.NewRow(); for (int i = 0; i < pFields.FieldCount; i++) { string fldName; fldName = pFields.get_Field(i).Name; if (fldName == "Shape") { fldValue = Convert.ToString(pFeature.Shape.GeometryType); } else fldValue = Convert.ToString(pFeature.get_Value(i)); dr[i] = fldValue; } pDataTable.Rows.Add(dr); pFeature = pFeatureCursor.NextFeature(); } Global.dgvattribution.DataSource = pDataTable; }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { // DialogResult res = MessageBox.Show("是否保存当前文档?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); // if (res == DialogResult.Yes) // { // ICommand command = new ControlsSaveAsDocCommandClass(); // if (m_mapcontrol != null) // { // command.OnCreate(m_controlsSynchronizer.MapControl.Object); // } // else // { // command.OnCreate(m_controlsSynchronizer.PageLayoutControl.Object); // } // command.OnClick(); // } // IMap map = new MapClass(); // map.Name = "新建地图文档"; // m_controlsSynchronizer.MapControl.DocumentFilename = string.Empty; // m_controlsSynchronizer.ReplaceMap(map); IMapControl3 mapControl = null; //get the MapControl from the hook in case the container is a ToolbatControl if (m_hookHelper.Hook is IToolbarControl) { mapControl = (IMapControl3)((IToolbarControl)m_hookHelper.Hook).Buddy; } //In case the container is MapControl else if (m_hookHelper.Hook is IMapControl3) { mapControl = (IMapControl3)m_hookHelper.Hook; } else { MessageBox.Show("Active control must be MapControl!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //allow the user to save the current document DialogResult res = MessageBox.Show("保存当前文档?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { //launch the save command (why work hard!?) ICommand command = new ControlsSaveAsDocCommandClass(); command.OnCreate(m_hookHelper.Hook); command.OnClick(); } //craete a new Map IMap map = new MapClass(); map.Name = "新建地图文档"; //assign the new map to the MapControl mapControl.DocumentFilename = string.Empty; mapControl.Map = map; }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { IMapControl3 mapControl = null; //get the MapControl from the hook in case the container is a ToolbarControl if (m_hookHelper.Hook is IToolbarControl) { mapControl = (IMapControl3)((IToolbarControl)m_hookHelper.Hook).Buddy; } //In case the container is MapControl else if (m_hookHelper.Hook is IMapControl3) { mapControl = (IMapControl3)m_hookHelper.Hook; } else { MessageBox.Show("Active control must be MapControl!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //check to see if there is an active edit session and whether edits have been made DialogResult result; IEngineEditor engineEditor = new EngineEditorClass(); if ((engineEditor.EditState == esriEngineEditState.esriEngineStateEditing) && (engineEditor.HasEdits() == true)) { result = MessageBox.Show("Would you like to save your edits", "Save Edits", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (result) { case DialogResult.Cancel: return; case DialogResult.No: engineEditor.StopEditing(false); break; case DialogResult.Yes: engineEditor.StopEditing(true); break; } } //allow the user to save the current document DialogResult res = MessageBox.Show("Would you like to save the current document?", "AoView", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { //launch the save command ICommand command = new ControlsSaveAsDocCommandClass(); command.OnCreate(m_hookHelper.Hook); command.OnClick(); } //create a new Map IMap map = new MapClass(); map.Name = "Map"; //assign the new map to the MapControl mapControl.DocumentFilename = string.Empty; mapControl.Map = map; }
public override void OnClick() {//XZQLocation if (_hook == null) return; if (_hook.MainUserControl == null) return; DevComponents.AdvTree.AdvTree xzqTree = _hook.XZQTree; IGeometry xzqGeo = ModGetData.getExtentByXZQ(xzqTree.SelectedNode); if (xzqGeo == null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未找到相应的行政区范围!"); return; } try { Plugin.Application.IAppFormRef pAppFormRef = _AppHk as Plugin.Application.IAppFormRef; if (this.WriteLog) { Plugin.LogTable.Writelog("出" + this._Caption); } IMap pMap = null; bool isSpecial = ModGetData.IsMapSpecial(); if (isSpecial) { pMap = new MapClass(); ModGetData.AddMapOfByXZQ(pMap, "ZTGH", "", _hook.ArcGisMapControl.Map, xzqTree.SelectedNode.Text); if (pMap.LayerCount == 0) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未找到图层。"); return; } ModuleMap.LayersComposeEx(pMap);//图层排序 } else { IObjectCopy pOC = new ObjectCopyClass(); pMap = pOC.Copy(_hook.ArcGisMapControl.Map) as IMap;//复制地图 } if (pMap.LayerCount == 0) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未找到图层。"); return; } string xzqdmFD = ""; //构造晕线和渲染图层 IFeatureClass xzqFC = ModGetData.getFCByXZQ(xzqTree.SelectedNode, ref xzqdmFD); if (xzqFC != null && xzqdmFD != null) { ILayer hachureLyr = GeoPageLayoutFn.createHachureLyr(xzqFC, xzqdmFD, xzqTree.SelectedNode.Name); if (hachureLyr != null) { IMapLayers pMapLayers = pMap as IMapLayers; IGroupLayer pGroupLayer = pMap.get_Layer(0) as IGroupLayer; if (pGroupLayer != null) { pMapLayers.InsertLayerInGroup(pGroupLayer, hachureLyr, false, 0); } } } GeoPageLayout pGL = new GeoPageLayout(); pGL.WriteLog = WriteLog;//ygc 2012-9-12 是否写日志 pGL.pageLayoutZTGHTXQT(pMap, xzqGeo, xzqTree.SelectedNode.Text); } catch(Exception ex) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", ex.Message); } }
/// <summary> /// 将MapControl和PageLayoutControl通过同一个焦点Map进行绑定 /// </summary> /// <param name="activateMapFirst">如果MapControl作为默认活动控件设置为True</param> public void BindControls(bool activateMapFirst) { if (m_pageLayoutControl == null || m_mapControl == null) throw new Exception("ControlsSynchronizer::BindControls:\r\nMapControl或PageLayoutControl没有初始化!"); //产生一个Map对象 //这里需要对引用的carto 设置嵌入互操作类型改为false //解释 http://www.cnblogs.com/pnljs/archive/2012/02/20/2359313.html IMap newMap = new MapClass(); newMap.Name = "图层"; //产生一个地图容器IMaps对象 //这里的maps是自己构建的类用来解决两个控件传入地图参数一个是IMaps一个是IMap实际上前者是后者的集合 IMaps maps = new Maps(); maps.Add(newMap); m_pageLayoutControl.PageLayout.ReplaceMaps(maps); m_mapControl.Map = newMap; ////重设active tools //m_pageLayoutActiveTool = null; //m_mapActiveTool = null; if (activateMapFirst) this.ActivateMap(); else this.ActivatePageLayout(); }
// All instances of Map class have bounds so camera fits them accordingly void SetMap() { map = GameObject.FindGameObjectWithTag("MAP").GetComponent <MapClass>(); xBound = map.getXBound(); yBound = map.getYBound(); }
/// <summary> /// ������Ӧ�ó����ʱ����û�м��ص�ͼ����һ���յĵ�ͼ�����������ؼ��������ͼ����һ���������ܱ���һ�� /// </summary> /// <param name="activateMapFirst">true if the MapControl supposed to be activated first</param> public void BindControls(bool _ActivateMapFirst) { if (pPageLayoutControl == null || pMapControl == null) throw new Exception("ControlsSynchronizer::BindControls:\r\nEither MapControl or PageLayoutControl are not initialized!"); //����һ����ͼʵ�� IMap pNewMap = new MapClass(); pNewMap.Name = "Map"; //����MapsΪ���Ǵ�����һ���࣬��ʾ���ǵ�ͼ�ļ��� IMaps pMaps = new Maps(); //add the new Map instance to the Maps collection pMaps.Add(pNewMap); //call replace map on the PageLayout in order to replace the focus map pPageLayoutControl.PageLayout.ReplaceMaps(pMaps); //assign the new map to the MapControl pMapControl.Map = pNewMap; //reset the active tools pPageLayoutActiveTool = null; pMapActiveTool = null; //make sure that the last active control is activated if (_ActivateMapFirst) this.ActivateMap(); else this.ActivatePageLayout(); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { IMapControl3 mapControl = null; //get the MapControl from the hook in case the container is a ToolbatControl if (m_hookHelper.Hook is IToolbarControl) { mapControl = (IMapControl3)((IToolbarControl)m_hookHelper.Hook).Buddy; } //In case the container is MapControl else if (m_hookHelper.Hook is IMapControl3) { mapControl = (IMapControl3)m_hookHelper.Hook; } else { MessageBox.Show("Active control must be MapControl!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //allow the user to save the current document DialogResult res = MessageBox.Show("Would you like to save the current document?", "AoView", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { //launch the save command (why work hard!?) ICommand command = new ControlsSaveAsDocCommandClass(); command.OnCreate(m_hookHelper.Hook); command.OnClick(); } //create a new Map IMap map = new MapClass(); map.Name = "Map"; //assign the new map to the MapControl mapControl.DocumentFilename = string.Empty; mapControl.Map = map; }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { IBasicMap map = new MapClass(); ILayer layer = new FeatureLayerClass(); // Carto object other = new object(); object index = new object(); esriTOCControlItem item = new esriTOCControlItem(); axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); if (layer != null) { #region 可视化表格 if (!listView_table.Visible) { axMapControl1.Height -= listView_table.Height; listView_table.Visible = true; } #endregion #region 清空可能已有的表格字段和属性列 listView_table.Items.Clear(); listView_table.Columns.Clear(); #endregion // 获取当前点击图层的信息 IFeatureLayer pFeatureLayer = layer as IFeatureLayer; IFields pFields = pFeatureLayer.FeatureClass.Fields; // 循环添加表头信息 for (int i = 0; i < pFields.FieldCount; i++) { this.gis_CreateTableHeader(pFields.Field[i].Name); } // 循环添加要素属性信息 IFeatureCursor pFeatureCursor = pFeatureLayer.FeatureClass.Search(null, false); IFeature pFeature = pFeatureCursor.NextFeature(); while (pFeature != null) { string[] fldVaue = new string[pFields.FieldCount]; // 顺换添加要素中的每个字段信息 for (int i = 0; i < pFields.FieldCount; i++) { string fldName = pFields.get_Field(i).Name; if (fldName == pFeatureLayer.FeatureClass.ShapeFieldName) { // 去除 "esrigeometry"前缀 string type = Convert.ToString(pFeature.Shape.GeometryType).Substring(12); fldVaue[i] = type; } else { fldVaue[i] = Convert.ToString(pFeature.get_Value(i)); // 属性信息 } } ListViewItem lstVwItem = new ListViewItem(fldVaue); listView_table.Items.Add(lstVwItem); pFeature = pFeatureCursor.NextFeature(); // 迭代 } } }
/// <summary> /// ��MapControl��PageLayoutControlͨ��ͬһ������Map���а� /// </summary> /// <param name="activateMapFirst">���MapControl��ΪĬ�ϻ�ؼ�����ΪTrue</param> public void BindControls(bool activateMapFirst) { if (m_pageLayoutControl == null || m_mapControl == null) throw new Exception("ControlsSynchronizer::BindControls:\r\nMapControl��PageLayoutControlû�г�ʼ��!"); //����һ��Map���� IMap newMap = new MapClass(); newMap.Name = "��ͼ"; //����һ����ͼ����IMaps���� IMaps maps = new Maps(); maps.Add(newMap); m_pageLayoutControl.PageLayout.ReplaceMaps(maps); m_mapControl.Map = newMap; if (activateMapFirst) this.ActivateMap(); else this.ActivatePageLayout(); }
public void TestMapException() { MapClass map = new MapClass(); map.GetMap(0, 1, "", ""); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { IMapControl3 mapControl = null; //get the MapControl from the hook in case the container is a ToolbarControl if (getSetHookHelper.Hook is IToolbarControl) { mapControl = (IMapControl3)((IToolbarControl)getSetHookHelper.Hook).Buddy; } //In case the container is MapControl else if (getSetHookHelper.Hook is IMapControl3) { mapControl = (IMapControl3)getSetHookHelper.Hook; } else { MessageBox.Show("Active control must be MapControl!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //check to see if there is an active edit session and whether edits have been made DialogResult result; IEngineEditor engineEditor = new EngineEditorClass(); if ((engineEditor.EditState == esriEngineEditState.esriEngineStateEditing) && (engineEditor.HasEdits() == true)) { result = MessageBox.Show("Would you like to save your edits", "Save Edits", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (result) { case DialogResult.Cancel: return; case DialogResult.No: engineEditor.StopEditing(false); break; case DialogResult.Yes: engineEditor.StopEditing(true); break; } } //allow the user to save the current document DialogResult res = MessageBox.Show("Would you like to save the current document?", "AoView", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { //launch the save command ICommand command = new ControlsSaveAsDocCommandClass(); command.OnCreate(getSetHookHelper.Hook); command.OnClick(); } //create a new Map IMap map = new MapClass(); map.Name = "Map"; //assign the new map to the MapControl mapControl.DocumentFilename = string.Empty; mapControl.Map = map; }
private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e) { if (axMapControl1.LayerCount > 0) { esriTOCControlItem pItem = new esriTOCControlItem(); pGlobalFeatureLayer = new FeatureLayerClass(); IBasicMap pBasicMap = new MapClass(); object pOther = new object(); object pIndex = new object(); axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pBasicMap, ref pGlobalFeatureLayer, ref pOther, ref pIndex); } if (e.button == 2) { context.Show(axTOCControl1, e.x, e.y); } }