コード例 #1
0
 public override void OnDblClick()
 {
     if (this._lineFeedback != null)
     {
         this._Point = null;
         IPolyline polyline = this._lineFeedback.Stop();
         this._lineFeedback = null;
         if (!polyline.IsEmpty)
         {
             frmInputText frm = new frmInputText();
             frm.Title             = "输入缓冲距离";
             frm.Label             = "缓冲距离";
             frm.txtText.EditValue = 50;
             if (frm.ShowDialog() != DialogResult.OK)
             {
                 return;
             }
             double bufferDist = 50;
             try
             {
                 bufferDist = Convert.ToDouble(frm.txtText.EditValue);
             }
             catch (Exception)
             {
                 MessageService.Current.Warn("缓冲距离必须为数字!");
                 return;
             }
             ITopologicalOperator topo   = polyline as ITopologicalOperator;
             IGeometry            buffer = topo.Buffer(bufferDist);
             _plugin.FireFenceAdded(new FenceAddedArgs((IGeometry)buffer));
             IActiveView activeView = this._context.FocusMap as IActiveView;
             activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, buffer.Envelope);
         }
     }
 }
コード例 #2
0
ファイル: CmdNewTitle.cs プロジェクト: secondii/Yutai
        public override void OnClick()
        {
            frmInputText frmInputText = new frmInputText();

            if (frmInputText.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string       text        = frmInputText.txtText.Text;
                IElement     element     = new TextElement();
                ITextElement textElement = element as ITextElement;
                ITextSymbol  textSymbol  = new TextSymbol();
                textSymbol.Text = text;
                textSymbol.Size = 48.0;
                IActiveView activeView = this._context.ActiveView as IActiveView;
                activeView.ScreenDisplay.StartDrawing(0, 0);
                double num;
                double num2;
                textSymbol.GetTextSize(activeView.ScreenDisplay.WindowDC, activeView.ScreenDisplay.DisplayTransformation,
                                       text, out num, out num2);
                activeView.ScreenDisplay.FinishDrawing();
                textSymbol.Text = text;
                num            *= 0.0353;
                num2           *= 0.0353;
                IEnvelope extent = (this._context.ActiveView as IActiveView).Extent;
                double    num3;
                double    num4;
                double    num5;
                double    num6;
                extent.QueryCoords(out num3, out num4, out num5, out num6);
                num3 = (num3 + num5) / 2.0;
                num4 = num6 - 3.0;
                num5 = num3 + 1.2 * num;
                num6 = num4 + 1.2 * num2;
                num3 = (double)((int)num3);
                num4 = (double)((int)num4);
                num5 = (double)((int)num5);
                num6 = (double)((int)num6);
                extent.PutCoords(num3, num4, num5, num6);
                textElement.Symbol = textSymbol;
                textElement.Text   = text;
                IPoint point = new ESRI.ArcGIS.Geometry.Point();
                point.PutCoords(num3, num4);
                element.Geometry = point;
                IGraphicsContainer arg_181_0 = activeView.GraphicsContainer;
                (element as IElementProperties2).AutoTransform = true;
                INewElementOperation operation = new NewElementOperation
                {
                    ActiveView = this._context.ActiveView,
                    Element    = element
                };
                this._context.OperationStack.Do(operation);
            }
        }
コード例 #3
0
        public override void OnMouseDown(int button, int Shift, int x, int y)
        {
            if (button != 1)
            {
                return;
            }
            if (this._context.ActiveView is IPageLayout)
            {
                IPoint location = this._context.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
                IMap   map      = this._context.ActiveView.HitTestMap(location);
                if (map == null)
                {
                    return;
                }
                if (map != this._context.FocusMap)
                {
                    this._context.ActiveView.FocusMap = map;
                    this._context.ActiveView.Refresh();
                }
            }
            IPoint point = ((IActiveView)this._context.FocusMap).ScreenDisplay.DisplayTransformation.ToMapPoint(x,
                                                                                                                y);

            frmInputText frm = new frmInputText();

            frm.txtText.Properties.EditFormat.FormatType = FormatType.Numeric;
            frm.Label = "输入半径";
            if (frm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            try
            {
                double radius = Convert.ToDouble(frm.txtText.EditValue);
                IConstructCircularArc2 arc2 = new CircularArc() as IConstructCircularArc2;
                arc2.ConstructCircle(point, radius, false);
                IPolygon polygon = new Polygon() as IPolygon;
                object   value   = Missing.Value;
                (polygon as ISegmentCollection).AddSegment(arc2 as ISegment, ref value, ref value);
                _plugin.FireFenceAdded(new FenceAddedArgs((IGeometry)polygon));
                IActiveView activeView = this._context.FocusMap as IActiveView;
                activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, polygon.Envelope);
            }
            catch (Exception ex)
            {
                MessageService.Current.Warn("半径必须为数字!");
            }
        }