コード例 #1
0
        public BurstTriggerSettable(float triggerPeriod, ITransform2D transform)
        {
            Ensure.True(triggerPeriod > 0);
         // Ensure.NotNull(transform); // allow null transform... so that SetTransform can be called to set it

            _triggerPeriod = triggerPeriod;
            _transform = transform;
        }
コード例 #2
0
        public VelocityTriggerSettable(float triggerDistance, ITransform2D transform)
        {
            Ensure.IsValid(triggerDistance);
            Ensure.True(triggerDistance > 0);

            _triggerDistance = triggerDistance;
            _transform = transform;
            _previousPosition = _transform.Position;
        }
コード例 #3
0
        /// <summary>
        /// Constructs the optimal ITransform2D object for the supplied x and y axes.
        /// </summary>
        /// <param name="xAxis">The xAxis to use for the world to physical transform.</param>
        /// <param name="yAxis">The yAxis to use for the world to physical transform.</param>
        /// <returns>An ITransform2D derived object for converting from world to physical coordinates.</returns>
        public static ITransform2D GetTransformer(PhysicalAxis xAxis, PhysicalAxis yAxis)
        {
            ITransform2D ret = null;

//			if (xAxis.Axis.IsLinear && yAxis.Axis.IsLinear && !xAxis.Axis.Reversed && !yAxis.Axis.Reversed)
//				ret = new FastTransform2D( xAxis, yAxis );
//			else
//				ret = new DefaultTransform2D( xAxis, yAxis );

            ret = new DefaultTransform2D(xAxis, yAxis);

            return(ret);
        }
コード例 #4
0
        public void ScalePolyline(IPolyline Raai, double scale)
        {
            ITransform2D TransForm2D = Raai as ITransform2D;


            // Get the center point of the envelope.
            IEnvelope envelope    = Raai.Envelope;
            IPoint    centerPoint = new PointClass();

            centerPoint.X = ((envelope.XMax - envelope.XMin) / 2) + envelope.XMin;
            centerPoint.Y = ((envelope.YMax - envelope.YMin) / 2) + envelope.YMin;

            TransForm2D.Scale(centerPoint, scale, scale);
        }
コード例 #5
0
ファイル: MyText.cs プロジェクト: secondii/Yutai
        private void QueryBoundsFromGeom(int hDC, ref IDisplayTransformation transform, ref IPolygon boundary,
                                         ref IGeometry point)
        {
            IPointCollection pointCollection = null;

            pointCollection = (IPointCollection)boundary;
            try
            {
                IPolygon    polygonClass    = new Polygon() as IPolygon;
                ITextSymbol textSymbolClass = new TextSymbol()
                {
                    Text = this.m_NumeratorText
                };
                (textSymbolClass as ISymbol).QueryBoundary(hDC, transform, point, polygonClass);
                IEnvelope envelope = polygonClass.Envelope;
                IPolygon  polygon  = new Polygon() as IPolygon;
                textSymbolClass = new TextSymbol()
                {
                    Text = this.m_DenominatorText
                };
                (textSymbolClass as ISymbol).QueryBoundary(hDC, transform, point, polygon);
                envelope.Union(polygon.Envelope);
                envelope.Expand(4, 0, false);
                object value = Missing.Value;
                object obj   = Missing.Value;
                pointCollection.AddPoint(envelope.LowerLeft, ref value, ref value);
                pointCollection.AddPoint(envelope.LowerRight, ref value, ref value);
                pointCollection.AddPoint(envelope.UpperRight, ref value, ref value);
                pointCollection.AddPoint(envelope.UpperLeft, ref value, ref value);
                pointCollection.AddPoint(envelope.LowerLeft, ref value, ref value);
                ITransform2D transform2D = null;
                if (this.m_Angle + this.m_dMapRotation != 0)
                {
                    transform2D = boundary as ITransform2D;
                    if (point is IPoint)
                    {
                        transform2D.Rotate(point as IPoint, Utility.Radians(this.m_Angle + this.m_dMapRotation));
                    }
                    else if (point is IEnvelope)
                    {
                        transform2D.Rotate((point as IEnvelope).LowerLeft,
                                           Utility.Radians(this.m_Angle + this.m_dMapRotation));
                    }
                }
            }
            catch (Exception exception)
            {
                exception.ToString();
            }
        }
コード例 #6
0
ファイル: MoveFeature.cs プロジェクト: siszoey/geosufan
        private void moveFeature(int x, int y)
        {
            IFeatureLayer  curLayer = getEditLayer.isExistLayer(m_MapControl.Map) as IFeatureLayer;
            IWorkspaceEdit iWE      = (curLayer.FeatureClass as IDataset).Workspace as IWorkspaceEdit;

            if (!iWE.IsBeingEdited())
            {
                iWE.StartEditing(false);
            }

            IFeatureSelection curLayerSn = curLayer as IFeatureSelection;
            ISelectionSet     pSS        = curLayerSn.SelectionSet;

            if (pSS.Count != 1)
            {
                return;
            }
            ISelectionSet iSS = (curLayer as IFeatureSelection).SelectionSet;
            ICursor       iCursor;

            iSS.Search(null, false, out iCursor);
            IFeatureCursor iFC        = iCursor as IFeatureCursor;
            IFeature       tmpFeature = iFC.NextFeature();
            IPoint         pPnt       = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
            IGeometry      pGeometry  = tmpFeature.ShapeCopy;

            if (pGeometry.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                pGeometry = pPnt;
            }
            else if (pGeometry.GeometryType == esriGeometryType.esriGeometryPolyline || pGeometry.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                double offX = 0, offY = 0;
                offX = pGeometry.Envelope.XMin + pGeometry.Envelope.Width / 2 - pPnt.X;
                offY = pGeometry.Envelope.YMin + pGeometry.Envelope.Height / 2 - pPnt.Y;
                ITransform2D iT2D = pGeometry as ITransform2D;
                iT2D.Move(-offX, -offY);
            }
            iWE.StartEditOperation();
            tmpFeature.Shape = pGeometry;
            tmpFeature.Store();
            iWE.StopEditOperation();
            //iWE.StopEditing(true);
            iWE = null;
            curLayerSn.Clear();
            curLayerSn.Add(tmpFeature);
            m_MapControl.ActiveView.Refresh();
        }
コード例 #7
0
 IGeometry IGeometricEffect.NextGeometry()
 {
     if (m_bDone)
     {
         return(null);
     }
     else
     {
         m_pCloneGeom = (IClone)m_pGeom;
         m_pGeomCopy  = (IGeometry)m_pCloneGeom.Clone();
         m_pTransform = (ITransform2D)m_pGeomCopy;
         m_pTransform.Scale(m_pCenterPoint, m_dFactorX, m_dFactorY);
         m_bDone = true;
         return(m_pGeomCopy);
     }
 }
 IGeometry IGeometricEffect.NextGeometry()
 {
     if (m_bDone)
     {
         return(null);
     }
     else
     {
         m_pCloneGeom = (IClone)m_pGeom;
         m_pGeomCopy  = (IGeometry)m_pCloneGeom.Clone();
         m_pTransform = (ITransform2D)m_pGeomCopy;
         m_pTransform.Move(m_dOffsetX, m_dOffsetY);
         m_bDone = true;
         return(m_pGeomCopy);
     }
 }
コード例 #9
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            if (Button == 1)
            {
                if (m_element is AnnotationElement)
                {
                    IPoint centerPoint = new PointClass
                    {
                        X = (m_element.Geometry.Envelope.LowerLeft.X + m_element.Geometry.Envelope.LowerRight.X) / 2,
                        Y = (m_element.Geometry.Envelope.LowerLeft.Y + m_element.Geometry.Envelope.UpperRight.Y) / 2
                    };
                    if (AnnotationLayer == null)
                    {
                        //ILayer pLayer = CommonFunctions.GetFeatureLayer("注记", m_hookHelper);
                        //AnnotationLayer = pLayer as IFeatureLayer;
                    }
                    //IFeatureClass pFeatureClass = AnnotationLayer.FeatureClass;
                    //IDataset pDataset = (IDataset)pFeatureClass;
                    //IWorkspaceEdit pWorkspaceEdit = (IWorkspaceEdit)pDataset.Workspace;
                    //pWorkspaceEdit.StartEditing(true);
                    //pWorkspaceEdit.StartEditOperation();
                    //pWorkspaceEdit.EnableUndoRedo();

                    double       angle        = ((ITextElement)m_viewElement).Symbol.Angle;
                    double       oldAngle     = ((ITextElement)m_element).Symbol.Angle;
                    ITransform2D pTransform2D = m_element as ITransform2D;
                    pTransform2D.Rotate(centerPoint, (angle - oldAngle) * Math.PI / 180);

                    IGraphicsContainer pGraphicsContainer = m_hookHelper.ActiveView as IGraphicsContainer;
                    pGraphicsContainer.UpdateElement(m_element);
                    //pWorkspaceEdit.DisableUndoRedo();
                    //pWorkspaceEdit.StopEditOperation();
                    //pWorkspaceEdit.StopEditing(true);
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_hookHelper.ActiveView.Extent);
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, m_element, m_hookHelper.ActiveView.Extent);

                    pGraphicsContainer.DeleteElement(m_viewElement);
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, m_viewElement, m_hookHelper.ActiveView.Extent);
                }
                m_moving      = false;
                m_element     = null;
                m_point       = null;
                m_viewElement = null;
                m_oldPoint    = null;
            }
        }
コード例 #10
0
        public void StartEditElement(IActiveView pView, ref IElement pElement)
        {
            if (pElement == null)
            {
                return;
            }
            m_pOrgElement = pElement;
            m_pBoundProp  = (IBoundsProperties)m_pOrgElement;
            m_pTransform  = (ITransform2D)m_pOrgElement;

            m_pActiveView = pView;
            m_pDisplay    = pView.ScreenDisplay;
            m_pGraphicCtn = pView.GraphicsContainer;
            SetUI(m_pOrgElement);
            GetProperty(m_pDisplay, m_pOrgElement);
            //this.ShowDialog();
        }
コード例 #11
0
ファイル: MeasureArea.cs プロジェクト: zhongshuiyuan/gews
 /// <summary>
 /// 按指定的角度旋转
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="originPt"></param>
 /// <param name="rotate"></param>
 void TransformByRotate(ref object obj, IPoint originPt, double rotate)
 {
     if (obj == null && originPt == null)
     {
         return;
     }
     try
     {
         ITransform2D transform2D = obj as ITransform2D;
         if (transform2D == null)
         {
             return;
         }
         transform2D.Rotate(originPt, rotate);
     }
     catch
     { }
 }
コード例 #12
0
ファイル: LogoMarkerSymbol.cs プロジェクト: secondii/Yutai
        private void QueryBoundsFromGeom(int hDC, ref IDisplayTransformation transform, ref IPolygon boundary,
                                         ref IPoint point)
        {
            double map  = 0;
            double num  = 0;
            double map1 = 0;

            num = this.PointsToMap(transform, this.m_dSize);
            if (this.m_dXOffset != 0)
            {
                map = this.PointsToMap(transform, this.m_dXOffset);
            }
            if (this.m_dYOffset != 0)
            {
                map1 = this.PointsToMap(transform, this.m_dYOffset);
            }
            point.PutCoords(point.X + map, point.Y + map1);
            this.SetupDeviceRatio(hDC, transform);
            IPointCollection   pointCollection   = null;
            ISegmentCollection segmentCollection = null;
            double             num1 = 0;
            double             num2 = 0;

            pointCollection   = (IPointCollection)boundary;
            segmentCollection = (ISegmentCollection)boundary;
            num2 = num / 2;
            num1 = Math.Sqrt(num2 * num2 / 2);
            object value = Missing.Value;

            pointCollection.AddPoint(Utility.CreatePoint(point.X + num1, point.Y - num1), ref value, ref value);
            pointCollection.AddPoint(Utility.CreatePoint(point.X - num1, point.Y - num1), ref value, ref value);
            pointCollection.AddPoint(Utility.CreatePoint(point.X - num1, point.Y + num1), ref value, ref value);
            IPoint point1 = pointCollection.Point[0];

            segmentCollection.AddSegment((ISegment)Utility.CreateCircArc(point, pointCollection.Point[2], ref point1),
                                         ref value, ref value);
            ITransform2D transform2D = null;

            if (this.m_dAngle + this.m_dMapRotation != 0)
            {
                transform2D = boundary as ITransform2D;
                transform2D.Rotate(point, Utility.Radians(this.m_dAngle + this.m_dMapRotation));
            }
        }
コード例 #13
0
        private void method_1()
        {
            int num = 0;

            this.ienumElement_0.Reset();
            for (IElement i = this.ienumElement_0.Next(); i != null; i = this.ienumElement_0.Next())
            {
                if (this.method_6(i))
                {
                    IPoint item = this.ilist_0[num] as IPoint;
                    num++;
                    this.iactiveView_0.PartialRefresh(esriViewDrawPhase.esriViewGraphics, i, null);
                    ITransform2D transform2D = i as ITransform2D;
                    transform2D.Move(-item.X, -item.Y);
                    this.igraphicsContainer_0.UpdateElement(i);
                    this.iactiveView_0.PartialRefresh(esriViewDrawPhase.esriViewGraphics, i, null);
                }
                ElementChangeEvent.ElementPositionChange(i);
            }
        }
コード例 #14
0
        public ISegmentCollection Modify1Segment(IGeometryCollection polyline, Double searchRadius, Double offsetX, Double offsetY)
        {
            IPoint   queryPoint = m_activePoint;
            IPoint   hitPoint = new PointClass();
            double   hitDistance = 0; int hitPartIndex = 0;
            int      hitSegmentIndex = 0; bool rightSide = false;
            IHitTest hitTest       = (IHitTest)polyline;
            bool     foundGeometry = hitTest.HitTest(queryPoint, searchRadius, esriGeometryHitPartType.esriGeometryPartBoundary, hitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref rightSide);

            if (foundGeometry == true)
            {
                IGeometry          geometry          = polyline.get_Geometry(hitPartIndex);
                ISegmentCollection segmentCollection =
                    (ISegmentCollection)geometry;
                ISegment     segment     = segmentCollection.get_Segment(hitSegmentIndex);
                ITransform2D transform2D = (ITransform2D)segment;
                transform2D.Move(offsetX, offsetY);
                segmentCollection.SegmentsChanged();
                return(segmentCollection);
            }
            return(null);
        }
コード例 #15
0
        private SortedList <double, int> Rotate(CPolyline frcpl, CPolyline tocpl, IPoint icentralpt)
        {
            IPointCollection4 pCol = new PolylineClass();

            pCol.AddPointCollection(tocpl as IPointCollection4);
            IPolyline5   newpolyline  = pCol as IPolyline5;
            ITransform2D pTransform2D = newpolyline as ITransform2D;

            SortedList <double, int> dblSimilaritySLt = new SortedList <double, int>(new CCmpDbl());
            double dblRotateAngle = 2 * Math.PI / 360;

            for (int i = 0; i < 360; i++)
            {
                pTransform2D.Rotate(icentralpt, dblRotateAngle);
                CPolyline        tocpl2        = new CPolyline(i, newpolyline);
                List <CCorrCpts> pCorrCptsLt   = BuildCorrespondences(frcpl, tocpl2);
                double           dblSimilarity = CalSimilarity(pCorrCptsLt);
                dblSimilaritySLt.Add(dblSimilarity, i);
            }

            return(dblSimilaritySLt);
        }
コード例 #16
0
ファイル: RotateTrackFeedback.cs プロジェクト: secondii/Yutai
 private void method_1(double double_1, int int_0)
 {
     for (int i = 0; i < this.igeometryCollection_0.GeometryCount; i++)
     {
         IGeometry    geometry    = this.igeometryCollection_0.Geometry[i];
         ITransform2D transform2D = (geometry as IClone).Clone() as ITransform2D;
         transform2D.Rotate(this.ipoint_1, double_1);
         if (
             !(geometry.GeometryType == esriGeometryType.esriGeometryMultipoint
                 ? false
                 : geometry.GeometryType != esriGeometryType.esriGeometryPoint))
         {
             if (this.isymbol_0 != null)
             {
                 this.isymbol_0.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
                 this.isymbol_0.SetupDC(int_0, this.iscreenDisplay_0.DisplayTransformation);
                 this.isymbol_0.Draw(transform2D as IGeometry);
                 this.isymbol_0.ResetDC();
             }
         }
         else if (geometry.GeometryType == esriGeometryType.esriGeometryPolyline)
         {
             if (this.isymbol_1 != null)
             {
                 this.isymbol_1.ROP2 = esriRasterOpCode.esriROPXOrPen;
                 this.isymbol_1.SetupDC(int_0, this.iscreenDisplay_0.DisplayTransformation);
                 this.isymbol_1.Draw(transform2D as IGeometry);
                 this.isymbol_1.ResetDC();
             }
         }
         else if (geometry.GeometryType == esriGeometryType.esriGeometryPolygon && this.isymbol_1 != null)
         {
             this.isymbol_1.ROP2 = esriRasterOpCode.esriROPXOrPen;
             this.isymbol_1.SetupDC(int_0, this.iscreenDisplay_0.DisplayTransformation);
             this.isymbol_1.Draw(transform2D as IGeometry);
             this.isymbol_1.ResetDC();
         }
     }
 }
コード例 #17
0
        public IPointCollection4 modify1VertexOfAPolyline(IGeometryCollection geo, Double searchRadius, Double offsetX, Double offsetY)
        {
            IPoint   queryPoint = m_activePoint;
            IPoint   hitPoint = new PointClass();
            Double   hitDistance = 0; Int32 hitPartIndex = 0;
            Int32    hitSegmentIndex = 0;
            Boolean  rightSide       = false;
            IHitTest hitTest         = (IHitTest)geo;
            Boolean  foundGeometry   = hitTest.HitTest(queryPoint, searchRadius, esriGeometryHitPartType.esriGeometryPartVertex, hitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref rightSide);

            if (foundGeometry == true)
            {
                IGeometry         geometry        = geo.get_Geometry(hitPartIndex);
                IPointCollection4 pointCollection = (IPointCollection4)geometry;
                IPoint            transformPoint  = pointCollection.get_Point(hitSegmentIndex);
                ITransform2D      transform2D     = (ITransform2D)transformPoint;
                transform2D.Move(offsetX, offsetY);
                pointCollection.UpdatePoint(hitSegmentIndex, transformPoint);
                return(pointCollection);
            }
            return(null);
        }
コード例 #18
0
        public virtual bool Zoom(double zoom) //???未写完
        {
            bool rbc = false;

            if (this.pFeature != null)
            {
                if (this.pFeature is IAnnotationFeature)
                {   //是注记要素
                    IAnnotationFeature anFeat = this.pFeature as IAnnotationFeature;
                    IElement           TextEl = (IElement)((IClone)anFeat.Annotation).Clone();
                    ITransform2D       trans  = TextEl as ITransform2D;
                    //trans.Move(dx, dy);
                    anFeat.Annotation = TextEl;
                }
                else
                {   //是一般要素
                    //if (this.pFeature.Shape.GeometryType== esriGeometryType.esriGeometryPolygon)
                    //{
                    double           x   = 0;
                    double           y   = 0;
                    IPoint           p   = null;
                    IGeometry        geo = this.pFeature.ShapeCopy;
                    IPointCollection pn  = geo as IPointCollection;
                    for (int i = 0; i < pn.PointCount; i++)
                    {
                        p = pn.get_Point(i);
                        x = p.X;
                        y = p.Y;
                        //???
                    }
                    rbc = true;
                    //}
                }
            }
            return(rbc);
        }
コード例 #19
0
 public void SetTransform(ITransform2D transform)
 {
     Ensure.NotNull(transform);
     _transform = transform;
 }
コード例 #20
0
 public void SetTransform(ITransform2D transform)
 {
     _transform = transform;
     _previousPosition = _transform.Position;
 }
コード例 #21
0
        /// <summary>
        /// Draws the line plot on a GDI+ surface against the provided x and y axes.
        /// </summary>
        /// <param name="g">The GDI+ surface on which to draw.</param>
        /// <param name="xAxis">The X-Axis to draw against.</param>
        /// <param name="yAxis">The Y-Axis to draw against.</param>
        /// <param name="drawShadow">If true draw the shadow for the line. If false, draw line.</param>
        public void DrawLineOrShadow(Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis, bool drawShadow)
        {
            Pen shadowPen = null;

            if (drawShadow)
            {
                shadowPen       = (Pen)this.Pen.Clone();
                shadowPen.Color = this.ShadowColor;
            }

            SequenceAdapter data =
                new SequenceAdapter(this.DataSource, this.DataMember, this.OrdinateData, this.AbscissaData);

            ITransform2D t = Transform2D.GetTransformer(xAxis, yAxis);

            int numberPoints = data.Count;

            if (data.Count == 0)
            {
                return;
            }

            // clipping is now handled assigning a clip region in the
            // graphic object before this call
            if (numberPoints == 1)
            {
                Point physical = t.Transform(data[0]);

                if (drawShadow)
                {
                    g.DrawLine(shadowPen,
                               (int)(physical.X - 0.5f + this.ShadowOffset.X),
                               physical.Y + this.ShadowOffset.Y,
                               (int)(physical.X + 0.5f + this.ShadowOffset.X),
                               physical.Y + this.ShadowOffset.Y);
                }
                else
                {
                    g.DrawLine(Pen, (int)(physical.X - 0.5f), physical.Y, (int)(physical.X + 0.5f), physical.Y);
                }
            }
            else
            {
                // prepare for clipping
                double leftCutoff  = xAxis.PhysicalToWorld(xAxis.PhysicalMin, false);
                double rightCutoff = xAxis.PhysicalToWorld(xAxis.PhysicalMax, false);
                if (leftCutoff > rightCutoff)
                {
                    Utils.Swap(ref leftCutoff, ref rightCutoff);
                }
                if (drawShadow)
                {
                    // correct cut-offs
                    double shadowCorrection =
                        xAxis.PhysicalToWorld(ShadowOffset, false) - xAxis.PhysicalToWorld(new Point(0, 0), false);
                    leftCutoff  -= shadowCorrection;
                    rightCutoff -= shadowCorrection;
                }

                for (int i = 1; i < numberPoints; ++i)
                {
                    // check to see if any values null. If so, then continue.
                    double dx1 = data[i - 1].X;
                    double dx2 = data[i].X;
                    double dy1 = data[i - 1].Y;
                    double dy2 = data[i].Y;
                    if (Double.IsNaN(dx1) || Double.IsNaN(dy1) ||
                        Double.IsNaN(dx2) || Double.IsNaN(dy2))
                    {
                        continue;
                    }

                    // do horizontal clipping here, to speed up
                    if ((dx1 < leftCutoff || rightCutoff < dx1) &&
                        (dx2 < leftCutoff || rightCutoff < dx2))
                    {
                        continue;
                    }

                    // else draw line.
                    Point p1 = t.Transform(data[i - 1]);
                    Point p2 = t.Transform(data[i]);

                    // when very far zoomed in, points can fall ontop of each other,
                    // and g.DrawLine throws an overflow exception
                    if (p1.Equals(p2))
                    {
                        continue;
                    }

                    if (drawShadow)
                    {
                        g.DrawLine(shadowPen,
                                   p1.X + ShadowOffset.X,
                                   p1.Y + ShadowOffset.Y,
                                   p2.X + ShadowOffset.X,
                                   p2.Y + ShadowOffset.Y);
                    }
                    else
                    {
                        g.DrawLine(Pen, p1.X, p1.Y, p2.X, p2.Y);
                    }
                }
            }
        }
コード例 #22
0
ファイル: frmMapMoveUI.cs プロジェクト: hsg77/ArcMapByCommon
        //开始平移 事件
        private void Btn_MapMove_Click(object sender, EventArgs e)
        {
            frmProgressBar2 pb2 = null;

            try
            {
                this.Btn_MapMove.Enabled = false;
                this.Cursor = Cursors.WaitCursor;
                string LineText = "";

                double dx = 0.0;
                double dy = 0.0;

                dx = CommonClass.TNum(this.numericBox1.Text.Trim());
                dy = CommonClass.TNum(this.numericBox2.Text.Trim());

                if (MessageBox.Show("请确认是否要对选中项进行整体平移操作?", "提示", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
                {
                    this.Btn_MapMove.Enabled = true;
                    this.Cursor = Cursors.Default;
                    return;
                }

                //获取选中的要素类
                List <IFeatureClass> fcList = new List <IFeatureClass>();
                for (int i = 0; i < this.checkedListBox1.Items.Count; i++)
                {
                    if (this.checkedListBox1.GetItemChecked(i) == true)
                    {   //选中要素类
                        CommonComboBoxItem cbitem = this.checkedListBox1.Items[i] as CommonComboBoxItem;
                        fcList.Add(cbitem.Tag as IFeatureClass);
                    }
                }
                if (fcList != null && fcList.Count > 0)
                {
                    pb2      = new frmProgressBar2();
                    pb2.Text = "平移进度...";
                    pb2.progressBar1.Maximum = fcList.Count + 1;
                    pb2.progressBar1.Value   = 0;
                    pb2.Caption1.Text        = "正在平移...";
                    pb2.Show(this);
                    Application.DoEvents();
                    //
                    ZHFeaturePoint zhfeat    = null;
                    int            featIndex = 0;
                    int            featCount = 0;
                    for (int i = 0; i < fcList.Count; i++)
                    {
                        featIndex = 0;
                        IFeatureClass fc = fcList[i];
                        pb2.Caption1.Text      = "正在平移图层:" + fc.AliasName + "...";
                        pb2.progressBar1.Value = i;
                        Application.DoEvents();
                        //
                        featCount = fc.FeatureCount(null);
                        pb2.progressBar2.Value   = 0;
                        pb2.progressBar2.Maximum = featCount + 1;
                        pb2.Caption2.Text        = "正在平移要素...";
                        Application.DoEvents();
                        //
                        IFeatureCursor fcur = fc.Update(null, false);
                        IFeature       feat = fcur.NextFeature();
                        while (feat != null)
                        {
                            featIndex += 1;
                            if (featIndex % 200 == 0)
                            {
                                pb2.Caption2.Text      = "正在平移图层:" + fc.AliasName + "(当前:" + featIndex.ToString() + "/" + featCount.ToString() + ")";
                                pb2.progressBar2.Value = featIndex;
                                Application.DoEvents();
                                fcur.Flush();
                            }
                            zhfeat = new ZHFeaturePoint(feat);
                            if (fc.FeatureType == esriFeatureType.esriFTAnnotation)
                            {   //注记要素移动 OK
                                IAnnotationFeature anFeat = feat as IAnnotationFeature;
                                IElement           TextEl = (IElement)((IClone)anFeat.Annotation).Clone();
                                ITransform2D       trans  = TextEl as ITransform2D;
                                trans.Move(dx, dy);
                                anFeat.Annotation = TextEl;
                                fcur.UpdateFeature(feat);
                            }
                            else
                            {   //一般要素移动 OK
                                zhfeat.Move(dx, dy);
                                fcur.UpdateFeature(feat);
                            }
                            //
                            feat = fcur.NextFeature();
                        }
                        fcur.Flush();
                        if (fcur != null)
                        {
                            TokayWorkspace.ComRelease(fcur);
                            fcur = null;
                        }
                        pb2.Caption2.Text = "正在重新计算Extent范围...";
                        Application.DoEvents();
                        //重新计算Extent范围
                        TokayWorkspace.UpdateExtent(fc);
                    }
                    if (pb2 != null)
                    {
                        pb2.Close();
                        pb2.Dispose();
                        pb2 = null;
                    }
                    MessageBox.Show("地图平移完毕!", "提示");
                }
            }
            catch (Exception ee)
            {
                Log.WriteLine(ee);
                MessageBox.Show(ee.Message, "提示");
            }
            finally
            {
                this.Btn_MapMove.Enabled = true;
                this.Cursor = Cursors.Default;
                if (pb2 != null)
                {
                    pb2.Close();
                    pb2.Dispose();
                    pb2 = null;
                }
            }
        }
コード例 #23
0
        /// <summary>
        /// 平移图形
        /// </summary>
        /// <param name="geometry">要平移的对象</param>
        /// <param name="dx">在x方向上的平移量</param>
        /// <param name="dy">在y方向上的平移量</param>
        public static void MoveGeometry(IGeometry geometry, double dx, double dy)
        {
            ITransform2D transform2D = geometry as ITransform2D;

            transform2D.Move(dx, dy);
        }
コード例 #24
0
        /// <summary>
        /// 平移图形元素
        /// </summary>
        /// <param name="feature">要平移的对象</param>
        /// <param name="dx">在x方向上的平移量</param>
        /// <param name="dy">在y方向上的平移量</param>
        public static void MoveGeometry(IFeature feature, double dx, double dy)
        {
            ITransform2D transform2D = feature.Shape as ITransform2D;

            transform2D.Move(dx, dy);
        }
コード例 #25
0
        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            if (Button == 1)
            {
                if (!m_moving)
                {
                    return;
                }

                IPoint centerPoint = new PointClass
                {
                    X = (m_element.Geometry.Envelope.LowerLeft.X + m_element.Geometry.Envelope.LowerRight.X) / 2,
                    Y = (m_element.Geometry.Envelope.LowerLeft.Y + m_element.Geometry.Envelope.UpperRight.Y) / 2
                };
                if (m_element is AnnotationElement)
                {
                    // 如果旧点为空,则赋OnMouseDown事件所获取的点值
                    if (m_oldPoint == null)
                    {
                        m_oldPoint = m_point;
                    }
                    // 新点为当前的鼠标点坐标
                    IPoint newPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                    // 获取旧点角度
                    IPointCollection pPointCollection = new PolylineClass();
                    object           missing          = Type.Missing;
                    pPointCollection.AddPoint(centerPoint, ref missing, ref missing);
                    pPointCollection.AddPoint(m_oldPoint, ref missing, ref missing);
                    double oldAngle = GetAngle(pPointCollection as IPolyline);
                    // 获取新点角度
                    IPointCollection pointCollection = new PolylineClass();
                    pointCollection.AddPoint(centerPoint, ref missing, ref missing);
                    pointCollection.AddPoint(newPoint, ref missing, ref missing);
                    double newAngle = GetAngle(pointCollection as IPolyline);
                    // 旋转Element,角度为新旧点之差
                    ITransform2D pTransform2D = m_viewElement as ITransform2D;
                    pTransform2D.Rotate(centerPoint, (newAngle - oldAngle));
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, m_viewElement, m_hookHelper.ActiveView.Extent);

                    // 更新旧点变量
                    m_oldPoint = newPoint;
                }
                else
                {
                    object           missing          = Type.Missing;
                    IPoint           newPoint         = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                    IPointCollection pPointCollection = new PolylineClass();
                    pPointCollection.AddPoint(centerPoint, ref missing, ref missing);
                    pPointCollection.AddPoint(m_point, ref missing, ref missing);
                    double oldAngle = GetAngle(pPointCollection as IPolyline);

                    IPointCollection pointCollection = new PolylineClass();
                    pointCollection.AddPoint(centerPoint, ref missing, ref missing);
                    pointCollection.AddPoint(newPoint, ref missing, ref missing);
                    double newAngle = GetAngle(pointCollection as IPolyline);

                    ITransform2D pTransform2D = m_element as ITransform2D;
                    pTransform2D.Rotate(centerPoint, (newAngle - oldAngle));
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, m_element, m_hookHelper.ActiveView.Extent);
                    m_point = newPoint;
                }
            }
        }
コード例 #26
0
        IGeometry IGeometricEffect.NextGeometry()
        {
            if (m_bDone)
            {
                return null;
            }
            else
            {
                m_pCloneGeom = (IClone)m_pGeom;
                m_pGeomCopy = (IGeometry)m_pCloneGeom.Clone();
                m_pTransform = (ITransform2D)m_pGeomCopy;
                m_pTransform.Move(m_dOffsetX, m_dOffsetY);
                m_bDone = true;
                return m_pGeomCopy;
            }

        }
コード例 #27
0
        /// <summary>
        /// Draw the filled region
        /// </summary>
        /// <param name="g">The Drawing Context with which to draw.</param>
        /// <param name="xAxis">The X-Axis to draw against.</param>
        /// <param name="yAxis">The Y-Axis to draw against.</param>
        public void Draw(Context ctx, PhysicalAxis xAxis, PhysicalAxis yAxis)
        {
            ITransform2D t = Transform2D.GetTransformer(xAxis, yAxis);

            ctx.Save();

            if (hl1 != null && hl2 != null)
            {
                ctx.MoveTo(t.Transform(xAxis.Axis.WorldMin, hl1.OrdinateValue));
                ctx.LineTo(t.Transform(xAxis.Axis.WorldMax, hl1.OrdinateValue));
                ctx.LineTo(t.Transform(xAxis.Axis.WorldMax, hl2.OrdinateValue));
                ctx.LineTo(t.Transform(xAxis.Axis.WorldMin, hl2.OrdinateValue));
                ctx.ClosePath();
            }
            else if (vl1 != null && vl2 != null)
            {
                ctx.MoveTo(t.Transform(vl1.AbscissaValue, yAxis.Axis.WorldMin));
                ctx.LineTo(t.Transform(vl1.AbscissaValue, yAxis.Axis.WorldMax));
                ctx.LineTo(t.Transform(vl2.AbscissaValue, yAxis.Axis.WorldMax));
                ctx.LineTo(t.Transform(vl2.AbscissaValue, yAxis.Axis.WorldMin));
                ctx.ClosePath();
            }
            else if (lp1 != null && lp2 != null)
            {
                SequenceAdapter a1 = new SequenceAdapter(lp1.DataSource, lp1.DataMember, lp1.OrdinateData, lp1.AbscissaData);
                SequenceAdapter a2 = new SequenceAdapter(lp2.DataSource, lp2.DataMember, lp2.OrdinateData, lp2.AbscissaData);

                // Start at first point of LinePlot 1 within plot bounds
                int start = 0;
                while (t.Transform(a1 [start]).X < xAxis.PhysicalMin.X)
                {
                    ++start;
                }
                Point first = t.Transform(a1 [start]);
                ctx.MoveTo(first);
                // Join LinePlot 1 points in ascending order
                Point next;
                for (int i = start + 1; i < a1.Count - 1; ++i)
                {
                    next = t.Transform(a1 [i]);
                    if (next.X > xAxis.PhysicalMax.X)
                    {
                        break;
                    }
                    ctx.LineTo(next);
                }
                // Then join LinePlot 2 points in descending order
                int end = a2.Count - 1;
                while (t.Transform(a2 [end]).X > xAxis.PhysicalMax.X)
                {
                    --end;
                }
                for (int i = end; i > 0; --i)
                {
                    next = t.Transform(a2 [i]);
                    if (next.X < xAxis.PhysicalMin.X)
                    {
                        break;
                    }
                    ctx.LineTo(next);
                }
                ctx.LineTo(first);
                ctx.ClosePath();
            }
            else
            {
                throw new XwPlotException("Filled Region bounds not defined");
            }
            ctx.SetColor(FillColor);
            ctx.Fill();
            ctx.Restore();
        }
コード例 #28
0
ファイル: Controller2D.cs プロジェクト: Cyanch/Okroma
 public Controller2D(string id, ITransform2D transform, ICollidableSource collidableSource) : base(id)
 {
     this.CollidableSource = collidableSource;
     this.Transform        = transform;
 }
コード例 #29
0
 public void Trigger(ITransform2D transform)
 {
     this.Trigger(transform.Position, transform.Rotation, Global.Random.Next(this.ReleaseParameters.Quantity));
 }
コード例 #30
0
        public static IGeometry GetExample11()
        {
            const double CircleDegrees         = 360.0;
            const int    CircleDivisions       = 36;
            const double VectorComponentOffset = 0.0000001;
            const double CircleRadius          = 3.0;
            const double BaseZ = 0.0;

            //Extrusion: 3D Circle Polyline Extruded Along 3D Line Via ConstructExtrudeAlongLine()

            IPointCollection polylinePointCollection = new PolylineClass();

            IGeometry polylineGeometry = polylinePointCollection as IGeometry;

            GeometryUtilities.MakeZAware(polylineGeometry);

            IPoint originPoint = GeometryUtilities.ConstructPoint3D(0, 0, 0);

            IVector3D upperAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, 10);

            IVector3D lowerAxisVector3D = GeometryUtilities.ConstructVector3D(0, 0, -10);

            lowerAxisVector3D.XComponent += VectorComponentOffset;

            IVector3D normalVector3D = upperAxisVector3D.CrossProduct(lowerAxisVector3D) as IVector3D;

            normalVector3D.Magnitude = CircleRadius;

            double rotationAngleInRadians = GeometryUtilities.GetRadians(CircleDegrees / CircleDivisions);

            for (int i = 0; i < CircleDivisions; i++)
            {
                normalVector3D.Rotate(-1 * rotationAngleInRadians, upperAxisVector3D);

                IPoint vertexPoint = GeometryUtilities.ConstructPoint3D(originPoint.X + normalVector3D.XComponent,
                                                                        originPoint.Y + normalVector3D.YComponent,
                                                                        BaseZ);

                polylinePointCollection.AddPoint(vertexPoint, ref _missing, ref _missing);
            }

            polylinePointCollection.AddPoint(polylinePointCollection.get_Point(0), ref _missing, ref _missing);

            ITopologicalOperator topologicalOperator = polylineGeometry as ITopologicalOperator;

            topologicalOperator.Simplify();

            //Define Line To Extrude Along

            ILine extrusionLine = new LineClass();

            extrusionLine.FromPoint = GeometryUtilities.ConstructPoint3D(-4, -4, -5);
            extrusionLine.ToPoint   = GeometryUtilities.ConstructPoint3D(4, 4, 5);

            //Perform Extrusion

            IConstructMultiPatch constructMultiPatch = new MultiPatchClass();

            constructMultiPatch.ConstructExtrudeAlongLine(extrusionLine, polylineGeometry);

            //Transform Extrusion Result

            IPoint centroid = GeometryUtilities.ConstructPoint2D(0.5 * (polylineGeometry.Envelope.XMax + polylineGeometry.Envelope.XMin),
                                                                 0.5 * (polylineGeometry.Envelope.YMax + polylineGeometry.Envelope.YMin));

            ITransform2D transform2D = constructMultiPatch as ITransform2D;

            transform2D.Move(extrusionLine.FromPoint.X - centroid.X, extrusionLine.FromPoint.Y - centroid.Y);

            return(constructMultiPatch as IGeometry);
        }
コード例 #31
0
 public void Trigger(ITransform2D transform)
 {
     this.Trigger(transform.Position, transform.Rotation);
 }
コード例 #32
0
 void ITile.Draw(GameTime gameTime, SpriteBatch spriteBatch, ITransform2D transform, Color color, SpriteEffects spriteEffects, float depth)
 {
     BaseTile.Draw(gameTime, spriteBatch, transform, color, spriteEffects, depth);
 }
コード例 #33
0
        /// <summary>
        /// Draws the line plot on a GDI+ surface against the provided x and y axes.
        /// </summary>
        /// <param name="g">The GDI+ surface on which to draw.</param>
        /// <param name="xAxis">The X-Axis to draw against.</param>
        /// <param name="yAxis">The Y-Axis to draw against.</param>
        /// <param name="drawShadow">If true draw the shadow for the line. If false, draw line.</param>
        public void DrawLineOrShadow(Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis, bool drawShadow)
        {
            Pen shadowPen = null;

            if (drawShadow)
            {
                shadowPen       = (Pen)this.Pen.Clone();
                shadowPen.Color = this.ShadowColor;
            }

            SequenceAdapter data =
                new SequenceAdapter(this.DataSource, this.DataMember, this.OrdinateData, this.AbscissaData);

            int numberPoints = data.Count;

            if (data.Count == 0)
            {
                return;
            }

            // clipping is now handled assigning a clip region in the
            // graphic object before this call
            if (numberPoints == 1)
            {
                PointF physical = Transform2D.GetTransformer(xAxis, yAxis).Transform(data[0]);

                if (drawShadow)
                {
                    g.DrawLine(shadowPen,
                               physical.X - 0.5f + this.ShadowOffset.X,
                               physical.Y + this.ShadowOffset.Y,
                               physical.X + 0.5f + this.ShadowOffset.X,
                               physical.Y + this.ShadowOffset.Y);
                }
                else
                {
                    g.DrawLine(Pen, physical.X - 0.5f, physical.Y, physical.X + 0.5f, physical.Y);
                }
            }
            else
            {
                // prepare for clipping
                double leftCutoff  = xAxis.PhysicalToWorld(xAxis.PhysicalMin, false);
                double rightCutoff = xAxis.PhysicalToWorld(xAxis.PhysicalMax, false);
                if (leftCutoff > rightCutoff)
                {
                    double temp = leftCutoff;
                    leftCutoff  = rightCutoff;
                    rightCutoff = temp;
                }
                if (drawShadow)
                {
                    // correct cut-offs
                    double shadowCorrection =
                        xAxis.PhysicalToWorld(ShadowOffset, false) - xAxis.PhysicalToWorld(new Point(0, 0), false);
                    leftCutoff  -= shadowCorrection;
                    rightCutoff -= shadowCorrection;
                }

                // determine which points to plot
                double        tradingTimeOffset = 0;
                List <PointD> plotPoints        = new List <PointD>(numberPoints);
                PointD        d1 = data[0];
                PointD        d2 = d1;
                if ((d1.X >= leftCutoff) && (d1.X <= rightCutoff))
                {
                    plotPoints.Add(d1);
                }
                DateTime prevTime = (DateTime)((System.Data.DataTable) this.DataSource).Rows[0][(string)this.AbscissaData];
                for (int i = 1; i < numberPoints; ++i)
                {
                    // check to see if any values null. If so, then continue.
                    d1 = d2;
                    d2 = data[i];
                    if (Double.IsNaN(d1.X) || Double.IsNaN(d1.Y) ||
                        Double.IsNaN(d2.X) || Double.IsNaN(d2.Y))
                    {
                        continue;
                    }

                    // Get the X axis offset to strip out the non-trading time
                    d1.X -= tradingTimeOffset;
                    DateTime nextTime = (DateTime)((System.Data.DataTable) this.DataSource).Rows[i][(string)this.AbscissaData];
                    if (nextTime.TimeOfDay < prevTime.TimeOfDay)
                    {
                        tradingTimeOffset += (double)(nextTime - prevTime).Ticks;
                    }
                    prevTime = nextTime;
                    d2.X    -= tradingTimeOffset;

                    // do horizontal clipping here, to speed up
                    if ((d1.X < leftCutoff && d2.X < leftCutoff) ||
                        (rightCutoff < d1.X && rightCutoff < d2.X))
                    {
                        continue;
                    }

                    // Add a point to plot
                    plotPoints.Add(d2);
                }

                // create a transform, which takes into account the skipped time
                PhysicalAxis shunkAxis = new PhysicalAxis(new DateTimeAxis(xAxis.Axis.WorldMin, xAxis.Axis.WorldMax - tradingTimeOffset), xAxis.PhysicalMin, xAxis.PhysicalMax);
                ITransform2D t         = Transform2D.GetTransformer(shunkAxis, yAxis);

                // plot those points
                for (int i = 1; i < plotPoints.Count; i++)
                {
                    // else draw line.
                    PointF p1 = t.Transform(plotPoints[i - 1]);
                    PointF p2 = t.Transform(plotPoints[i]);

                    // when very far zoomed in, points can fall ontop of each other,
                    // and g.DrawLine throws an overflow exception
                    if (p1.Equals(p2))
                    {
                        continue;
                    }

                    if (drawShadow)
                    {
                        g.DrawLine(shadowPen,
                                   p1.X + ShadowOffset.X,
                                   p1.Y + ShadowOffset.Y,
                                   p2.X + ShadowOffset.X,
                                   p2.Y + ShadowOffset.Y);
                    }
                    else
                    {
                        g.DrawLine(Pen, p1.X, p1.Y, p2.X, p2.Y);
                    }
                }
            }
        }
コード例 #34
0
 IGeometry IGeometricEffect.NextGeometry()
 {
     if (m_bDone)
     {
         return null;
     }
     else
     {
         m_pCloneGeom = (IClone)m_pGeom;
         m_pGeomCopy = (IGeometry)m_pCloneGeom.Clone();
         m_pTransform = (ITransform2D)m_pGeomCopy;
         m_pTransform.Scale(m_pCenterPoint, m_dFactorX, m_dFactorY);
         m_bDone = true;
         return m_pGeomCopy;                
     }
 }
コード例 #35
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            m_command.OnClick();
            m_hookHelper.ActiveView.Refresh();
            IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            pPoint = GIS.GraphicEdit.SnapSetting.getSnapPoint(pPoint);
            IFeatureLayer featureLayer = GIS.Common.DataEditCommon.copypasteLayer;

            if (featureLayer == null)
            {
                return;
            }
            IFeatureSelection m_featureSelection = featureLayer as IFeatureSelection;

            ESRI.ArcGIS.Geodatabase.ISelectionSet m_selectionSet = m_featureSelection.SelectionSet;
            if (m_selectionSet.Count == 0)
            {
                return;
            }
            IFeatureClass pFeatureClass = featureLayer.FeatureClass;
            ICursor       pCursor       = null;

            m_selectionSet.Search(null, false, out pCursor);
            IFeatureCursor pFeatureCursor = pCursor as IFeatureCursor;
            IFeature       m_pFeature     = pFeatureCursor.NextFeature();
            double         dx             = 0;
            double         dy             = 0;

            if (m_pFeature == null)
            {
                return;
            }
            DataEditCommon.InitEditEnvironment();
            DataEditCommon.CheckEditState();
            while (m_pFeature != null)
            {
                ITransform2D pTrans2D = m_pFeature.ShapeCopy as ITransform2D;
                if (m_pFeature.Shape.Dimension == esriGeometryDimension.esriGeometry0Dimension)
                {
                    IPoint pt = m_pFeature.Shape as IPoint;
                    if (dx == 0)
                    {
                        dx = pPoint.X - pt.X;
                    }
                    if (dy == 0)
                    {
                        dy = pPoint.Y - pt.Y;
                    }
                    pTrans2D.Move(dx, dy);
                    m_pFeature.Shape = pTrans2D as IGeometry;
                    m_pFeature.Store();
                }
                else if (m_pFeature.Shape.Dimension == esriGeometryDimension.esriGeometry1Dimension)
                {
                    IPolyline lPolyline = m_pFeature.Shape as IPolyline;
                    if (dx == 0)
                    {
                        dx = pPoint.X - lPolyline.FromPoint.X;
                    }
                    if (dy == 0)
                    {
                        dy = pPoint.Y - lPolyline.FromPoint.Y;
                    }
                    pTrans2D.Move(dx, dy);
                    m_pFeature.Shape = pTrans2D as IGeometry;
                    m_pFeature.Store();
                }
                else if (m_pFeature.Shape.Dimension == esriGeometryDimension.esriGeometry2Dimension)
                {
                    if (m_pFeature.FeatureType == esriFeatureType.esriFTAnnotation)
                    {
                        IAnnotationFeature annoFeature = m_pFeature as IAnnotationFeature;

                        IElement     element     = (IElement)annoFeature.Annotation;
                        ITextElement textElement = new TextElementClass();
                        IPoint       mPoint      = element.Geometry as IPoint;
                        pTrans2D = mPoint as ITransform2D;
                        if (dx == 0)
                        {
                            dx = pPoint.X - mPoint.X;
                        }
                        if (dy == 0)
                        {
                            dy = pPoint.Y - mPoint.Y;
                        }
                        pTrans2D.Move(dx, dy);
                        element.Geometry       = pTrans2D as IGeometry;
                        annoFeature.Annotation = element;
                        m_pFeature.Store();
                    }
                    else
                    {
                        IPolygon lPolyline = m_pFeature.Shape as IPolygon;
                        if (dx == 0)
                        {
                            dx = pPoint.X - lPolyline.FromPoint.X;
                        }
                        if (dy == 0)
                        {
                            dy = pPoint.Y - lPolyline.FromPoint.Y;
                        }
                        pTrans2D.Move(dx, dy);
                        m_pFeature.Shape = pTrans2D as IGeometry;
                        m_pFeature.Store();
                    }
                }
                else
                {
                }
                m_pFeature = pFeatureCursor.NextFeature();
            }
            DataEditCommon.g_engineEditor.StopOperation("editpaste");
            GIS.Common.DataEditCommon.copypaste = 0;
            DataEditCommon.copypasteLayer       = null;
            m_hookHelper.ActiveView.Refresh();
            //IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            //pPoint = GIS.GraphicEdit.SnapSetting.getSnapPoint(pPoint);
            //IFeatureLayer featureLayer = DataEditCommon.g_pLayer as IFeatureLayer;
            //if (featureLayer == null) return;
            //if (DataEditCommon.MyCopy.m_featureLayer.FeatureClass.ShapeType == featureLayer.FeatureClass.ShapeType && DataEditCommon.MyCopy.m_featureLayer.FeatureClass.FeatureType == featureLayer.FeatureClass.FeatureType)
            //{
            //    ESRI.ArcGIS.Geodatabase.ISelectionSet m_selectionSet = DataEditCommon.MyCopy.m_selectionSet;
            //    for (int i = 0; i < m_selectionSet.Count; i++)
            //    {

            //    }
            //}
            //else if (DataEditCommon.MyCopy.m_featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline && featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon && featureLayer.FeatureClass.FeatureType != esriFeatureType.esriFTAnnotation)
            //{

            //}
            //else if (DataEditCommon.MyCopy.m_featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon && DataEditCommon.MyCopy.m_featureLayer.FeatureClass.FeatureType!=esriFeatureType.esriFTAnnotation&& featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
            //{

            //}
            //DataEditCommon.InitEditEnvironment();
            //DataEditCommon.CheckEditState();
        }
コード例 #36
0
        //复制要素
        public static void CopyFeatureAndTran(IFeatureCursor pCursor, IFeatureClass pToFeatureClass, ITransformation inTransformation)
        {
            IFeature       pFeature       = pCursor.NextFeature();
            IFeatureCursor pFeatureCursor = pToFeatureClass.Insert(true);
            int            iCount         = 0;

            while (pFeature != null)
            {
                IFeatureBuffer pFeatureBuffer = pToFeatureClass.CreateFeatureBuffer();

                for (int i = 0; i < pFeature.Fields.FieldCount; i++)
                {
                    string sFieldName = pFeature.Fields.get_Field(i).Name;

                    int iIndex = pFeatureBuffer.Fields.FindField(sFieldName);

                    if ((iIndex > -1) && (pFeatureBuffer.Fields.get_Field(iIndex).Editable == true))
                    {
                        pFeatureBuffer.set_Value(iIndex, pFeature.get_Value(i));
                    }
                }
                if (pEnumFieldError != null)//yjl20110804 add
                {
                    pEnumFieldError.Reset();
                    IFieldError pFieldError = pEnumFieldError.Next();
                    while (pFieldError != null)
                    {
                        int srcIx = pFieldError.FieldIndex;                                             //错误字段的源索引
                        int desIx = pFeatureBuffer.Fields.FindField(pFixedField.get_Field(srcIx).Name); //错误字段的新索引
                        if (desIx == -1)
                        {
                            pFieldError = pEnumFieldError.Next();
                            continue;
                        }
                        IField pFld = pFeatureBuffer.Fields.get_Field(desIx);
                        if ((desIx > -1) && (pFld.Editable == true) && pFld.Type != esriFieldType.esriFieldTypeGeometry)
                        {
                            pFeatureBuffer.set_Value(desIx, pFeature.get_Value(srcIx));
                        }
                        pFieldError = pEnumFieldError.Next();
                    }
                }
                IGeometry    shpTransformed = pFeature.ShapeCopy;
                ITransform2D pTransform2D   = shpTransformed as ITransform2D;
                pTransform2D.Transform(esriTransformDirection.esriTransformForward, inTransformation);
                pFeatureBuffer.Shape = shpTransformed;
                pFeatureCursor.InsertFeature(pFeatureBuffer);
                if (iCount == 500)
                {
                    pFeatureCursor.Flush();
                    iCount = 0;
                }
                iCount++;
                pFeature = pCursor.NextFeature();
            }
            if (iCount > 0)
            {
                pFeatureCursor.Flush();
            }

            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
            pFeatureCursor = null;
        }
コード例 #37
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button == 2)
            {
                return;
            }
            INewLineFeedback pLineFeed;

            if (m_pPoint1 == null)
            {
                m_pPoint1   = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                m_pPoint1   = GIS.GraphicEdit.SnapSetting.getSnapPoint(m_pPoint1);
                m_pFeedback = new NewLineFeedbackClass();
                pLineFeed   = (INewLineFeedback)m_pFeedback;
                pLineFeed.Start(m_pPoint1);
                if (m_pFeedback != null)
                {
                    m_pFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay;
                }
            }
            else if (m_pPoint2 == null)
            {
                ///20140216 lyf
                ICursor pCursor = null;
                m_selectionSet.Search(null, false, out pCursor);
                IFeatureCursor pFeatureCursor = pCursor as IFeatureCursor;
                IFeature       m_pFeature     = pFeatureCursor.NextFeature();

                if (pCursor != null)
                {
                    pCursor = null;
                    ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(pCursor);
                }

                if (m_pFeature == null)
                {
                    MessageBox.Show(@"所选要素为空,请重新选择要素。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                m_pPoint2 = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                m_pPoint2 = GIS.GraphicEdit.SnapSetting.getSnapPoint(m_pPoint2);
                //线和要素都齐全了,开始复制
                //IFeatureLayer pFeatureLayer = m_pCurrentLayer as IFeatureLayer;
                IFeatureClass pFeatureClass = m_featureLayer.FeatureClass;
                ILine         nLine         = new LineClass();//镜像轴线
                nLine.PutCoords(m_pPoint1, m_pPoint2);
                ITransformation         nTransformation         = new AffineTransformation2DClass();
                IAffineTransformation2D nAffineTransformation2D = nTransformation as IAffineTransformation2D;
                nAffineTransformation2D.DefineReflection(nLine);

                //启动编辑
                IWorkspaceEdit pWorkspaceEdit = DataEditCommon.g_CurWorkspaceEdit; // GetWorkspaceEdit();

                ITransform2D nTransform2D = m_pFeature.Shape as ITransform2D;      //镜像目标

                nTransform2D.Transform(esriTransformDirection.esriTransformForward, nTransformation);

                if (m_pFeature.Shape.Dimension == esriGeometryDimension.esriGeometry0Dimension)
                {
                    pWorkspaceEdit.StartEditOperation();
                    IFeature pNewFeature = pFeatureClass.CreateFeature();
                    IPoint   pNewPoint   = nTransform2D as IPoint;
                    pNewFeature.Shape = pNewPoint;
                    pNewFeature.Store();
                    pWorkspaceEdit.StopEditOperation();
                    DataEditCommon.g_pMyMapCtrl.Map.ClearSelection();
                    DataEditCommon.g_pMyMapCtrl.Map.SelectFeature(m_pCurrentLayer, pNewFeature);
                }
                else if (m_pFeature.Shape.Dimension == esriGeometryDimension.esriGeometry1Dimension)
                {
                    pWorkspaceEdit.StartEditOperation();
                    IFeature  pNewFeature  = pFeatureClass.CreateFeature();
                    IPolyline pNewPolyline = nTransform2D as IPolyline;//镜像所得
                    pNewFeature.Shape = pNewPolyline;
                    pNewFeature.Store();
                    pWorkspaceEdit.StopEditOperation();
                    DataEditCommon.g_pMyMapCtrl.Map.ClearSelection();
                    DataEditCommon.g_pMyMapCtrl.Map.SelectFeature(m_pCurrentLayer, pNewFeature);
                }
                else if (m_pFeature.Shape.Dimension == esriGeometryDimension.esriGeometry2Dimension)
                {
                    pWorkspaceEdit.StartEditOperation();
                    IFeature pNewFeature = pFeatureClass.CreateFeature();
                    IPolygon pNewPolygon = nTransform2D as IPolygon;//镜像所得
                    pNewFeature.Shape = pNewPolygon;
                    pNewFeature.Store();
                    pWorkspaceEdit.StopEditOperation();
                    DataEditCommon.g_pMyMapCtrl.Map.ClearSelection();
                    DataEditCommon.g_pMyMapCtrl.Map.SelectFeature(m_pCurrentLayer, pNewFeature);
                }
                else
                {
                }
                pLineFeed = (INewLineFeedback)m_pFeedback;
                pLineFeed.AddPoint(m_pPoint2);

                pLineFeed.Stop();//拖拽停止
                m_pFeature = null;
                m_pPoint1  = null;
                m_pPoint2  = null;
            }

            m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
コード例 #38
0
ファイル: CmdRotateFeature.cs プロジェクト: secondii/Yutai
 public override void OnMouseUp(int int_0, int int_1, int int_2, int int_3)
 {
     if (this.irotateTrackerFeedback_0 != null)
     {
         if (int_0 == 1 && this.bool_2)
         {
             _context.ActiveView.Refresh();
         }
         else if (this.bool_1)
         {
             this.bool_1 = false;
             if (this.irotateTrackerFeedback_0 != null)
             {
                 this.irotateTrackerFeedback_0.ClearGeometry();
                 if (this.irotateTrackerFeedback_0.Angle != 0)
                 {
                     IEnvelope    envelope         = null;
                     IEnumFeature featureSelection = _context.FocusMap.FeatureSelection as IEnumFeature;
                     featureSelection.Reset();
                     for (IFeature i = featureSelection.Next(); i != null; i = featureSelection.Next())
                     {
                         ITransform2D shapeCopy = i.ShapeCopy as ITransform2D;
                         if (envelope != null)
                         {
                             envelope.Union((shapeCopy as IGeometry).Envelope);
                         }
                         else
                         {
                             envelope = (shapeCopy as IGeometry).Envelope;
                         }
                         if (shapeCopy != null)
                         {
                             shapeCopy.Rotate(this.irotateTrackerFeedback_0.Origin,
                                              this.irotateTrackerFeedback_0.Angle);
                             Yutai.ArcGIS.Common.Editor.Editor.StartEditOperation(i.Class as IDataset);
                             try
                             {
                                 i.Shape = shapeCopy as IGeometry;
                                 i.Store();
                                 envelope.Union((shapeCopy as IGeometry).Envelope);
                             }
                             catch (Exception exception)
                             {
                                 CErrorLog.writeErrorLog(this, exception, "");
                             }
                             Yutai.ArcGIS.Common.Editor.Editor.StopEditOperation(i.Class as IDataset);
                         }
                     }
                     if (envelope != null)
                     {
                         double mapUnits = Common.ConvertPixelsToMapUnits(_context.ActiveView, 10);
                         envelope.Expand(mapUnits, mapUnits, false);
                         _context.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null,
                                                            envelope);
                     }
                     _context.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null,
                                                        null);
                     this.irotateTrackerFeedback_0.Origin = null;
                 }
             }
         }
     }
 }