예제 #1
0
        protected override void OnClick()
        {
            //
            //  TODO: Sample code showing how to access button host
            //
            ArcMap.Application.CurrentTool = null;
            ElementListForm frm = new ElementListForm();

            frm.AlignHandler = new AlignElementDelegate(AlignElementMethod);
            IGraphicsContainer cont = ArcMap.Document.ActiveView as IGraphicsContainer;

            cont.Reset();
            IElement ele = cont.Next();

            while (ele != null)
            {
                IElementProperties3 pros = ele as IElementProperties3;
                if (pros.Name != "")
                {
                    frm.AddItem(pros.Name);
                }
                ele = cont.Next();
            }
            frm.ShowDialog();
        }
예제 #2
0
        internal void AddPPGeocodedPoint(double lat, double lng)
        {
            // Set the coordinate system of the data frame.
            ArcMap.Document.ActiveView.FocusMap.SpatialReference = DefineGCS();
            ArcMap.Document.ActiveView.Refresh();

            IPoint iPoint = new PointClass();

            // Set the coordinate system of your point to match your data frame
            iPoint.SpatialReference = DefineGCS();
            iPoint.X = lng;
            iPoint.Y = lat;

            IMap map = ArcMap.Document.ActiveView as IMap;
            IGraphicsContainer graphicsContainer = (IGraphicsContainer)map; // Explicit Cast
            IElement           element           = null;

            // set the point color
            IColor pointColor = new RgbColor();

            //pointColor.RGB = 255255255;
            pointColor.RGB = 255000000;

            // Marker symbols
            ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
            simpleMarkerSymbol.Color        = pointColor;
            simpleMarkerSymbol.Outline      = true;
            simpleMarkerSymbol.OutlineColor = pointColor;
            simpleMarkerSymbol.Size         = 10;
            simpleMarkerSymbol.Style        = esriSimpleMarkerStyle.esriSMSCircle;

            // Marker element
            IMarkerElement markerElement = new MarkerElementClass();

            markerElement.Symbol       = simpleMarkerSymbol;
            markerElement.Symbol.Color = pointColor;

            element = (IElement)markerElement; // Explicit Cast

            // set the element name
            IElementProperties3 elemProperties = element as IElementProperties3;

            elemProperties.Name        = string.Concat(lng, " ,", lat);
            elemProperties.AnchorPoint = esriAnchorPointEnum.esriCenterPoint;

            // Add the element to a graphics container and refresh the ActiveView
            if (!(element == null))
            {
                element.Geometry = iPoint;
                graphicsContainer.AddElement(element, 0);
                IEnvelope envelope = new EnvelopeClass();
                envelope = ArcMap.Document.ActiveView.Extent;
                envelope.CenterAt(iPoint);
                //ArcMap.Document.ActiveView.Extent = envelope;
                //map.MapScale = 2400;
                map.MapScale = 5000;
                ArcMap.Document.ActiveView.Refresh();
            }
        }
예제 #3
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            if (m_InUse == false)
            {
                return;
            }

            //Stop capturing mouse events
            if (GetCapture() == m_HookHelper.ActiveView.ScreenDisplay.hWnd)
            {
                ReleaseCapture();
            }

            //If an envelope has not been tracked or its height/width is 0
            if (m_Feedback == null)
            {
                m_Feedback = null;
                m_InUse    = false;
                return;
            }
            IEnvelope envelope = m_Feedback.Stop();

            if ((envelope.IsEmpty) || (envelope.Width == 0) || (envelope.Height == 0))
            {
                m_Feedback = null;
                m_InUse    = false;
                return;
            }

            frmSymbolSelector symbolForm       = new frmSymbolSelector();
            IStyleGalleryItem styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassScaleTexts, null);

            //Release the form
            symbolForm.Dispose();
            if (symbolForm.DialogResult != DialogResult.OK)
            {
                return;
            }
            if (styleGalleryItem == null)
            {
                return;
            }

            //Get the map frame of the focus map
            IMapFrame mapFrame = (IMapFrame)m_HookHelper.ActiveView.GraphicsContainer.FindFrame(m_HookHelper.ActiveView.FocusMap);

            //Create a map surround frame
            UID vUid = new UIDClass();

            vUid.Value = "{7A3F91DC-B9E3-11d1-8756-0000F8751720}";
            IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(vUid, (IMapSurround)styleGalleryItem.Item);

            IElement element = (IElement)mapSurroundFrame;

            element.Geometry = envelope;
            IElementProperties3 pep = element as IElementProperties3;

            pep.Name = "比例尺";
            IGraphicsContainerSelect pGraphicsSel = m_HookHelper.ActiveView.GraphicsContainer as IGraphicsContainerSelect;

            pGraphicsSel.UnselectAllElements();
            pGraphicsSel.SelectElement(element);
            m_HookHelper.ActiveView.GraphicsContainer.AddElement(element, 0);
            //Refresh
            m_HookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            m_Feedback = null;
            m_InUse    = false;
        }
예제 #4
0
        private void btnExp2Map_Click_1(object sender, EventArgs e)
        {
            if (m_pApp != null)
            {
                IRasterLayer pRLayer = new RasterLayerClass();
                try
                {
                    this.Cursor = Cursors.WaitCursor;
                    DateTime fechaExportacion = monthCalendar1.SelectionStart;
                    int      iMonth           = fechaExportacion.Month;
                    string   sMonth           = (iMonth.ToString().Length == 1 ? "0" + iMonth.ToString() : iMonth.ToString());

                    int                iYear          = fechaExportacion.Year;
                    string             sNombreFileGDB = iYear.ToString() + "-" + sMonth + "-Modelos.gdb";
                    IWorkspaceFactory  pWF            = new FileGDBWorkspaceFactoryClass();
                    string             sRutaFileGDB   = Sigpi.Parametros.RutaSIGPI + "\\" + Sigpi.Parametros.Resultado + "\\" + sNombreFileGDB;
                    IRasterWorkspaceEx pRWorkspace    = (IRasterWorkspaceEx)pWF.OpenFromFile(sRutaFileGDB, 0);
                    string             sNombreCapa    = "Amenaza_" + fechaExportacion.ToString("yyyy_MM_dd");

                    IRasterDataset pRDataset = pRWorkspace.OpenRasterDataset(sNombreCapa);
                    pRLayer.CreateFromDataset(pRDataset);
                    pRLayer.Name = sNombreCapa;
                    IMxDocument pMxDoc = m_pApp.Document as IMxDocument;
                    IMap        pMap   = pMxDoc.FocusMap;

                    AsignarSimbologiaProbabilidad(pRLayer);
                    IEnumLayer pEnumLayer  = pMap.Layers;
                    ILayer     pLayer      = pEnumLayer.Next();
                    Boolean    bLayerInMap = false;
                    while (pLayer != null)
                    {
                        if (pLayer.Name.Contains("Amenaza_"))
                        {
                            pLayer.Visible = false;
                        }
                        if (pLayer.Name.Equals(sNombreCapa))
                        {
                            bLayerInMap    = true;
                            pLayer.Visible = true;
                        }
                        pLayer = pEnumLayer.Next();
                    }

                    System.Windows.Forms.Application.DoEvents();

                    if (!bLayerInMap)
                    {
                        pMap.AddLayer(pRLayer);
                        if (pMap.LayerCount > 0)
                        {
                            pMap.MoveLayer(pRLayer, pMap.LayerCount - 1);
                        }
                    }

                    if (!(pMxDoc.ActiveView is IPageLayout))
                    {
                        pMxDoc.ActiveView = (IActiveView)pMxDoc.PageLayout;
                    }

                    IPageLayout        pageLayout         = pMxDoc.PageLayout;
                    IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)pageLayout;
                    pGraphicsContainer.Reset();
                    IElement pElement;
                    pElement = pGraphicsContainer.Next();
                    while (pElement != null)
                    {
                        if (pElement is ITextElement)
                        {
                            ITextElement        pTxtElement     = (ITextElement)pElement;
                            IElementProperties3 pElemProperties = (IElementProperties3)pTxtElement;
                            if (pElemProperties.Name.Equals("lblProbabilidad"))
                            {
                                pTxtElement.Text = "PROBABILIDAD PARA EL " + fechaExportacion.ToLongDateString();
                            }
                            if (pElemProperties.Name.Equals("lblFechaGeneracion"))
                            {
                                pTxtElement.Text = "Fecha Generación: " + DateTime.Now.ToLongTimeString();
                            }
                        }
                        pElement = pGraphicsContainer.Next();
                    }

                    pMxDoc.UpdateContents();
                    pMxDoc.ActiveView.Refresh();


                    String fileName = Sigpi.Parametros.RutaSIGPI + "\\" + "JPG" + "\\" + sNombreCapa + "_Incendios_INTERNET_.jpg";
                    CreateJPEGFromActiveView(pMxDoc.ActiveView, fileName);

                    fileName = Sigpi.Parametros.RutaSIGPI + "\\" + "JPG" + "\\" + sNombreCapa + "_Incendios.jpg";
                    CreateJPEGHiResolutionFromActiveView(pMxDoc.ActiveView, fileName);

                    MessageBox.Show("Se ha generado el mapa de amenazas en formato JPG");

                    // opens the folder in explorer
                    Process.Start(Sigpi.Parametros.RutaSIGPI + "\\" + "JPG");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error cargando Capa!!!");
                }
            }
            this.Cursor = Cursors.Default;



            //string sTipo = "";
            //string sRuta = "";
            //if (radioBtnProbabilidad.Checked)
            //{
            //  sTipo = "Probabilidad";
            //  sRuta = _sigpi.Parametros.RutaSIGPI + _sigpi.Parametros.Resultado;
            //}
            //else if (radioBtnModelo.Checked)
            //{
            //  sTipo = "Modelo";
            //  sRuta = _sigpi.Parametros.RutaSIGPI + _sigpi.Parametros.Raster;
            //}

            //if (lvwModelos.SelectedIndices.Count > 0)
            //{
            //  string sModelo = lvwModelos.SelectedItems[0].Text;
            //  IMxDocument pMxDoc = m_pApp.Document as IMxDocument;
            //  IMap pMap = pMxDoc.FocusMap;
            //  IRasterLayer pRLayer = new RasterLayerClass();
            //  pRLayer.CreateFromFilePath(sRuta + "\\" + sModelo);
            //  AsignarSimbologiaProbabilidad(pRLayer);


            //  pMap.AddLayer(pRLayer);

            //  if (pMap.LayerCount > 0)
            //  {
            //    pMap.MoveLayer(pRLayer, pMap.LayerCount - 1);
            //  }

            //  pMxDoc.UpdateContents();
            //  pMxDoc.ActiveView.Refresh();
            //}

            //FrmExportMap frmExportMap = new FrmExportMap(_sigpi, lvwModelos.SelectedItems[0].Text, sTipo);
            //frmExportMap.ShowDialog();
        }
예제 #5
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            if (m_InUse == false)
            {
                return;
            }

            if (GetCapture() == m_HookHelper.ActiveView.ScreenDisplay.hWnd)
            {
                ReleaseCapture();
            }

            if (m_Feedback == null)
            {
                m_Feedback = null;
                m_InUse    = false;
                return;
            }
            IEnvelope envelope = m_Feedback.Stop();

            if ((envelope.IsEmpty) || (envelope.Width == 0) || (envelope.Height == 0))
            {
                m_Feedback = null;
                m_InUse    = false;
                return;
            }

            frmSymbolSelector symbolForm       = new frmSymbolSelector();
            IStyleGalleryItem styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassNorthArrows, null);

            symbolForm.Dispose();
            if (symbolForm.DialogResult != DialogResult.OK)
            {
                return;
            }
            if (styleGalleryItem == null)
            {
                return;
            }
            IMapFrame mapFrame = (IMapFrame)m_HookHelper.ActiveView.GraphicsContainer.FindFrame(m_HookHelper.ActiveView.FocusMap);
            UID       vUid     = new UIDClass();

            vUid.Value = "{7A3F91DD-B9E3-11d1-8756-0000F8751720}";
            IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(vUid, (IMapSurround)styleGalleryItem.Item);

            IElement element = (IElement)mapSurroundFrame;

            element.Geometry = envelope;
            IElementProperties3 pep = element as IElementProperties3;

            pep.Name = "指北针";
            IGraphicsContainerSelect pGraphicsSel = m_HookHelper.ActiveView.GraphicsContainer as IGraphicsContainerSelect;

            pGraphicsSel.UnselectAllElements();
            pGraphicsSel.SelectElement(element);
            m_HookHelper.ActiveView.GraphicsContainer.AddElement(element, 0);
            m_HookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            if (m_HookHelper.Hook is IPageLayoutControl)
            {
                IPageLayoutControl pPLC = m_HookHelper.Hook as IPageLayoutControl;
                if (pPLC != null)
                {
                    ////初始化控件工具为选择元素工具
                    //string progID = "esriControls.ControlsSelectTool";
                    //int index = axToolbarControl1.Find(progID);
                    //if (index != -1)
                    //{
                    //    IToolbarItem toolItem = axToolbarControl1.GetItem(index);
                    //    ICommand _cmd = toolItem.Command;
                    //    ITool _tool = (ITool)_cmd;
                    //    pPLC.CurrentTool = _tool;
                    //}
                }
            }
            m_Feedback = null;
            m_InUse    = false;
        }
예제 #6
0
        public bool SetElementProp()
        {
            try
            {
                //if (txtName.Text.Trim() == "")
                //{
                //    MessageBox.Show("请输入变量名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);yjl0616
                //    return false;
                //}
                IElementProperties3 pElementProp = m_pOrgElement as IElementProperties3;

                if (pElementProp != null)
                {
                    pElementProp.Name = txtName.Text;
                }

                //对于FrameElement的情况
                if (m_pOrgElement is IFrameElement)
                {
                    IFrameProperties pFrameProperty      = null;
                    IFrameDecoration pFrameDecoration    = null;
                    DevComponents.Editors.ComboItem item = cmbBorder.SelectedItem as DevComponents.Editors.ComboItem;
                    if (cmbBorder.SelectedIndex != -1 && item != null)
                    {
                        IBorder pBorder = (IBorder)(item.Tag);
                        pFrameDecoration = (IFrameDecoration)pBorder;
                        pFrameDecoration.HorizontalSpacing    = (double)numBorderGapX.Value;
                        pFrameDecoration.VerticalSpacing      = (double)numBorderGapY.Value;
                        pFrameDecoration.CornerRounding       = (short)numBorderRound.Value;
                        ((IFrameElement)m_pOrgElement).Border = pBorder;
                    }
                    else
                    {
                        ((IFrameElement)m_pOrgElement).Border = null;
                    }
                    item = cmbBack.SelectedItem as DevComponents.Editors.ComboItem;
                    if (cmbBack.SelectedIndex != -1 && item != null)
                    {
                        IBackground pBackground = (IBackground)(item.Tag);
                        pFrameDecoration = (IFrameDecoration)pBackground;
                        pFrameDecoration.HorizontalSpacing        = (double)numBackGapX.Value;
                        pFrameDecoration.VerticalSpacing          = (double)numBackGapY.Value;
                        pFrameDecoration.CornerRounding           = (short)numBackRound.Value;
                        ((IFrameElement)m_pOrgElement).Background = pBackground;
                    }
                    else
                    {
                        ((IFrameElement)m_pOrgElement).Background = null;
                    }
                    item = cmbShadow.SelectedItem as DevComponents.Editors.ComboItem;
                    if (cmbShadow.SelectedIndex != -1 && item != null)
                    {
                        IShadow pShadow = (IShadow)(item.Tag);
                        pFrameDecoration = (IFrameDecoration)pShadow;
                        pFrameDecoration.HorizontalSpacing = (double)numShadowGapX.Value;
                        pFrameDecoration.VerticalSpacing   = (double)numShadowGapY.Value;
                        pFrameDecoration.CornerRounding    = (short)numShadowRound.Value;
                        pFrameProperty        = (IFrameProperties)m_pOrgElement;
                        pFrameProperty.Shadow = pShadow;
                    }
                    else
                    {
                        pFrameProperty        = (IFrameProperties)m_pOrgElement;
                        pFrameProperty.Shadow = null;
                    }
                }
                IEnvelope pBounds = new EnvelopeClass();
                m_pOrgElement.QueryBounds(m_pDisplay, pBounds);

                //设置偏移
                double dx, dy;
                IPoint pFromPoint = pBounds.LowerLeft;

                if (chkUseOffDist.Checked)
                {
                    dx = Convert.ToDouble(numLowerLeftX.Text);
                    dy = Convert.ToDouble(numLowerLeftY.Text);
                }
                else
                {
                    dx = Convert.ToDouble(numLowerLeftX.Text) - pFromPoint.X;
                    dy = Convert.ToDouble(numLowerLeftY.Text) - pFromPoint.Y;
                }
                m_pTransform.Move(dx, dy);

                //设置缩放
                pFromPoint = pBounds.LowerLeft;
                if (chkUsePercent.Checked)
                {
                    dx = ((Convert.ToDouble(numWidth.Text) / 100) * pBounds.Width) / pBounds.Width;
                    dy = ((Convert.ToDouble(numHeight.Text) / 100) * pBounds.Width) / pBounds.Height;
                }
                else
                {
                    dx = Convert.ToDouble(numWidth.Text) / pBounds.Width;
                    dy = Convert.ToDouble(numHeight.Text) / pBounds.Height;
                }
                m_pTransform.Scale(pFromPoint, dx, dy);

                //设置符号
                if (m_pOrgElement is IMarkerElement)
                {
                    IMarkerElement pMrkElement = m_pOrgElement as IMarkerElement;
                    IMarkerSymbol  pSymbol     = (IMarkerSymbol)picPoint.Tag;
                    double         dblSize     = pMrkElement.Symbol.Size;
                    pMrkElement.Symbol = (IMarkerSymbol)picPoint.Tag;
                    pSymbol.Size       = dblSize;
                    pMrkElement.Symbol = pSymbol;
                }
                else if (m_pOrgElement is ILineElement)
                {
                    ILineElement pLinElement = m_pOrgElement as ILineElement;
                    pLinElement.Symbol = (ILineSymbol)picLine.Tag;
                }
                else if (m_pOrgElement is IFillShapeElement)
                {
                    IFillShapeElement pFillElement = m_pOrgElement as IFillShapeElement;
                    pFillElement.Symbol = (IFillSymbol)picPoly.Tag;
                }
                else if (m_pOrgElement is ITextElement)
                {
                    ITextElement pTxtElement = m_pOrgElement as ITextElement;
                    pTxtElement.Text   = txtText.Text;
                    pTxtElement.Symbol = (ITextSymbol)picText.Tag;
                }

                if (m_pOrgElement is IFrameElement)
                {
                    //判断指北针,比例尺,比例文本
                    IMapSurroundFrame pMapSurroundFrame = m_pOrgElement as IMapSurroundFrame;
                    if (pMapSurroundFrame != null)
                    {
                        IMapSurround pMapSurround = pMapSurroundFrame.MapSurround;
                        if (pMapSurround != null)
                        {
                            if (pMapSurround is INorthArrow)
                            {
                                pMapSurroundFrame.MapSurround      = (IMapSurround)picArrow.Tag;
                                pMapSurroundFrame.MapSurround.Name = "指北针";
                            }
                            else if (pMapSurround is IScaleBar)
                            {
                                pMapSurroundFrame.MapSurround      = (IMapSurround)picScale.Tag;
                                pMapSurroundFrame.MapSurround.Name = "比例尺";
                            }
                            else if (pMapSurround is IScaleText)
                            {
                                pMapSurroundFrame.MapSurround      = (IMapSurround)picScaleText.Tag;
                                pMapSurroundFrame.MapSurround.Name = "比例尺";
                            }
                        }
                    }
                }

                m_pGraphicCtn.UpdateElement(m_pOrgElement);
                m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                if (chkUseOffDist.Checked)
                {
                    numLowerLeftX.Text = "0";
                    numLowerLeftY.Text = "0";
                }
                if (chkUsePercent.Checked)
                {
                    numHeight.Text = "100";
                    numWidth.Text  = "100";
                }
                return(true);
            }
            catch
            {
                //MessageBox.Show("保存属性时出现错误,错误描述为:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            //
        }
예제 #7
0
        //支持6中element,点,线,面,注记,Inkgraphic,MapFrame
        private bool GetProperty(IDisplay pDisplay, IElement pElement)
        {
            try
            {
                //获得FrameELEment的属性
                if (pElement is IFrameElement)
                {
                    IFrameProperties pFrameProperty   = (IFrameProperties)pElement;
                    IFrameDecoration pFrameDecoration = null;
                    IClone           pClone;
                    int  i;
                    bool bExist = false;

                    //得到地图边框属性
                    if (pFrameProperty.Border != null)
                    {
                        pFrameDecoration = (IFrameDecoration)pFrameProperty.Border;
                        //判断和列表框中的符号是否相同
                        bExist = false;
                        for (i = 0; i < cmbBorder.Items.Count; i++)
                        {
                            pClone = (IClone)pFrameProperty.Border;
                            DevComponents.Editors.ComboItem item = cmbBorder.Items[i] as DevComponents.Editors.ComboItem;
                            if (item == null)
                            {
                                continue;
                            }
                            if (pClone.Equals(item.Tag))
                            {
                                bExist = true;
                                break;
                            }
                        }
                        if (bExist)
                        {
                            cmbBorder.SelectedIndex = i;
                        }
                        else
                        {
                            PreViewCustom(cmbBorder, pFrameProperty.Border, esriSymbologyStyleClass.esriStyleClassBorders);
                        }

                        GetDecorationColor(pFrameDecoration, btnBorderColor);
                        numBorderGapX.Value  = (decimal)pFrameDecoration.HorizontalSpacing;
                        numBorderGapY.Value  = (decimal)pFrameDecoration.VerticalSpacing;
                        numBorderRound.Value = (decimal)pFrameDecoration.CornerRounding;
                    }

                    //得到地图背景属性
                    if (pFrameProperty.Background != null)
                    {
                        pFrameDecoration = (IFrameDecoration)((IFrameElement)pElement).Background;
                        //判断和列表框中的符号是否相同
                        bExist = false;
                        for (i = 0; i < cmbBack.Items.Count; i++)
                        {
                            pClone = (IClone)pFrameProperty.Background;
                            DevComponents.Editors.ComboItem item = cmbBack.Items[i] as DevComponents.Editors.ComboItem;
                            if (item == null)
                            {
                                continue;
                            }
                            if (pClone.Equals(item.Tag))
                            {
                                bExist = true;
                                break;
                            }
                        }
                        if (bExist)
                        {
                            cmbBack.SelectedIndex = i;
                        }
                        else
                        {
                            PreViewCustom(cmbBack, pFrameProperty.Background, esriSymbologyStyleClass.esriStyleClassBackgrounds);
                        }

                        GetDecorationColor(pFrameDecoration, btnBackColor);

                        numBackGapX.Value  = (decimal)pFrameDecoration.HorizontalSpacing;
                        numBackGapY.Value  = (decimal)pFrameDecoration.VerticalSpacing;
                        numBackRound.Value = (decimal)pFrameDecoration.CornerRounding;
                    }

                    //得到地图阴影属性
                    if (pFrameProperty.Shadow != null)
                    {
                        pFrameDecoration = (IFrameDecoration)pFrameProperty.Shadow;
                        //判断和列表框中的符号是否相同
                        bExist = false;
                        for (i = 0; i < cmbShadow.Items.Count; i++)
                        {
                            pClone = (IClone)pFrameProperty.Shadow;
                            DevComponents.Editors.ComboItem item = cmbShadow.Items[i] as DevComponents.Editors.ComboItem;
                            if (item == null)
                            {
                                continue;
                            }
                            if (pClone.Equals(item.Tag))
                            {
                                bExist = true;
                                break;
                            }
                        }
                        if (bExist)
                        {
                            cmbShadow.SelectedIndex = i;
                        }
                        else
                        {
                            PreViewCustom(cmbShadow, pFrameProperty.Shadow, esriSymbologyStyleClass.esriStyleClassShadows);
                        }

                        GetDecorationColor(pFrameDecoration, btnShadowColor);

                        numShadowGapX.Value  = (decimal)pFrameDecoration.HorizontalSpacing;
                        numShadowGapY.Value  = (decimal)pFrameDecoration.VerticalSpacing;
                        numShadowRound.Value = (decimal)pFrameDecoration.CornerRounding;
                    }
                }
                IElementProperties3 pElementProp = pElement as IElementProperties3;
                txtName.Text = pElementProp.Name;
                IEnvelope pBounds = new EnvelopeClass();
                pElement.QueryBounds(pDisplay, pBounds);
                IArea pArea = (IArea)pBounds;
                numCenterX.Text    = pArea.Centroid.X.ToString("f4");
                numCenterY.Text    = pArea.Centroid.Y.ToString("f4");
                numHeight.Text     = pBounds.Height.ToString("f4");
                numWidth.Text      = pBounds.Width.ToString("f4");
                numLowerLeftX.Text = pBounds.LowerLeft.X.ToString("f4");
                numLowerLeftY.Text = pBounds.LowerLeft.Y.ToString("f4");

                if (pElement is IMarkerElement)
                {
                    IMarkerElement pMrkElement = pElement as IMarkerElement;
                    picPoint.Tag = pMrkElement.Symbol;
                    PreViewSymbol((ISymbol)picPoint.Tag, ref picPoint);
                }
                else if (pElement is ILineElement)
                {
                    ILineElement pLinElement = pElement as ILineElement;
                    picLine.Tag = pLinElement.Symbol;
                    PreViewSymbol((ISymbol)picLine.Tag, ref picLine);
                }
                else if (pElement is IFillShapeElement)
                {
                    IFillShapeElement pFillElement = pElement as IFillShapeElement;
                    picPoly.Tag = pFillElement.Symbol;
                    PreViewSymbol((ISymbol)picPoly.Tag, ref picPoly);

                    //得到面积
                    pArea        = (IArea)pElement.Geometry;
                    numArea.Text = pArea.Area.ToString("0.00");
                    //得到周长
                    IPolygon pPolygon = new PolygonClass();
                    pElement.QueryOutline(m_pDisplay, pPolygon);
                    IRing pOutRing = new RingClass();
                    pPolygon.QueryExteriorRings(ref pOutRing);
                    numLength.Text = pOutRing.Length.ToString("0.00");
                }
                else if (pElement is ITextElement)
                {
                    ITextElement pTxtElement = pElement as ITextElement;
                    txtText.Text = pTxtElement.Text;
                    picText.Tag  = pTxtElement.Symbol;
                    PreViewSymbol((ISymbol)picText.Tag, ref picText);
                }
                if (pElement is IFrameElement)
                {
                    //判断指北针,比例尺,比例文本
                    IMapSurroundFrame pMapSurroundFrame = pElement as IMapSurroundFrame;
                    if (pMapSurroundFrame != null)
                    {
                        IMapSurround pMapSurround = pMapSurroundFrame.MapSurround;
                        if (pMapSurround != null)
                        {
                            if (pMapSurround is INorthArrow)
                            {
                                picArrow.Tag = pMapSurround;
                                PreViewSymbol(pMapSurround, ref picArrow);
                            }
                            else if (pMapSurround is IScaleBar)
                            {
                                picScale.Tag = pMapSurround;
                                PreViewSymbol(pMapSurround, ref picScale);
                            }
                            else if (pMapSurround is IScaleText)
                            {
                                picScaleText.Tag = pMapSurround;
                                PreViewSymbol(pMapSurround, ref picScaleText);
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("显示属性出错:" + ex.Message);
                return(false);
            }
        }
예제 #8
0
        void AlignElementMethod(string name, string h, string v, string hDirection, string vDirection, bool isPage)
        {
            IElement           targetEle = null;
            double             xmin      = 0;
            double             xmax      = 0;
            double             ymin      = 0;
            double             ymax      = 0;
            IEnvelope          targetEnv = new EnvelopeClass() as IEnvelope;
            IGraphicsContainer cont      = ArcMap.Document.ActiveView as IGraphicsContainer;

            if (!isPage)
            {
                cont.Reset();
                IElement ele = cont.Next();
                while (ele != null)
                {
                    IElementProperties3 pros = ele as IElementProperties3;
                    if (pros.Name == name)
                    {
                        targetEle = ele;
                        break;
                    }
                    ele = cont.Next();
                }
                if (targetEle == null)
                {
                    return;
                }
                targetEle.QueryBounds(ArcMap.Document.ActiveView.ScreenDisplay, targetEnv);
                xmin = targetEnv.XMin;
                xmax = targetEnv.XMax;
                ymin = targetEnv.YMin;
                ymax = targetEnv.YMax;
            }
            else
            {
                IPageLayout layout = ArcMap.Document.ActiveView as IPageLayout;
                IPage       pg     = layout.Page;
                pg.QuerySize(out xmax, out ymax);
            }

            double vH = 0;
            double vV = 0;
            bool   bH = double.TryParse(h, out vH);
            bool   bV = double.TryParse(v, out vV);

            IGraphicsContainerSelect contAlign = ArcMap.Document.ActiveView as IGraphicsContainerSelect;
            IEnumElement             enumEle   = contAlign.SelectedElements;
            IElement eleSel = enumEle.Next();

            while (eleSel != null)
            {
                IElementProperties3 pros = eleSel as IElementProperties3;
                IEnvelope           env  = new EnvelopeClass() as IEnvelope;
                eleSel.QueryBounds(ArcMap.Document.ActiveView.ScreenDisplay, env);
                double dx = 0;
                double dy = 0;
                if (bH)
                {
                    if (hDirection == "左侧Left")
                    {
                        dx = xmin - env.XMin - vH;
                    }
                    else
                    {
                        dx = xmax - env.XMax + vH;
                    }
                }
                if (bV)
                {
                    if (vDirection == "上侧Top")
                    {
                        dy = ymax - env.YMax + vV;
                    }
                    else
                    {
                        dy = ymin - env.YMin - vV;
                    }
                }
                ITransform2D trans = eleSel.Geometry as ITransform2D;
                trans.Move(dx, dy);
                eleSel.Geometry = trans as IGeometry;
                cont.UpdateElement(eleSel);
                eleSel = enumEle.Next();
            }
            ArcMap.Document.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGraphicSelection, null, null);
        }
예제 #9
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            if (m_InUse == false)
            {
                return;
            }

            if (GetCapture() == m_HookHelper.ActiveView.ScreenDisplay.hWnd)
            {
                ReleaseCapture();
            }

            if (m_Feedback == null)
            {
                m_Feedback = null;
                m_InUse    = false;
                return;
            }
            IEnvelope envelope = m_Feedback.Stop();

            if ((envelope.IsEmpty) || (envelope.Width == 0) || (envelope.Height == 0))
            {
                m_Feedback = null;
                m_InUse    = false;
                return;
            }

            frmSymbolSelector symbolForm       = new frmSymbolSelector();
            IStyleGalleryItem styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassScaleBars, null);

            symbolForm.Dispose();
            if (symbolForm.DialogResult != DialogResult.OK)
            {
                return;
            }
            if (styleGalleryItem == null)
            {
                return;
            }

            IMapFrame mapFrame = (IMapFrame)m_HookHelper.ActiveView.GraphicsContainer.FindFrame(m_HookHelper.ActiveView.FocusMap);
            UID       vUid     = new UIDClass();

            vUid.Value = "{6589F143-F7F7-11d2-B872-00600802E603}";
            IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(vUid, (IMapSurround)styleGalleryItem.Item);

            if (mapSurroundFrame.MapSurround is IScaleBar)
            {
                IScaleBar pScalbeBar = (IScaleBar)mapSurroundFrame.MapSurround;
                pScalbeBar.Units = mapFrame.Map.MapUnits;
                switch (pScalbeBar.Units)
                {
                case esriUnits.esriMeters:
                    pScalbeBar.UnitLabel = "米";
                    break;

                case esriUnits.esriKilometers:
                    pScalbeBar.UnitLabel = "公里";
                    break;

                case esriUnits.esriMiles:
                    pScalbeBar.UnitLabel = "英里";
                    break;

                case esriUnits.esriDecimalDegrees:
                    pScalbeBar.UnitLabel = "度";
                    break;
                }
            }


            IElement element = (IElement)mapSurroundFrame;

            element.Geometry = envelope;
            IElementProperties3 pep = element as IElementProperties3;

            pep.Name = "比例尺";

            IGraphicsContainerSelect pGraphicsSel = m_HookHelper.ActiveView.GraphicsContainer as IGraphicsContainerSelect;

            pGraphicsSel.UnselectAllElements();
            pGraphicsSel.SelectElement(element);
            m_HookHelper.ActiveView.GraphicsContainer.AddElement(element, 0);
            m_HookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            m_Feedback = null;
            m_InUse    = false;
        }