Beispiel #1
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            //弹出对话框
            IGraphicElements iGraphicElements = new GraphicElementsClass();

            FrmCreateText frmCreateText = new FrmCreateText();
            ITextElement  iTextElement  = new TextElementClass();

            //XtraMessageBox.Show("请输入文本");
            //string str = Interaction.InputBox("请输入文本", "字符串", "", 100, 100);//即获取用户输入的数据
            if (frmCreateText.ShowDialog() == DialogResult.OK)
            {
                //string str = textEdit1.Text;
                iTextElement.Text      = FrmCreateText.value;
                iTextElement.ScaleText = true;
                //string str = frmCreateText.textEdit1.Text;
                //iTextElement.Text = "HAO";//this.iMapDocument.DocumentFilename;//判断
                ITextSymbol sce = new TextSymbolClass();
                //ISymbolCollectionElement sce = (ISymbolCollectionElement)iTextElement;
                sce.Size = 200;
                Color  color  = ColorTranslator.FromHtml(SystemInfo.Instance.TextColor);
                IColor pColor = new RgbColorClass();
                pColor.RGB          = color.B * 65536 + color.G * 256 + color.R;
                sce.Color           = pColor;
                iTextElement.Symbol = sce;
                IElement    iElement    = (IElement)iTextElement;
                IActiveView iActiveView = this.m_pMapControl.ActiveView;
                IEnvelope   env         = m_pMapControl.ActiveView.Extent;
                tagRECT     rect        = new tagRECT();
                m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.TransformRect(env, ref rect,
                                                                                           (int)esriDisplayTransformationEnum.esriTransformToDevice);

                Rectangle rectangle = new Rectangle(rect.left, rect.top, rect.right - rect.left,
                                                    rect.bottom - rect.top);

                int x1 = (rectangle.Left + rectangle.Right) / 2;
                int y1 = (rectangle.Top + rectangle.Bottom) / 2;

                IPoint pt = this.m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
                int    x2 = (int)pt.X;
                int    y2 = (int)pt.Y;
                iElement.Geometry =
                    iActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x2, y2);
                iElement.Geometry =
                    this.m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
                this.m_pMapControl.ActiveView.GraphicsContainer.AddElement(iElement, 0);
                this.m_pMapControl.ActiveView.Refresh();
            }
        }
Beispiel #2
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            FrmCreateText frmCreateText = new FrmCreateText();

            if (frmCreateText.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    ITextElement textElement = new TextElementClass();
                    textElement.ScaleText = true;
                    textElement.Text      = frmCreateText.Words;

                    ITextSymbol sym = new TextSymbol();

                    Color  color  = ColorTranslator.FromHtml(SystemInfo.Instance.TextColor);
                    IColor pColor = new RgbColorClass();
                    pColor.RGB = color.B * 65536 + color.G * 256 + color.R;

                    sym.Color          = pColor;
                    sym.Size           = (double)frmCreateText.WordsSize;
                    textElement.Symbol = sym;


                    IPoint point = new PointClass();
                    point.PutCoords(mapX, mapY);


                    IElement element = textElement as IElement;
                    element.Geometry = point;
                    pGraphicsContainer.AddElement(element, 0);
                    m_ActiveView.Refresh();
                }
                catch (System.Exception ex)
                {
                }
            }
        }