Example #1
0
        internal void DrawImage(MapGraphics g, bool drawShadow)
        {
            if (!Visible || (drawShadow && ShadowOffset == 0f))
            {
                return;
            }
            Image image = Common.ImageLoader.LoadImage(Image);

            if (image.Width == 0 || image.Height == 0)
            {
                return;
            }
            Point point = new Point(ImageOrigin.X, ImageOrigin.Y);

            if (point.X == 0 && point.Y == 0)
            {
                point.X = image.Width / 2;
                point.Y = image.Height / 2;
            }
            float  absoluteDimension  = g.GetAbsoluteDimension(Width);
            float  absoluteDimension2 = g.GetAbsoluteDimension(MarkerLength);
            float  num  = absoluteDimension / (float)image.Width;
            float  num2 = absoluteDimension2 / (float)image.Height;
            float  num3 = CalculateMarkerDistance();
            float  positionFromValue = GetScale().GetPositionFromValue(Position);
            PointF pointF            = Point.Empty;

            pointF = ((GetGauge().GetOrientation() != 0) ? g.GetAbsolutePoint(new PointF(num3, positionFromValue)) : g.GetAbsolutePoint(new PointF(positionFromValue, num3)));
            Rectangle       rectangle       = new Rectangle((int)(pointF.X - (float)point.X * num) + 1, (int)(pointF.Y - (float)point.Y * num2) + 1, (int)((float)image.Width * num) + 1, (int)((float)image.Height * num2) + 1);
            ImageAttributes imageAttributes = new ImageAttributes();

            if (ImageTransColor != Color.Empty)
            {
                imageAttributes.SetColorKey(ImageTransColor, ImageTransColor, ColorAdjustType.Default);
            }
            if (drawShadow)
            {
                ColorMatrix colorMatrix = new ColorMatrix();
                colorMatrix.Matrix00 = 0f;
                colorMatrix.Matrix11 = 0f;
                colorMatrix.Matrix22 = 0f;
                colorMatrix.Matrix33 = Common.MapCore.ShadowIntensity / 100f;
                imageAttributes.SetColorMatrix(colorMatrix);
            }
            g.DrawImage(image, rectangle, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
            if (!drawShadow)
            {
                using (GraphicsPath graphicsPath = new GraphicsPath())
                {
                    graphicsPath.AddRectangle(rectangle);
                    Common.MapCore.HotRegionList.SetHotRegion(g, this, graphicsPath);
                }
            }
        }
Example #2
0
        internal override void Render(MapGraphics g)
        {
            g.StartHotRegion(this);
            MapDashStyle mapDashStyle = BorderStyle;

            if (!string.IsNullOrEmpty(Image))
            {
                ImageSmoothingState imageSmoothingState = new ImageSmoothingState(g);
                imageSmoothingState.Set();
                DrawImage(g, image, drawShadow: true);
                DrawImage(g, image, drawShadow: false);
                imageSmoothingState.Restore();
            }
            else
            {
                string       text         = "No image.";
                Font         font         = new Font("Microsoft Sans Serif", 8.25f);
                SizeF        sizeF        = g.MeasureString(text, font);
                StringFormat stringFormat = new StringFormat();
                stringFormat.Alignment     = StringAlignment.Center;
                stringFormat.LineAlignment = StringAlignment.Center;
                RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));
                PointF     absolutePoint     = g.GetAbsolutePoint(new PointF(50f, 50f));
                new RectangleF(absolutePoint.X, absolutePoint.Y, 0f, 0f).Inflate(sizeF.Width / 2f, sizeF.Height / 2f);
                using (Brush brush = new SolidBrush(Color.Gray))
                {
                    g.DrawString(text, font, brush, absoluteRectangle, stringFormat);
                }
                mapDashStyle = MapDashStyle.Solid;
            }
            if (mapDashStyle != 0 && BorderColor != Color.Transparent && BorderWidth != 0)
            {
                using (GraphicsPath path = GetPath(g))
                {
                    using (Pen pen = GetPen())
                    {
                        AntiAliasing antiAliasing = g.AntiAliasing;
                        if (Angle % 90f == 0f)
                        {
                            g.AntiAliasing = AntiAliasing.None;
                        }
                        g.DrawPath(pen, path);
                        g.AntiAliasing = antiAliasing;
                    }
                }
            }
            g.EndHotRegion();
        }
Example #3
0
        public PointF GetCenterPointInContentPixels(MapGraphics g)
        {
            MapCore mapCore = this.GetMapCore();

            if (mapCore == null)
            {
                return(PointF.Empty);
            }
            MapPoint centralPoint = this.CentralPoint;

            centralPoint.X += this.CentralPointOffset.X;
            centralPoint.Y += this.CentralPointOffset.Y;
            PointF relative = mapCore.GeographicToPercents(centralPoint).ToPointF();

            return(g.GetAbsolutePoint(relative));
        }
Example #4
0
        public MarkerStyleAttrib GetMarkerStyleAttrib(MapGraphics g)
        {
            MarkerStyleAttrib markerStyleAttrib = new MarkerStyleAttrib();

            if (!string.IsNullOrEmpty(this.Image))
            {
                return(markerStyleAttrib);
            }
            float absoluteDimension  = g.GetAbsoluteDimension(this.MarkerLength);
            float absoluteDimension2 = g.GetAbsoluteDimension(this.Width);

            markerStyleAttrib.path = g.CreateMarker(new PointF(0f, 0f), absoluteDimension2, absoluteDimension, this.MarkerStyle);
            float num = 0f;

            if (this.Placement == Placement.Cross || this.Placement == Placement.Inside)
            {
                num = (float)(num + 180.0);
            }
            if (this.GetGauge().GetOrientation() == Orientation.Vertical)
            {
                num = (float)(num + 270.0);
            }
            if (num > 0.0)
            {
                using (Matrix matrix = new Matrix())
                {
                    matrix.Rotate(num);
                    markerStyleAttrib.path.Transform(matrix);
                }
            }
            float       num2              = this.CalculateMarkerDistance();
            LinearScale scale             = this.GetScale();
            float       positionFromValue = scale.GetPositionFromValue(scale.GetValueLimit(this.Position));
            PointF      pointOrigin       = Point.Empty;

            pointOrigin             = ((this.GetGauge().GetOrientation() != 0) ? g.GetAbsolutePoint(new PointF(num2, positionFromValue)) : g.GetAbsolutePoint(new PointF(positionFromValue, num2)));
            markerStyleAttrib.brush = g.GetMarkerBrush(markerStyleAttrib.path, this.MarkerStyle, pointOrigin, 0f, this.FillColor, this.FillGradientType, this.FillSecondaryColor, this.FillHatchStyle);
            using (Matrix matrix2 = new Matrix())
            {
                matrix2.Translate(pointOrigin.X, pointOrigin.Y, MatrixOrder.Append);
                markerStyleAttrib.path.Transform(matrix2);
                return(markerStyleAttrib);
            }
        }
Example #5
0
        private void RenderButton(MapGraphics g, PanelButton button)
        {
            float markerLength = Pointer.MarkerLength;

            markerLength += 5f;
            float  num  = 0f;
            float  num2 = 0f;
            float  num3;
            PointF relative;

            if (GetOrientation() == Orientation.Horizontal)
            {
                float relativeY = (100f - markerLength) / 2f;
                relativeY    = g.GetRelativeX(g.GetAbsoluteY(relativeY));
                markerLength = g.GetRelativeX(g.GetAbsoluteY(markerLength));
                num3         = g.GetAbsoluteX(markerLength);
                relative     = new PointF(markerLength / 2f + relativeY, 50f);
                if ((button.Type == PanelButtonType.ZoomOut && GetReversed()) || (button.Type == PanelButtonType.ZoomButton && !GetReversed()))
                {
                    num = 100f - markerLength - 2f * relativeY;
                }
            }
            else
            {
                float relativeX = (100f - markerLength) / 2f;
                relativeX    = g.GetRelativeY(g.GetAbsoluteX(relativeX));
                markerLength = g.GetRelativeY(g.GetAbsoluteX(markerLength));
                num3         = g.GetAbsoluteY(markerLength);
                relative     = new PointF(50f, markerLength / 2f + relativeX);
                if ((button.Type == PanelButtonType.ZoomOut && !GetReversed()) || (button.Type == PanelButtonType.ZoomButton && GetReversed()))
                {
                    num2 = 100f - markerLength - 2f * relativeX;
                }
            }
            relative.X += num;
            relative.Y += num2;
            relative    = g.GetAbsolutePoint(relative);
            RectangleF absolute = new RectangleF(relative.X, relative.Y, 0f, 0f);

            absolute.Inflate(num3 / 2f, num3 / 2f);
            button.Bounds = g.GetRelativeRectangle(absolute);
            button.Render(g);
        }
Example #6
0
        private GraphicsPath GetButtonPath(MapGraphics g)
        {
            GraphicsPath graphicsPath = new GraphicsPath();

            switch (this.Style)
            {
            case PanelButtonStyle.Rectangle:
                graphicsPath.AddRectangle(g.GetAbsoluteRectangle(this.Bounds));
                break;

            case PanelButtonStyle.Circle:
                graphicsPath.AddEllipse(g.GetAbsoluteRectangle(this.Bounds));
                break;

            case PanelButtonStyle.RoundedRectangle:
            {
                RectangleF absoluteRectangle = g.GetAbsoluteRectangle(this.Bounds);
                if (!(absoluteRectangle.Width < 1.0) && !(absoluteRectangle.Height < 1.0))
                {
                    float   num          = (float)(absoluteRectangle.Width / 8.0);
                    float[] cornerRadius = new float[8]
                    {
                        num,
                        num,
                        num,
                        num,
                        num,
                        num,
                        num,
                        num
                    };
                    graphicsPath.AddPath(g.CreateRoundedRectPath(absoluteRectangle, cornerRadius), false);
                    break;
                }
                return(graphicsPath);
            }

            case PanelButtonStyle.Triangle:
                switch (this.Type)
                {
                case PanelButtonType.NavigationButton:
                    graphicsPath.AddLines(new PointF[3]
                    {
                        g.GetAbsolutePoint(new PointF(this.Bounds.Left, this.Bounds.Bottom)),
                        g.GetAbsolutePoint(new PointF((float)((this.Bounds.Left + this.Bounds.Right) / 2.0), this.Bounds.Top)),
                        g.GetAbsolutePoint(new PointF(this.Bounds.Right, this.Bounds.Bottom))
                    });
                    graphicsPath.CloseAllFigures();
                    break;

                case PanelButtonType.NaviagateSouth:
                    graphicsPath.AddLines(new PointF[3]
                    {
                        g.GetAbsolutePoint(new PointF(this.Bounds.Left, this.Bounds.Top)),
                        g.GetAbsolutePoint(new PointF((float)((this.Bounds.Left + this.Bounds.Right) / 2.0), this.Bounds.Bottom)),
                        g.GetAbsolutePoint(new PointF(this.Bounds.Right, this.Bounds.Top))
                    });
                    graphicsPath.CloseAllFigures();
                    break;

                case PanelButtonType.NaviagateEast:
                    graphicsPath.AddLines(new PointF[3]
                    {
                        g.GetAbsolutePoint(new PointF(this.Bounds.Left, this.Bounds.Top)),
                        g.GetAbsolutePoint(new PointF(this.Bounds.Right, (float)((this.Bounds.Top + this.Bounds.Bottom) / 2.0))),
                        g.GetAbsolutePoint(new PointF(this.Bounds.Left, this.Bounds.Bottom))
                    });
                    graphicsPath.CloseAllFigures();
                    break;

                case PanelButtonType.NaviagateWest:
                    graphicsPath.AddLines(new PointF[3]
                    {
                        g.GetAbsolutePoint(new PointF(this.Bounds.Right, this.Bounds.Top)),
                        g.GetAbsolutePoint(new PointF(this.Bounds.Left, (float)((this.Bounds.Top + this.Bounds.Bottom) / 2.0))),
                        g.GetAbsolutePoint(new PointF(this.Bounds.Right, this.Bounds.Bottom))
                    });
                    graphicsPath.CloseAllFigures();
                    break;
                }
                break;
            }
            return(graphicsPath);
        }
Example #7
0
        internal void DrawImage(MapGraphics g, string imageName, bool drawShadow)
        {
            if (drawShadow && ShadowOffset == 0f)
            {
                return;
            }
            Image image = Common.ImageLoader.LoadImage(imageName);

            if (image.Width == 0 || image.Height == 0)
            {
                return;
            }
            RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));
            Rectangle  empty             = Rectangle.Empty;

            if (ResizeMode == ResizeMode.AutoFit)
            {
                empty = new Rectangle((int)absoluteRectangle.X, (int)absoluteRectangle.Y, (int)absoluteRectangle.Width, (int)absoluteRectangle.Height);
            }
            else
            {
                empty = new Rectangle(0, 0, image.Width, image.Height);
                PointF absolutePoint = g.GetAbsolutePoint(new PointF(50f, 50f));
                empty.X = (int)(absolutePoint.X - (float)(empty.Size.Width / 2));
                empty.Y = (int)(absolutePoint.Y - (float)(empty.Size.Height / 2));
            }
            ImageAttributes imageAttributes = new ImageAttributes();

            if (ImageTransColor != Color.Empty)
            {
                imageAttributes.SetColorKey(ImageTransColor, ImageTransColor, ColorAdjustType.Default);
            }
            float num  = (100f - Transparency) / 100f;
            float num2 = Common.MapCore.ShadowIntensity / 100f;

            if (drawShadow)
            {
                ColorMatrix colorMatrix = new ColorMatrix();
                colorMatrix.Matrix00 = 0f;
                colorMatrix.Matrix11 = 0f;
                colorMatrix.Matrix22 = 0f;
                colorMatrix.Matrix33 = num2 * num;
                imageAttributes.SetColorMatrix(colorMatrix);
            }
            else if (Transparency > 0f)
            {
                ColorMatrix colorMatrix2 = new ColorMatrix();
                colorMatrix2.Matrix33 = num;
                imageAttributes.SetColorMatrix(colorMatrix2);
            }
            if (Angle != 0f)
            {
                PointF point     = new PointF(absoluteRectangle.X + absoluteRectangle.Width / 2f, absoluteRectangle.Y + absoluteRectangle.Height / 2f);
                Matrix transform = g.Transform;
                Matrix matrix    = g.Transform.Clone();
                float  offsetX   = matrix.OffsetX;
                float  offsetY   = matrix.OffsetY;
                point.X += offsetX;
                point.Y += offsetY;
                matrix.RotateAt(Angle, point, MatrixOrder.Append);
                if (drawShadow)
                {
                    matrix.Translate(ShadowOffset, ShadowOffset, MatrixOrder.Append);
                }
                g.Transform = matrix;
                g.DrawImage(image, empty, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
                g.Transform = transform;
            }
            else
            {
                if (drawShadow)
                {
                    empty.X += (int)ShadowOffset;
                    empty.Y += (int)ShadowOffset;
                }
                g.DrawImage(image, empty, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
            }
            if (drawShadow)
            {
                return;
            }
            using (GraphicsPath graphicsPath = new GraphicsPath())
            {
                graphicsPath.AddRectangle(empty);
                if (Angle != 0f)
                {
                    PointF point2 = new PointF(absoluteRectangle.X + absoluteRectangle.Width / 2f, absoluteRectangle.Y + absoluteRectangle.Height / 2f);
                    using (Matrix matrix2 = new Matrix())
                    {
                        matrix2.RotateAt(Angle, point2, MatrixOrder.Append);
                        graphicsPath.Transform(matrix2);
                    }
                }
                Common.MapCore.HotRegionList.SetHotRegion(g, this, graphicsPath);
            }
        }
        private void RenderButton(MapGraphics g, PanelButton button)
        {
            float markerLength = this.Pointer.MarkerLength;

            markerLength = (float)(markerLength + 5.0);
            float  num  = 0f;
            float  num2 = 0f;
            float  relativeY;
            float  num3;
            PointF relative;
            float  relativeX;

            if (this.GetOrientation() == Orientation.Horizontal)
            {
                relativeY    = (float)((100.0 - markerLength) / 2.0);
                relativeY    = g.GetRelativeX(g.GetAbsoluteY(relativeY));
                markerLength = g.GetRelativeX(g.GetAbsoluteY(markerLength));
                num3         = g.GetAbsoluteX(markerLength);
                relative     = new PointF((float)(markerLength / 2.0 + relativeY), 50f);
                if (button.Type == PanelButtonType.ZoomOut && this.GetReversed())
                {
                    goto IL_00a1;
                }
                if (button.Type == PanelButtonType.ZoomButton && !this.GetReversed())
                {
                    goto IL_00a1;
                }
            }
            else
            {
                relativeX    = (float)((100.0 - markerLength) / 2.0);
                relativeX    = g.GetRelativeY(g.GetAbsoluteX(relativeX));
                markerLength = g.GetRelativeY(g.GetAbsoluteX(markerLength));
                num3         = g.GetAbsoluteY(markerLength);
                relative     = new PointF(50f, (float)(markerLength / 2.0 + relativeX));
                if (button.Type == PanelButtonType.ZoomOut && !this.GetReversed())
                {
                    goto IL_0126;
                }
                if (button.Type == PanelButtonType.ZoomButton && this.GetReversed())
                {
                    goto IL_0126;
                }
            }
            goto IL_0138;
IL_00a1:
            num = (float)(100.0 - markerLength - 2.0 * relativeY);
            goto IL_0138;
IL_0126:
            num2 = (float)(100.0 - markerLength - 2.0 * relativeX);
            goto IL_0138;
IL_0138:
            relative.X += num;
            relative.Y += num2;
            relative    = g.GetAbsolutePoint(relative);
            RectangleF absolute = new RectangleF(relative.X, relative.Y, 0f, 0f);

            absolute.Inflate((float)(num3 / 2.0), (float)(num3 / 2.0));
            button.Bounds = g.GetRelativeRectangle(absolute);
            button.Render(g);
        }