Пример #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //get the MapControl
            m_mapControl = (IMapControl3)axMapControl1.Object;

            //disable the Save menu (since there is no file yet)
            menuSaveFile.Enabled = false;

            // 取得 MapControl 和 PageLayoutControl 的引用
            pTocControl = (ITOCControl2)axTOCControl1.Object;
            pMapControl = (IMapControl3)axMapControl1.Object;
            // 创建菜单
            pToolMenuMap   = new ToolbarMenu();
            pToolMenuLayer = new ToolbarMenu();
            //添加菜单项
            pToolMenuLayer.AddItem(new ZoomToLayer(), -1, 0, true, esriCommandStyles.esriCommandStyleTextOnly);
            pToolMenuLayer.AddItem(new RemoveLayer(), -1, 0, true, esriCommandStyles.esriCommandStyleTextOnly);


            //设置菜单的hook
            pToolMenuLayer.SetHook(pMapControl);

            m_TOCControl = this.axTOCControl1.Object as ITOCControl;

            //Set buddy control
            axToolbarControl1.SetBuddyControl(axMapControl1);
            axToolbarControl2.SetBuddyControl(axMapControl1);
        }
Пример #2
0
        //public void ChangeRasterValue(IRasterDataset2 pRasterDatset, double dbScale, double dbOffset)
        //{
        //    IRaster2 pRaster2 = pRasterDatset.CreateFullRaster() as IRaster2;

        //    IPnt pPntBlock = new PntClass();

        //    pPntBlock.X = 128;
        //    pPntBlock.Y = 128;

        //    IRasterCursor pRasterCursor = pRaster2.CreateCursorEx(pPntBlock);
        //    IRasterEdit pRasterEdit = pRaster2 as IRasterEdit;

        //    if (pRasterEdit.CanEdit())
        //    {
        //        IRasterBandCollection pBands = pRasterDatset as IRasterBandCollection;
        //        IPixelBlock3 pPixelblock3 = null;
        //        int pBlockwidth = 0;
        //        int pBlockheight = 0;
        //        System.Array pixels;
        //        IPnt pPnt = null;
        //        object pValue;
        //        long pBandCount = pBands.Count;

        //        //获取Nodata
        //        IRasterProps pRasterPro = pRaster2 as IRasterProps;
        //        object pNodata = pRasterPro.NoDataValue;
        //        double dbNoData = Convert.ToDouble(((float[])pNodata)[0]);

        //        do
        //        {
        //            pPixelblock3 = pRasterCursor.PixelBlock as IPixelBlock3;
        //            pBlockwidth = pPixelblock3.Width;
        //            pBlockheight = pPixelblock3.Height;

        //            for (int k = 0; k < pBandCount; k++)
        //            {
        //                pixels = (System.Array)pPixelblock3.get_PixelData(k);
        //                for (int i = 0; i < pBlockwidth; i++)
        //                {
        //                    for (int j = 0; j < pBlockheight; j++)
        //                    {
        //                        pValue = pixels.GetValue(i, j);
        //                        double ob = Convert.ToDouble(pValue);
        //                        if (ob != dbNoData)
        //                        {
        //                            ob *= dbScale;  //翻转
        //                            ob += dbOffset; //Z方向偏移
        //                        }

        //                        pixels.SetValue(ob, i, j);
        //                    }
        //                }
        //                pPixelblock3.set_PixelData(k, pixels);

        //                System.Array textPixel = null;
        //                textPixel = (System.Array)pPixelblock3.get_PixelData(k);
        //            }

        //            pPnt = pRasterCursor.TopLeft;
        //            pRasterEdit.Write(pPnt, (IPixelBlock)pPixelblock3);
        //        }
        //        while (pRasterCursor.Next());

        //        pRasterEdit.Refresh();
        //        System.Runtime.InteropServices.Marshal.ReleaseComObject(pRasterEdit);
        //    }
        //}


        public CmdRasterTransZ(ITOCControl tocControl)
        {
            //
            // TODO: Define values for the public properties
            //
            base.m_category = "CustomCE";                 //localizable text
            base.m_caption  = "栅格图Z值变换";                  //localizable text
            base.m_message  = "栅格图Z值变换";                  //localizable text
            base.m_toolTip  = "栅格图Z值变换";                  //localizable text
            base.m_name     = "CustomCE.CmdRasterTransZ"; //unique id, non-localizable (e.g. "MyCategory_MyCommand")

            m_axTocControl = tocControl;
            try
            {
                //
                // TODO: change bitmap name if necessary
                //
                string bitmapResourceName = GetType().Name + ".bmp";
                base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
            }
        }
Пример #3
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            ITOCControl        pTOCControl = axTOCControl1.Object as ITOCControl;
            esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          map = null; ILayer layer = null;
            object             other = null; object index = null;

            pTOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            if (e.button == 2)
            {
                switch (item)
                {
                case esriTOCControlItem.esriTOCControlItemMap:
                    this.contextMenuTOCMap.Show(this.axTOCControl1, e.x, e.y);
                    break;
                }
            }
        }
        private void Form1_Load(object sender, System.EventArgs e)
        {
            m_tocControl = (ITOCControl)axTOCControl1.Object;

            //Set buddy control
            m_tocControl.SetBuddyControl(axPageLayoutControl1);

            //Get the directory of the executable
            m_tempDir = System.Reflection.Assembly.GetExecutingAssembly().Location;
            m_tempDir = Path.GetDirectoryName(m_tempDir);
            //The location to save the temporary metadata
            m_tempFile = m_tempDir + "metadata.htm";

            //Add style sheets to the combo box
            cboStyleSheets.Items.Insert(0, @"Brief.xsl");
            cboStyleSheets.Items.Insert(1, @"Attributes.xsl");
            cboStyleSheets.Items.Insert(2, @"DataDictionTable.xsl");
            cboStyleSheets.Items.Insert(3, @"DataDictionPage.xsl");
            cboStyleSheets.SelectedIndex = 0;
        }
Пример #5
0
        //  Show the TOC context menu when an NALayer is right-clicked on
        private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e)
        {
            if (e.button != 2)
            {
                return;
            }

            esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          map   = null;
            ILayer             layer = null;
            object             other = null;
            object             index = null;

            //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);

            // Only implemented a context menu for NALayers.  Exit if the layer is anything else.
            if ((layer as INALayer) == null)
            {
                return;
            }

            axTOCControl1.SelectItem(layer);

            // Set the layer into the CustomProperty.
            // This is used by the other commands to know what layer was right-clicked on
            // in the table of contents.
            axMapControl1.CustomProperty = layer;

            //Popup the correct context menu and update the TOC when it's done.
            if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                m_menuLayer.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
                ITOCControl toc = axTOCControl1.Object as ITOCControl;
                toc.Update();
            }
        }
Пример #6
0
        //TOCControl1鼠标点击事件,左键 符号变更,右键菜单
        private void axTOCControl1_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e)
        {
            this.axTOCControl1.HitTest(e.x, e.y, ref pTocItem, ref pBasicMap, ref pLayer, ref oLegendGroup, ref oIndex);
            axMapControl1.CustomProperty = pLayer;
            if (e.button == 1)  //符号变更
            {
                if (pTocItem == esriTOCControlItem.esriTOCControlItemLegendClass)
                {
                    ILegendClass pLegend = new LegendClassClass();          //首先获取图例,然后赋值过去
                    ISymbol      symbol  = null;                            //新建 symbol,从符号窗体中最后就是获得这个东西
                    if (oLegendGroup is ILegendGroup && (int)oIndex != -1)
                    {
                        pLegend = ((ILegendGroup)oLegendGroup).get_Class((int)oIndex) as ILegendClass;
                    }
                                                                                               //给上面建的图例类赋值

                    FormSymbology frm = new FormSymbology(pLegend, pLayer);                    //新建符号窗体,并将该赋值的赋值过去
                    frm.ShowDialog();                                                          //显示对话框,之后就获得了 symbol 了
                        symbol     = frm.pStyleGalleryItem.Item as ISymbol;                    //调用窗体的 public 字段
                    pLegend.Symbol = symbol;                                                   //将 symbol 赋值给图例
                    axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null);    //刷新地图
                }
            }
            else if (e.button == 2) //加载右键菜单
            {
                if (pTocItem == esriTOCControlItem.esriTOCControlItemMap)
                {
                }
                else if (pTocItem == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    pToolMenuLayer.PopupMenu(e.x, e.y, pTocControl.hWnd);
                    ITOCControl toc = axTOCControl1.Object as ITOCControl;
                    toc.Update();
                }
            }
        }
Пример #7
0
 private void Form1_Load(object sender, EventArgs e)
 {
     axTOCControl1.SetBuddyControl(axMapControl1);
     mTOCControl = axTOCControl1.Object as ITOCControl;
 }
		private void Form1_Load(object sender, System.EventArgs e)
		{
			m_tocControl = (ITOCControl) axTOCControl1.Object;
			
			//Set buddy control
			m_tocControl.SetBuddyControl(axPageLayoutControl1);

			//Get the directory of the executable
			m_tempDir = System.Reflection.Assembly.GetExecutingAssembly().Location;
			m_tempDir = Path.GetDirectoryName(m_tempDir); 
			//The location to save the temporary metadata
			m_tempFile = m_tempDir + "metadata.htm";
						
			//Add style sheets to the combo box
			cboStyleSheets.Items.Insert(0, @"Brief.xsl");
			cboStyleSheets.Items.Insert(1, @"Attributes.xsl");
			cboStyleSheets.Items.Insert(2, @"DataDictionTable.xsl");
			cboStyleSheets.Items.Insert(3, @"DataDictionPage.xsl");
			cboStyleSheets.SelectedIndex = 0;
		}
Пример #9
0
 private void frmlayerToc_Load(object sender, EventArgs e)
 {
     m_pTOCControl = (ITOCControl)TOCControl.Object;
     TOCControl.EnableLayerDragDrop = false;
 }
Пример #10
0
        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();
                    }
                }
            }
        }