示例#1
0
        //private Symbol2D _symbol;
        //private Symbol2D _highlightSymbol;
        //private Symbol2D _selectSymbol;

        #endregion

        /// <summary>
        /// Initializes a new VectorStyle with default values.
        /// </summary>
        /// <remarks>
        /// Default style values when initialized:<br/>
        /// <list type="table">
        /// <item>
        /// <term>AreFeaturesSelectable</term>
        /// <description>True</description>
        /// </item>
        /// <item>
        /// <term>LineStyle</term>
        /// <description>1px solid black</description>
        /// </item>
        /// <item>
        /// <term>FillStyle</term>
        /// <description>Solid black</description>
        /// </item>
        /// <item>
        /// <term>Outline</term>
        /// <description>No Outline</description>
        /// </item>
        /// <item>
        /// <term>Symbol</term>
        /// <description>Null reference (uses the geometry renderer default)</description>
        /// </item>
        /// </list>
        /// </remarks>
        public GeometryStyle()
        {
            Outline       = new StylePen(StyleColor.Black, 1);
            Line          = new StylePen(StyleColor.Black, 1);
            Fill          = new SolidStyleBrush(StyleColor.Black);
            EnableOutline = false;
        }
示例#2
0
 /// <summary>
 /// Initializes a new VectorStyle with default values.
 /// </summary>
 /// <remarks>
 /// Default style values when initialized:<br/>
 /// <list type="table">
 /// <item>
 /// <term>AreFeaturesSelectable</term>
 /// <description>True</description>
 /// </item>
 /// <item>
 /// <term>LineStyle</term>
 /// <description>1px solid black</description>
 /// </item>
 /// <item>
 /// <term>FillStyle</term>
 /// <description>Solid black</description>
 /// </item>
 /// <item>
 /// <term>Outline</term>
 /// <description>No Outline</description>
 /// </item>
 /// <item>
 /// <term>Symbol</term>
 /// <description>Null reference (uses the geometry renderer default)</description>
 /// </item>
 /// </list>
 /// </remarks>
 public GeometryStyle()
 {
     Outline = new StylePen(StyleColor.Black, 1);
     Line = new StylePen(StyleColor.Black, 1);
     Fill = new SolidStyleBrush(StyleColor.Black);
     EnableOutline = false;
 }
示例#3
0
        public override void DrawLine(GravurGIS.Styles.StylePen pen, int x1, int y1, int x2, int y2)
        {
            StyleColor color = pen.BackgroundBrush.Color;

            _graphics.DrawLine(new Pen(Color.FromArgb(color.R, color.G, color.B), pen.Width),
                               x1, y1, x2, y2);
        }
示例#4
0
文件: MapPanel.cs 项目: ntj/GravurGIS
        protected override void OnPaint(PaintEventArgs e)
        {
            _stopwatch.Reset();
            _stopwatch.Start();

            SizeF textSize;
            String text = String.Empty;

            System.Drawing.Graphics gx
                = vectorRenderer.Graphics
                = e.Graphics; // Graphics.FromImage(backBuffer); //e.Graphics;

            gx.Clear(Color.White);

            this.dpiX = gx.DpiX;
            this.dpiY = gx.DpiY;

            double scale = mainControler.LayerManager.Scale;
            int layerCount = mainControler.LayerManager.LayerCount;
            LayerManager lm = mainControler.LayerManager;

            // TransportLayer
            // TODO: [9] Ist TransportShapes malen mit QuadTree schneller oder wenn man alles malt? (ab wann ist das wichtig?)
            lm.generateCurrentVisibleIShapes(d, drawingArea.Width, drawingArea.Height, absoluteZoom);

            // now draw the image previously created in the given order
            // ! We assume that there are no gaps (e.g. "1, 2, 4") in the mapping-list
            Layer layer;
            RenderProperties rp = new RenderProperties(gx, e.ClipRectangle, d.x, d.y,
                            absoluteZoom, screenChanged, this.drawingArea, scale, mHighlight);

            for (int i = layerCount - 1; i >= 0; i--)
            {
                layer = lm.getLayerFromMapping(i);
                if (layer.Visible)
                {
                    if (!(layer.Render(rp)))
                    {
                        this.Invalidate();
                        return;
                    }

                }
            }

            //IntPtr hBackBuffert = MapPanelBindings.GetRotatedBitmapNT(backBuffer.HBitmap, 0.0f, MakeCOLORREF(255, 255, 255));

            //Image newBackImage = Image.FromHbitmap(hBackBuffert);
            //gx = Graphics.FromImage(newBackImage);

            //rotateImage(backBuffer, 0);

            if (screenChanged)
            {
                mZoom = false;
                screenChanged = false;
            }

            StringFormat format = new StringFormat(StringFormatFlags.NoWrap);
            StylePen blackPen = new StylePen(StyleColor.Black, 1.0f);
            SolidStyleBrush blackBrush = new SolidStyleBrush(StyleColor.Black);

            #region Transportlayer

            lm.TransportPolygonLayer.Render(rp);
            lm.TransportPolylineLayer.Render(rp);
            lm.TransportPointLayer.Render(rp);

            #endregion

            #region GPS-Layer

            if (config.UseGPS)
                lm.GPSLayer.Render(rp);

            #endregion

            #region Längenanzeige
            if (config.ShowDistanceLine)
            {
                StylePen borderPen = new StylePen(StyleColor.White, 1.0f);

                // get the scaling factor for other dimensions
                int multiplikator = (int)(dpiX / 96.0);

                // get the amount of pixels representing one centimeter
                int width = Convert.ToInt32(dpiX / 2.54); ;

                blackPen.Width *= multiplikator;

                int left = drawingArea.X + 7*multiplikator;
                int right = left + width;
                int top = drawingArea.Bottom - 15 * multiplikator;
                int bottom = top + 7 * multiplikator;

                double dM = width / mainControler.LayerManager.Scale;

                if (dM > 1000) // display as kilometers
                    text = String.Format("{0}km", (dM / 1000).ToString("#0.0"));
                else if (dM > 1) // display as meters
                    text = String.Format("{0}m", Convert.ToInt32(dM).ToString());
                else // display as centimeters
                    text = String.Format("{0}cm", Convert.ToInt32(dM * 10).ToString());

                textSize = gx.MeasureString(text, font);

                int x = left + (int)((right - left - textSize.Width) / 2F);
                int y = top - 4 * multiplikator;

                // a white background for the text
                vectorRenderer.FillRectangle(new SolidStyleBrush(StyleColor.White),
                    new Rectangle(x - 1, y - 1, (int)textSize.Width + 2, (int)textSize.Height + 2));

                vectorRenderer.DrawLine(blackPen, left, top, left, bottom);
                vectorRenderer.DrawLine(blackPen, left, bottom, right, bottom);
                vectorRenderer.DrawLine(blackPen, right, bottom, right, top);

                // the white outline
                vectorRenderer.DrawLine(borderPen, left - 1, top, left - 1, bottom);
                vectorRenderer.DrawLine(borderPen, left + 1, top, left + 1, bottom - 1);
                vectorRenderer.DrawLine(borderPen, left - 1, top - 1, left + 1, top - 1);

                vectorRenderer.DrawLine(borderPen, left - 1, bottom + 1, right + 1, bottom + 1);
                vectorRenderer.DrawLine(borderPen, left + 1, bottom - 1, right - 1, bottom - 1);

                vectorRenderer.DrawLine(borderPen, right - 1, top, right - 1, bottom - 1);
                vectorRenderer.DrawLine(borderPen, right + 1, top, right + 1, bottom);
                vectorRenderer.DrawLine(borderPen, right - 1, top - 1, right + 1, top - 1);

                // the text
                vectorRenderer.DrawString(text,
                    font,
                    blackBrush, x, y, format);
            }
            #endregion

            #region Nordpfeil

            if (config.ShowNorthArrow)
            {
                // linke Seite (weiß)
                vectorRenderer.FillPolygon(new SolidStyleBrush(StyleColor.White), new Point[] {
                new Point(drawingArea.Right - 20, drawingArea.Bottom -27),
                new Point(drawingArea.Right - 25, drawingArea.Bottom -5),
                new Point(drawingArea.Right - 20, drawingArea.Bottom -8)});

                vectorRenderer.DrawLines(new StylePen(StyleColor.Black, 1.0f), new Point[] {
                new Point(drawingArea.Right - 20, drawingArea.Bottom -27),
                new Point(drawingArea.Right - 25, drawingArea.Bottom -5),
                new Point(drawingArea.Right - 20, drawingArea.Bottom -8)});

                // rechte Seite (schwarz)
                vectorRenderer.FillPolygon(new SolidStyleBrush(StyleColor.Black), new Point[] {
                new Point(drawingArea.Right - 20, drawingArea.Bottom -27),
                new Point(drawingArea.Right - 20, drawingArea.Bottom -8),
                new Point(drawingArea.Right - 14, drawingArea.Bottom -4),
                new Point(drawingArea.Right - 20, drawingArea.Bottom -27)});
            }

            #endregion

            #region Draw backbuffer (Backbuffer is currently disabled!)
                //e.Graphics.DrawImage(backBuffer, 0, 0);
            #endregion

            #region Zoom rectangle
            if (mZoom)
                e.Graphics.DrawRectangle(new Pen(Color.Red, 1.0f), zoomRec);
            #endregion

            #region SelectedItem / Tracking Info

            text = String.Empty;
            if (displayTrackingStatus)
            {
                text = _trackingStatus;
            } else if (selectedTransportShape != null)
            {
                text = String.Empty;

                if (selectedTransportShape as ShpPolyline != null)
                {
                    text = String.Format("Länge: {0}m", ((ShpPolyline)selectedTransportShape).Length.ToString("#0.00"));
                }
                else if (selectedTransportShape as ShpPolygon != null)
                {
                    ShpPolygon pg = (ShpPolygon)selectedTransportShape;

                    text = String.Format("Umfang: {0}m Fläche: {1} m²", pg.Perimeter.ToString("#0.00"), pg.Area.ToString("#0.00"));
                }
            }

            if (!String.IsNullOrEmpty(text))
            {
                textSize = gx.MeasureString(text, font);

                m_TextHeight = (int)(textSize.Height + 4);

                vectorRenderer.FillRectangle(new SolidStyleBrush(StyleColor.White), drawingArea.X, drawingArea.Y,
                    drawingArea.Width, m_TextHeight);

                vectorRenderer.DrawLine(new StylePen(StyleColor.Blue, 1.0f), drawingArea.X, drawingArea.Y + m_TextHeight,
                    drawingArea.Width, drawingArea.Y + m_TextHeight);

                vectorRenderer.DrawString(text, font, blackBrush, drawingArea.X + 1, drawingArea.Y + 2, format);
            }

            #endregion

            #region Meta-Define Drawings
            #if DRAW_INVALIDATEREC
            foreach (Rectangle r in this.rectangleList)
            {   GKCoord gk = new GKCoord();
                gk.r_value = r.X;
                gk.h_value = r.Y;
                PointD p = CoordCalculator.calculateDisplayCoords(gk, this.DX, this.DY, mainControler.LayerManager.Scale);
                gx.DrawRectangle(new Pen(Color.Pink), new Rectangle((int)(p.x),(int)(p.y),r.Width,r.Height));
            }
            #endif

            #if DRAW_GRID
                // Grid drawing
                for (int i = (int)(mainControler.LayerManager.ShapeArray[0].Width * mainControler.LayerManager.Scale); i >= 0;
                    i -= mainControler.LayerManager.ShapeArray[0].PartGrid.Cell_width)
                {

                    gx.DrawLine(new Pen(Color.Red), (int)d[0] + i, (int)d[1] + margin, (int)d[0] + i,
                         (int)(d[1] + mainControler.LayerManager.ShapeArray[0].Height * mainControler.LayerManager.Scale) - margin);
                }
                for (int i = (int)(mainControler.LayerManager.ShapeArray[0].Height * mainControler.LayerManager.Scale); i >= 0;
                    i -= mainControler.LayerManager.ShapeArray[0].PartGrid.Cell_height)
                {

                    gx.DrawLine(new Pen(Color.Red), (int)d[0] + margin, (int)d[1]  + i,
                        (int)(d[0] + mainControler.LayerManager.ShapeArray[0].Width * mainControler.LayerManager.Scale) - margin,
                        (int)d[1] + i);
                }
            #endif

            #if DRAW_QUADTREE
            mainControler.LayerManager.draw_QuadTree(gx, d);
            #endif

            #if DRAW_BOUNDINGBOXES
                            // Draw Boundingboxes
                           List<Rectangle> transportRectangleList = new List<Rectangle>();
                            // :: Points
                            mainControler.LayerManager.generateBBList(ref transportRectangleList, absoluteZoom);

                            if (transportRectangleList.Count != 0)
                            {
                                Pen temporaryPen = new Pen(Color.Green);
                                for (int i = transportRectangleList.Count - 1; i >= 0; i--)
                                    gx.DrawRectangle(temporaryPen, transportRectangleList[i]);
                            }
            #endif

            #endregion

            //Bounding Box of selected IShape
            //if (selectedTransportShape != null)
            //    vectorRenderer.DrawRectangle(new Pen(Color.Green), selectedTransportShape.getDisplayBoundingBox(
            //        d.x, d.y, config.ExPntLayerPointWidth, scale, 1));

            //Boundary rectangle
            Rectangle rc = this.ClientRectangle;
            rc.Width--;
            rc.Height--;
            //Draw boundary
            e.Graphics.DrawRectangle(new Pen(Color.Blue), rc);
            gx.Dispose();

            _stopwatch.Stop();

            // if the render time is higher than the gps update interval
            // we have to set the update interval higher
            if (_stopwatch.ElapsedMilliseconds >= config.GPSUpdateInterval) {
                // base update interval is render time * 1.2
                double newInterval = _stopwatch.ElapsedMilliseconds * 1.2;
                // since we want full 1000th as interval we round up to the next 1000
                try {
                    config.GPSUpdateInterval = Convert.ToUInt32( newInterval + ( 1000 - newInterval % 1000 ) );
                } catch { config.GPSUpdateInterval = 5000; }
                finally { mainControler.OnSettingsChanged(); }
            }
        }
示例#5
0
        public override void DrawRectangle(GravurGIS.Styles.StylePen pen, System.Drawing.Rectangle rectangle)
        {
            StyleColor color = pen.BackgroundBrush.Color;

            _graphics.DrawRectangle(new Pen(Color.FromArgb(color.R, color.G, color.B), pen.Width), rectangle);
        }
示例#6
0
        public override void DrawLines(GravurGIS.Styles.StylePen pen, System.Drawing.Point[] points)
        {
            StyleColor color = pen.BackgroundBrush.Color;

            _graphics.DrawLines(new Pen(Color.FromArgb(color.R, color.G, color.B), pen.Width), points);
        }