Ejemplo n.º 1
0
        internal GraphicsPath GetPath(MapGraphics g, bool outlineOnly)
        {
            if (Shapes.Count == 0)
            {
                return(null);
            }
            if (outlineOnly)
            {
                ArrayList arrayList = new ArrayList();
                foreach (Shape shape in Shapes)
                {
                    GraphicsPath[] paths = shape.GetPaths(g);
                    arrayList.Add(paths[shape.largestPathIndex]);
                }
                if (arrayList.Count > 0 && !GetMapCore().IsDesignMode())
                {
                    return(new GraphicsPathOutliner(g.Graphics).GetOutlinePath((GraphicsPath[])arrayList.ToArray(typeof(GraphicsPath))));
                }
                return(null);
            }
            GraphicsPath graphicsPath = new GraphicsPath();

            foreach (Shape shape2 in Shapes)
            {
                GraphicsPath[] paths2 = shape2.GetPaths(g);
                foreach (GraphicsPath addingPath in paths2)
                {
                    graphicsPath.AddPath(addingPath, connect: false);
                }
            }
            return(graphicsPath);
        }
Ejemplo n.º 2
0
 bool IContentElement.IsVisible(MapGraphics g, Layer layer, bool allLayers, RectangleF clipRect)
 {
     if (!Visible)
     {
         return(false);
     }
     if (allLayers)
     {
         if (!((ILayerElement)this).BelongsToAllLayers)
         {
             return(false);
         }
     }
     else if (layer != null)
     {
         if (!((ILayerElement)this).BelongsToLayer || layer.Name != ((ILayerElement)this).Layer)
         {
             return(false);
         }
     }
     else if (((ILayerElement)this).BelongsToAllLayers || ((ILayerElement)this).BelongsToLayer)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 3
0
        public bool IsVisible(MapGraphics g)
        {
            RectangleF areasRect = new RectangleF(0f, 0f, 100f, 100f);

            AdjustAreasPosition(g, ref areasRect);
            return(!g.GetAbsoluteRectangle(areasRect).Contains(g.Clip.GetBounds(g.Graphics)));
        }
Ejemplo n.º 4
0
 public void Render(MapGraphics g)
 {
     if (InnerLayers != null)
     {
         for (int i = 0; i < InnerLayers.Length; i++)
         {
             InnerLayers[i].Render(g);
         }
     }
     if (Paths == null)
     {
         return;
     }
     g.TranslateTransform(Origin.X, Origin.Y);
     for (int j = 0; j < Paths.Length; j++)
     {
         if (Brushes[j] != null)
         {
             g.FillPath(Brushes[j], Paths[j]);
         }
         if (Pens[j] != null)
         {
             g.DrawPath(Pens[j], Paths[j]);
         }
     }
     g.TranslateTransform(0f - Origin.X, 0f - Origin.Y);
 }
        protected override void DrawTopDown(MapGraphics graphics)
        {
            graphics.drawLayers[(int)MapGraphics.DrawLayers.FillBuffers].Add(() =>
            {
                foreach (var tri in this.GetTrianglesWithinDist())
                {
                    float p1_p2_x = (tri.X2 - tri.X1);
                    float p1_p2_z = (tri.Z2 - tri.Z1);

                    float p1_p3_x = (tri.X3 - tri.X1);
                    float p1_p3_z = (tri.Z3 - tri.Z1);

                    float cross = (p1_p2_z * p1_p3_x - p1_p2_x * p1_p3_z);

                    graphics.triangleRenderer.Add(
                        new Vector3(tri.X1, 0, tri.Z1),
                        cross > 0 ? new Vector3(tri.X2, 0, tri.Z2) : new Vector3(tri.X3, 0, tri.Z3),
                        cross > 0 ? new Vector3(tri.X3, 0, tri.Z3) : new Vector3(tri.X2, 0, tri.Z2),
                        ShowTriUnits,
                        new Vector4(Color.R / 255f, Color.G / 255f, Color.B / 255f, OpacityByte / 255f),
                        new Vector4(OutlineColor.R / 255f, OutlineColor.G / 255f, OutlineColor.B / 255f, OutlineColor.A / 255f),
                        OutlineWidth,
                        graphics.view.mode != MapView.ViewMode.TopDown);
                }
            });
        }
Ejemplo n.º 6
0
        public virtual void RenderBorder(MapGraphics g)
        {
            AntiAliasing antiAliasing = g.AntiAliasing;

            g.AntiAliasing = AntiAliasing.None;
            RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));

            absoluteRectangle.X      = (float)Math.Round((double)absoluteRectangle.X);
            absoluteRectangle.Y      = (float)Math.Round((double)absoluteRectangle.Y);
            absoluteRectangle.Width  = (float)Math.Round((double)absoluteRectangle.Width);
            absoluteRectangle.Height = (float)Math.Round((double)absoluteRectangle.Height);
            try
            {
                if (this.BorderWidth > 0 && !this.BorderColor.IsEmpty && this.BorderStyle != 0)
                {
                    using (Pen pen = new Pen(this.BorderColor, (float)this.BorderWidth))
                    {
                        pen.DashStyle = MapGraphics.GetPenStyle(this.BorderStyle);
                        pen.Alignment = PenAlignment.Inset;
                        if (this.BorderWidth == 1)
                        {
                            absoluteRectangle.Width  -= 1f;
                            absoluteRectangle.Height -= 1f;
                        }
                        g.DrawRectangle(pen, absoluteRectangle.X, absoluteRectangle.Y, absoluteRectangle.Width, absoluteRectangle.Height);
                    }
                }
            }
            finally
            {
                g.AntiAliasing = antiAliasing;
            }
        }
Ejemplo n.º 7
0
 public void Render(MapGraphics g)
 {
     if (this.InnerLayers != null)
     {
         for (int i = 0; i < this.InnerLayers.Length; i++)
         {
             this.InnerLayers[i].Render(g);
         }
     }
     if (this.Paths != null)
     {
         g.TranslateTransform(this.Origin.X, this.Origin.Y);
         for (int j = 0; j < this.Paths.Length; j++)
         {
             if (this.Brushes[j] != null)
             {
                 g.FillPath(this.Brushes[j], this.Paths[j]);
             }
             if (this.Pens[j] != null)
             {
                 g.DrawPath(this.Pens[j], this.Paths[j]);
             }
         }
         g.TranslateTransform((float)(0.0 - this.Origin.X), (float)(0.0 - this.Origin.Y));
     }
 }
 public override void Load(MapGraphics graphics)
 {
     _vertexBuffer = GL.GenBuffer();
     GL.BindBuffer(BufferTarget.ArrayBuffer, _vertexBuffer);
     GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(_loadedVertices.Length * Vertex.Size),
                   _loadedVertices, BufferUsageHint.DynamicDraw);
 }
Ejemplo n.º 9
0
        protected override List <Vector3> GetVertices(MapGraphics graphics)
        {
            List <Vector3> vertices = new List <Vector3>();

            foreach (var posAngle in positionAngleProvider())
            {
                float x    = (float)posAngle.X;
                float y    = (float)posAngle.Y;
                float z    = (float)posAngle.Z;
                float yaw  = (float)getYaw(posAngle);
                float size = useRecommendedArrowLength ? (float)getRecommendedSize(posAngle) : Size;
                (float arrowHeadX, float arrowHeadZ) =
                    ((float, float))MoreMath.AddVectorToPoint(size, yaw, x, z);

                (float pointSide1X, float pointSide1Z) =
                    ((float, float))MoreMath.AddVectorToPoint(_arrowHeadSideLength, yaw + 32768 + 8192, arrowHeadX, arrowHeadZ);
                (float pointSide2X, float pointSide2Z) =
                    ((float, float))MoreMath.AddVectorToPoint(_arrowHeadSideLength, yaw + 32768 - 8192, arrowHeadX, arrowHeadZ);

                vertices.Add(new Vector3(x, y, z));
                vertices.Add(new Vector3(arrowHeadX, y, arrowHeadZ));

                vertices.Add(new Vector3(arrowHeadX, y, arrowHeadZ));
                vertices.Add(new Vector3(pointSide1X, y, pointSide1Z));

                vertices.Add(new Vector3(arrowHeadX, y, arrowHeadZ));
                vertices.Add(new Vector3(pointSide2X, y, pointSide2Z));
            }
            return(vertices);
        }
Ejemplo n.º 10
0
 public override IHoverData GetHoverData(MapGraphics graphics)
 {
     if (graphics.view.mode == MapView.ViewMode.TopDown)
     {
         foreach (var tri in GetTrianglesWithinDist())
         {
             var dat = MapUtilities.Get2DWallDataFromTri(tri);
             if (dat != null)
             {
                 bool  zProjection       = !dat.Value.xProjection;
                 float v                 = zProjection ? graphics.mapCursorPosition.X : graphics.mapCursorPosition.Z;
                 float vOther            = zProjection ? graphics.mapCursorPosition.Z : graphics.mapCursorPosition.X;
                 float one               = zProjection ? dat.Value.x1 : dat.Value.z1;
                 float two               = zProjection ? dat.Value.x2 : dat.Value.z2;
                 float min               = Math.Min(one, two);
                 float max               = Math.Max(one, two);
                 float otherOne          = zProjection ? dat.Value.z1 : dat.Value.x1;
                 float otherTwo          = zProjection ? dat.Value.z2 : dat.Value.x2;
                 float interpolatedOther = otherOne + ((v - one) / (two - one)) * (otherTwo - otherOne);
                 var   angle             = MoreMath.AngleTo_Radians(dat.Value.x1, dat.Value.z1, dat.Value.x2, dat.Value.z2);
                 float projectionDist    = Size / (float)Math.Abs(!zProjection ? Math.Cos(angle) : Math.Sin(angle));
                 if (v >= min && v <= max && Math.Abs(vOther - interpolatedOther) < projectionDist)
                 {
                     hoverData.triangle = tri;
                     return(hoverData);
                 }
             }
         }
     }
     return(null);
 }
Ejemplo n.º 11
0
        internal override void Render(MapGraphics g)
        {
            AntiAliasing antiAliasing = g.AntiAliasing;

            g.AntiAliasing = AntiAliasing.None;
            RectangleF rectangleF = new RectangleF(GetAbsoluteLocation(), GetAbsoluteSize());

            rectangleF.X      = (float)Math.Round(rectangleF.X);
            rectangleF.Y      = (float)Math.Round(rectangleF.Y);
            rectangleF.Width  = (float)Math.Round(rectangleF.Width);
            rectangleF.Height = (float)Math.Round(rectangleF.Height);
            if (!(rectangleF.Width > 0f) || !(rectangleF.Height > 0f))
            {
                return;
            }
            try
            {
                if (BackShadowOffset != 0)
                {
                    RectangleF rect = rectangleF;
                    rect.Offset(BackShadowOffset, BackShadowOffset);
                    g.FillRectangle(g.GetShadowBrush(), rect);
                }
                using (Brush brush = g.CreateBrush(rectangleF, BackColor, BackHatchStyle, "", MapImageWrapMode.Unscaled, Color.Empty, MapImageAlign.Center, BackGradientType, BackSecondaryColor))
                {
                    g.FillRectangle(brush, rectangleF);
                }
            }
            finally
            {
                g.AntiAliasing = antiAliasing;
            }
        }
        public override void DrawBorder(MapGraphics graph, Frame borderSkin, RectangleF rect, Color backColor, MapHatchStyle backHatchStyle, string backImage, MapImageWrapMode backImageMode, Color backImageTranspColor, MapImageAlign backImageAlign, GradientType backGradientType, Color backSecondaryColor, Color borderColor, int borderWidth, MapDashStyle borderStyle)
        {
            base.drawBottomShadow         = true;
            base.sunken                   = false;
            base.outsideShadowRate        = 0.9f;
            base.drawOutsideTopLeftShadow = false;
            bool drawScrews = base.drawScrews;

            base.drawScrews = false;
            base.DrawBorder(graph, borderSkin, rect, borderSkin.BackColor, borderSkin.BackHatchStyle, borderSkin.BackImage, borderSkin.BackImageMode, borderSkin.BackImageTranspColor, borderSkin.BackImageAlign, borderSkin.BackGradientType, borderSkin.BackSecondaryColor, borderSkin.BorderColor, borderSkin.BorderWidth, borderSkin.BorderStyle);
            base.drawScrews = drawScrews;
            rect.X         += base.sizeLeftTop.Width;
            rect.Y         += base.sizeLeftTop.Height;
            rect.Width     -= base.sizeRightBottom.Width + base.sizeLeftTop.Width;
            rect.Height    -= base.sizeRightBottom.Height + base.sizeLeftTop.Height;
            if (rect.Width > 0.0 && rect.Height > 0.0)
            {
                float[] array = new float[8];
                array                         = (float[])base.cornerRadius.Clone();
                base.cornerRadius             = this.innerCorners;
                base.drawBottomShadow         = false;
                base.sunken                   = true;
                base.drawOutsideTopLeftShadow = true;
                base.outsideShadowRate        = 1.4f;
                Color pageColor = borderSkin.PageColor;
                borderSkin.PageColor = Color.Transparent;
                base.DrawBorder(graph, borderSkin, rect, backColor, backHatchStyle, backImage, backImageMode, backImageTranspColor, backImageAlign, backGradientType, backSecondaryColor, borderColor, borderWidth, borderStyle);
                borderSkin.PageColor = pageColor;
                base.cornerRadius    = array;
            }
        }
Ejemplo n.º 13
0
        private void AdjustScaleSize(MapGraphics g)
        {
            float markerLength = Pointer.MarkerLength;
            float width        = Pointer.Width;
            float num          = 0f;

            if (GetOrientation() == Orientation.Horizontal)
            {
                markerLength = g.GetAbsoluteY(markerLength);
                width        = g.GetAbsoluteY(width);
                num          = (g.GetAbsoluteY(100f) - markerLength) / 2f;
            }
            else
            {
                markerLength = g.GetAbsoluteX(markerLength);
                width        = g.GetAbsoluteX(width);
                num          = (g.GetAbsoluteX(100f) - markerLength) / 2f;
            }
            float num2 = 2f + width / 2f;

            if (ZoomButtonsVisible)
            {
                num2 += markerLength + num;
            }
            num2 = ((GetOrientation() != 0) ? g.GetRelativeY(num2) : g.GetRelativeX(num2));
            num2 = Math.Min(Math.Max(0f, num2), 100f);
            Scale.StartMargin = num2;
            Scale.EndMargin   = num2;
        }
Ejemplo n.º 14
0
        public override void SetDrawCalls(MapGraphics graphics)
        {
            instances.Clear();
            if (graphics.view.drawCylinderOutlines)
            {
                graphics.drawLayers[(int)MapGraphics.DrawLayers.FillBuffersRedirect].Add(() =>
                {
                    foreach (var instance in instances)
                    {
                        var oldPointLow  = Vector3.TransformPosition(vertices[FIRST_LOWER_VERTEX].Xyz, instance.transform);
                        var oldPointHigh = Vector3.TransformPosition(vertices[FIRST_UPPER_VERTEX].Xyz, instance.transform);
                        for (int i = 1; i <= NUM_CIRCLE_VERTICES; i++)
                        {
                            var newPointLow  = Vector3.TransformPosition(vertices[FIRST_LOWER_VERTEX + i].Xyz, instance.transform);
                            var newPointHigh = Vector3.TransformPosition(vertices[FIRST_UPPER_VERTEX + i].Xyz, instance.transform);

                            graphics.lineRenderer.Add(oldPointLow, newPointLow, new Vector4(0, 0, 0, 1), 2);
                            graphics.lineRenderer.Add(oldPointHigh, newPointHigh, new Vector4(0, 0, 0, 1), 2);

                            oldPointLow  = newPointLow;
                            oldPointHigh = newPointHigh;
                        }
                    }
                });
            }
        }
Ejemplo n.º 15
0
        private void DrawText(MapGraphics g, bool drawShadow)
        {
            if (string.IsNullOrEmpty(Text))
            {
                return;
            }
            RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));
            string     text = Text;

            _    = Font;
            text = text.Replace("\\n", "\n");
            StringFormat      stringFormat      = GetStringFormat();
            TextRenderingHint textRenderingHint = g.TextRenderingHint;
            float             num = DetermineAngle();

            if (num % 90f != 0f)
            {
                g.TextRenderingHint = TextRenderingHint.AntiAlias;
            }
            Brush brush = null;

            brush = ((!drawShadow) ? new SolidBrush(TextColor) : g.GetShadowBrush());
            try
            {
                if (num != 0f)
                {
                    RectangleF layoutRectangle = DetermineTextRectangle(g, stringFormat);
                    PointF     point           = new PointF(layoutRectangle.X + layoutRectangle.Width / 2f, layoutRectangle.Y + layoutRectangle.Height / 2f);
                    Matrix     transform       = g.Transform;
                    Matrix     matrix          = g.Transform.Clone();
                    matrix.RotateAt(num, point, MatrixOrder.Prepend);
                    if (drawShadow)
                    {
                        matrix.Translate(TextShadowOffset, TextShadowOffset, MatrixOrder.Append);
                    }
                    g.Transform = matrix;
                    StringFormat stringFormat2 = new StringFormat();
                    stringFormat2.Alignment     = StringAlignment.Center;
                    stringFormat2.LineAlignment = StringAlignment.Center;
                    stringFormat2.Trimming      = StringTrimming.EllipsisCharacter;
                    layoutRectangle.Inflate(1000f, 1000f);
                    g.DrawString(text, Font, brush, layoutRectangle, stringFormat2);
                    g.Transform = transform;
                }
                else
                {
                    if (drawShadow)
                    {
                        absoluteRectangle.X += TextShadowOffset;
                        absoluteRectangle.Y += TextShadowOffset;
                    }
                    g.DrawString(text, Font, brush, absoluteRectangle, stringFormat);
                }
            }
            finally
            {
                brush?.Dispose();
            }
            g.Graphics.TextRenderingHint = textRenderingHint;
        }
Ejemplo n.º 16
0
 void ISelectable.DrawSelection(MapGraphics g, RectangleF clipRect, bool designTimeSelection)
 {
     if (this.Shapes.Count != 0)
     {
         MapCore mapCore = this.GetMapCore();
         using (GraphicsPath graphicsPath = this.GetPath(g, false))
         {
             if (graphicsPath != null)
             {
                 RectangleF bounds = graphicsPath.GetBounds();
                 RectangleF rect   = bounds;
                 rect.Inflate(6f, 6f);
                 if (clipRect.IntersectsWith(rect) && !bounds.IsEmpty)
                 {
                     g.DrawSelection(bounds, designTimeSelection, mapCore.SelectionBorderColor, mapCore.SelectionMarkerColor);
                     PointF       centerPointInContentPixels = this.GetCenterPointInContentPixels(g);
                     AntiAliasing antiAliasing = g.AntiAliasing;
                     g.AntiAliasing = AntiAliasing.None;
                     g.DrawLine(Pens.Red, (float)(centerPointInContentPixels.X - 8.0), centerPointInContentPixels.Y, (float)(centerPointInContentPixels.X + 8.0), centerPointInContentPixels.Y);
                     g.DrawLine(Pens.Red, centerPointInContentPixels.X, (float)(centerPointInContentPixels.Y - 8.0), centerPointInContentPixels.X, (float)(centerPointInContentPixels.Y + 8.0));
                     g.AntiAliasing = antiAliasing;
                 }
             }
         }
     }
 }
Ejemplo n.º 17
0
        internal void Paint(MapGraphics chartGraph, int fontSizeReducedBy, Font legendAutoFont, Size singleWCharacterSize)
        {
            if (cellPosition.Width <= 0 || cellPosition.Height <= 0 || !GetLegend().Common.ProcessModePaint)
            {
                return;
            }
            Color cellBackColor = GetCellBackColor();

            if (!cellBackColor.IsEmpty)
            {
                chartGraph.FillRectangleRel(chartGraph.GetRelativeRectangle(cellPositionWithMargins), cellBackColor, MapHatchStyle.None, string.Empty, MapImageWrapMode.Tile, Color.Empty, MapImageAlign.Center, GradientType.None, Color.Empty, Color.Empty, 0, MapDashStyle.None, Color.Empty, 0, PenAlignment.Inset);
            }
            if (GetLegend().Common.ProcessModePaint)
            {
                switch (CellType)
                {
                case LegendCellType.Text:
                    PaintCellText(chartGraph, fontSizeReducedBy, legendAutoFont, singleWCharacterSize);
                    break;

                case LegendCellType.Image:
                    PaintCellImage(chartGraph, fontSizeReducedBy, legendAutoFont, singleWCharacterSize);
                    break;

                case LegendCellType.Symbol:
                    PaintCellSeriesSymbol(chartGraph, fontSizeReducedBy, legendAutoFont, singleWCharacterSize);
                    break;

                default:
                    throw new InvalidOperationException("Unknown legend cell type: '" + CellType.ToString(CultureInfo.CurrentCulture) + "'.");
                }
            }
        }
Ejemplo n.º 18
0
        bool IContentElement.IsVisible(MapGraphics g, Layer layer, bool allLayers, RectangleF clipRect)
        {
            if (!this.Visible)
            {
                return(false);
            }
            if (allLayers)
            {
                if (!((ILayerElement)this).BelongsToAllLayers)
                {
                    return(false);
                }
                goto IL_004b;
            }
            if (layer != null)
            {
                if (((ILayerElement)this).BelongsToLayer && !(layer.Name != ((ILayerElement)this).Layer))
                {
                    goto IL_004b;
                }
                return(false);
            }
            if (!((ILayerElement)this).BelongsToAllLayers && !((ILayerElement)this).BelongsToLayer)
            {
                goto IL_004b;
            }
            return(false);

IL_004b:
            return(true);
        }
Ejemplo n.º 19
0
 void IContentElement.RenderText(MapGraphics g, HotRegionList hotRegions)
 {
     if (this.Shapes.Count > 0)
     {
         this.RenderText(g);
     }
 }
Ejemplo n.º 20
0
        private RectangleF DetermineTextRectangle(MapGraphics g, StringFormat stringFormat)
        {
            RectangleF result            = default(RectangleF);
            RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));
            SizeF      sizeF             = this.DetermineTextSizeAfterRotation(g);

            if (stringFormat.Alignment == StringAlignment.Near)
            {
                result.X = absoluteRectangle.X;
            }
            else if (stringFormat.Alignment == StringAlignment.Center)
            {
                result.X = (float)(absoluteRectangle.X + absoluteRectangle.Width / 2.0 - sizeF.Width / 2.0);
            }
            else if (stringFormat.Alignment == StringAlignment.Far)
            {
                result.X = absoluteRectangle.Right - sizeF.Width;
            }
            if (stringFormat.LineAlignment == StringAlignment.Near)
            {
                result.Y = absoluteRectangle.Y;
            }
            else if (stringFormat.LineAlignment == StringAlignment.Center)
            {
                result.Y = (float)(absoluteRectangle.Y + absoluteRectangle.Height / 2.0 - sizeF.Height / 2.0);
            }
            else if (stringFormat.LineAlignment == StringAlignment.Far)
            {
                result.Y = absoluteRectangle.Bottom - sizeF.Height;
            }
            result.Width  = sizeF.Width;
            result.Height = sizeF.Height;
            return(result);
        }
Ejemplo n.º 21
0
        public GraphicsPath GetPath(MapGraphics g, bool outlineOnly)
        {
            if (this.Shapes.Count == 0)
            {
                return(null);
            }
            if (outlineOnly)
            {
                ArrayList arrayList = new ArrayList();
                foreach (Shape shape3 in this.Shapes)
                {
                    GraphicsPath[] paths = shape3.GetPaths(g);
                    arrayList.Add(paths[shape3.largestPathIndex]);
                }
                if (arrayList.Count > 0 && !this.GetMapCore().IsDesignMode())
                {
                    GraphicsPathOutliner graphicsPathOutliner = new GraphicsPathOutliner(g.Graphics);
                    return(graphicsPathOutliner.GetOutlinePath((GraphicsPath[])arrayList.ToArray(typeof(GraphicsPath))));
                }
                return(null);
            }
            GraphicsPath graphicsPath = new GraphicsPath();

            foreach (Shape shape4 in this.Shapes)
            {
                GraphicsPath[] paths2 = shape4.GetPaths(g);
                GraphicsPath[] array  = paths2;
                foreach (GraphicsPath addingPath in array)
                {
                    graphicsPath.AddPath(addingPath, false);
                }
            }
            return(graphicsPath);
        }
Ejemplo n.º 22
0
        internal virtual void RenderBorder(MapGraphics g)
        {
            AntiAliasing antiAliasing = g.AntiAliasing;

            g.AntiAliasing = AntiAliasing.None;
            RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));

            absoluteRectangle.X      = (float)Math.Round(absoluteRectangle.X);
            absoluteRectangle.Y      = (float)Math.Round(absoluteRectangle.Y);
            absoluteRectangle.Width  = (float)Math.Round(absoluteRectangle.Width);
            absoluteRectangle.Height = (float)Math.Round(absoluteRectangle.Height);
            try
            {
                if (BorderWidth <= 0 || BorderColor.IsEmpty || BorderStyle == MapDashStyle.None)
                {
                    return;
                }
                using (Pen pen = new Pen(BorderColor, BorderWidth))
                {
                    pen.DashStyle = MapGraphics.GetPenStyle(BorderStyle);
                    pen.Alignment = PenAlignment.Inset;
                    if (BorderWidth == 1)
                    {
                        absoluteRectangle.Width  -= 1f;
                        absoluteRectangle.Height -= 1f;
                    }
                    g.DrawRectangle(pen, absoluteRectangle.X, absoluteRectangle.Y, absoluteRectangle.Width, absoluteRectangle.Height);
                }
            }
            finally
            {
                g.AntiAliasing = antiAliasing;
            }
        }
Ejemplo n.º 23
0
        public override SizeF GetOptimalSize(MapGraphics g, SizeF maxSizeAbs)
        {
            SizeF result = this.DetermineTextSizeAfterRotation(g);
            SizeF sizeF;

            if (base.DockedInsideViewport)
            {
                sizeF         = this.Common.MapCore.Viewport.GetSizeInPixels();
                sizeF.Width  -= (float)(this.Common.MapCore.Viewport.Margins.Left + this.Common.MapCore.Viewport.Margins.Right);
                sizeF.Height -= (float)(this.Common.MapCore.Viewport.Margins.Top + this.Common.MapCore.Viewport.Margins.Bottom);
            }
            else
            {
                sizeF = this.Common.MapCore.CalculateMapDockBounds(g).Size;
            }
            if (this.Dock == PanelDockStyle.Top || this.Dock == PanelDockStyle.Bottom)
            {
                result.Width = sizeF.Width - (float)base.Margins.Left - (float)base.Margins.Right;
            }
            else if (this.Dock == PanelDockStyle.Left || this.Dock == PanelDockStyle.Right)
            {
                result.Height = sizeF.Height - (float)base.Margins.Top - (float)base.Margins.Bottom;
            }
            return(result);
        }
Ejemplo n.º 24
0
        public override Matrix4 GetModelMatrix(MapGraphics graphics)
        {
            float _yDepth = graphics.Camera is MapCameraTopView ? -0x2000 : Y + 20f;

            return(Matrix4.CreateScale(Region.Width, 1.0f, Region.Height)
                   * Matrix4.CreateTranslation(Region.Location.X, _yDepth, Region.Location.Y));
        }
Ejemplo n.º 25
0
        private void CheckUpdateImage(MapGraphics graphics)
        {
            // Image already updated
            if (_imageUpdated)
            {
                return;
            }

            // Remove previous image
            GL.DeleteTexture(_imageTexID);
            _imageTexID   = -1;
            _imageUpdated = true;

            // Don't add image if its null (we want it cleared)
            if (_image == null)
            {
                return;
            }

            // Update image
            _imageTexID = graphics.Utilities.LoadTexture(_image);

            // Dispose of temp copy (its in graphics memory now)
            _image.Dispose();
            _image = null;
        }
Ejemplo n.º 26
0
        protected override List <Vector3> GetVertices(MapGraphics graphics)
        {
            // failsafe to prevent filling the whole screen
            if (!graphics.hasUnitPrecision)
            {
                return(new List <Vector3>());
            }

            float marioY = Config.Stream.GetSingle(MarioConfig.StructAddress + MarioConfig.YOffset);

            int xMin = (int)graphics.MapViewXMin - 1;
            int xMax = (int)graphics.MapViewXMax + 1;
            int zMin = (int)graphics.MapViewZMin - 1;
            int zMax = (int)graphics.MapViewZMax + 1;

            var vertices = new List <Vector3>();

            for (int x = xMin; x <= xMax; x += 1)
            {
                vertices.Add(new Vector3(x, marioY, zMin));
                vertices.Add(new Vector3(x, marioY, zMax));
            }
            for (int z = zMin; z <= zMax; z += 1)
            {
                vertices.Add(new Vector3(xMin, marioY, z));
                vertices.Add(new Vector3(xMax, marioY, z));
            }
            return(vertices);
        }
Ejemplo n.º 27
0
 internal virtual bool IsRenderVisible(MapGraphics g, RectangleF clipRect)
 {
     if (!IsVisible())
     {
         return(false);
     }
     return(clipRect.IntersectsWith(GetBoundsInPixels()));
 }
Ejemplo n.º 28
0
        internal virtual GraphicsPath GetHotRegionPath(MapGraphics g)
        {
            GraphicsPath graphicsPath = new GraphicsPath();
            RectangleF   rect         = new RectangleF(GetAbsoluteLocation(), GetAbsoluteSize());

            graphicsPath.AddRectangle(rect);
            return(graphicsPath);
        }
Ejemplo n.º 29
0
        public bool IsVisible(MapGraphics g)
        {
            RectangleF relative = new RectangleF(0f, 0f, 100f, 100f);

            this.AdjustAreasPosition(g, ref relative);
            relative = g.GetAbsoluteRectangle(relative);
            return(!relative.Contains(g.Clip.GetBounds(g.Graphics)));
        }
Ejemplo n.º 30
0
 public override bool IsRenderVisible(MapGraphics g, RectangleF clipRect)
 {
     if (base.IsRenderVisible(g, clipRect))
     {
         return(!this.IsEmpty);
     }
     return(false);
 }