Пример #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);
                }
            }
        }
        private void RenderButton(MapGraphics g, PanelButton button)
        {
            float num          = (float)(g.GetAbsoluteDimension(100f) - 1.0);
            SizeF absoluteSize = g.GetAbsoluteSize(new SizeF(100f, 100f));

            absoluteSize.Width  -= 1f;
            absoluteSize.Height -= 1f;
            SizeF  sizeF  = new SizeF((float)((absoluteSize.Width - num) / 2.0), (float)((absoluteSize.Height - num) / 2.0));
            float  num2   = (float)(num / 3.0);
            PointF pointF = PointF.Empty;

            switch (button.Type)
            {
            case PanelButtonType.NavigationButton:
                pointF = new PointF((float)(num / 2.0), (float)(num2 / 2.0));
                if (!this.CenterButtonVisible)
                {
                    pointF.Y += 2f;
                }
                break;

            case PanelButtonType.NaviagateSouth:
                pointF = new PointF((float)(num / 2.0), (float)(num - num2 / 2.0));
                if (!this.CenterButtonVisible)
                {
                    pointF.Y -= 2f;
                }
                break;

            case PanelButtonType.NaviagateEast:
                pointF = new PointF((float)(num - num2 / 2.0), (float)(num / 2.0));
                if (!this.CenterButtonVisible)
                {
                    pointF.X -= 2f;
                }
                break;

            case PanelButtonType.NaviagateWest:
                pointF = new PointF((float)(num2 / 2.0), (float)(num / 2.0));
                if (!this.CenterButtonVisible)
                {
                    pointF.X += 2f;
                }
                break;

            case PanelButtonType.NaviagateCenter:
                pointF = new PointF((float)(num / 2.0), (float)(num / 2.0));
                break;

            default:
                throw new ArgumentException(SR.invalid_button_type);
            }
            num2 = (float)(num2 - 4.0);
            RectangleF absolute = new RectangleF((float)(sizeF.Width + pointF.X - num2 / 2.0), (float)(sizeF.Height + pointF.Y - num2 / 2.0), num2, num2);

            button.Bounds = g.GetRelativeRectangle(absolute);
            button.Render(g);
        }
        private void RenderButton(MapGraphics g, PanelButton button)
        {
            float num          = g.GetAbsoluteDimension(100f) - 1f;
            SizeF absoluteSize = g.GetAbsoluteSize(new SizeF(100f, 100f));

            absoluteSize.Width  -= 1f;
            absoluteSize.Height -= 1f;
            SizeF  sizeF = new SizeF((absoluteSize.Width - num) / 2f, (absoluteSize.Height - num) / 2f);
            float  num2  = num / 3f;
            PointF empty = PointF.Empty;

            switch (button.Type)
            {
            case PanelButtonType.NavigationButton:
                empty = new PointF(num / 2f, num2 / 2f);
                if (!CenterButtonVisible)
                {
                    empty.Y += 2f;
                }
                break;

            case PanelButtonType.NaviagateSouth:
                empty = new PointF(num / 2f, num - num2 / 2f);
                if (!CenterButtonVisible)
                {
                    empty.Y -= 2f;
                }
                break;

            case PanelButtonType.NaviagateEast:
                empty = new PointF(num - num2 / 2f, num / 2f);
                if (!CenterButtonVisible)
                {
                    empty.X -= 2f;
                }
                break;

            case PanelButtonType.NaviagateWest:
                empty = new PointF(num2 / 2f, num / 2f);
                if (!CenterButtonVisible)
                {
                    empty.X += 2f;
                }
                break;

            case PanelButtonType.NaviagateCenter:
                empty = new PointF(num / 2f, num / 2f);
                break;

            default:
                throw new ArgumentException(SR.invalid_button_type);
            }
            num2 -= 4f;
            RectangleF absolute = new RectangleF(sizeF.Width + empty.X - num2 / 2f, sizeF.Height + empty.Y - num2 / 2f, num2, num2);

            button.Bounds = g.GetRelativeRectangle(absolute);
            button.Render(g);
        }
Пример #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);
            }
        }