Example #1
0
        /// <inheritdoc />
        public bool Equals([AllowNull] HoverLabel other)
        {
            if (other == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     BgColor == other.BgColor ||
                     BgColor != null &&
                     BgColor.Equals(other.BgColor)
                     ) &&
                 (
                     BorderColor == other.BorderColor ||
                     BorderColor != null &&
                     BorderColor.Equals(other.BorderColor)
                 ) &&
                 (
                     Font == other.Font ||
                     Font != null &&
                     Font.Equals(other.Font)
                 ) &&
                 (
                     Align == other.Align ||
                     Align != null &&
                     Align.Equals(other.Align)
                 ) &&
                 (
                     NameLength == other.NameLength ||
                     NameLength != null &&
                     NameLength.Equals(other.NameLength)
                 ));
        }
Example #2
0
        void PaintContents(object sender, SKPaintSurfaceEventArgs e)
        {
            var canvas = e.Surface.Canvas;

            canvas.Clear(SKColors.Transparent);
            var b = canvas.LocalClipBounds;

            if (FillColor != Color.Transparent)
            {
                using (var paint = new SKPaint
                {
                    IsAntialias = true,
                    IsStroke = false,
                    Color = FillColor.ToSKColor(),
                })
                {
                    canvas.DrawRoundRect(b, (float)CornerRadius, (float)CornerRadius, paint);
                }
            }

            if (BorderColor != Color.Transparent)
            {
                using (var paint = new SKPaint
                {
                    IsAntialias = true,
                    IsStroke = true,
                    StrokeWidth = 1.5f,
                    Color = BorderColor.ToSKColor(),
                })
                {
                    var rect = new SKRect(b.Left + paint.StrokeWidth,
                                          b.Top + paint.StrokeWidth,
                                          b.Right - paint.StrokeWidth,
                                          b.Bottom - paint.StrokeWidth);
                    canvas.DrawRoundRect(rect, (float)CornerRadius, (float)CornerRadius, paint);
                }
            }
        }
Example #3
0
        public static Entry GetEntry(BorderColor color)
        {
            switch (color)
            {
            case BorderColor.White:
                return(new CustomWhiteEntry());

            case BorderColor.Black:
                return(new CustomBlackEntry());

            case BorderColor.Red:
                return(new CustomRedEntry());

            case BorderColor.Green:
                return(new CustomGreenEntry());

            case BorderColor.Yellow:
                return(new CustomYellowEntry());

            default:
                return(new Entry());
            }
        }
Example #4
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Picture?.Length.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ (MouseIcon?.Length.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ MinorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ MajorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ (PropMask?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ForeColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (BackColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)VariousPropertyBits;
         hashCode = (hashCode * 397) ^ (Caption?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)PicturePosition;
         hashCode = (hashCode * 397) ^ (int)MousePointer;
         hashCode = (hashCode * 397) ^ (BorderColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)BorderStyle;
         hashCode = (hashCode * 397) ^ (int)SpecialEffect;
         hashCode = (hashCode * 397) ^ (Accelerator?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Size?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
        internal SLDataBar2010 Clone()
        {
            var db = new SLDataBar2010();

            db.Cfvo1                                = Cfvo1.Clone();
            db.Cfvo2                                = Cfvo2.Clone();
            db.FillColor                            = FillColor.Clone();
            db.BorderColor                          = BorderColor.Clone();
            db.NegativeFillColor                    = NegativeFillColor.Clone();
            db.NegativeBorderColor                  = NegativeBorderColor.Clone();
            db.AxisColor                            = AxisColor.Clone();
            db.MinLength                            = MinLength;
            db.MaxLength                            = MaxLength;
            db.ShowValue                            = ShowValue;
            db.Border                               = Border;
            db.Gradient                             = Gradient;
            db.Direction                            = Direction;
            db.NegativeBarColorSameAsPositive       = NegativeBarColorSameAsPositive;
            db.NegativeBarBorderColorSameAsPositive = NegativeBarBorderColorSameAsPositive;
            db.AxisPosition                         = AxisPosition;

            return(db);
        }
Example #6
0
        protected override void Draw()
        {
            base.Draw();

            Vector2    screenPos = ScreenPosition;
            RectangleF rect      = new RectangleF(screenPos.X, screenPos.Y, Width, Height);

            switch (ButtonStyle)
            {
            case UIButtonStyle.None:
            {
                if (isPressed)
                {
                    Color pressedColor = Color.FromNonPremultiplied(new Vector4(Vector3.Zero, 0.3f * CompositeAlpha));
                    Graphics2D.Texture.FillRectangle(renderConfig, rect, pressedColor);
                }
            }
            break;

            case UIButtonStyle.Custom:
                // Nothing to do here
                break;

            case UIButtonStyle.Flat:
            {
                if (isPressed)
                {
                    Color pressedColor = Color.FromNonPremultiplied(new Vector4(Vector3.Zero, 0.3f * CompositeAlpha));
                    Graphics2D.Texture.FillRectangle(renderConfig, rect, pressedColor);
                }

                Color borderColor = Color.FromNonPremultiplied(new Vector4(BorderColor.ToVector3(), CompositeAlpha));
                Graphics2D.Texture.RenderRectangle(renderConfig, rect, borderColor, BorderWidth);
            }
            break;
            }
        }
Example #7
0
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;

                if (BgColor != null)
                {
                    hashCode = hashCode * 59 + BgColor.GetHashCode();
                }

                if (BorderColor != null)
                {
                    hashCode = hashCode * 59 + BorderColor.GetHashCode();
                }

                if (Font != null)
                {
                    hashCode = hashCode * 59 + Font.GetHashCode();
                }

                return(hashCode);
            }
        }
Example #8
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (firstpaint)
            {
                System.ComponentModel.IContainer ic = this.GetParentContainerComponents();

                ic?.CopyToolTips(this, new Control[] { textbox });

                firstpaint = false;
            }

            using (Brush highlight = new SolidBrush(controlbackcolor))
            {
                e.Graphics.FillRectangle(highlight, ClientRectangle);
            }

            base.OnPaint(e);

            //System.Diagnostics.Debug.WriteLine("Repaint" + Name + ":" + ClientRectangle.Size + " " + textbox.Location + " " + textbox.Size + " " + BorderColor + " " + textbox.BorderStyle);

            if (OurBorder)
            {
                Rectangle clientborder = new Rectangle(0, 0, ClientRectangle.Width, textbox.Height + borderoffset * 2);       // paint it around the actual area of the textbox, not just bit

                Color color1 = BorderColor;
                Color color2 = BorderColor.Multiply(BorderColorScaling);

                GraphicsPath g1 = ControlHelpersStaticFunc.RectCutCorners(clientborder.X + 1, clientborder.Y + 1, clientborder.Width - 2, clientborder.Height - 1, 1, 1);
                using (Pen pc1 = new Pen(color1, 1.0F))
                    e.Graphics.DrawPath(pc1, g1);

                GraphicsPath g2 = ControlHelpersStaticFunc.RectCutCorners(clientborder.X, clientborder.Y, clientborder.Width, clientborder.Height - 1, 2, 2);
                using (Pen pc2 = new Pen(color2, 1.0F))
                    e.Graphics.DrawPath(pc2, g2);
            }
        }
Example #9
0
        public override void Draw(RectangleF rectB)
        {
            CGColorSpace cs  = null;
            CGContext    ctx = null;
            RectangleF   bds;

            using (ctx = UIGraphics.GetCurrentContext()) {
                using (cs = CGColorSpace.CreateDeviceRGB()) {
                    if (Vertical)
                    {
                        ctx.TranslateCTM(0, Bounds.Height);
                        ctx.ScaleCTM(1, -1);
                        bds = Bounds;
                    }
                    else
                    {
                        ctx.TranslateCTM(0, Bounds.Height);
                        ctx.RotateCTM(-(float)Math.PI / 2);
                        bds = new RectangleF(0, 0, Bounds.Height, Bounds.Width);
                    }

                    ctx.SetFillColorSpace(cs);
                    ctx.SetStrokeColorSpace(cs);

                    if (NumLights == 0)
                    {
                        float currentTop = 0;

                        if (BgColor != null)
                        {
                            BgColor.SetColor();
                            ctx.FillRect(bds);
                        }

                        foreach (var thisTresh in ColorThresholds)
                        {
                            var val = Math.Min(thisTresh.MaxValue, Level);

                            var rect = new RectangleF(0, bds.Height * currentTop, bds.Width, bds.Height * (val - currentTop));
                            thisTresh.Color.SetColor();
                            ctx.FillRect(rect);

                            if (Level < thisTresh.MaxValue)
                            {
                                break;
                            }
                            currentTop = val;
                        }

                        if (BorderColor != null)
                        {
                            BorderColor.SetColor();
                            bds.Inflate(-0.5f, -0.5f);
                            ctx.StrokeRect(bds);
                        }
                    }
                    else
                    {
                        float lightMinVal = 0;
                        float insetAmount, lightVSpace;
                        int   peakLight = -1;

                        lightVSpace = bds.Height / (float)NumLights;
                        if (lightVSpace < 4)
                        {
                            insetAmount = 0;
                        }
                        else if (lightVSpace < 8)
                        {
                            insetAmount = 0.5f;
                        }
                        else
                        {
                            insetAmount = 1;
                        }

                        if (PeakLevel > 0)
                        {
                            peakLight = (int)(PeakLevel * NumLights);
                            if (peakLight >= NumLights)
                            {
                                peakLight = NumLights - 1;
                            }
                        }

                        for (int light_i = 0; light_i < NumLights; light_i++)
                        {
                            float      lightMaxVal = (light_i + 1) / (float)NumLights;
                            float      lightIntensity;
                            RectangleF lightRect;
                            UIColor    lightColor;

                            if (light_i == peakLight)
                            {
                                lightIntensity = 1;
                            }
                            else
                            {
                                lightIntensity = (Level - lightMinVal) / (lightMaxVal - lightMinVal);
                                lightIntensity = Clamp(0, lightIntensity, 1);
                                if (!VariableLightIntensity && lightIntensity > 0)
                                {
                                    lightIntensity = 1;
                                }
                            }
                            lightColor = ColorThresholds [0].Color;
                            int color_i = 0;
                            for (; color_i < ColorThresholds.Length - 1; color_i++)
                            {
                                var thisTresh = ColorThresholds [color_i];
                                var nextTresh = ColorThresholds [color_i + 1];
                                if (thisTresh.MaxValue <= lightMaxVal)
                                {
                                    //Console.WriteLine ("PICKED COLOR at {0}", color_i);
                                    lightColor = nextTresh.Color;
                                }
                            }

                            lightRect = new RectangleF(0, bds.Height * light_i / (float)NumLights,
                                                       bds.Width, bds.Height * (1f / NumLights));
                            lightRect.Inset(insetAmount, insetAmount);

                            if (BgColor != null)
                            {
                                BgColor.SetColor();
                                ctx.FillRect(lightRect);
                            }

                            //Console.WriteLine ("Got: {0} {1}", lightColor, UIColor.Red);
                            //lightColor = UIColor.Red;
                            if (lightIntensity == 1)
                            {
                                lightColor.SetColor();
                                //Console.WriteLine ("Setting color to {0}", lightColor);
                                ctx.FillRect(lightRect);
                            }
                            else if (lightIntensity > 0)
                            {
                                using (var clr = new CGColor(lightColor.CGColor, lightIntensity)) {
                                    ctx.SetFillColor(clr);
                                    ctx.FillRect(lightRect);
                                }
                            }

                            if (BorderColor != null)
                            {
                                BorderColor.SetColor();
                                lightRect.Inset(0.5f, 0.5f);
                                ctx.StrokeRect(lightRect);
                            }

                            lightMinVal = lightMaxVal;
                        }
                    }
                }
            }
        }
Example #10
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (firstpaint)
            {
                System.ComponentModel.IContainer ic = this.GetParentContainerComponents();

                if (ic != null)    // yes we have a container object
                {
                    ic.CopyToolTips(this, new Control[] { this, _cbsystem });
                }

                firstpaint = true;
            }

            base.OnPaint(e);

            if (this.FlatStyle != FlatStyle.System)
            {
                int extraborder = 1;

                topBoxTextArea = new Rectangle(ClientRectangle.X + extraborder, ClientRectangle.Y + extraborder,
                                               ClientRectangle.Width - 2 * extraborder - ScrollBarWidth, ClientRectangle.Height - 2 * extraborder);

                arrowRectangleArea = new Rectangle(ClientRectangle.Width - ScrollBarWidth - extraborder, ClientRectangle.Y + extraborder,
                                                   ScrollBarWidth, ClientRectangle.Height - 2 * extraborder);

                topBoxOutline = new Rectangle(ClientRectangle.X, ClientRectangle.Y,
                                              ClientRectangle.Width - 1, ClientRectangle.Height - 1);

                topBoxTextTotalArea = new Rectangle(ClientRectangle.X + extraborder, ClientRectangle.Y + extraborder,
                                                    ClientRectangle.Width - 2 * extraborder, ClientRectangle.Height - 2 * extraborder);

                int hoffset = arrowRectangleArea.Width / 3;
                int voffset = arrowRectangleArea.Height / 3;
                arrowpt1 = new Point(arrowRectangleArea.X + hoffset, arrowRectangleArea.Y + voffset);
                arrowpt2 = new Point(arrowRectangleArea.X + arrowRectangleArea.Width / 2, arrowRectangleArea.Y + arrowRectangleArea.Height - voffset);
                arrowpt3 = new Point(arrowRectangleArea.X + arrowRectangleArea.Width - hoffset, arrowpt1.Y);

                arrowpt1c = new Point(arrowpt1.X, arrowpt2.Y);
                arrowpt2c = new Point(arrowpt2.X, arrowpt1.Y);
                arrowpt3c = new Point(arrowpt3.X, arrowpt2.Y);

                SizeF sz = e.Graphics.MeasureString("Represent THIS", this.Font);
                topBoxTextArea.Y += (topBoxTextArea.Height - (int)sz.Height) / 2;

                Brush textb;
                Pen   p, p2;

                bool todraw = Enabled && Items.Count > 0;

                if (todraw)
                {
                    textb    = new SolidBrush(this.ForeColor);
                    p        = new Pen(BorderColor);
                    p2       = new Pen(ForeColor);
                    p2.Width = ArrowWidth;
                }
                else
                {
                    textb = new SolidBrush(ForeColor.Multiply(0.5F));
                    p     = new Pen(BorderColor.Multiply(0.5F));
                    p2    = null;
                }

                e.Graphics.DrawRectangle(p, topBoxOutline);

                Color bck;

                if (todraw)
                {
                    bck = (mouseover) ? MouseOverBackgroundColor : BackColor;
                }
                else
                {
                    bck = BackColor.Multiply(0.5F);
                }

                Brush bbck;

                if (FlatStyle == FlatStyle.Popup)
                {
                    bbck = new System.Drawing.Drawing2D.LinearGradientBrush(topBoxTextTotalArea, bck, bck.Multiply(ButtonColorScaling), 90);
                }
                else
                {
                    bbck = new SolidBrush(bck);
                }

                e.Graphics.FillRectangle(bbck, topBoxTextTotalArea);

                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

                if (p2 != null)
                {
                    if (isActivated)
                    {
                        e.Graphics.DrawLine(p2, arrowpt1c, arrowpt2c);            // the arrow!
                        e.Graphics.DrawLine(p2, arrowpt2c, arrowpt3c);
                    }
                    else
                    {
                        e.Graphics.DrawLine(p2, arrowpt1, arrowpt2);            // the arrow!
                        e.Graphics.DrawLine(p2, arrowpt2, arrowpt3);
                    }
                }

                using (StringFormat f = new StringFormat()
                {
                    Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Near, FormatFlags = StringFormatFlags.NoWrap
                })
                    e.Graphics.DrawString(this.Text, this.Font, textb, topBoxTextArea, f);

                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;

                bbck.Dispose();

                textb.Dispose();
                p.Dispose();

                if (p2 != null)
                {
                    p2.Dispose();
                }
            }
        }
Example #11
0
        public string ToString(ObjectStyle defaultStyle)
        {
            StringBuilder sb = new StringBuilder();

            if (!Number.IsEqualTo(xStart, defaultStyle.xStart))
            {
                sb.AppendFormat("xstart:{0};", xStart);
            }

            if (!Number.IsEqualTo(yStart, defaultStyle.yStart))
            {
                sb.AppendFormat("ystart:{0};", yStart);
            }

            if (relativeWidth != defaultStyle.relativeWidth)
            {
                sb.AppendFormat("width:{0}%;", relativeWidth ?? 100);
            }

            if (width != defaultStyle.width)
            {
                sb.AppendFormat("width:{0};", width ?? 0);
            }

            if (relativeHeight != defaultStyle.relativeHeight)
            {
                sb.AppendFormat("height:{0}%;", relativeHeight ?? 100);
            }

            if (height != defaultStyle.height)
            {
                sb.AppendFormat("height:{0};", height ?? 0);
            }

            if (hPadding == vPadding &&
                ((hPadding != defaultStyle.hPadding || vPadding != defaultStyle.vPadding)))
            {
                sb.AppendFormat("padding:{0};", Padding ?? 0);
            }
            else
            {
                if (hPadding != defaultStyle.hPadding)
                {
                    sb.AppendFormat("hpadding:{0};", hPadding ?? 0);
                }

                if (vPadding != defaultStyle.vPadding)
                {
                    sb.AppendFormat("vpadding:{0};", vPadding ?? 0);
                }
            }

            if (hFill != defaultStyle.hFill)
            {
                sb.AppendFormat("hfill:{0};", (hFill ?? false).ToString().ToLower());
            }

            if (vFill != defaultStyle.vFill)
            {
                sb.AppendFormat("vfill:{0};", (vFill ?? false).ToString().ToLower());
            }

            if (border != defaultStyle.border)
            {
                sb.AppendFormat("border:{0};", border ?? 0);
            }

            if (innerVerticalBorder == innerHorizontalBorder &&
                (innerVerticalBorder != defaultStyle.innerVerticalBorder || innerHorizontalBorder != defaultStyle.innerHorizontalBorder))
            {
                sb.AppendFormat("innerborder:{0};", InnerBorder ?? 0);
            }
            else
            {
                if (innerHorizontalBorder != defaultStyle.innerHorizontalBorder)
                {
                    sb.AppendFormat("innerhborder:{0};", innerHorizontalBorder ?? 0);
                }

                if (innerVerticalBorder != defaultStyle.innerVerticalBorder)
                {
                    sb.AppendFormat("innervborder:{0};", innerVerticalBorder ?? 0);
                }
            }

            if (spacing != defaultStyle.spacing)
            {
                sb.AppendFormat("spacing:{0};", spacing ?? 0);
            }

            if (innerVSpacing == innerHSpacing &&
                (innerVSpacing != defaultStyle.innerVSpacing || innerHSpacing != defaultStyle.innerHSpacing))
            {
                sb.AppendFormat("innerspacing:{0};", InnerSpacing ?? 0);
            }
            else
            {
                if (innerHSpacing != defaultStyle.innerHSpacing)
                {
                    sb.AppendFormat("innerhspacing:{0};", innerHSpacing ?? 0);
                }

                if (innerVSpacing != defaultStyle.innerVSpacing)
                {
                    sb.AppendFormat("innervspacing:{0};", innerVSpacing ?? 0);
                }
            }

            if (HAlign != HorizontalAlignment.Left && HAlign != defaultStyle.HAlign)
            {
                switch (HAlign)
                {
                case HorizontalAlignment.Right:
                    sb.Append("halign:right;");
                    break;

                case HorizontalAlignment.Center:
                    sb.Append("halign:center;");
                    break;
                }
            }

            if (VAlign != VerticalAlignment.Top && VAlign != defaultStyle.VAlign)
            {
                switch (VAlign)
                {
                case VerticalAlignment.Bottom:
                    sb.Append("valign:bottom;");
                    break;

                case VerticalAlignment.Center:
                    sb.Append("valign:center;");
                    break;
                }
            }

            if (DrawEmpty != defaultStyle.DrawEmpty)
            {
                sb.AppendFormat("drawempty:{0};", DrawEmpty.ToString().ToLowerInvariant());
            }

            if (AllowHBreak != defaultStyle.AllowHBreak)
            {
                sb.AppendFormat("allowhbreak:{0};", AllowHBreak.ToString().ToLowerInvariant());
            }

            if (AllowVBreak != defaultStyle.AllowVBreak)
            {
                sb.AppendFormat("allowvbreak:{0};", AllowVBreak.ToString().ToLowerInvariant());
            }

            if (!bgColor.Equal(defaultStyle.BgColor))
            {
                sb.AppendFormat("bgcolor:{0};", BgColor.ToHTMLColor());
            }

            if (!fgColor.Equal(defaultStyle.FgColor))
            {
                sb.AppendFormat("fgcolor:{0};", FgColor.ToHTMLColor());
            }

            if (!borderColor.Equals(defaultStyle.BorderColor))
            {
                sb.AppendFormat("bordercolor:{0};", BorderColor.ToHTMLColor());
            }

            return(sb.ToString().TrimEnd(';'));
        }
Example #12
0
        public override void Render(RenderContext renderContext, Stretch stretchMode, StretchDirection stretchDirection)
        {
            Allocate();

            Texture    currentTexture       = CurrentTexture;
            SizeF      currentRawSourceSize = CurrentRawSourceSize;
            RectangleF currentTextureClip   = CurrentTextureClip;
            Vector4    frameData            = new Vector4(currentRawSourceSize.Width, currentRawSourceSize.Height, (float)EffectTimer, 0);

            if (_transitionActive)
            {
                double elapsed = (SkinContext.FrameRenderingStartTime - _transitionStart).TotalSeconds / Math.Max(TransitionDuration, 0.01);
                if (elapsed > 1.0)
                {
                    _transitionActive = false;
                }
                else
                {
                    Texture    lastTexture       = LastTexture;
                    SizeF      lastRawSourceSize = LastRawSourceSize;
                    RectangleF lastTextureClip   = LastTextureClip;
                    Vector4    lastFrameData     = new Vector4(lastRawSourceSize.Width, lastRawSourceSize.Height, (float)EffectTimer, 0);

                    Texture start = lastTexture ?? NullTexture.Texture;
                    Texture end   = currentTexture ?? NullTexture.Texture;

                    if (start != end)
                    {
                        SizeF startSize = StretchSource(_lastImageContext.RotatedFrameSize, lastRawSourceSize, stretchMode, stretchDirection);
                        SizeF endSize   = StretchSource(_imageContext.RotatedFrameSize, currentRawSourceSize, stretchMode, stretchDirection);

                        // Render transition from last texture to current texture
                        _lastImageContext.Update(startSize, start, lastTextureClip);

                        if (_imageContext.StartRenderTransition(renderContext, (float)elapsed, _lastImageContext,
                                                                endSize, end, currentTextureClip, BorderColor.ToArgb(), lastFrameData, frameData))
                        {
                            _primitiveBuffer.Render(0);
                            _imageContext.EndRenderTransition();
                        }
                    }
                    return;
                }
            }

            if (IsAllocated)
            {
                SizeF sourceSize = StretchSource(_imageContext.RotatedFrameSize, currentRawSourceSize, stretchMode, stretchDirection);
                if (_imageContext.StartRender(renderContext, sourceSize, currentTexture, currentTextureClip, BorderColor.ToArgb(), frameData))
                {
                    _primitiveBuffer.Render(0);
                    _imageContext.EndRender();
                }
            }
        }
Example #13
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (firstpaint)
            {
                System.ComponentModel.IContainer ic = this.GetParentContainerComponents();

                ic?.CopyToolTips(this, new Control[] { this, _cbsystem });

                firstpaint = false;
            }

            base.OnPaint(e);

            if (this.FlatStyle != FlatStyle.System)
            {
                int extraborder     = 1;
                int texthorzspacing = 1;

                textBoxBackArea = new Rectangle(ClientRectangle.X + extraborder, ClientRectangle.Y + extraborder,
                                                ClientRectangle.Width - 2 * extraborder, ClientRectangle.Height - 2 * extraborder);

                topBoxTextArea = new Rectangle(ClientRectangle.X + extraborder + texthorzspacing, ClientRectangle.Y + extraborder,
                                               ClientRectangle.Width - 2 * extraborder - 2 * texthorzspacing - ScrollBarWidth, ClientRectangle.Height - 2 * extraborder);

                arrowRectangleArea = new Rectangle(ClientRectangle.Width - ScrollBarWidth - extraborder, ClientRectangle.Y + extraborder,
                                                   ScrollBarWidth, ClientRectangle.Height - 2 * extraborder);

                topBoxOutline = new Rectangle(ClientRectangle.X, ClientRectangle.Y,
                                              ClientRectangle.Width - 1, ClientRectangle.Height - 1);


                int hoffset = arrowRectangleArea.Width / 3;
                int voffset = arrowRectangleArea.Height / 3;
                arrowpt1 = new Point(arrowRectangleArea.X + hoffset, arrowRectangleArea.Y + voffset);
                arrowpt2 = new Point(arrowRectangleArea.X + arrowRectangleArea.Width / 2, arrowRectangleArea.Y + arrowRectangleArea.Height - voffset);
                arrowpt3 = new Point(arrowRectangleArea.X + arrowRectangleArea.Width - hoffset, arrowpt1.Y);

                arrowpt1c = new Point(arrowpt1.X, arrowpt2.Y);
                arrowpt2c = new Point(arrowpt2.X, arrowpt1.Y);
                arrowpt3c = new Point(arrowpt3.X, arrowpt2.Y);

                Brush textb;
                Pen   p, p2;

                bool todraw = Enabled && Items.Count > 0;

                if (todraw)
                {
                    textb    = new SolidBrush(this.ForeColor);
                    p        = new Pen(BorderColor);
                    p2       = new Pen(ForeColor);
                    p2.Width = ArrowWidth;
                }
                else
                {
                    textb = new SolidBrush(ForeColor.Multiply(0.5F));
                    p     = new Pen(BorderColor.Multiply(0.5F));
                    p2    = null;
                }

                e.Graphics.DrawRectangle(p, topBoxOutline);

                Color bck;

                if (todraw)
                {
                    bck = (mouseover) ? MouseOverBackgroundColor : BackColor;
                }
                else
                {
                    bck = DisableBackgroundDisabledShadingGradient ? BackColor : BackColor.Multiply(0.5F);
                }

                Brush bbck;

                if (FlatStyle == FlatStyle.Popup && !DisableBackgroundDisabledShadingGradient)
                {
                    bbck = new System.Drawing.Drawing2D.LinearGradientBrush(textBoxBackArea, bck, bck.Multiply(ButtonColorScaling), 90);
                }
                else
                {
                    bbck = new SolidBrush(bck);
                }

                e.Graphics.FillRectangle(bbck, textBoxBackArea);

                //using (Brush test = new SolidBrush(Color.Red)) e.Graphics.FillRectangle(test, topBoxTextArea); // used to check alignment

                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

                if (p2 != null)
                {
                    if (isActivated)
                    {
                        e.Graphics.DrawLine(p2, arrowpt1c, arrowpt2c);            // the arrow!
                        e.Graphics.DrawLine(p2, arrowpt2c, arrowpt3c);
                    }
                    else
                    {
                        e.Graphics.DrawLine(p2, arrowpt1, arrowpt2);            // the arrow!
                        e.Graphics.DrawLine(p2, arrowpt2, arrowpt3);
                    }
                }

                using (var fmt = ControlHelpersStaticFunc.StringFormatFromContentAlignment(RtlTranslateAlignment(TextAlign)))
                {
                    fmt.FormatFlags = StringFormatFlags.NoWrap;
                    e.Graphics.DrawString(this.Text, this.Font, textb, topBoxTextArea, fmt);
                }

                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;

                bbck.Dispose();

                textb.Dispose();
                p.Dispose();

                if (p2 != null)
                {
                    p2.Dispose();
                }
            }
        }
Example #14
0
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;

                if (Visible != null)
                {
                    hashCode = hashCode * 59 + Visible.GetHashCode();
                }

                if (Buttons != null)
                {
                    hashCode = hashCode * 59 + Buttons.GetHashCode();
                }

                if (X != null)
                {
                    hashCode = hashCode * 59 + X.GetHashCode();
                }

                if (XAnchor != null)
                {
                    hashCode = hashCode * 59 + XAnchor.GetHashCode();
                }

                if (Y != null)
                {
                    hashCode = hashCode * 59 + Y.GetHashCode();
                }

                if (YAnchor != null)
                {
                    hashCode = hashCode * 59 + YAnchor.GetHashCode();
                }

                if (Font != null)
                {
                    hashCode = hashCode * 59 + Font.GetHashCode();
                }

                if (BgColor != null)
                {
                    hashCode = hashCode * 59 + BgColor.GetHashCode();
                }

                if (ActiveColor != null)
                {
                    hashCode = hashCode * 59 + ActiveColor.GetHashCode();
                }

                if (BorderColor != null)
                {
                    hashCode = hashCode * 59 + BorderColor.GetHashCode();
                }

                if (BorderWidth != null)
                {
                    hashCode = hashCode * 59 + BorderWidth.GetHashCode();
                }

                return(hashCode);
            }
        }
Example #15
0
        public bool Equals([AllowNull] HoverLabel other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((BgColor == other.BgColor && BgColor != null && other.BgColor != null && BgColor.Equals(other.BgColor)) &&
                   (Equals(BgColorArray, other.BgColorArray) || BgColorArray != null && other.BgColorArray != null && BgColorArray.SequenceEqual(other.BgColorArray)) &&
                   (BorderColor == other.BorderColor && BorderColor != null && other.BorderColor != null && BorderColor.Equals(other.BorderColor)) &&
                   (Equals(BorderColorArray, other.BorderColorArray) || BorderColorArray != null && other.BorderColorArray != null && BorderColorArray.SequenceEqual(other.BorderColorArray)) &&
                   (Font == other.Font && Font != null && other.Font != null && Font.Equals(other.Font)) &&
                   (Align == other.Align && Align != null && other.Align != null && Align.Equals(other.Align)) &&
                   (Equals(AlignArray, other.AlignArray) || AlignArray != null && other.AlignArray != null && AlignArray.SequenceEqual(other.AlignArray)) &&
                   (NameLength == other.NameLength && NameLength != null && other.NameLength != null && NameLength.Equals(other.NameLength)) &&
                   (Equals(NameLengthArray, other.NameLengthArray) || NameLengthArray != null && other.NameLengthArray != null && NameLengthArray.SequenceEqual(other.NameLengthArray)) &&
                   (BgColorSrc == other.BgColorSrc && BgColorSrc != null && other.BgColorSrc != null && BgColorSrc.Equals(other.BgColorSrc)) &&
                   (BorderColorSrc == other.BorderColorSrc && BorderColorSrc != null && other.BorderColorSrc != null && BorderColorSrc.Equals(other.BorderColorSrc)) &&
                   (AlignSrc == other.AlignSrc && AlignSrc != null && other.AlignSrc != null && AlignSrc.Equals(other.AlignSrc)) &&
                   (NameLengthSrc == other.NameLengthSrc && NameLengthSrc != null && other.NameLengthSrc != null && NameLengthSrc.Equals(other.NameLengthSrc)));
        }
Example #16
0
        public override void DrawRect(CGRect dirtyRect)
        {
            if (Gradient != null)
            {
                Gradient.DrawInRect(dirtyRect, GradientAngle);
            }

            // -----------------------------------------
            nfloat textOffset   = 0f;
            nfloat imageXOffset = 0f;
            nfloat imageWidth   = 0f;

            if (Image != null)
            {
                if (Image.Size.Height > dirtyRect.Height)
                {
                    Image.Size = new CGSize(Image.Size.Height, dirtyRect.Height);
                }
                if (Image.Size.Width > dirtyRect.Width)
                {
                    Image.Size = new CGSize(dirtyRect.Width, Image.Size.Width);
                }

                imageWidth = Image.Size.Width;

                nfloat minXOffset = (dirtyRect.Height - Image.Size.Height) / 2f;

                imageXOffset = CornerRadius;
                if (imageXOffset < minXOffset)
                {
                    imageXOffset = minXOffset;
                }

                if (AttributedTitle == null)
                {
                    imageXOffset = dirtyRect.Width / 2f - Image.Size.Width / 2f;
                }
                else if (IconLocation == IconLocationEnum.Right_BeforeCenteredText)
                {
                    imageXOffset = dirtyRect.Width / 2f - AttributedTitle.Size.Width / 2f - Image.Size.Width - minXOffset / 2f;
                }
                else if (IconLocation == IconLocationEnum.Left_AfterCenteredText)
                {
                    imageXOffset = dirtyRect.Width / 2f + AttributedTitle.Size.Width / 2f + minXOffset / 2f;
                }
                else if (IconLocation == IconLocationEnum.Right_AfterCenteredText)
                {
                    imageXOffset = dirtyRect.Width - minXOffset / 2f - Image.Size.Width;
                }
                else if (IconLocation == IconLocationEnum.Right)
                {
                    nfloat space = (dirtyRect.Width - AttributedTitle.Size.Width - Image.Size.Width) / 3;
                    textOffset   = space;
                    imageXOffset = space + AttributedTitle.Size.Width + space;
                }
                else if (IconLocation == IconLocationEnum.Left)
                {
                    nfloat space = (dirtyRect.Width - AttributedTitle.Size.Width - Image.Size.Width) / 3;
                    imageXOffset = space;
                    textOffset   = space + Image.Size.Width + space;
                }

                CGRect imgRect = new CGRect(dirtyRect.X + imageXOffset,
                                            dirtyRect.Y + dirtyRect.Height / 2f - Image.Size.Height / 2f,
                                            Image.Size.Width,
                                            Image.Size.Height);
                Image.Draw(imgRect);
            }

            if (AttributedTitle != null)
            {
                if (IconLocation == IconLocationEnum.Right_BeforeCenteredText || IconLocation == IconLocationEnum.Left_BeforeCenteredText)
                {
                    if ((imageXOffset + imageWidth) > (dirtyRect.Width - AttributedTitle.Size.Width) / 2f)
                    {
                        textOffset = imageXOffset + imageWidth;
                    }
                }

                CGRect titleRect = new CGRect(dirtyRect.X + textOffset,
                                              dirtyRect.Y + dirtyRect.Height / 2f - AttributedTitle.Size.Height / 2f - 1f,
                                              dirtyRect.Width - textOffset,
                                              AttributedTitle.Size.Height);

                this.AttributedTitle.DrawInRect(titleRect);
            }

            if (Highlighted)
            {
                NSColor fillColor = HighlitedColorOverlay;
                if (fillColor == null)
                {
                    fillColor = NSColor.FromRgba(0, 0, 0, 0.1f);
                }
                fillColor.Set();

                NSBezierPath highlitedFill = new NSBezierPath();
                highlitedFill.AppendPathWithRoundedRect(dirtyRect, CornerRadius, CornerRadius);
                highlitedFill.Fill();
            }

            if (!this.Enabled && DoNotChangeColorWhenDisabled != true)
            {
                NSColor fillColor = HighlitedColorOverlay;
                if (fillColor == null)
                {
                    fillColor = NSColor.FromRgba(0, 0, 0, 0.1f);
                }
                fillColor.Set();

                NSBezierPath highlitedFill = new NSBezierPath();
                highlitedFill.AppendPathWithRoundedRect(dirtyRect, CornerRadius, CornerRadius);
                highlitedFill.Fill();
            }
            // -----------------------------------------
            //base.DrawRect (dirtyRect);

            if (!Highlighted && BorderShadow != null)
            {
                BorderShadow.Set();
            }


            NSBezierPath bounds = new NSBezierPath();

            bounds.AppendPathWithRoundedRect(dirtyRect, CornerRadius, CornerRadius);
            bounds.AddClip();

            bounds.LineWidth = BorderLineWidth;

            if (BorderColor != null)
            {
                BorderColor.SetStroke();
            }

            bounds.Stroke();
        }
Example #17
0
        public bool Equals([AllowNull] HoverLabel other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((BgColor == other.BgColor && BgColor != null && other.BgColor != null && BgColor.Equals(other.BgColor)) &&
                   (BorderColor == other.BorderColor && BorderColor != null && other.BorderColor != null && BorderColor.Equals(other.BorderColor)) &&
                   (Font == other.Font && Font != null && other.Font != null && Font.Equals(other.Font)));
        }
Example #18
0
        /// <inheritdoc />
        public bool Equals([AllowNull] ColorBar other)
        {
            if (other == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     ThicknessMode == other.ThicknessMode ||
                     ThicknessMode != null &&
                     ThicknessMode.Equals(other.ThicknessMode)
                     ) &&
                 (
                     Thickness == other.Thickness ||
                     Thickness != null &&
                     Thickness.Equals(other.Thickness)
                 ) &&
                 (
                     LenMode == other.LenMode ||
                     LenMode != null &&
                     LenMode.Equals(other.LenMode)
                 ) &&
                 (
                     Len == other.Len ||
                     Len != null &&
                     Len.Equals(other.Len)
                 ) &&
                 (
                     X == other.X ||
                     X != null &&
                     X.Equals(other.X)
                 ) &&
                 (
                     XAnchor == other.XAnchor ||
                     XAnchor != null &&
                     XAnchor.Equals(other.XAnchor)
                 ) &&
                 (
                     XPad == other.XPad ||
                     XPad != null &&
                     XPad.Equals(other.XPad)
                 ) &&
                 (
                     Y == other.Y ||
                     Y != null &&
                     Y.Equals(other.Y)
                 ) &&
                 (
                     YAnchor == other.YAnchor ||
                     YAnchor != null &&
                     YAnchor.Equals(other.YAnchor)
                 ) &&
                 (
                     YPad == other.YPad ||
                     YPad != null &&
                     YPad.Equals(other.YPad)
                 ) &&
                 (
                     OutlineColor == other.OutlineColor ||
                     OutlineColor != null &&
                     OutlineColor.Equals(other.OutlineColor)
                 ) &&
                 (
                     OutlineWidth == other.OutlineWidth ||
                     OutlineWidth != null &&
                     OutlineWidth.Equals(other.OutlineWidth)
                 ) &&
                 (
                     BorderColor == other.BorderColor ||
                     BorderColor != null &&
                     BorderColor.Equals(other.BorderColor)
                 ) &&
                 (
                     BorderWidth == other.BorderWidth ||
                     BorderWidth != null &&
                     BorderWidth.Equals(other.BorderWidth)
                 ) &&
                 (
                     BgColor == other.BgColor ||
                     BgColor != null &&
                     BgColor.Equals(other.BgColor)
                 ) &&
                 (
                     TickMode == other.TickMode ||
                     TickMode != null &&
                     TickMode.Equals(other.TickMode)
                 ) &&
                 (
                     NTicks == other.NTicks ||
                     NTicks != null &&
                     NTicks.Equals(other.NTicks)
                 ) &&
                 (
                     Tick0 == other.Tick0 ||
                     Tick0 != null &&
                     Tick0.Equals(other.Tick0)
                 ) &&
                 (
                     DTick == other.DTick ||
                     DTick != null &&
                     DTick.Equals(other.DTick)
                 ) &&
                 (
                     Equals(TickVals, other.TickVals) ||
                     TickVals != null && other.TickVals != null &&
                     TickVals.SequenceEqual(other.TickVals)
                 ) &&
                 (
                     Equals(TickText, other.TickText) ||
                     TickText != null && other.TickText != null &&
                     TickText.SequenceEqual(other.TickText)
                 ) &&
                 (
                     Ticks == other.Ticks ||
                     Ticks != null &&
                     Ticks.Equals(other.Ticks)
                 ) &&
                 (
                     TickLen == other.TickLen ||
                     TickLen != null &&
                     TickLen.Equals(other.TickLen)
                 ) &&
                 (
                     TickWidth == other.TickWidth ||
                     TickWidth != null &&
                     TickWidth.Equals(other.TickWidth)
                 ) &&
                 (
                     TickColor == other.TickColor ||
                     TickColor != null &&
                     TickColor.Equals(other.TickColor)
                 ) &&
                 (
                     ShowTickLabels == other.ShowTickLabels ||
                     ShowTickLabels != null &&
                     ShowTickLabels.Equals(other.ShowTickLabels)
                 ) &&
                 (
                     TickFont == other.TickFont ||
                     TickFont != null &&
                     TickFont.Equals(other.TickFont)
                 ) &&
                 (
                     TickAngle == other.TickAngle ||
                     TickAngle != null &&
                     TickAngle.Equals(other.TickAngle)
                 ) &&
                 (
                     TickFormat == other.TickFormat ||
                     TickFormat != null &&
                     TickFormat.Equals(other.TickFormat)
                 ) &&
                 (
                     Equals(TickFormatStops, other.TickFormatStops) ||
                     TickFormatStops != null && other.TickFormatStops != null &&
                     TickFormatStops.SequenceEqual(other.TickFormatStops)
                 ) &&
                 (
                     TickPrefix == other.TickPrefix ||
                     TickPrefix != null &&
                     TickPrefix.Equals(other.TickPrefix)
                 ) &&
                 (
                     ShowTickPrefix == other.ShowTickPrefix ||
                     ShowTickPrefix != null &&
                     ShowTickPrefix.Equals(other.ShowTickPrefix)
                 ) &&
                 (
                     TickSuffix == other.TickSuffix ||
                     TickSuffix != null &&
                     TickSuffix.Equals(other.TickSuffix)
                 ) &&
                 (
                     ShowTickSuffix == other.ShowTickSuffix ||
                     ShowTickSuffix != null &&
                     ShowTickSuffix.Equals(other.ShowTickSuffix)
                 ) &&
                 (
                     SeparateThousands == other.SeparateThousands ||
                     SeparateThousands != null &&
                     SeparateThousands.Equals(other.SeparateThousands)
                 ) &&
                 (
                     ExponentFormat == other.ExponentFormat ||
                     ExponentFormat != null &&
                     ExponentFormat.Equals(other.ExponentFormat)
                 ) &&
                 (
                     MinExponent == other.MinExponent ||
                     MinExponent != null &&
                     MinExponent.Equals(other.MinExponent)
                 ) &&
                 (
                     ShowExponent == other.ShowExponent ||
                     ShowExponent != null &&
                     ShowExponent.Equals(other.ShowExponent)
                 ) &&
                 (
                     Title == other.Title ||
                     Title != null &&
                     Title.Equals(other.Title)
                 ) &&
                 (
                     TickValsSrc == other.TickValsSrc ||
                     TickValsSrc != null &&
                     TickValsSrc.Equals(other.TickValsSrc)
                 ) &&
                 (
                     TickTextSrc == other.TickTextSrc ||
                     TickTextSrc != null &&
                     TickTextSrc.Equals(other.TickTextSrc)
                 ));
        }
 public void SetBorderColor(BorderColor color)
 {
     this.BorderColor = color;
 }
 public override string ToString()
 {
     return(ForeColor.ToString() + ", " + BackColor.ToString() + ", " + BorderColor.ToString());
 }
Example #21
0
 public bool ShouldSerializeBorderColor() =>
 SerializeDefaults ||
 !BorderColor.Equals(ZPLForgeDefaults.Elements.Rectangle.BorderColor);
Example #22
0
 public Style()
 {
     this.BorderStyle = new BorderStyle();
     this.BorderColor = new BorderColor();
     this.BorderWidth = new BorderWidth();
 }
Example #23
0
        /// <inheritdoc />
        public bool Equals([AllowNull] Annotation other)
        {
            if (other == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Visible == other.Visible ||
                     Visible != null &&
                     Visible.Equals(other.Visible)
                     ) &&
                 (
                     X == other.X ||
                     X != null &&
                     X.Equals(other.X)
                 ) &&
                 (
                     Y == other.Y ||
                     Y != null &&
                     Y.Equals(other.Y)
                 ) &&
                 (
                     Z == other.Z ||
                     Z != null &&
                     Z.Equals(other.Z)
                 ) &&
                 (
                     Ax == other.Ax ||
                     Ax != null &&
                     Ax.Equals(other.Ax)
                 ) &&
                 (
                     Ay == other.Ay ||
                     Ay != null &&
                     Ay.Equals(other.Ay)
                 ) &&
                 (
                     XAnchor == other.XAnchor ||
                     XAnchor != null &&
                     XAnchor.Equals(other.XAnchor)
                 ) &&
                 (
                     XShift == other.XShift ||
                     XShift != null &&
                     XShift.Equals(other.XShift)
                 ) &&
                 (
                     YAnchor == other.YAnchor ||
                     YAnchor != null &&
                     YAnchor.Equals(other.YAnchor)
                 ) &&
                 (
                     YShift == other.YShift ||
                     YShift != null &&
                     YShift.Equals(other.YShift)
                 ) &&
                 (
                     Text == other.Text ||
                     Text != null &&
                     Text.Equals(other.Text)
                 ) &&
                 (
                     TextAngle == other.TextAngle ||
                     TextAngle != null &&
                     TextAngle.Equals(other.TextAngle)
                 ) &&
                 (
                     Font == other.Font ||
                     Font != null &&
                     Font.Equals(other.Font)
                 ) &&
                 (
                     Width == other.Width ||
                     Width != null &&
                     Width.Equals(other.Width)
                 ) &&
                 (
                     Height == other.Height ||
                     Height != null &&
                     Height.Equals(other.Height)
                 ) &&
                 (
                     Opacity == other.Opacity ||
                     Opacity != null &&
                     Opacity.Equals(other.Opacity)
                 ) &&
                 (
                     Align == other.Align ||
                     Align != null &&
                     Align.Equals(other.Align)
                 ) &&
                 (
                     VAlign == other.VAlign ||
                     VAlign != null &&
                     VAlign.Equals(other.VAlign)
                 ) &&
                 (
                     BgColor == other.BgColor ||
                     BgColor != null &&
                     BgColor.Equals(other.BgColor)
                 ) &&
                 (
                     BorderColor == other.BorderColor ||
                     BorderColor != null &&
                     BorderColor.Equals(other.BorderColor)
                 ) &&
                 (
                     BorderPad == other.BorderPad ||
                     BorderPad != null &&
                     BorderPad.Equals(other.BorderPad)
                 ) &&
                 (
                     BorderWidth == other.BorderWidth ||
                     BorderWidth != null &&
                     BorderWidth.Equals(other.BorderWidth)
                 ) &&
                 (
                     ShowArrow == other.ShowArrow ||
                     ShowArrow != null &&
                     ShowArrow.Equals(other.ShowArrow)
                 ) &&
                 (
                     ArrowColor == other.ArrowColor ||
                     ArrowColor != null &&
                     ArrowColor.Equals(other.ArrowColor)
                 ) &&
                 (
                     Arrowhead == other.Arrowhead ||
                     Arrowhead != null &&
                     Arrowhead.Equals(other.Arrowhead)
                 ) &&
                 (
                     StartArrowhead == other.StartArrowhead ||
                     StartArrowhead != null &&
                     StartArrowhead.Equals(other.StartArrowhead)
                 ) &&
                 (
                     ArrowSide == other.ArrowSide ||
                     ArrowSide != null &&
                     ArrowSide.Equals(other.ArrowSide)
                 ) &&
                 (
                     ArrowSize == other.ArrowSize ||
                     ArrowSize != null &&
                     ArrowSize.Equals(other.ArrowSize)
                 ) &&
                 (
                     StartArrowSize == other.StartArrowSize ||
                     StartArrowSize != null &&
                     StartArrowSize.Equals(other.StartArrowSize)
                 ) &&
                 (
                     ArrowWidth == other.ArrowWidth ||
                     ArrowWidth != null &&
                     ArrowWidth.Equals(other.ArrowWidth)
                 ) &&
                 (
                     Standoff == other.Standoff ||
                     Standoff != null &&
                     Standoff.Equals(other.Standoff)
                 ) &&
                 (
                     StartStandoff == other.StartStandoff ||
                     StartStandoff != null &&
                     StartStandoff.Equals(other.StartStandoff)
                 ) &&
                 (
                     HoverText == other.HoverText ||
                     HoverText != null &&
                     HoverText.Equals(other.HoverText)
                 ) &&
                 (
                     HoverLabel == other.HoverLabel ||
                     HoverLabel != null &&
                     HoverLabel.Equals(other.HoverLabel)
                 ) &&
                 (
                     CaptureEvents == other.CaptureEvents ||
                     CaptureEvents != null &&
                     CaptureEvents.Equals(other.CaptureEvents)
                 ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     TemplateItemName == other.TemplateItemName ||
                     TemplateItemName != null &&
                     TemplateItemName.Equals(other.TemplateItemName)
                 ));
        }
Example #24
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (FlatStyle == FlatStyle.System || FlatStyle == FlatStyle.Standard)
            {
                base.OnPaint(e);
            }
            else if (DisplayRectangle.Width > 0 && DisplayRectangle.Height > 0)   // Popup and Flat are ours, as long as its got size
            {
                int topline = DisplayRectangle.Y / 2;

                Color colorback = BackColor;

                if (!colorback.IsFullyTransparent())
                {
                    Color color2 = (FlatStyle == FlatStyle.Popup) ? colorback.Multiply(BackColorScaling) : BackColor;

                    Rectangle borderrect = ClientRectangle;

                    using (Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(borderrect, colorback, color2, 90))
                        e.Graphics.FillRectangle(b, borderrect);
                }

                if (!BorderColor.IsFullyTransparent())
                {
                    Color color1 = BorderColor;
                    Color color2 = BorderColor.Multiply(BorderColorScaling);

                    int textlength = 0;
                    if (this.Text != "")
                    {           // +1 for rounding down..
                        textlength = (int)e.Graphics.MeasureString(this.Text, this.Font).Width + TextPadding * 2 + 1;
                    }

                    int textstart = TextStartPosition;
                    if (textstart == 0)                                          // auto centre
                    {
                        textstart = ClientRectangle.Width / 2 - textlength / 2;  // centre
                    }
                    else if (textstart == -1)                                    // left
                    {
                        textstart = 15;
                    }
                    else if (textstart == 1)                                          // right
                    {
                        textstart = ClientRectangle.Width - 15 - textlength;
                    }

                    if (textstart < 4)                                          // need 4 pixels
                    {
                        textstart = 4;
                    }

                    e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;

                    using (GraphicsPath g1 = ControlHelpersStaticFunc.RectCutCorners(1, topline + 1, ClientRectangle.Width - 2, ClientRectangle.Height - topline - 1, 1, 1, textstart - 1, textlength))
                        using (Pen pc1 = new Pen(color1, 1.0F))
                            e.Graphics.DrawPath(pc1, g1);

                    using (GraphicsPath g2 = ControlHelpersStaticFunc.RectCutCorners(0, topline, ClientRectangle.Width, ClientRectangle.Height - topline - 1, 2, 2, textstart, textlength))
                        using (Pen pc2 = new Pen(color2, 1.0F))
                            e.Graphics.DrawPath(pc2, g2);

                    if (textlength > 0)
                    {
                        e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

                        int twidth = ClientRectangle.Width - textstart - 4;            // What size have we left..
                        twidth = (textlength < twidth) ? textlength: twidth;           // clip
                        Rectangle textarea = new Rectangle(textstart, 0, twidth, DisplayRectangle.Y);

                        using (Brush textb = new SolidBrush(this.ForeColor))
                            using (StringFormat fmt = new StringFormat()
                            {
                                Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                            })
                            {
                                e.Graphics.DrawString(this.Text, this.Font, textb, textarea, fmt);
                            }

                        e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
                    }
                }
            }
        }
Example #25
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         if (Visible != null)
         {
             hashCode = hashCode * 59 + Visible.GetHashCode();
         }
         if (X != null)
         {
             hashCode = hashCode * 59 + X.GetHashCode();
         }
         if (Y != null)
         {
             hashCode = hashCode * 59 + Y.GetHashCode();
         }
         if (Z != null)
         {
             hashCode = hashCode * 59 + Z.GetHashCode();
         }
         if (Ax != null)
         {
             hashCode = hashCode * 59 + Ax.GetHashCode();
         }
         if (Ay != null)
         {
             hashCode = hashCode * 59 + Ay.GetHashCode();
         }
         if (XAnchor != null)
         {
             hashCode = hashCode * 59 + XAnchor.GetHashCode();
         }
         if (XShift != null)
         {
             hashCode = hashCode * 59 + XShift.GetHashCode();
         }
         if (YAnchor != null)
         {
             hashCode = hashCode * 59 + YAnchor.GetHashCode();
         }
         if (YShift != null)
         {
             hashCode = hashCode * 59 + YShift.GetHashCode();
         }
         if (Text != null)
         {
             hashCode = hashCode * 59 + Text.GetHashCode();
         }
         if (TextAngle != null)
         {
             hashCode = hashCode * 59 + TextAngle.GetHashCode();
         }
         if (Font != null)
         {
             hashCode = hashCode * 59 + Font.GetHashCode();
         }
         if (Width != null)
         {
             hashCode = hashCode * 59 + Width.GetHashCode();
         }
         if (Height != null)
         {
             hashCode = hashCode * 59 + Height.GetHashCode();
         }
         if (Opacity != null)
         {
             hashCode = hashCode * 59 + Opacity.GetHashCode();
         }
         if (Align != null)
         {
             hashCode = hashCode * 59 + Align.GetHashCode();
         }
         if (VAlign != null)
         {
             hashCode = hashCode * 59 + VAlign.GetHashCode();
         }
         if (BgColor != null)
         {
             hashCode = hashCode * 59 + BgColor.GetHashCode();
         }
         if (BorderColor != null)
         {
             hashCode = hashCode * 59 + BorderColor.GetHashCode();
         }
         if (BorderPad != null)
         {
             hashCode = hashCode * 59 + BorderPad.GetHashCode();
         }
         if (BorderWidth != null)
         {
             hashCode = hashCode * 59 + BorderWidth.GetHashCode();
         }
         if (ShowArrow != null)
         {
             hashCode = hashCode * 59 + ShowArrow.GetHashCode();
         }
         if (ArrowColor != null)
         {
             hashCode = hashCode * 59 + ArrowColor.GetHashCode();
         }
         if (Arrowhead != null)
         {
             hashCode = hashCode * 59 + Arrowhead.GetHashCode();
         }
         if (StartArrowhead != null)
         {
             hashCode = hashCode * 59 + StartArrowhead.GetHashCode();
         }
         if (ArrowSide != null)
         {
             hashCode = hashCode * 59 + ArrowSide.GetHashCode();
         }
         if (ArrowSize != null)
         {
             hashCode = hashCode * 59 + ArrowSize.GetHashCode();
         }
         if (StartArrowSize != null)
         {
             hashCode = hashCode * 59 + StartArrowSize.GetHashCode();
         }
         if (ArrowWidth != null)
         {
             hashCode = hashCode * 59 + ArrowWidth.GetHashCode();
         }
         if (Standoff != null)
         {
             hashCode = hashCode * 59 + Standoff.GetHashCode();
         }
         if (StartStandoff != null)
         {
             hashCode = hashCode * 59 + StartStandoff.GetHashCode();
         }
         if (HoverText != null)
         {
             hashCode = hashCode * 59 + HoverText.GetHashCode();
         }
         if (HoverLabel != null)
         {
             hashCode = hashCode * 59 + HoverLabel.GetHashCode();
         }
         if (CaptureEvents != null)
         {
             hashCode = hashCode * 59 + CaptureEvents.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (TemplateItemName != null)
         {
             hashCode = hashCode * 59 + TemplateItemName.GetHashCode();
         }
         return(hashCode);
     }
 }
Example #26
0
        public override void RenderBorder(Graphics g, Rectangle borderRectangle)
        {
            Color borderColor = !ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled ? BorderColor.ToGrayScale() : BorderColor;

            g.SetClip(borderRectangle);

            using (Pen borderPen = new Pen(borderColor))
            {
                g.DrawRectangle(borderPen, borderRectangle.X, borderRectangle.Y, borderRectangle.Width - 1, borderRectangle.Height - 1);
            }

            g.ResetClip();
        }
Example #27
0
        public bool Equals([AllowNull] RangeSelector other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((Visible == other.Visible && Visible != null && other.Visible != null && Visible.Equals(other.Visible)) &&
                   (Equals(Buttons, other.Buttons) || Buttons != null && other.Buttons != null && Buttons.SequenceEqual(other.Buttons)) &&
                   (X == other.X && X != null && other.X != null && X.Equals(other.X)) &&
                   (XAnchor == other.XAnchor && XAnchor != null && other.XAnchor != null && XAnchor.Equals(other.XAnchor)) &&
                   (Y == other.Y && Y != null && other.Y != null && Y.Equals(other.Y)) &&
                   (YAnchor == other.YAnchor && YAnchor != null && other.YAnchor != null && YAnchor.Equals(other.YAnchor)) &&
                   (Font == other.Font && Font != null && other.Font != null && Font.Equals(other.Font)) &&
                   (BgColor == other.BgColor && BgColor != null && other.BgColor != null && BgColor.Equals(other.BgColor)) &&
                   (ActiveColor == other.ActiveColor && ActiveColor != null && other.ActiveColor != null && ActiveColor.Equals(other.ActiveColor)) &&
                   (BorderColor == other.BorderColor && BorderColor != null && other.BorderColor != null && BorderColor.Equals(other.BorderColor)) &&
                   (BorderWidth == other.BorderWidth && BorderWidth != null && other.BorderWidth != null && BorderWidth.Equals(other.BorderWidth)));
        }
Example #28
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         if (ThicknessMode != null)
         {
             hashCode = hashCode * 59 + ThicknessMode.GetHashCode();
         }
         if (Thickness != null)
         {
             hashCode = hashCode * 59 + Thickness.GetHashCode();
         }
         if (LenMode != null)
         {
             hashCode = hashCode * 59 + LenMode.GetHashCode();
         }
         if (Len != null)
         {
             hashCode = hashCode * 59 + Len.GetHashCode();
         }
         if (X != null)
         {
             hashCode = hashCode * 59 + X.GetHashCode();
         }
         if (XAnchor != null)
         {
             hashCode = hashCode * 59 + XAnchor.GetHashCode();
         }
         if (XPad != null)
         {
             hashCode = hashCode * 59 + XPad.GetHashCode();
         }
         if (Y != null)
         {
             hashCode = hashCode * 59 + Y.GetHashCode();
         }
         if (YAnchor != null)
         {
             hashCode = hashCode * 59 + YAnchor.GetHashCode();
         }
         if (YPad != null)
         {
             hashCode = hashCode * 59 + YPad.GetHashCode();
         }
         if (OutlineColor != null)
         {
             hashCode = hashCode * 59 + OutlineColor.GetHashCode();
         }
         if (OutlineWidth != null)
         {
             hashCode = hashCode * 59 + OutlineWidth.GetHashCode();
         }
         if (BorderColor != null)
         {
             hashCode = hashCode * 59 + BorderColor.GetHashCode();
         }
         if (BorderWidth != null)
         {
             hashCode = hashCode * 59 + BorderWidth.GetHashCode();
         }
         if (BgColor != null)
         {
             hashCode = hashCode * 59 + BgColor.GetHashCode();
         }
         if (TickMode != null)
         {
             hashCode = hashCode * 59 + TickMode.GetHashCode();
         }
         if (NTicks != null)
         {
             hashCode = hashCode * 59 + NTicks.GetHashCode();
         }
         if (Tick0 != null)
         {
             hashCode = hashCode * 59 + Tick0.GetHashCode();
         }
         if (DTick != null)
         {
             hashCode = hashCode * 59 + DTick.GetHashCode();
         }
         if (TickVals != null)
         {
             hashCode = hashCode * 59 + TickVals.GetHashCode();
         }
         if (TickText != null)
         {
             hashCode = hashCode * 59 + TickText.GetHashCode();
         }
         if (Ticks != null)
         {
             hashCode = hashCode * 59 + Ticks.GetHashCode();
         }
         if (TickLen != null)
         {
             hashCode = hashCode * 59 + TickLen.GetHashCode();
         }
         if (TickWidth != null)
         {
             hashCode = hashCode * 59 + TickWidth.GetHashCode();
         }
         if (TickColor != null)
         {
             hashCode = hashCode * 59 + TickColor.GetHashCode();
         }
         if (ShowTickLabels != null)
         {
             hashCode = hashCode * 59 + ShowTickLabels.GetHashCode();
         }
         if (TickFont != null)
         {
             hashCode = hashCode * 59 + TickFont.GetHashCode();
         }
         if (TickAngle != null)
         {
             hashCode = hashCode * 59 + TickAngle.GetHashCode();
         }
         if (TickFormat != null)
         {
             hashCode = hashCode * 59 + TickFormat.GetHashCode();
         }
         if (TickFormatStops != null)
         {
             hashCode = hashCode * 59 + TickFormatStops.GetHashCode();
         }
         if (TickPrefix != null)
         {
             hashCode = hashCode * 59 + TickPrefix.GetHashCode();
         }
         if (ShowTickPrefix != null)
         {
             hashCode = hashCode * 59 + ShowTickPrefix.GetHashCode();
         }
         if (TickSuffix != null)
         {
             hashCode = hashCode * 59 + TickSuffix.GetHashCode();
         }
         if (ShowTickSuffix != null)
         {
             hashCode = hashCode * 59 + ShowTickSuffix.GetHashCode();
         }
         if (SeparateThousands != null)
         {
             hashCode = hashCode * 59 + SeparateThousands.GetHashCode();
         }
         if (ExponentFormat != null)
         {
             hashCode = hashCode * 59 + ExponentFormat.GetHashCode();
         }
         if (MinExponent != null)
         {
             hashCode = hashCode * 59 + MinExponent.GetHashCode();
         }
         if (ShowExponent != null)
         {
             hashCode = hashCode * 59 + ShowExponent.GetHashCode();
         }
         if (Title != null)
         {
             hashCode = hashCode * 59 + Title.GetHashCode();
         }
         if (TickValsSrc != null)
         {
             hashCode = hashCode * 59 + TickValsSrc.GetHashCode();
         }
         if (TickTextSrc != null)
         {
             hashCode = hashCode * 59 + TickTextSrc.GetHashCode();
         }
         return(hashCode);
     }
 }
        public override void RenderButton(Graphics g, Rectangle buttonRectangle)
        {
            if (ToggleSwitch.IsButtonOnLeftSide)
            {
                buttonRectangle.X += 1;
            }
            else if (ToggleSwitch.IsButtonOnRightSide)
            {
                buttonRectangle.X -= 1;
            }

            g.SmoothingMode   = SmoothingMode.HighQuality;
            g.PixelOffsetMode = PixelOffsetMode.HighQuality;

            //Draw button shadow
            buttonRectangle.Inflate(1, 1);

            Rectangle shadowClipRectangle = new Rectangle(buttonRectangle.Location, buttonRectangle.Size);

            shadowClipRectangle.Inflate(0, -1);

            if (ToggleSwitch.IsButtonOnLeftSide)
            {
                shadowClipRectangle.X    += shadowClipRectangle.Width / 2;
                shadowClipRectangle.Width = shadowClipRectangle.Width / 2;
            }
            else if (ToggleSwitch.IsButtonOnRightSide)
            {
                shadowClipRectangle.Width = shadowClipRectangle.Width / 2;
            }

            g.SetClip(shadowClipRectangle);

            Color buttonShadowColor = (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled) ? ButtonShadowColor.ToGrayScale() : ButtonShadowColor;

            using (Pen buttonShadowPen = new Pen(buttonShadowColor))
            {
                g.DrawEllipse(buttonShadowPen, buttonRectangle);
            }

            g.ResetClip();

            buttonRectangle.Inflate(-1, -1);

            //Draw outer button border
            Color buttonOuterBorderColor = ButtonNormalOuterBorderColor;

            if (ToggleSwitch.IsButtonPressed)
            {
                buttonOuterBorderColor = ButtonPressedOuterBorderColor;
            }
            else if (ToggleSwitch.IsButtonHovered)
            {
                buttonOuterBorderColor = ButtonHoverOuterBorderColor;
            }

            if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
            {
                buttonOuterBorderColor = buttonOuterBorderColor.ToGrayScale();
            }

            using (Brush outerBorderBrush = new SolidBrush(buttonOuterBorderColor))
            {
                g.FillEllipse(outerBorderBrush, buttonRectangle);
            }

            //Draw inner button border
            buttonRectangle.Inflate(-1, -1);

            Color buttonInnerBorderColor = ButtonNormalInnerBorderColor;

            if (ToggleSwitch.IsButtonPressed)
            {
                buttonInnerBorderColor = ButtonPressedInnerBorderColor;
            }
            else if (ToggleSwitch.IsButtonHovered)
            {
                buttonInnerBorderColor = ButtonHoverInnerBorderColor;
            }

            if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
            {
                buttonInnerBorderColor = buttonInnerBorderColor.ToGrayScale();
            }

            using (Brush innerBorderBrush = new SolidBrush(buttonInnerBorderColor))
            {
                g.FillEllipse(innerBorderBrush, buttonRectangle);
            }

            //Draw button surface
            buttonRectangle.Inflate(-1, -1);

            Color buttonUpperSurfaceColor = ButtonNormalSurfaceColor1;

            if (ToggleSwitch.IsButtonPressed)
            {
                buttonUpperSurfaceColor = ButtonPressedSurfaceColor1;
            }
            else if (ToggleSwitch.IsButtonHovered)
            {
                buttonUpperSurfaceColor = ButtonHoverSurfaceColor1;
            }

            if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
            {
                buttonUpperSurfaceColor = buttonUpperSurfaceColor.ToGrayScale();
            }

            Color buttonLowerSurfaceColor = ButtonNormalSurfaceColor2;

            if (ToggleSwitch.IsButtonPressed)
            {
                buttonLowerSurfaceColor = ButtonPressedSurfaceColor2;
            }
            else if (ToggleSwitch.IsButtonHovered)
            {
                buttonLowerSurfaceColor = ButtonHoverSurfaceColor2;
            }

            if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
            {
                buttonLowerSurfaceColor = buttonLowerSurfaceColor.ToGrayScale();
            }

            using (Brush buttonSurfaceBrush = new LinearGradientBrush(buttonRectangle, buttonUpperSurfaceColor, buttonLowerSurfaceColor, LinearGradientMode.Vertical))
            {
                g.FillEllipse(buttonSurfaceBrush, buttonRectangle);
            }

            g.CompositingMode    = CompositingMode.SourceOver;
            g.CompositingQuality = CompositingQuality.HighQuality;

            //Draw outer control border
            Rectangle controlRectangle = new Rectangle(0, 0, ToggleSwitch.Width, ToggleSwitch.Height);

            using (GraphicsPath borderPath = GetControlClipPath(controlRectangle))
            {
                Color controlBorderColor = (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled) ? BorderColor.ToGrayScale() : BorderColor;

                using (Pen borderPen = new Pen(controlBorderColor))
                {
                    g.DrawPath(borderPen, borderPath);
                }
            }

            g.ResetClip();

            //Draw button image
            Image buttonImage = ToggleSwitch.ButtonImage ?? (ToggleSwitch.Checked ? ToggleSwitch.OnButtonImage : ToggleSwitch.OffButtonImage);

            if (buttonImage != null)
            {
                g.SetClip(GetButtonClipPath());

                ToggleSwitch.ToggleSwitchButtonAlignment alignment = ToggleSwitch.ButtonImage != null ? ToggleSwitch.ButtonAlignment : (ToggleSwitch.Checked ? ToggleSwitch.OnButtonAlignment : ToggleSwitch.OffButtonAlignment);

                Size imageSize = buttonImage.Size;

                Rectangle imageRectangle;

                int imageXPos = buttonRectangle.X;

                bool scaleImage = ToggleSwitch.ButtonImage != null ? ToggleSwitch.ButtonScaleImageToFit : (ToggleSwitch.Checked ? ToggleSwitch.OnButtonScaleImageToFit : ToggleSwitch.OffButtonScaleImageToFit);

                if (scaleImage)
                {
                    Size canvasSize       = buttonRectangle.Size;
                    Size resizedImageSize = ImageHelper.RescaleImageToFit(imageSize, canvasSize);

                    if (alignment == ToggleSwitch.ToggleSwitchButtonAlignment.Center)
                    {
                        imageXPos = (int)((float)buttonRectangle.X + (((float)buttonRectangle.Width - (float)resizedImageSize.Width) / 2));
                    }
                    else if (alignment == ToggleSwitch.ToggleSwitchButtonAlignment.Right)
                    {
                        imageXPos = (int)((float)buttonRectangle.X + (float)buttonRectangle.Width - (float)resizedImageSize.Width);
                    }

                    imageRectangle = new Rectangle(imageXPos, (int)((float)buttonRectangle.Y + (((float)buttonRectangle.Height - (float)resizedImageSize.Height) / 2)), resizedImageSize.Width, resizedImageSize.Height);

                    if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
                    {
                        g.DrawImage(buttonImage, imageRectangle, 0, 0, buttonImage.Width, buttonImage.Height, GraphicsUnit.Pixel, ImageHelper.GetGrayscaleAttributes());
                    }
                    else
                    {
                        g.DrawImage(buttonImage, imageRectangle);
                    }
                }
                else
                {
                    if (alignment == ToggleSwitch.ToggleSwitchButtonAlignment.Center)
                    {
                        imageXPos = (int)((float)buttonRectangle.X + (((float)buttonRectangle.Width - (float)imageSize.Width) / 2));
                    }
                    else if (alignment == ToggleSwitch.ToggleSwitchButtonAlignment.Right)
                    {
                        imageXPos = (int)((float)buttonRectangle.X + (float)buttonRectangle.Width - (float)imageSize.Width);
                    }

                    imageRectangle = new Rectangle(imageXPos, (int)((float)buttonRectangle.Y + (((float)buttonRectangle.Height - (float)imageSize.Height) / 2)), imageSize.Width, imageSize.Height);

                    if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
                    {
                        g.DrawImage(buttonImage, imageRectangle, 0, 0, buttonImage.Width, buttonImage.Height, GraphicsUnit.Pixel, ImageHelper.GetGrayscaleAttributes());
                    }
                    else
                    {
                        g.DrawImageUnscaled(buttonImage, imageRectangle);
                    }
                }

                g.ResetClip();
            }
        }
Example #30
0
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;

                if (BgColor != null)
                {
                    hashCode = hashCode * 59 + BgColor.GetHashCode();
                }

                if (BgColorArray != null)
                {
                    hashCode = hashCode * 59 + BgColorArray.GetHashCode();
                }

                if (BorderColor != null)
                {
                    hashCode = hashCode * 59 + BorderColor.GetHashCode();
                }

                if (BorderColorArray != null)
                {
                    hashCode = hashCode * 59 + BorderColorArray.GetHashCode();
                }

                if (Font != null)
                {
                    hashCode = hashCode * 59 + Font.GetHashCode();
                }

                if (Align != null)
                {
                    hashCode = hashCode * 59 + Align.GetHashCode();
                }

                if (AlignArray != null)
                {
                    hashCode = hashCode * 59 + AlignArray.GetHashCode();
                }

                if (NameLength != null)
                {
                    hashCode = hashCode * 59 + NameLength.GetHashCode();
                }

                if (NameLengthArray != null)
                {
                    hashCode = hashCode * 59 + NameLengthArray.GetHashCode();
                }

                if (BgColorSrc != null)
                {
                    hashCode = hashCode * 59 + BgColorSrc.GetHashCode();
                }

                if (BorderColorSrc != null)
                {
                    hashCode = hashCode * 59 + BorderColorSrc.GetHashCode();
                }

                if (AlignSrc != null)
                {
                    hashCode = hashCode * 59 + AlignSrc.GetHashCode();
                }

                if (NameLengthSrc != null)
                {
                    hashCode = hashCode * 59 + NameLengthSrc.GetHashCode();
                }

                return(hashCode);
            }
        }
Example #31
0
        public bool Equals([AllowNull] Gauge other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((Shape == other.Shape && Shape != null && other.Shape != null && Shape.Equals(other.Shape)) &&
                   (Bar == other.Bar && Bar != null && other.Bar != null && Bar.Equals(other.Bar)) &&
                   (BgColor == other.BgColor && BgColor != null && other.BgColor != null && BgColor.Equals(other.BgColor)) &&
                   (BorderColor == other.BorderColor && BorderColor != null && other.BorderColor != null && BorderColor.Equals(other.BorderColor)) &&
                   (BorderWidth == other.BorderWidth && BorderWidth != null && other.BorderWidth != null && BorderWidth.Equals(other.BorderWidth)) &&
                   (Axis == other.Axis && Axis != null && other.Axis != null && Axis.Equals(other.Axis)) &&
                   (Equals(Steps, other.Steps) || Steps != null && other.Steps != null && Steps.SequenceEqual(other.Steps)) &&
                   (Threshold == other.Threshold && Threshold != null && other.Threshold != null && Threshold.Equals(other.Threshold)));
        }