Example #1
0
        public GaugeStrip()
        {
            FillColor = new GradientFillColor();

            _StartValue = double.NaN;
            _EndValue = double.NaN;
        }
Example #2
0
        public Bitmap GetMarkerBitmap(Graphics g,
            GaugeMarkerStyle style, GradientFillColor fillColor, int width, int length)
        {
            Bitmap bitmap = FindBitmap(fillColor);

            if (bitmap == null)
            {
                width = Math.Max(width, 3);
                length = Math.Max(length, 3);

                bitmap = new Bitmap(width, length, g);

                _Bitmaps.Add(new BitmapEntry(fillColor, bitmap));

                using (Graphics gBmp = Graphics.FromImage(bitmap))
                {
                    gBmp.SmoothingMode = SmoothingMode.AntiAlias;

                    Rectangle r = new Rectangle();
                    r.Height = length;
                    r.Width = width;

                    using (GraphicsPath path = GetMarkerPath(style, r))
                        FillMarkerPath(gBmp, path, r, style, fillColor);
                }
            }

            return (bitmap);
        }
Example #3
0
        public Bitmap FindBitmap(GradientFillColor fillColor)
        {
            foreach (BitmapEntry entry in _Bitmaps)
            {
                if (entry.FillColor.IsEqualTo(fillColor) == true)
                    return (entry.Bitmap);
            }

            return (null);
        }
Example #4
0
        public GaugeFrame(GaugeControl gaugeControl)
        {
            _GaugeControl = gaugeControl;

            Style = GaugeFrameStyle.None;

            _InnerBevel = .035f;
            _OuterBevel = .05f;
            _RoundRectangleArc = .125f;

            _BackSigmaFocus = 1;
            _BackSigmaScale = 1;
            _FrameSigmaFocus = .15f;
            _FrameSigmaScale = 1;

            BackColor = new GradientFillColor(Color.Silver, Color.Gray, 45);
            FrameColor = new GradientFillColor(Color.Gainsboro, Color.Gray, 45);
        }
Example #5
0
        public TickMarkLayout(GaugeMarkerStyle style, float width, float length)
        {
            _Style = style;
            _Width = width;
            _Length = length;

            _DefaultStyle = style;
            _DefaultWidth = width;
            _DefaultLength = length;

            _Placement = DisplayPlacement.Center;

            FillColor = new GradientFillColor(Color.DarkGray, Color.White);
            FillColor.BorderColor = Color.DimGray;
            FillColor.BorderWidth = 1;

            _Overlap = GaugeTickMarkOverlap.ReplaceAll;
        }
Example #6
0
        public GaugePin(GaugeScale scale, bool isMmaxPin, string name)
        {
            _Scale = scale;
            _IsMaxPin = isMmaxPin;

            Name = name;

            _GaugeMarker = new GaugeMarker();
            _Label = new GaugePinLabel(this);

            FillColor = new GradientFillColor(Color.WhiteSmoke);
            FillColor.BorderColor = Color.DimGray;
            FillColor.BorderWidth = 1;

            Length = .06f;
            Width = .06f;

            _EndOffset = .02f;

            HookEvents(true);
        }
Example #7
0
 internal void ResetFrameColor()
 {
     FrameColor = new GradientFillColor(Color.Gainsboro, Color.Gray, 45);
 }
Example #8
0
 public BitmapEntry(GradientFillColor fillColor, Bitmap bitmap)
 {
     FillColor = (GradientFillColor)fillColor.Clone();
     Bitmap = bitmap;
 }
Example #9
0
        private void RenderBackPath(Graphics g,
            GraphicsPath path, Rectangle bounds, GradientFillColor fillColor)
        {
            Rectangle r = bounds;
            GradientFillType fillType = fillColor.GradientFillType;

            if (fillColor.End.IsEmpty)
            {
                fillType = GradientFillType.None;
            }
            else
            {
                if (fillColor.GradientFillType == GradientFillType.Auto)
                    fillType = GradientFillType.Center;
            }

            switch (fillType)
            {
                case GradientFillType.Angle:
                    using (Brush br = fillColor.GetBrush(r))
                    {
                        if (br is LinearGradientBrush)
                            ((LinearGradientBrush)br).WrapMode = WrapMode.TileFlipXY;

                        g.FillPath(br, path);
                    }
                    break;

                case GradientFillType.StartToEnd:
                    using (Brush br = fillColor.GetBrush(r, 90))
                    {
                        if (br is LinearGradientBrush)
                            ((LinearGradientBrush)br).WrapMode = WrapMode.TileFlipXY;

                        g.FillPath(br, path);
                    }
                    break;

                case GradientFillType.HorizontalCenter:
                    r.Height /= 2;

                    if (r.Height <= 0)
                        r.Height = 1;

                    using (LinearGradientBrush br = new
                        LinearGradientBrush(r, fillColor.Start, fillColor.End, 90))
                    {
                        br.WrapMode = WrapMode.TileFlipXY;

                        g.FillPath(br, path);
                    }
                    break;

                case GradientFillType.VerticalCenter:
                    r.Width /= 2;

                    if (r.Width <= 0)
                        r.Width = 1;

                    using (LinearGradientBrush br = new
                        LinearGradientBrush(r, fillColor.Start, fillColor.End, 0f))
                    {
                        br.WrapMode = WrapMode.TileFlipXY;

                        g.FillPath(br, path);
                    }
                    break;

                case GradientFillType.Center:
                    using (PathGradientBrush br = new PathGradientBrush(path))
                    {
                        br.CenterPoint = new PointF(bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2);
                        br.CenterColor = fillColor.Start;
                        br.SurroundColors = new Color[] { fillColor.End };

                        g.FillPath(br, path);
                    }
                    break;

                default:
                    using (Brush br = new SolidBrush(fillColor.Start))
                        g.FillPath(br, path);

                    break;
            }

            if (fillColor.BorderWidth > 0 && fillColor.BorderColor.IsEmpty == false)
            {
                using (Pen pen = new Pen(fillColor.BorderColor, fillColor.BorderWidth))
                    g.DrawPath(pen, path);
            }
            else
            {
                if (fillType == GradientFillType.Center)
                {
                    using (Pen pen = new Pen(fillColor.End))
                        g.DrawPath(pen, path);
                }
            }
        }
Example #10
0
        private GradientFillType GetMarkerFillType(GaugeMarkerStyle style, GradientFillColor fillColor)
        {
            if (fillColor.End.IsEmpty == true)
                return (GradientFillType.None);

            if (fillColor.GradientFillType == GradientFillType.Auto)
            {
                switch (style)
                {
                    case GaugeMarkerStyle.Circle:
                    case GaugeMarkerStyle.Star5:
                    case GaugeMarkerStyle.Star7:
                        return (GradientFillType.Center);

                    default:
                        return (GradientFillType.VerticalCenter);
                }
            }

            return (fillColor.GradientFillType);
        }
Example #11
0
        private void RenderFill(Graphics g, Rectangle r, GraphicsPath path,
            GradientFillColor fillColor, GradientFillType fillType, int angle, bool offset)
        {
            if (fillColor.Color2.IsEmpty)
                fillType = GradientFillType.None;

            switch (fillType)
            {
                case GradientFillType.Auto:
                case GradientFillType.Angle:
                    if (offset == false)
                        angle += fillColor.GradientAngle;

                    using (Brush br = fillColor.GetBrush(r, angle))
                    {
                        if (br is LinearGradientBrush)
                            ((LinearGradientBrush)br).WrapMode = WrapMode.TileFlipXY;

                        g.FillPath(br, path);
                    }
                    break;

                case GradientFillType.StartToEnd:
                    using (Brush br = fillColor.GetBrush(r, 90 + angle))
                    {
                        if (br is LinearGradientBrush)
                            ((LinearGradientBrush)br).WrapMode = WrapMode.TileFlipXY;

                        g.FillPath(br, path);
                    }
                    break;

                case GradientFillType.HorizontalCenter:
                    if (r.Height >= 2)
                        r.Height /= 2;

                    using (LinearGradientBrush br = new
                        LinearGradientBrush(r, fillColor.Start, fillColor.End, 90 + angle))
                    {
                        br.WrapMode = WrapMode.TileFlipXY;

                        g.FillPath(br, path);
                    }
                    break;

                case GradientFillType.VerticalCenter:
                    if (r.Width >= 2)
                        r.Width /= 2;

                    using (LinearGradientBrush br = new
                        LinearGradientBrush(r, fillColor.Start, fillColor.End, 0f + angle))
                    {
                        br.WrapMode = WrapMode.TileFlipXY;

                        g.FillPath(br, path);
                    }
                    break;

                case GradientFillType.Center:
                    using (PathGradientBrush br = new PathGradientBrush(path))
                    {
                        if (offset == true && Scale is GaugeCircularScale)
                            br.CenterPoint = ((GaugeCircularScale)Scale).GetPoint((int) (r.Width * .45f), 180 + 45 + angle);

                        br.CenterColor = fillColor.Start;
                        br.SurroundColors = new Color[] { fillColor.End };

                        g.FillPath(br, path);
                    }
                    break;

                default:
                    using (Brush br = new SolidBrush(fillColor.Start))
                        g.FillPath(br, path);

                    break;
            }
        }
Example #12
0
        private void RenderBorder(
            Graphics g, GraphicsPath path, GradientFillColor fillColor)
        {
            if (fillColor.BorderWidth > 0)
            {
                using (Pen pen = new Pen(fillColor.BorderColor, fillColor.BorderWidth))
                {
                    pen.Alignment = PenAlignment.Inset;

                    g.DrawPath(pen, path);
                }
            }
        }
Example #13
0
        protected virtual void RenderBarByCenter(Graphics g, GraphicsPath path, GradientFillColor fillColor)
        {
            using (PathGradientBrush br = new PathGradientBrush(path))
            {
                br.WrapMode = WrapMode.TileFlipXY;

                br.CenterColor = fillColor.Color1;
                br.SurroundColors = new Color[] {fillColor.Color2};

                if (Scale is GaugeCircularScale)
                {
                    br.CenterPoint = Scale.Center;

                    float m = (float)Width / (_Bounds.Width / 2);

                    Blend blnd = new Blend();
                    blnd.Positions = new float[] { 0f, m, 1f };
                    blnd.Factors = new float[] { 1f, 0f, 0f };
                    br.Blend = blnd;
                }

                g.FillPath(br, path);
            }
        }
Example #14
0
 internal virtual void ResetBackColor()
 {
     BackColor = new GradientFillColor(Color.Silver, Color.Gray, 45);
 }
Example #15
0
        internal void FillMarkerPath(Graphics g, GraphicsPath path,
            Rectangle r, GaugeMarkerStyle style, GradientFillColor fillColor)
        {
            GradientFillType fillType = GetMarkerFillType(style, fillColor);

            switch (fillType)
            {
                case GradientFillType.Angle:
                    using (Brush br = fillColor.GetBrush(r))
                    {
                        if (br is LinearGradientBrush)
                            ((LinearGradientBrush)br).WrapMode = WrapMode.TileFlipXY;

                        g.FillPath(br, path);
                    }
                    break;

                case GradientFillType.StartToEnd:
                    using (Brush br = fillColor.GetBrush(r, 90))
                    {
                        if (br is LinearGradientBrush)
                            ((LinearGradientBrush)br).WrapMode = WrapMode.TileFlipXY;

                        g.FillPath(br, path);
                    }
                    break;

                case GradientFillType.HorizontalCenter:
                    r.Height /= 2;

                    if (r.Height <= 0)
                        r.Height = 1;

                    using (LinearGradientBrush br = new
                        LinearGradientBrush(r, fillColor.Start, fillColor.End, 90))
                    {
                        br.WrapMode = WrapMode.TileFlipXY;

                        g.FillPath(br, path);
                    }
                    break;

                case GradientFillType.VerticalCenter:
                    r.Width /= 2;

                    if (r.Width <= 0)
                        r.Width = 1;

                    using (LinearGradientBrush br = new
                        LinearGradientBrush(r, fillColor.Start, fillColor.End, 0f))
                    {
                        br.WrapMode = WrapMode.TileFlipXY;

                        g.FillPath(br, path);
                    }
                    break;

                case GradientFillType.Center:
                    using (PathGradientBrush br = new PathGradientBrush(path))
                    {
                        br.CenterColor = fillColor.Start;
                        br.SurroundColors = new Color[] { fillColor.End };

                        g.FillPath(br, path);
                    }
                    break;

                default:
                    using (Brush br = new SolidBrush(fillColor.Start))
                        g.FillPath(br, path);

                    break;
            }

            if (fillColor.BorderWidth > 0)
            {
                using (Pen pen = new Pen(fillColor.BorderColor, fillColor.BorderWidth))
                {
                    pen.Alignment = PenAlignment.Inset;

                    g.DrawPath(pen, path);
                }
            }
        }
Example #16
0
        private void RenderBarStartToEnd(Graphics g,
            GraphicsPath path, GradientFillColor fillColor)
        {
            if (Scale is GaugeCircularScale)
            {
                using (PathGradientBrush br = ((GaugeCircularScale)Scale).CreateGradient(
                    Scale.GaugeControl.Frame.Bounds, _StartAngle, _SweepAngle, fillColor, Width * 2))
                {
                    if (GaugePointer.BarStyle == BarPointerStyle.Rounded)
                    {
                        using (Brush br2 = new SolidBrush(fillColor.Color2))
                            g.FillPath(br2, path);
                    }

                    g.FillPath(br, path);
                }
            }
            else
            {
                Rectangle t = Rectangle.Round(path.GetBounds());

                float angle = _RoundAngle + (Scale.Reversed ? 180 : 0);

                using (Brush br = fillColor.GetBrush(t, (int)angle))
                    g.FillPath(br, path);
            }
        }
Example #17
0
 internal void ResetFillColor()
 {
     FillColor = new GradientFillColor(Color.DarkGray, Color.White);
     FillColor.BorderColor = Color.DimGray;
     FillColor.BorderWidth = 1;
 }
Example #18
0
 private GradientFillType GetGradientFillType(GradientFillColor fc)
 {
     return (fc.End.IsEmpty ? GradientFillType.None : fc.GradientFillType);
 }
Example #19
0
        public object Clone()
        {
            GradientFillColor fillColor = new GradientFillColor();

            fillColor.Color1 = Color1;
            fillColor.Color2 = Color2;
            fillColor.BorderColor = BorderColor;
            fillColor.BorderWidth = BorderWidth;
            fillColor.GradientFillType = GradientFillType;
            fillColor.GradientAngle = GradientAngle;

            return (fillColor);
        }
Example #20
0
 /// <summary>
 /// Determines if the fillcolor is equal to the given one
 /// </summary>
 /// <param name="fillColor">FillColor to compare</param>
 /// <returns>true if equal</returns>
 public bool IsEqualTo(GradientFillColor fillColor)
 {
     return (Color1 == fillColor.Color1 && Color2 == fillColor.Color2 &&
         GradientAngle == fillColor.GradientAngle && GradientFillType == fillColor.GradientFillType &&
         BorderColor == fillColor.BorderColor && BorderWidth == fillColor._BorderWidth);
 }
Example #21
0
        protected override void RenderBarByCenter(
            Graphics g, GraphicsPath path, GradientFillColor fillColor)
        {
            using (PathGradientBrush br = new PathGradientBrush(path))
            {
                br.WrapMode = WrapMode.TileFlipXY;

                br.CenterColor = fillColor.Color1;
                br.SurroundColors = new Color[] { fillColor.Color2 };

                br.CenterPoint = new PointF(
                    _BulbBounds.X + _BulbBounds.Width / 2, _BulbBounds.Y + _BulbBounds.Height / 2);

                g.FillPath(br, path);
            }
        }
Example #22
0
        protected void RenderBar(Graphics g, GraphicsPath path, GradientFillColor fillColor)
        {

            if (fillColor.End.IsEmpty == true || fillColor.Color1 == fillColor.Color2 ||
                fillColor.GradientFillType == GradientFillType.None)
            {
                using (Brush br = new SolidBrush(fillColor.Color1))
                    g.FillPath(br, path);
            }
            else
            {
                GradientFillType fillType = (fillColor.GradientFillType == GradientFillType.Auto)
                                                ? GradientFillType.Center
                                                : fillColor.GradientFillType;
                switch (fillType)
                {
                    case GradientFillType.Auto:
                    case GradientFillType.StartToEnd:
                        RenderBarStartToEnd(g, path, fillColor);
                        break;

                    case GradientFillType.Angle:
                        RenderBarByAngle(g, path, fillColor);
                        break;

                    case GradientFillType.Center:
                        RenderBarByCenter(g, path, fillColor);
                        break;

                    case GradientFillType.HorizontalCenter:
                        RenderBarByHc(g, path, fillColor);
                        break;

                    case GradientFillType.VerticalCenter:
                        RenderBarByVc(g, path, fillColor);
                        break;
                }
            }

            if (fillColor.BorderWidth > 0)
            {
                using (Pen pen = new Pen(fillColor.BorderColor, fillColor.BorderWidth))
                    g.DrawPath(pen, path);
            }
        }
Example #23
0
        private void FillBackground(Graphics g,
            Rectangle bounds, GradientFillColor fillColor)
        {
            Rectangle r = bounds;

            GradientFillType fillType =
                fillColor.End.IsEmpty ? GradientFillType.None : fillColor.GradientFillType;

            switch (fillType)
            {
                case GradientFillType.Angle:
                    using (Brush br = fillColor.GetBrush(r))
                    {
                        if (br is LinearGradientBrush)
                            ((LinearGradientBrush)br).WrapMode = WrapMode.TileFlipXY;

                        g.FillRectangle(br, r);
                    }
                    break;

                case GradientFillType.StartToEnd:
                    using (Brush br = fillColor.GetBrush(r, 90))
                    {
                        if (br is LinearGradientBrush)
                            ((LinearGradientBrush)br).WrapMode = WrapMode.TileFlipXY;

                        g.FillRectangle(br, r);
                    }
                    break;

                case GradientFillType.HorizontalCenter:
                    r.Height /= 2;

                    if (r.Height <= 0)
                        r.Height = 1;

                    using (LinearGradientBrush br = new
                        LinearGradientBrush(r, fillColor.Start, fillColor.End, 90))
                    {
                        br.WrapMode = WrapMode.TileFlipXY;

                        g.FillRectangle(br, bounds);
                    }
                    break;

                case GradientFillType.VerticalCenter:
                    r.Width /= 2;

                    if (r.Width <= 0)
                        r.Width = 1;

                    using (LinearGradientBrush br = new
                        LinearGradientBrush(r, fillColor.Start, fillColor.End, 0f))
                    {
                        br.WrapMode = WrapMode.TileFlipXY;

                        g.FillRectangle(br, bounds);
                    }
                    break;

                case GradientFillType.Center:
                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddRectangle(r);

                        using (PathGradientBrush br = new PathGradientBrush(path))
                        {
                            br.CenterColor = fillColor.Start;
                            br.SurroundColors = new Color[] { fillColor.End };

                            g.FillRectangle(br, r);
                        }
                    }
                    break;

                default:
                    using (Brush br = new SolidBrush(fillColor.Start))
                        g.FillRectangle(br, r);

                    break;
            }
        }
Example #24
0
        private void RenderBarByAngle(Graphics g, GraphicsPath path, GradientFillColor fillColor)
        {
            int n = Width / 2;

            Rectangle t = Rectangle.Round(path.GetBounds());
            t.Inflate(n, n);

            using (Brush br = fillColor.GetBrush(t))
                g.FillPath(br, path);
        }
Example #25
0
        private void RenderCapPathSytle1(Graphics g,
            Rectangle r, GradientFillColor fillColor, GradientFillType fillType)
        {
            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddEllipse(r);

                RenderFill(g, r, path, fillColor, fillType, 0, true);
                RenderBorder(g, path, fillColor);
            }
        }
Example #26
0
        private void RenderBarByVc(Graphics g, GraphicsPath path, GradientFillColor fillColor)
        {
            Rectangle t = Rectangle.Round(path.GetBounds());
            t.Width /= 2;

            using (LinearGradientBrush br = new
                LinearGradientBrush(t, fillColor.Color1, fillColor.Color2, 0f))
            {
                br.WrapMode = WrapMode.TileFlipXY;

                g.FillPath(br, path);
            }
        }
Example #27
0
        private void RenderCapPathSytle2(Graphics g,
            Rectangle r, GradientFillColor fillColor, GradientFillType fillType)
        {
            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddEllipse(r);

                RenderFill(g, r, path, fillColor, fillType, 0, true);
                RenderBorder(g, path, fillColor);

                path.Reset();

                int angle = 180;
                int outer = (int)(r.Width * GaugePointer.CapOuterBevel);

                if (outer > 0)
                {
                    r.Inflate(-outer, -outer);

                    if (r.Width >= 2)
                    {
                        path.AddEllipse(r);
                        RenderFill(g, r, path, fillColor, fillType, 180, true);

                        path.Reset();

                        angle = 0;
                    }
                }

                int inner = (int) (r.Width*GaugePointer.CapInnerBevel);

                if (inner > 0)
                {
                    r.Inflate(-inner, -inner);

                    if (r.Width >= 2)
                    {
                        path.AddEllipse(r);
                        RenderFill(g, r, path, fillColor, fillType, angle, true);
                    }
                }
            }
        }