Exemplo n.º 1
0
        /// <summary>
        /// record feature delete
        /// </summary>
        /// <param name="featrueIdx">featureID</param>
        /// <param name="feature">what was deleted</param>
        public void featureDeleted(int featrueIdx, Feature feature)
        {
            Debug.Assert(feature != null);

            operationType = UndoElementType.DeleteFeature;
            this.featureIndex = featrueIdx;
            this.feature = feature;
        }
Exemplo n.º 2
0
        public void addFeature(Feature feature)
        {
            if (feature == null) return;

            feature.FeatureID = m_oFeatures.Count;
            feature.setParentContainer(this);

            m_oFeatures.Add(feature);
            boundsOK = false;
        }
Exemplo n.º 3
0
        private void drawMapFeature(Graphics g, Rectangle Rect, DRect rectScreenInLayer, CoordConverter oCC, Feature feature, bool selectionStyle)
        {
            Debug.Assert(feature != null);

            if (feature is PolylineFeature)
            {
                PolylineFeature oP = (PolylineFeature)feature;

                // draw polyline points
                for (int iPart = 0; iPart < oP.m_oParts.Count; iPart++)
                {
                    List<DPoint> Points_list = oP.m_oParts[iPart].Points;
                    if (Points_list.Count > 0)
                    {
                        DPoint[] Points_src = oP.m_oParts[iPart].Points.ToArray();
                        int ipp_count = Points_src.GetLength(0);
                        Point[] Points_array = new Point[ipp_count];
                        Rectangle rect = new Rectangle(0, 0, 6, 6);

                        int? currPointX = null;
                        int? currPointY = null;
                        int? prevPointX = null;
                        int? prevPointY = null;

                        for (int ipp = 0; ipp < ipp_count; ipp++)
                        {

                            // only points withing screen area
                            if (rectScreenInLayer.Contains((double)Points_src[ipp].X, (double)Points_src[ipp].Y))
                            {
                                oCC.Convert(Points_src[ipp].X, Points_src[ipp].Y);
                                currPointX = (int)oCC.X;
                                currPointY = (int)oCC.Y;

                                rect.X = (int)oCC.X - 3;
                                rect.Y = (int)oCC.Y - 3;
                                rect.Width = 6;
                                rect.Height = 6;
                                if (Points_src[ipp].Selected)
                                {
                                    m_oRenderGDIplus.FillRectangle(g, rect, 0xffff0000); // red
                                }
                                else
                                {
                                    m_oRenderGDIplus.DrawRectangle(g, rect, 0xff0000ff);  // blue
                                }
                            }
                            else
                            {
                                currPointX = null;
                                currPointY = null;
                            }

                            // "add point marker"
                            if (ipp > 0)
                            {
                                if (currPointX != null || prevPointX != null)
                                { // draw if at least one point is visible

                                    if (prevPointX == null)
                                    {
                                        // failed to calculate earlier (not visible), do it now
                                        oCC.Convert(Points_src[ipp - 1].X, Points_src[ipp - 1].Y);
                                        prevPointX = (int)oCC.X;
                                        prevPointY = (int)oCC.Y;
                                    }
                                    if (currPointX == null)
                                    {
                                        // failed to calculate earlier (not visible), do it now
                                        oCC.Convert(Points_src[ipp].X, Points_src[ipp].Y);
                                        currPointX = (int)oCC.X;
                                        currPointY = (int)oCC.Y;
                                    }

                                    int dx = (int)(currPointX - prevPointX);
                                    int dy = (int)(currPointY - prevPointY);
                                    int len = (int)Math.Sqrt(dx * dx + dy * dy);

                                    // draw when line segment longer than 20 pixels
                                    if (len > 20)
                                    {
                                        int pointX = (int)(prevPointX + currPointX) / 2;
                                        int pointY = (int)(prevPointY + currPointY) / 2;

                                        //m_oRenderGDIplus.DrawLine(g, pointX - 3, pointY - 3, pointX + 3, pointY + 3, 2, Color.Blue, 1);
                                        //m_oRenderGDIplus.DrawLine(g, pointX - 3, pointY + 3, pointX + 3, pointY - 3, 2, Color.Blue, 1);
                                    }
                                }
                            }
                            prevPointX = currPointX;
                            prevPointY = currPointY;
                        }
                    }
                }

                // draw actual polyline
                for (int iPart = 0; iPart < oP.m_oParts.Count; iPart++)
                {
                    List<DPoint> Points_list = oP.m_oParts[iPart].Points;
                    if (Points_list.Count > 0)
                    {
                        DPoint[] Points_src = oP.m_oParts[iPart].Points.ToArray();

                        int ipp_count = Points_src.GetLength(0);
                        Point[] Points_array = new Point[ipp_count];
                        for (int ipp = 0; ipp < ipp_count; ipp++)
                        {
                            oCC.Convert((double)Points_src[ipp].X, (double)Points_src[ipp].Y);
                            Points_array[ipp] = new Point((int)oCC.X, (int)oCC.Y);
                        }
                        if (oP.Selected)
                        {
                            m_oRenderGDIplus.DrawPolylineFeature(g, Points_array, oP.Style.LinePattern, Color.Red, oP.Style.LineWidth);
                        }
                        else
                        {
                            m_oRenderGDIplus.DrawPolylineFeature(g, Points_array, oP.Style.LinePattern, oP.Style.LineColor, oP.Style.LineWidth);
                        }
                    }
                }
            }
            else if (feature is SymbolFeature)
            {
                SymbolFeature oP = (SymbolFeature)feature;

                oCC.Convert(oP.x, oP.y);
                Rectangle rect = new Rectangle((int)oCC.X - 2, (int)oCC.Y - 2, 4, 4);
                if ((oP.color & 0xff000000) != 0x00)
                {
                    if (feature.Selected)
                    {
                        m_oRenderGDIplus.DrawRectangle(g, rect, (uint)Color.Red.ToArgb());
                    }
                    else
                    {
                        m_oRenderGDIplus.DrawRectangle(g, rect, oP.color);
                    }
                }
            }
            else if (feature is RectangleFeature)
            {
                RectangleFeature oP = (RectangleFeature)feature;

                oCC.Convert(oP.x, oP.y);
                Rectangle rect = new Rectangle((int)oCC.X - 2, (int)oCC.Y - 2, 4, 4);
                m_oRenderGDIplus.DrawRectangle(g, rect, (uint)0xff000000);
            }
            else if (feature is BitmapFeature)
            {
                BitmapFeature oB = feature as BitmapFeature;

                oCC.Convert(oB.X, oB.Y);
                int x = (int)oCC.X;
                int y = (int)oCC.Y;

                g.DrawImageUnscaled(oB.Bitmap, new Point(x - oB.Anchorx, y - oB.Anchory));
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Exemplo n.º 4
0
        internal void insertFeature(int idx, Feature feature)
        {
            Debug.Assert(feature != null);
            Debug.Assert(feature.ParentContainer == null);
            Debug.Assert(m_oFeatures[idx] == null); // make sure position is empty

            m_oFeatures[idx] = feature;
            feature.FeatureID = idx;
            feature.setParentContainer(this);

            boundsOK = false;
        }
Exemplo n.º 5
0
 public void recordRemoveFeature(Feature feature)
 {
     undoElementCurrent.removeFeature(feature.FeatureID);
     redoElements.Clear();
 }
Exemplo n.º 6
0
 public void featureMoved(SymbolFeature actualFeatureMoved, SymbolFeature originalFeatureLocation)
 {
     operationType = UndoElementType.MoveFeature;
     this.feature = actualFeatureMoved;
     this.originalFeature = originalFeatureLocation;
 }