Пример #1
0
        public InsertTextForm()
        {
            InitializeComponent();
            ////变量初始化
            //_textAngle = 0;
            //_textColor = ColorImp.GetRGBColor(Color.Red.R, Color.Red.G, Color.Red.B) as IColor;
            //_textFont = new stdole.StdFontClass() as stdole.IFontDisp;
            //_textFont.Name = FontType.宋体.ToString();
            //_textSize = 20;

            ////控件初始化
            //txbxInsertText.Text = "未知文本";
            //txbxInsertText.SelectAll();
            //cmbxFont.DataSource = System.Enum.GetNames(typeof(FontType));
            //cmbxFont.SelectedIndex = 0;
            //cmbxSize.DataSource = _sizeArr;
            //cmbxSize.SelectedIndex = this.cmbxSize.FindString("20");
            //btnColor.BackColor = Color.Red;

            IColor    textColor = ElementPropetyImp.GetRGBColor(0, 0, 0) as IColor;
            IFontDisp textFont  = new stdole.StdFontClass() as stdole.IFontDisp;

            textFont.Name = FontType.宋体.ToString();
            InitVariablesAndControls(0, textColor, textFont, 20, "未知文本");
        }
        private void btnApply_Click(object sender, EventArgs e)
        {
            IScaleBar mapScaleBar = (m_styleGalleryItem.Item as IScaleBar);

            if (mapScaleBar == null)
            {
                return;
            }

            //设置单位
            int unitIndex = cmbxUnit.SelectedIndex;

            mapScaleBar.Units = (esriUnits)unitIndex;

            //设置文本字体、大小与颜色
            ITextSymbol textSymbol = mapScaleBar.LabelSymbol;

            textSymbol.Font.Name = cmbxTextFont.Text;
            textSymbol.Size      = Convert.ToDouble(cmbxTextSize.Text);
            textSymbol.Color     = ElementPropetyImp.GetRGBColor(btnTextColor.BackColor.R, btnTextColor.BackColor.G, btnTextColor.BackColor.B) as IColor;

            mapScaleBar.LabelSymbol = textSymbol;

            //设置条块大小与颜色
            mapScaleBar.BarHeight = Convert.ToDouble(cmbxSymbolSize.Text);
            mapScaleBar.BarColor  = ElementPropetyImp.GetRGBColor(btnSymbolColor.BackColor.R, btnSymbolColor.BackColor.G, btnSymbolColor.BackColor.B) as IColor;

            PreviewImage();
        }
Пример #3
0
        private void btnFillColor_Click(object sender, EventArgs e)
        {
            ColorDialog  colorDialog = new ColorDialog();
            DialogResult result      = colorDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                btnFillColor.BackColor = colorDialog.Color;

                IMapSurround pMapSurround = m_styleGalleryItem.Item as IMapSurround;
                if (pMapSurround == null)
                {
                    return;
                }

                if (pMapSurround is IMarkerNorthArrow)
                {
                    IMarkerSymbol markerSymbol = (pMapSurround as IMarkerNorthArrow).MarkerSymbol;
                    markerSymbol.Color = ElementPropetyImp.GetRGBColor(colorDialog.Color.R, colorDialog.Color.G, colorDialog.Color.B);
                    (pMapSurround as IMarkerNorthArrow).MarkerSymbol = markerSymbol;
                }
                else
                {
                    return;
                }

                PreviewImage();
            }
        }
Пример #4
0
        private void btnColor_Click(object sender, EventArgs e)
        {
            ColorDialog  colorDialog = new ColorDialog();
            DialogResult result      = colorDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                btnColor.BackColor = colorDialog.Color;
                _textColor         = ElementPropetyImp.GetRGBColor(btnColor.BackColor.R, btnColor.BackColor.G, btnColor.BackColor.B) as IColor;
            }
        }
Пример #5
0
        public bool OnContextMenu(int x, int y)
        {
            ESRI.ArcGIS.Geometry.IPoint point = this.hk.PageLayoutControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);

            IElement mapSurroundElement = ElementPropetyImp.GetElementFromPage(this.hk.PageLayoutControl, (int)point.X, (int)point.Y);

            _rightMenu1.SetCurrentElement(mapSurroundElement);
            _rightMenu2.SetCurrentElement(mapSurroundElement);
            _layerMenu.PopupMenu(x, y, this.hk.PageLayoutControl.hWnd);

            return(false);
        }
Пример #6
0
        public override void OnClick()
        {
            if (m_currentElement == null)
            {
                return;
            }

            switch (m_subType)
            {
            case 1:
                try
                {
                    if (m_currentElement is IMapFrame)
                    {
                        break;
                    }
                    this.m_pageLayoutControl.GraphicsContainer.DeleteElement(m_currentElement);
                    this.m_pageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                    break;
                }
                catch (System.Exception ex)
                {
                    break;
                }

            case 2:
                if (m_currentElement is ITextElement)
                {
                    ITextElement   textElement = m_currentElement as ITextElement;
                    InsertTextForm textFrm     = ElementPropetyImp.GetTextElementForm(textElement);
                    if (textFrm.ShowDialog() == DialogResult.OK)
                    {
                        ElementPropetyImp.SetTextElementByTextForm(textFrm, textElement);
                        //Refresh the PageLayout
                        this.m_pageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, textElement, null);
                    }
                }
                else if (m_currentElement is IMapSurroundFrame)
                {
                    IMapSurroundFrame mapSurroundFrame = m_currentElement as IMapSurroundFrame;
                    IMapSurround      pMapSurround     = mapSurroundFrame.MapSurround;
                    //原始 envelope
                    IEnvelope originEnvelope = (mapSurroundFrame as IElement).Geometry.Envelope;
                    double    xmin           = originEnvelope.XMin;
                    double    ymin           = originEnvelope.YMin;

                    IStyleGalleryItem styleGalleryItem = null;
                    if (pMapSurround is IMarkerNorthArrow)
                    {
                        InsertNorthArrowForm symbolForm1 = new InsertNorthArrowForm(pMapSurround);
                        styleGalleryItem = symbolForm1.GetItem(esriSymbologyStyleClass.esriStyleClassNorthArrows);
                        symbolForm1.Dispose();
                    }
                    else if (pMapSurround is IScaleBar)
                    {
                        InsertScaleBarForm symbolForm2 = new InsertScaleBarForm(pMapSurround);
                        styleGalleryItem = symbolForm2.GetItem(esriSymbologyStyleClass.esriStyleClassScaleBars);
                        symbolForm2.Dispose();
                    }
                    //InsertNorthArrowForm symbolForm = new InsertNorthArrowForm(pMapSurround);
                    //IStyleGalleryItem styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassNorthArrows);
                    //Release the form

                    if (styleGalleryItem == null)
                    {
                        return;
                    }

                    mapSurroundFrame.MapSurround = (IMapSurround)styleGalleryItem.Item;

                    //QI to IElement and set its geometry
                    IElement element = (IElement)mapSurroundFrame;

                    //Refresh the PageLayout
                    this.m_pageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, element, null);
                }

                break;

            default:
                break;
            }
        }