/// <summary> /// Read the band and pixelType information. /// </summary> /// <param name="rasterFile">The raster file.</param> /// <param name="bandCount">The band count.</param> /// <param name="pixelType">Type of the pixel.</param> /// <returns><c>true</c> succeed, <c>false</c> failed.</returns> public static bool ReadBandAndPixelInfo(string rasterFile, out int bandCount, out string pixelType) { IRasterLayer pRasterLayer = null; try { pRasterLayer = new RasterLayerClass(); pRasterLayer.CreateFromFilePath(rasterFile); bandCount = pRasterLayer.BandCount; IRaster pRaster = pRasterLayer.Raster; IRasterProps pRasterProps = pRaster as IRasterProps; pixelType = MapAPI.GetPixelType(pRasterProps); return(true); } catch (Exception ex) { XtraMessageBox.Show("读取栅格元数据失败!请检查文件是否损坏:" + rasterFile, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); Log.WriteLog(typeof(MapAPI), ex); bandCount = -1; pixelType = string.Empty; return(false); } finally { if (pRasterLayer != null) { Marshal.ReleaseComObject(pRasterLayer); } } }
/// <summary> /// 初始化主程序类 /// </summary> /// <param name="barList">工具条列表</param> /// <param name="appMenu">开始菜单</param> /// <param name="frameMenu">图框菜单</param> /// <param name="lyrMenu">图层菜单</param> /// <param name="rgbMenu">波段组合菜单</param> /// <param name="layerItem">图层选择控件</param> /// <param name="sptItem">状态栏坐标系</param> /// <param name="xyItem">状态栏坐标</param> /// <param name="rasterItem">状态栏栅格信息</param> /// <param name="swipeItem">卷帘按钮</param> /// <param name="eagleItem">鹰眼按钮</param> /// <param name="dpEagle">鹰眼控件</param> /// <param name="lstRecentFiles">最近历史控件</param> /// <param name="tableContainer">属性表容器</param> public void Initialize(List <Bar> barList, ApplicationMenu appMenu, PopupMenu frameMenu, PopupMenu lyrMenu, PopupMenu rgbMenu, BarEditItem layerItem, BarItem sptItem, BarItem xyItem, BarItem rasterItem, BarItem swipeItem, BarButtonItem eagleItem, DockPanel dpEagle, ImageListBoxControl lstRecentFiles, ControlContainer tableContainer) { MapAPI.NewDocument(); this._barList = barList; this._appMenu = appMenu; this._popMenuFrame = frameMenu; this._popMenuLayer = lyrMenu; this._popMenuRGB = rgbMenu; this._barEditLyList = layerItem; this._barItemSwipe = swipeItem; this._layerEffectProperties = new CommandsEnvironmentClass(); this._barItemSPt = sptItem; this._barItemXY = xyItem; this._barItemRaster = rasterItem; this._barEagle = eagleItem; this._dpEagle = dpEagle; this._lstRecently = lstRecentFiles; //EnviVars.instance.TablePanel = tablePanel; EnviVars.instance.TableContainer = tableContainer; EnviVars.instance.RecentFilesCtrl = lstRecentFiles; history = new TaskHistory(ConstDef.FILE_RENCENTFILES, 5); EnviVars.instance.history = history; history.LoadHistory(); _eagleEye = new MapControlEagle(this._mapControl as IMapControl4, this._mapControlEagle as IMapControl4); this._barEagle.ItemClick += new ItemClickEventHandler(this._barEagle_ItemClick); lstRecentFiles.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lstRecently_MouseClick); this._barEditLyList.EditValueChanged += new EventHandler(this.barEditLyList_EditValueChanged); //绑定工具条按钮事件 IEnumerator enumerator; foreach (Bar current in barList) { enumerator = current.ItemLinks.GetEnumerator(); this.GetContainerCommandList(enumerator); } //绑定开始菜单按钮事件 enumerator = appMenu.ItemLinks.GetEnumerator(); this.GetContainerCommandList(enumerator); //绑定图框菜单按钮事件 enumerator = frameMenu.ItemLinks.GetEnumerator(); this.GetContainerCommandList(enumerator); //绑定图层菜单按钮事件 enumerator = lyrMenu.ItemLinks.GetEnumerator(); this.GetContainerCommandList(enumerator); }
/// <summary> /// Updates the eagle map control. /// </summary> public void UpdateEagleMapControl() { if (EnviVars.instance.EagleVisible) { //this.LogLayers(this._layerDict, this._mapControlMain.ActiveView.FocusMap); if (_mapControlEagle.LayerCount != _mapControlMain.LayerCount) { MapAPI.CopyAndOverwriteMap(this._mapControlMain, this._mapControlEagle); this._mapControlEagle.ActiveView.Extent = this._mapControlEagle.ActiveView.FullExtent; } this.DrawEagleExtent(this._mapControlMain.Extent); //this._mapControlEagle.ActiveView.Refresh(); } }
// //历史任务双击击事件 // private void lstRecently_MouseClick(object obj, System.Windows.Forms.MouseEventArgs mouseEventArgs) { if (mouseEventArgs.Button == System.Windows.Forms.MouseButtons.Left) { int num = this._lstRecently.IndexFromPoint(mouseEventArgs.Location); if (num >= 0) { ImageListBoxItem task = this._lstRecently.Items[num]; string file = task.Value.ToString(); if (File.Exists(file)) { MapAPI.OpenDocument(file); } else { XtraMessageBox.Show("未找到任务文档!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); _lstRecently.Items.RemoveAt(num); } } } }
/// <summary> /// Handles the Click event of the MenuItemMore control. /// </summary> /// <param name="obj">The source of the event.</param> /// <param name="eventArgs">The <see cref="EventArgs"/> instance containing the event data.</param> private void MenuItemMore_Click(object obj, EventArgs eventArgs) { MapAPI.AddStyleFile(this.axSymbologyControl1, Path.Combine(System.Windows.Forms.Application.StartupPath, "styles")); }
private static IFeatureClass CreateFeatureClass(IWorkspace workspace, string sName, IFields fields, ISpatialReference spatialRef) { return(MapAPI.CreateFeatureClass(workspace, sName, fields, spatialRef, esriGeometryType.esriGeometryPolygon)); }