Exemplo n.º 1
0
        private void method_0(bool bool_0)
        {
            double width  = this.ienvelope_0.Width;
            double height = this.ienvelope_0.Height;

            if (width == 0)
            {
                this.ienvelope_0.Width = 1;
                this.ienvelope_1.Width = 1;
            }
            if (height == 0)
            {
                this.ienvelope_0.Height = 1;
                this.ienvelope_1.Height = 1;
            }
            IAffineTransformation2D affineTransformation2DClass =
                new AffineTransformation2D() as IAffineTransformation2D;

            affineTransformation2DClass.DefineFromEnvelopes(this.ienvelope_0, this.ienvelope_1);
            ITransform2D ielement0 = this.ielement_0 as ITransform2D;

            if (!bool_0)
            {
                ielement0.Transform(esriTransformDirection.esriTransformReverse, affineTransformation2DClass);
            }
            else
            {
                ielement0.Transform(esriTransformDirection.esriTransformForward, affineTransformation2DClass);
            }
        }
Exemplo n.º 2
0
        private void method_0(bool bool_0)
        {
            double width  = this.ienvelope_0.Width;
            double height = this.ienvelope_0.Height;

            if (width == 0.0)
            {
                this.ienvelope_0.Width = 1.0;
                this.ienvelope_1.Width = 1.0;
            }
            if (height == 0.0)
            {
                this.ienvelope_0.Height = 1.0;
                this.ienvelope_1.Height = 1.0;
            }
            IAffineTransformation2D transformation = new AffineTransformation2DClass();

            transformation.DefineFromEnvelopes(this.ienvelope_0, this.ienvelope_1);
            ITransform2D transformd = this.ielement_0 as ITransform2D;

            if (bool_0)
            {
                transformd.Transform(esriTransformDirection.esriTransformForward, transformation);
            }
            else
            {
                transformd.Transform(esriTransformDirection.esriTransformReverse, transformation);
            }
        }
Exemplo n.º 3
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>
        public void Draw(Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis)
        {
            SequenceAdapter dataTop =
                new SequenceAdapter(this.DataSource, this.DataMember, this.OrdinateDataTop, this.AbscissaData);

            SequenceAdapter dataBottom =
                new SequenceAdapter(this.DataSource, this.DataMember, this.OrdinateDataBottom, this.AbscissaData);

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

            for (int i = 0; i < dataTop.Count; ++i)
            {
                PointF physicalBottom = t.Transform(dataBottom[i]);
                PointF physicalTop    = t.Transform(dataTop[i]);

                if (physicalBottom != physicalTop)
                {
                    Rectangle r = new Rectangle((int)(physicalBottom.X - BarWidth / 2), (int)physicalTop.Y,
                                                (int)BarWidth, (int)(physicalBottom.Y - physicalTop.Y));

                    g.FillRectangle(this.rectangleBrush_.Get(r), r);
                    g.DrawRectangle(borderPen_, r);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Draws the line plot using the Drawing Context and x and y axes provided
        /// </summary>
        /// <param name="ctx">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)
        {
            SequenceAdapter dataTop    = new SequenceAdapter(DataSource, DataMember, OrdinateDataTop, AbscissaData);
            SequenceAdapter dataBottom = new SequenceAdapter(DataSource, DataMember, OrdinateDataBottom, AbscissaData);

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

            ctx.Save();
            for (int i = 0; i < dataTop.Count; ++i)
            {
                Point physicalBottom = t.Transform(dataBottom[i]);
                Point physicalTop    = t.Transform(dataTop[i]);

                if (physicalBottom != physicalTop)
                {
                    Rectangle r = new Rectangle(physicalBottom.X - BarWidth / 2, physicalTop.Y, BarWidth, (physicalBottom.Y - physicalTop.Y));
                    ctx.SetColor(fillColor);
                    ctx.Rectangle(r);
                    ctx.FillPreserve();
                    ctx.SetColor(borderColor);
                    ctx.Stroke();
                }
            }
            ctx.Restore();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Draw the filled region
        /// </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>
        public void Draw(System.Drawing.Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis)
        {
            ITransform2D t = Transform2D.GetTransformer(xAxis, yAxis);

            Brush b = brush_;

            if (b == null)
            {
                b = areaBrush_.Get(new Rectangle(xAxis.PhysicalMin.X, yAxis.PhysicalMax.Y, xAxis.PhysicalLength, yAxis.PhysicalLength));
            }

            if (hl1_ != null && hl2_ != null)
            {
                PointF[] points = new PointF[4];
                points[0] = t.Transform(xAxis.Axis.WorldMin, hl1_.OrdinateValue);
                points[1] = t.Transform(xAxis.Axis.WorldMax, hl1_.OrdinateValue);
                points[2] = t.Transform(xAxis.Axis.WorldMax, hl2_.OrdinateValue);
                points[3] = t.Transform(xAxis.Axis.WorldMin, hl2_.OrdinateValue);

                g.FillPolygon(b, points);
            }
            else if (vl1_ != null && vl2_ != null)
            {
                PointF[] points = new PointF[4];
                points[0] = t.Transform(vl1_.AbscissaValue, yAxis.Axis.WorldMin);
                points[1] = t.Transform(vl1_.AbscissaValue, yAxis.Axis.WorldMax);
                points[2] = t.Transform(vl2_.AbscissaValue, yAxis.Axis.WorldMax);
                points[3] = t.Transform(vl2_.AbscissaValue, yAxis.Axis.WorldMin);

                g.FillPolygon(b, points);
            }
            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);


                int      count  = a1.Count + a2.Count;
                PointF[] points = new PointF[count];
                for (int i = 0; i < a1.Count; ++i)
                {
                    points[i] = t.Transform(a1[i]);
                }
                for (int i = 0; i < a2.Count; ++i)
                {
                    points[i + a1.Count] = t.Transform(a2[a2.Count - i - 1]);
                }

                g.FillPolygon(b, points);
            }
            else
            {
                throw new NPlotException("One of bounds was set to null");
            }
        }
Exemplo n.º 6
0
        private void execAdjust(ITransformation trans)
        {
            if (DialogResult.Yes != MessageBox.Show("是否确定执行转换?", "", MessageBoxButtons.YesNo))
            {
                return;
            }

            for (int i = 0; i < m_CmdSetAdjustData.ListLayers.Count; i++)
            {
                //获得layer
                IFeatureClass  pFC      = ((IFeatureLayer)findLayer(m_CmdSetAdjustData.ListLayers[i])).FeatureClass;
                IFeatureCursor pFCursor = pFC.Update(null, false);
                IFeature       pF       = pFCursor.NextFeature();
                while (pF != null)
                {
                    ITransform2D pTrans = pF.Shape as ITransform2D;
                    pTrans.Transform(esriTransformDirection.esriTransformForward, trans);
                    pF.Store();
                    pF = pFCursor.NextFeature();
                }
            }

            m_NewDisplacement.OriginPoints.RemovePoints(0, m_NewDisplacement.OriginPoints.PointCount);
            m_NewDisplacement.TargetPoints.RemovePoints(0, m_NewDisplacement.TargetPoints.PointCount);
            m_NewDisplacement.VectorLinkTable.RefreshDataTable();
            m_NewDisplacement.RefreshLayer();
            m_pControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 实现对要素类的坐标的仿射变换
        /// </summary>
        /// <param name="inFC">要素类</param>
        /// <param name="inTransformation">转换类</param>
        private void coordTransfermation(IFeatureClass inFC, ITransformation inTransformation)
        {
            IFeatureCursor pFCursor = inFC.Update(null, false);
            IFeature       pFeature = pFCursor.NextFeature();

            while (pFeature != null)
            {
                IGeometry    shpTransformed = pFeature.ShapeCopy;
                ITransform2D pTransform2D   = shpTransformed as ITransform2D;
                pTransform2D.Transform(esriTransformDirection.esriTransformForward, inTransformation);
                pFeature.Shape = shpTransformed;
                //int id = inFC.FindField("LAYER_OID");
                //if((inFC as IDataset).Name=="宗地_Project54_1")
                //pFeature.set_Value(id,"1");

                pFCursor.UpdateFeature(pFeature);
                //cursor后移
                pFeature = pFCursor.NextFeature();
            }
            Marshal.ReleaseComObject(pFCursor);//释放cursor
            ISpatialReference     unKnownSR = new UnknownCoordinateSystemClass();
            IGeoDatasetSchemaEdit pGDSE     = inFC as IGeoDatasetSchemaEdit;

            if (pGDSE.CanAlterSpatialReference)
            {
                pGDSE.AlterSpatialReference(unKnownSR);//更新要素类的投影
            }
            IFeatureClassManage pFCM = inFC as IFeatureClassManage;

            pFCM.UpdateExtent();//更新要素类的最值范围
            IGeoDataset pGD = inFC as IGeoDataset;
            IEnvelope   ppp = pGD.Extent;
        }
Exemplo n.º 8
0
        public bool GetTK(IPageLayout ipageLayout_0)
        {
            IEnvelope envelope;
            IEnvelope envelope2;

            if (this.string_2.Length == 0)
            {
                return(false);
            }
            IMapFrame frame = (ipageLayout_0 as IActiveView).GraphicsContainer.FindFrame((ipageLayout_0 as IActiveView).FocusMap) as IMapFrame;

            if ((this.double_1 != 0.0) || (this.double_2 != 0.0))
            {
                ipageLayout_0.Page.PutCustomSize(this.double_1 + 6.0, this.double_2 + 6.0);
                envelope  = (frame as IElement).Geometry.Envelope;
                envelope2 = new EnvelopeClass();
                if (this.double_1 == 0.0)
                {
                    this.double_1 = envelope.Width;
                }
                if (this.double_2 == 0.0)
                {
                    this.double_2 = envelope.Height;
                }
                envelope2.PutCoords(envelope.XMin, envelope.YMin, envelope.XMin + this.double_1, envelope.YMin + this.double_2);
                IAffineTransformation2D transformation = new AffineTransformation2DClass();
                transformation.DefineFromEnvelopes(envelope, envelope2);
                ITransform2D transformd = frame as ITransform2D;
                transformd.Transform(esriTransformDirection.esriTransformForward, transformation);
                double dx = 0.0;
                double dy = 0.0;
                if (envelope.XMin < 2.0)
                {
                    dx = 2.0;
                }
                if (envelope.YMin < 2.0)
                {
                    dy = 2.0;
                }
                if ((dx != 0.0) && (dy != 0.0))
                {
                    transformd.Move(dx, dy);
                }
            }
            if (this.double_0 > 0.0)
            {
                envelope = (frame as IElement).Geometry.Envelope;
                double    num3   = (envelope.Width * this.double_0) / 100.0;
                double    num4   = (envelope.Height * this.double_0) / 100.0;
                IEnvelope extent = (frame.Map as IActiveView).Extent;
                envelope2 = new EnvelopeClass();
                envelope2.PutCoords(extent.XMin, extent.YMin, extent.XMin + num3, extent.YMin + num4);
                (frame.Map as IActiveView).Extent = envelope2;
            }
            frame.Border = null;
            return(true);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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();
        }
Exemplo n.º 11
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);
                    }
                }
            }
        }
Exemplo n.º 12
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);
                    }
                }
            }
        }
Exemplo n.º 13
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;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Draws the line plot using the Context and Physical Axes provided
        /// </summary>
        /// <param name="ctx">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>
        /// <param name="drawShadow">If true draw the shadow for the line. If false, draw line.</param>
        public void DrawLineOrShadow(Context ctx, PhysicalAxis xAxis, PhysicalAxis yAxis, bool drawShadow)
        {
            SequenceAdapter data = new SequenceAdapter(DataSource, DataMember, OrdinateData, AbscissaData);

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

            int numberPoints = data.Count;

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

            ctx.Save();
            ctx.SetLineWidth(lineWidth);
            if (lineDash != null)
            {
                ctx.SetLineDash(0, lineDash);
            }

            if (numberPoints == 1)
            {
                Point physical = t.Transform(data[0]);

                if (drawShadow)
                {
                    ctx.SetColor(shadowColor);
                    ctx.MoveTo(physical.X - 0.5 + ShadowOffset.X, physical.Y + ShadowOffset.Y);
                    ctx.LineTo(physical.X + 0.5 + ShadowOffset.X, physical.Y + ShadowOffset.Y);
                    ctx.Stroke();
                }
                else
                {
                    ctx.SetColor(lineColor);
                    ctx.MoveTo(physical.X - 0.5, physical.Y);
                    ctx.LineTo(physical.X + 0.5, physical.Y);
                    ctx.Stroke();
                }
            }
            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 && dx2 < leftCutoff) || (rightCutoff < dx1 && 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)
                    {
                        ctx.SetColor(shadowColor);
                        ctx.MoveTo(p1.X + ShadowOffset.X, p1.Y + ShadowOffset.Y);
                        ctx.LineTo(p2.X + ShadowOffset.X, p2.Y + ShadowOffset.Y);
                        ctx.Stroke();
                    }
                    else
                    {
                        ctx.SetColor(lineColor);
                        ctx.MoveTo(p1.X, p1.Y);
                        ctx.LineTo(p2.X, p2.Y);
                        ctx.Stroke();
                    }
                }
            }
            ctx.Restore();
        }