⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qbutton.cs

📁 基于C/S的医疗卫生管理系统
💻 CS
📖 第 1 页 / 共 4 页
字号:
        public uint AC { get { return ac; } set { System.Math.Min(value, 255); } }
        #endregion

        #region RGB
        private int rc = 0, gc = 0, bc = 0; //RGB Components > -1 

        public int RC { get { return rc; } set { rc = System.Math.Min(value, 255); } }
        public int GC { get { return gc; } set { gc = System.Math.Min(value, 255); } }
        public int BC { get { return bc; } set { bc = System.Math.Min(value, 255); } }


        public Color GetColor()
        {

            int conv;
            double hue, sat, val;
            int basis;

            hue = (float)hc / 100.0f;
            sat = (float)sc / 100.0f;
            val = (float)vc / 100.0f;

            if ((float)sc == 0) // Gray Colors
            {
                conv = (int)(255.0f * val);
                rc = gc = bc = conv;
                return Color.FromArgb((int)rc, (int)gc, (int)bc);
            }

            basis = (int)(255.0f * (1.0 - sat) * val);

            switch ((int)((float)hc / 60.0f))
            {
                case 0:
                    rc = (int)(255.0f * val);
                    gc = (int)((255.0f * val - basis) * (hc / 60.0f) + basis);
                    bc = (int)basis;
                    break;

                case 1:
                    rc = (int)((255.0f * val - basis) * (1.0f - ((hc % 60) / 60.0f)) + basis);
                    gc = (int)(255.0f * val);
                    bc = (int)basis;
                    break;

                case 2:
                    rc = (int)basis;
                    gc = (int)(255.0f * val);
                    bc = (int)((255.0f * val - basis) * ((hc % 60) / 60.0f) + basis);
                    break;

                case 3:
                    rc = (int)basis;
                    gc = (int)((255.0f * val - basis) * (1.0f - ((hc % 60) / 60.0f)) + basis);
                    bc = (int)(255.0f * val);
                    break;

                case 4:
                    rc = (int)((255.0f * val - basis) * ((hc % 60) / 60.0f) + basis);
                    gc = (int)basis;
                    bc = (int)(255.0f * val);
                    break;

                case 5:
                    rc = (int)(255.0f * val);
                    gc = (int)basis;
                    bc = (int)((255.0f * val - basis) * (1.0f - ((hc % 60) / 60.0f)) + basis);
                    break;
            }
            return Color.FromArgb((int)ac, (int)rc, (int)gc, (int)bc);

        }

        public uint GetRed()
        {
            return GetColor().R;
        }

        public uint GetGreen()
        {
            return GetColor().G;
        }

        public uint GetBlue()
        {
            return GetColor().B;
        }

        #endregion

        #region HSV

        private int hc = 0, sc = 0, vc = 0;

        public float HC { get { return hc; } set { hc = (int)System.Math.Min(value, 359); hc = (int)System.Math.Max(hc, 0); } }
        public float SC { get { return sc; } set { sc = (int)System.Math.Min(value, 100); sc = (int)System.Math.Max(sc, 0); } }
        public float VC { get { return vc; } set { vc = (int)System.Math.Min(value, 100); vc = (int)System.Math.Max(vc, 0); } }

        public enum C { Red, Green, Blue, None }
        private int maxval = 0, minval = 0;
        private C CompMax;
        //private C CompMin;

        private void HSV()
        {
            hc = this.GetHue();
            sc = this.GetSaturation();
            vc = this.GetBrightness();
        }

        public void CMax()
        {
            if (rc > gc)
            {
                if (rc < bc) { maxval = bc; CompMax = C.Blue; }
                else { maxval = rc; CompMax = C.Red; }
            }
            else
            {
                if (gc < bc) { maxval = bc; CompMax = C.Blue; }
                else { maxval = gc; CompMax = C.Green; }
            }
        }

        public void CMin()
        {
            if (rc < gc)
            {
                if (rc > bc) 
                { minval = bc; /*CompMin = C.Blue; */ }
                else 
                { minval = rc; /*CompMin = C.Red; */ }
            }
            else
            {
                if (gc > bc){ minval = bc;/*CompMin = C.Blue; */ }
                else { minval = gc; /*CompMin = C.Green; */}
            }

        }

        public int GetBrightness()  //Brightness is from 0 to 100
        {
            CMax(); return 100 * maxval / 255;
        }

        public int GetSaturation() //Saturation from 0 to 100
        {
            CMax(); CMin();
            if (CompMax == C.None)
                return 0;
            else if (maxval != minval)
            {
                Decimal d_sat = Decimal.Divide(minval, maxval);
                d_sat = Decimal.Subtract(1, d_sat);
                d_sat = Decimal.Multiply(d_sat, 100);
                return Convert.ToUInt16(d_sat);
            }
            else
            {
                return 0;
            }

        }

        public int GetHue()
        {
            CMax(); CMin();

            if (maxval == minval)
            {
                return 0;
            }
            else if (CompMax == C.Red)
            {
                if (gc >= bc)
                {
                    Decimal d1 = Decimal.Divide((gc - bc), (maxval - minval));
                    return Convert.ToUInt16(60 * d1);
                }
                else
                {
                    Decimal d1 = Decimal.Divide((bc - gc), (maxval - minval));
                    d1 = 60 * d1;
                    return Convert.ToUInt16(360 - d1);
                }
            }
            else if (CompMax == C.Green)
            {
                if (bc >= rc)
                {
                    Decimal d1 = Decimal.Divide((bc - rc), (maxval - minval));
                    d1 = 60 * d1;
                    return Convert.ToUInt16(120 + d1);
                }
                else
                {
                    Decimal d1 = Decimal.Divide((rc - bc), (maxval - minval));
                    d1 = 60 * d1;
                    return Convert.ToUInt16(120 - d1);
                }


            }
            else if (CompMax == C.Blue)
            {
                if (rc >= gc)
                {
                    Decimal d1 = Decimal.Divide((rc - gc), (maxval - minval));
                    d1 = 60 * d1;
                    return Convert.ToUInt16(240 + d1);
                }
                else
                {
                    Decimal d1 = Decimal.Divide((gc - rc), (maxval - minval));
                    d1 = 60 * d1;
                    return Convert.ToUInt16(240 - d1);
                }
            }
            else
            {
                return 0;
            }
        }  //Hue from 0 to 100

        #endregion

        #region Methods

        public bool IsDark()
        {
            if (BC > 50)
            {
                return false;
            }
            else
            {
                return true;
            }
        }

        public void IncreaseBrightness(int val)
        {
            this.VC = this.VC + val;

        }

        public void SetBrightness(int val)
        {
            this.VC = val;

        }

        public void IncreaseHue(int val)
        {
            this.HC = this.HC + val;

        }

        public void SetHue(int val)
        {
            this.HC = val;

        }

        public void IncreaseSaturation(int val)
        {
            this.SC = this.SC + val;

        }

        public void SetSaturation(int val)
        {
            this.SC = val;

        }

        public Color IncreaseHSV(int h, int s, int b)
        {
            this.HC = this.HC + h;
            this.SC = this.SC + s;
            this.VC = this.VC + b;
            return GetColor();
        }

        #endregion

    }

    public class RibbonMenuShadow : Form
    {

        public RibbonMenuShadow()
        {
            this.SetStyle(ControlStyles.SupportsTransparentBackColor |
                          ControlStyles.UserPaint |
                          ControlStyles.ResizeRedraw |
                          ControlStyles.DoubleBuffer, true);
            this.SetStyle(ControlStyles.Opaque, false);
            this.TransparencyKey = Color.Fuchsia;
            this.Padding = new Padding(1);
            this.FormBorderStyle = FormBorderStyle.None;

        }

        int _radius = 8;
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            g.SmoothingMode = SmoothingMode.Default;
            Rectangle reg = new Rectangle(0, 0, this.Width, this.Height);
            GraphicsPath path = new GraphicsPath();
            DrawArc(reg, path);
            this.Region = new Region(path);
            // g.FillRectangle(new SolidBrush(Color.Fuchsia), reg);

            Rectangle r = new Rectangle(10, 10, 110, 110);
            path = new GraphicsPath(); DrawArc(r, path);

            g.FillPath(new SolidBrush(Color.FromArgb(10, 10, 10, 10)), path);
            g.DrawPath(Pens.Red, path);
            //base.OnPaint(e);
        }



        public void DrawArc(Rectangle re, GraphicsPath pa)
        {
            int _radiusX0Y0 = _radius, _radiusXFY0 = _radius, _radiusX0YF = _radius, _radiusXFYF = _radius;
            pa.AddArc(re.X, re.Y, _radiusX0Y0, _radiusX0Y0, 180, 90);
            pa.AddArc(re.Width - _radiusXFY0, re.Y, _radiusXFY0, _radiusXFY0, 270, 90);
            pa.AddArc(re.Width - _radiusXFYF, re.Height - _radiusXFYF, _radiusXFYF, _radiusXFYF, 0, 90);
            pa.AddArc(re.X, re.Height - _radiusX0YF, _radiusX0YF, _radiusX0YF, 90, 90);
            pa.CloseFigure();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -