Exemplo n.º 1
0
        /// <summary>
        /// Lighten or darken a color, ratio + to lighten, - to darken
        /// </summary>
        public static string ModifyColorLuminosity(this string htmlColor, float ratio)
        {
            var color = ColorTranslator.FromHtml(htmlColor);

            return(ColorTranslator.ToHtml(ratio > 0 ? ControlPaint.Light(color, ratio) : ControlPaint.Dark(color, ratio)));

            /*
             * var isBlack = color.R == 0 && color.G == 0 && color.B == 0;
             * var red = (int)Math.Min(Math.Max(0, color.R + ((isBlack ? 255 : color.R) * ratio)), 255);
             * var green = (int)Math.Min(Math.Max(0, color.G + ((isBlack ? 255 : color.G) * ratio)), 255);
             * var blue = (int)Math.Min(Math.Max(0, color.B + ((isBlack ? 255 : color.B) * ratio)), 255);
             * return ColorTranslator.ToHtml(Color.FromArgb(red, green, blue));
             */
        }
Exemplo n.º 2
0
        public GSystemButton(int x, int y, int width, int height, Color backColor, Color foreColor, string text, IFont font) : base(x, y, width, height)
        {
            this.m_InactiveColor = backColor;
            this.m_ActiveColor   = ControlPaint.Dark(backColor, -this.Darkness);
            this.m_PressedColor  = ControlPaint.Light(backColor);
            this.m_ForeColor     = foreColor;
            base.m_CanDrag       = false;
            GLabel toAdd = new GLabel(text, font, Hues.Default, 0, 0);

            base.m_Children.Add(toAdd);
            toAdd.Center();
            base.FillAlpha = 1f;
            this.UpdateColors();
        }
Exemplo n.º 3
0
        }                                                                                                           // Collect garbage from the last button colour.

        public static Color GenerateHighlightLighterButton(Color InputColor)
        {
            byte BlueChannel; BlueChannel   = InputColor.B;
            byte RedChannel; RedChannel     = InputColor.R;
            byte GreenChannel; GreenChannel = InputColor.G;

            // Note, percentage is from 0%, 0.00 to 100%, 1.00 - directly expressed as float.
            Color newColor = ControlPaint.Light(InputColor, 0.05F);

            // DEBUG
            // MessageBox.Show("Input Colour: " + Convert.ToString(InputColor) + "\nToolstrip Colour: " + Convert.ToString(Program.BottomToolstrip.BackColor) + "\nNew Colour: " + Convert.ToString(newColor));

            return(newColor);
        }
Exemplo n.º 4
0
        public override void DrawMinuteLine(Graphics g, Rectangle rect, int minute)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            Color m_Color = ControlPaint.LightLight(SystemColors.WindowFrame);

            m_Color = ControlPaint.Light(m_Color);

            using (Pen m_Pen = new Pen(m_Color))
                g.DrawLine(m_Pen, rect.Left, rect.Y, rect.Width, rect.Y);
        }
    protected override void OnPaint(PaintEventArgs e)
    {
        Graphics g = e.Graphics;

        g.SmoothingMode = SmoothingMode.AntiAlias;
        g.FillRoundedRectangle(new SolidBrush(Color.White), 10, 10, this.Width - 40, this.Height - 60, 10);
        SolidBrush brush = new SolidBrush(
            Color.White
            );

        g.FillRoundedRectangle(brush, 12, 12, this.Width - 44, this.Height - 64, 10);
        g.DrawRoundedRectangle(new Pen(ControlPaint.Light(Color.White, 0.00f)), 12, 12, this.Width - 44, this.Height - 64, 10);
        g.FillRoundedRectangle(new SolidBrush(Color.White), 12, 12 + ((this.Height - 64) / 2), this.Width - 44, (this.Height - 64) / 2, 10);
    }
Exemplo n.º 6
0
        string GetHtml()
        {
            var defaultColor    = platformPlan.Color;
            var myColor         = ColorTranslator.FromHtml(defaultColor);
            var myBrighterColor = HexConverter(ControlPaint.Light(myColor));
            var myDarkerColor   = HexConverter(ControlPaint.Dark(myColor));
            var watermark       = AppSettings.InvestmentPlatform.ProofsWatermarkEnabled ? string.Format("{0}/Images/Misc/WATERMARK.png", AppSettings.Site.Url) : "";

            var htmlFromFile = File.ReadAllText(HttpContext.Current.Request.MapPath(TemplateLocation));

            string htmlString;

            if (AppSettings.InvestmentPlatform.LevelsEnabled)
            {
                htmlString = htmlFromFile
                             .Replace("[FIRST_COLOR]", defaultColor)
                             .Replace("[SECOND_COLOR]", myDarkerColor)
                             .Replace("[THIRD_COLOR]", myBrighterColor)
                             .Replace("[TICKET_NAME]", platformPlan.Name)
                             .Replace("[DATE_TIME]", ticket.Date.ToString())
                             .Replace("[TICKET_NO_TEXT]", string.Format("{0}:", U6012.TICKETNO))
                             .Replace("[TICKET_NO]", ticket.GenerateTicketNumber())
                             .Replace("[INVESTMENT_TEXT]", string.Format("{0}:", U6006.INVESTMENT))
                             .Replace("[DEPOSITED_AND_FEE]", string.Format("{0}: {1} + {2}", U6012.TICKETDEPOSITEDFEE, ticket.LevelPrice.ToString(), ticket.LevelFee.ToString()))
                             .Replace("[RECEIVE]", string.Format("{0}: {1}", U6012.TICKETRECEIVE, ticket.LevelEarnings.ToString()))
                             .Replace("[NOTE]", AppSettings.InvestmentPlatform.ProofsNote)
                             .Replace("[IMAGE_PATH]", watermark)
                             .Replace("[SITE_URL]", AppSettings.Site.Url);
            }
            else
            {
                htmlString = htmlFromFile
                             .Replace("[FIRST_COLOR]", defaultColor)
                             .Replace("[SECOND_COLOR]", myDarkerColor)
                             .Replace("[THIRD_COLOR]", myBrighterColor)
                             .Replace("[TICKET_NAME]", platformPlan.Name)
                             .Replace("[DATE_TIME]", userPlan.PurchaseDate.ToString())
                             .Replace("[TICKET_NO_TEXT]", string.Format("{0}:", U6012.TICKETNO))
                             .Replace("[TICKET_NO]", userPlan.GeneratePlanNumber())
                             .Replace("[INVESTMENT_TEXT]", string.Format("{0}:", U6006.INVESTMENT))
                             .Replace("[DEPOSITED_AND_FEE]", string.Format("{0}: {1}", L1.PRICE, platformPlan.Price.ToString()))
                             .Replace("[RECEIVE]", string.Format("{0}: {1}", U6012.TICKETRECEIVE, userPlan.MoneyToReturn.ToString()))
                             .Replace("[NOTE]", AppSettings.InvestmentPlatform.ProofsNote)
                             .Replace("[TIME]", string.Format("{0}: {1} {2}", U6006.REPURCHASETIME, platformPlan.Time.ToString(), L1.DAYS))
                             .Replace("[IMAGE_PATH]", watermark)
                             .Replace("[SITE_URL]", AppSettings.Site.Url);
            }

            return(htmlString);
        }
Exemplo n.º 7
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.FillRoundedRectangle(new SolidBrush(Color.FromArgb(78, 122, 159)), 10, 10, Width - 40, Height - 60, 10);
            SolidBrush brush = new SolidBrush(
                Color.FromArgb(78, 122, 159)
                );

            g.FillRoundedRectangle(brush, 12, 12, Width - 44, Height - 64, 10);
            g.DrawRoundedRectangle(new Pen(ControlPaint.Light(Color.FromArgb(78, 122, 159), 0.00f)), 12, 12, Width - 44, Height - 64, 10);
            g.FillRoundedRectangle(new SolidBrush(Color.FromArgb(78, 122, 159)), 12, 12 + ((Height - 64) / 2), Width - 44, (Height - 64) / 2, 10);
        }
Exemplo n.º 8
0
        private void StyleGrid()
        {
            this.BorderStyle               = System.Windows.Forms.BorderStyle.None;
            this.CellBorderStyle           = DataGridViewCellBorderStyle.None;
            this.EnableHeadersVisualStyles = false;
            this.SelectionMode             = DataGridViewSelectionMode.FullRowSelect;
            this.BackColor       = MetroPaint.BackColor.Form(Theme);
            this.BackgroundColor = MetroPaint.BackColor.Form(Theme);
            this.GridColor       = MetroPaint.BackColor.Form(Theme);
            this.ForeColor       = MetroPaint.ForeColor.Button.Disabled(Theme);
            this.Font            = new Font("Segoe UI", FontSize, FontStyle.Regular, GraphicsUnit.Pixel);
            if (!this.ReadOnly)
            {
                this.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                this.AutoSizeRowsMode          = DataGridViewAutoSizeRowsMode.AllCells;
                this.CellBeginEdit            += (sender, e) =>
                {
                    this.AutoSizeRowsMode        = DataGridViewAutoSizeRowsMode.None;
                    this.Rows[e.RowIndex].Height = Convert.ToInt32(FontSize * 4);
                };
                this.CellEndEdit += (sender, e) =>
                {
                    this.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
                };
            }
            this.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
            this.AllowUserToResizeRows   = false;

            this.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None;
            this.ColumnHeadersDefaultCellStyle.BackColor = MetroPaint.GetStyleColor(Style);
            this.ColumnHeadersDefaultCellStyle.ForeColor = MetroPaint.ForeColor.Button.Press(Theme);

            this.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.None;
            this.RowHeadersDefaultCellStyle.BackColor = MetroPaint.GetStyleColor(Style);
            this.RowHeadersDefaultCellStyle.ForeColor = MetroPaint.ForeColor.Button.Press(Theme);

            this.DefaultCellStyle.BackColor = MetroPaint.BackColor.Form(Theme);

            this.DefaultCellStyle.SelectionBackColor = ControlPaint.Light(MetroPaint.GetStyleColor(Style), _offset);
            this.DefaultCellStyle.SelectionForeColor = Color.FromArgb(17, 17, 17);

            this.DefaultCellStyle.SelectionBackColor = ControlPaint.Light(MetroPaint.GetStyleColor(Style), _offset);
            this.DefaultCellStyle.SelectionForeColor = Color.FromArgb(17, 17, 17);

            this.RowHeadersDefaultCellStyle.SelectionBackColor = ControlPaint.Light(MetroPaint.GetStyleColor(Style), _offset);
            this.RowHeadersDefaultCellStyle.SelectionForeColor = Color.FromArgb(17, 17, 17);

            this.ColumnHeadersDefaultCellStyle.SelectionBackColor = ControlPaint.Light(MetroPaint.GetStyleColor(Style), _offset);
            this.ColumnHeadersDefaultCellStyle.SelectionForeColor = Color.FromArgb(17, 17, 17);
        }
Exemplo n.º 9
0
        private void DrawRectRaised(Graphics graphics, Rectangle rect)
        {
            var darknessEnd   = _endColor.GetSaturation();
            var darknessBegin = _startColor.GetSaturation();

            mainColor = darknessEnd >= darknessBegin ? _endColor : _startColor;

            edgeColor1 = ControlPaint.Light(_startColor);
            edgeColor2 = ControlPaint.Dark(_endColor);

            DrawEdges(graphics, ref rect);
            rect.Inflate(-_edgeWidth, -_edgeWidth);
            DrawPanelStyled(graphics, rect);
        }
Exemplo n.º 10
0
 private void SelfDestructionButton_Click(object sender, EventArgs e)
 {
     if (!_selfDestruction)
     {
         selfDestructionButton.BackColor = ControlPaint.Light(Color.LawnGreen, 0.8f);
         selfDestructionPicker.Value     = DateTime.Now.AddMinutes(5);
     }
     else
     {
         selfDestructionButton.BackColor = Color.White;
     }
     _selfDestruction = !_selfDestruction;
     selfDestructionPicker.Visible = _selfDestruction;
 }
Exemplo n.º 11
0
        private void ProcurarCor(String tagPic)
        {
            foreach (var corEncontrada in Controls.OfType <PictureBox>())
            {
                if (corEncontrada.Tag.ToString() == tagPic)
                {
                    string tag = corEncontrada.Tag.ToString();

                    Color       piscar = ControlPaint.Light(corEncontrada.BackColor, brilho);
                    SoundPlayer som    = tag == "Azul" ? audios[0] : (tag == "Verde" ? audios[1] : (tag == "Amarelo" ? audios[2] : audios[3]));
                    MostrarCor(corEncontrada, piscar, corEncontrada.BackColor, som);
                }
            }
        }
Exemplo n.º 12
0
        private void RenderBefore2010ContextTab(RenderContext context, ContextTabSet cts)
        {
            // Grab the colors we draw the context separators and background in
            Color c1      = _paletteGeneral.GetRibbonTabSeparatorContextColor(PaletteState.Normal);
            Color c2      = cts.ContextColor;
            Color lightC2 = ControlPaint.Light(c2);
            Color c3      = CommonHelper.MergeColors(Color.Black, 0.1f, c2, 0.9f);

            Rectangle contextRect = new Rectangle(ClientRectangle.X - 1, ClientRectangle.Y - 1, ClientRectangle.Width + 2, ClientRectangle.Height + 1);
            Rectangle fillRect    = new Rectangle(ClientRectangle.X - 2, ClientRectangle.Y - 1, ClientRectangle.Width + 4, ClientRectangle.Height);

            using (LinearGradientBrush outerBrush = new LinearGradientBrush(contextRect, c1, Color.Transparent, 90f),
                   innerBrush = new LinearGradientBrush(contextRect, c3, Color.Transparent, 90f),
                   fillBrush = new LinearGradientBrush(contextRect, Color.FromArgb(64, lightC2), Color.Transparent, 90f))
            {
                fillBrush.Blend = _contextBlend2010;

                using (Pen outerPen = new Pen(outerBrush),
                       innerPen = new Pen(innerBrush))
                {
                    if (cts.IsFirstTab(this))
                    {
                        // Draw left separators
                        context.Graphics.DrawLine(outerPen, contextRect.X, contextRect.Y, contextRect.X, contextRect.Bottom - 2);
                        context.Graphics.DrawLine(innerPen, contextRect.X + 1, contextRect.Y, contextRect.X + 1, contextRect.Bottom - 2);
                        fillRect.X     += 2;
                        fillRect.Width -= 2;

                        if (cts.IsLastTab(this))
                        {
                            // Draw right separators
                            context.Graphics.DrawLine(outerPen, contextRect.Right - 1, contextRect.Y, contextRect.Right - 1, contextRect.Bottom - 2);
                            context.Graphics.DrawLine(innerPen, contextRect.Right - 2, contextRect.Y, contextRect.Right - 2, contextRect.Bottom - 2);
                            fillRect.Width -= 2;
                        }
                    }
                    else if (cts.IsLastTab(this))
                    {
                        // Draw right separators
                        context.Graphics.DrawLine(outerPen, contextRect.Right - 1, contextRect.Y, contextRect.Right - 1, contextRect.Bottom - 2);
                        context.Graphics.DrawLine(innerPen, contextRect.Right - 2, contextRect.Y, contextRect.Right - 2, contextRect.Bottom - 2);
                        fillRect.Width -= 2;
                    }

                    // Draw the background gradient
                    context.Graphics.FillRectangle(fillBrush, fillRect);
                }
            }
        }
Exemplo n.º 13
0
        private void DDB_Draw3DBorder(PaintEventArgs e, Rectangle r, bool raised)
        {
            if (Control.BackColor != SystemColors.Control && SystemInformation.HighContrast)
            {
                if (raised)
                {
                    Color c = ControlPaint.LightLight(Control.BackColor);
                    ControlPaint.DrawBorder(
                        e, r,
                        c, 1, ButtonBorderStyle.Outset,
                        c, 1, ButtonBorderStyle.Outset,
                        c, 2, ButtonBorderStyle.Inset,
                        c, 2, ButtonBorderStyle.Inset);
                }
                else
                {
                    ControlPaint.DrawBorderSolid(e, r, ControlPaint.Dark(Control.BackColor));
                }
            }
            else
            {
                if (raised)
                {
                    Color c = ControlPaint.Light(Control.BackColor);
                    ControlPaint.DrawBorder(
                        e, r,
                        c, 1, ButtonBorderStyle.Solid,
                        c, 1, ButtonBorderStyle.Solid,
                        Control.BackColor, 2, ButtonBorderStyle.Outset,
                        Control.BackColor, 2, ButtonBorderStyle.Outset);

                    Rectangle inside = r;
                    inside.Offset(1, 1);
                    inside.Width  -= 3;
                    inside.Height -= 3;
                    c              = ControlPaint.LightLight(Control.BackColor);
                    ControlPaint.DrawBorder(
                        e, inside,
                        c, 1, ButtonBorderStyle.Solid,
                        c, 1, ButtonBorderStyle.Solid,
                        c, 1, ButtonBorderStyle.None,
                        c, 1, ButtonBorderStyle.None);
                }
                else
                {
                    ControlPaint.DrawBorderSolid(e, r, ControlPaint.Dark(Control.BackColor));
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Show passwors summary elements according password
        /// </summary>
        private void SetPasswordSummary()
        {
            Zxcvbn.Result passwordResult = PasswordEvaluatorEngine.EvaluatePassword(txtPassword.Text);

            lblPasswordLengthValue.Text    = string.Concat(txtPassword.Text.Length, " ch.");
            lblPasswordCrackTimeValue.Text = passwordResult.CrackTimeDisplay;
            lblPasswordEntropyValue.Text   = string.Concat(Math.Round(passwordResult.Entropy), " bits");

            cpbPasswordStrength.Value = passwordResult.Score + 1;
            cpbPasswordStrength.Text  = (passwordResult.Score + 1).ToString();

            switch (passwordResult.Score)
            {
            case 0:
                lblPasswordStrength.Text          = "Very weak";
                lblPasswordStrength.ForeColor     = Color.Red;
                cpbPasswordStrength.ForeColor     = Color.Red;
                cpbPasswordStrength.ProgressColor = Color.Red;
                break;

            case 1:
                lblPasswordStrength.Text          = "Weak";
                lblPasswordStrength.ForeColor     = ControlPaint.Light(Color.Red);
                cpbPasswordStrength.ForeColor     = ControlPaint.Light(Color.Red);
                cpbPasswordStrength.ProgressColor = ControlPaint.Light(Color.Red);
                break;

            case 2:
                lblPasswordStrength.Text          = "Medium";
                lblPasswordStrength.ForeColor     = ControlPaint.Light(Color.Green);
                cpbPasswordStrength.ForeColor     = ControlPaint.Light(Color.Green);
                cpbPasswordStrength.ProgressColor = ControlPaint.Light(Color.Green);
                break;

            case 3:
                lblPasswordStrength.Text          = "Good";
                lblPasswordStrength.ForeColor     = Color.Green;
                cpbPasswordStrength.ForeColor     = Color.Green;
                cpbPasswordStrength.ProgressColor = Color.Green;
                break;

            case 4:
                lblPasswordStrength.Text          = "Strong";
                lblPasswordStrength.ForeColor     = Color.DarkGreen;
                cpbPasswordStrength.ForeColor     = Color.DarkGreen;
                cpbPasswordStrength.ProgressColor = Color.DarkGreen;
                break;
            }
        }
Exemplo n.º 15
0
        public override void DrawHourLabel(Graphics g, Rectangle rect, int hour)
        {
            Color m_Color = ControlPaint.LightLight(SystemColors.WindowFrame);

            m_Color = ControlPaint.Light(m_Color);

            using (Pen m_Pen = new Pen(m_Color))
                g.DrawLine(m_Pen, rect.Left, rect.Y, rect.Width, rect.Y);

            g.DrawString(hour.ToString("##00"), HourFont, SystemBrushes.ControlText, rect);

            rect.X += 27;

            g.DrawString("00", MinuteFont, SystemBrushes.ControlText, rect);
        }
Exemplo n.º 16
0
        private void InitializeStyles()
        {
            //Header
            header1.Logo = Properties.Resources.C1;
            header1.SampleTitleForeColor = SkinManager.PrimaryTextColor;

            header1.SampleTitleBackColor = SkinManager.PrimaryColor;

            //TileControl
            tileControl1.BackColor  = SkinManager.PrimaryBackColor;
            tileControl1.HoverColor = Color.FromArgb(64, 99, 99);

            sideBar1.treeView.SelectionColor     = ControlPaint.Light(SkinManager.PrimaryLightColor);
            sideBar1.treeView.SelectionForeColor = SkinManager.PrimaryTextColor;
        }
Exemplo n.º 17
0
        //método para procurar a cor de cada sequencia, piscá-la e mostrá-la
        private void SearchColor(string tagPic)
        {
            foreach (var foundedColor in Controls.OfType <PictureBox>())
            {
                if (foundedColor.Tag.ToString() == tagPic)
                {
                    string tag = foundedColor.Tag.ToString();

                    Color       blink = ControlPaint.Light(foundedColor.BackColor, bright);
                    SoundPlayer sound = sounds[0];

                    ShowColor(foundedColor, blink, foundedColor.BackColor, sound);
                }
            }
        }
        /// <summary>
        /// Draws the animation part
        /// </summary>
        private void FillPieAndTail()
        {
            Color color = this.ForeColor;

            for (int i = 0; i <= this.NumberOfTail; i++)
            {
                this.FillPieAccordingToTheIndex(this._index - i, color);

                // If there is tail, then the tail color is the lighter of the ForeColor
                color = ControlPaint.Light(color);
            }

            // Background Pie
            this.FillPieAccordingToTheIndex(this._index - (this.NumberOfTail + 1), this.RingColor);
        }
Exemplo n.º 19
0
        ///--------------------------------------------------------------------------------------------------
        /// <summary> Paints the area. </summary>
        /// <remarks> Oscvic, 2016-01-18. </remarks>
        /// <param name="e">          Paint event information. </param>
        /// <param name="filter">     Specifies the filter. </param>
        /// <param name="StartColor"> The start color. </param>
        /// <param name="EndColor">   The end color. </param>
        /// <param name="invertDark"> true to invert dark. </param>
        ///--------------------------------------------------------------------------------------------------
        private void PaintArea(PaintEventArgs e, RectangleEdgeFilter filter, Color StartColor, Color EndColor, Boolean invertDark)
        {
            StartColor = (invertDark) ? ControlPaint.Dark(StartColor, PercentageOfDark) : StartColor;
            EndColor   = (invertDark) ? ControlPaint.Light(StartColor, PercentageOfLight) : ControlPaint.Dark(EndColor, PercentageOfDark);


            using (LinearGradientBrush brush = new LinearGradientBrush(
                       new Point(this.Width / 2, (invertDark) ? -(this.Height / 2) : 0),
                       new Point(this.Width / 2, this.Height + ((invertDark) ? 0 : this.Height / 2)),
                       StartColor, EndColor))
                e.Graphics.FillRoundedRectangle(brush, 0, 0, this.Width - 1, this.Height, Radius, filter);

            using (Pen pen = new Pen((invertDark) ? StartColor : EndColor))
                e.Graphics.DrawRoundedRectangle(pen, 0, 0, this.Width - 1, this.Height - 1, Radius, filter);
        }
Exemplo n.º 20
0
        public override void ShowDay(CalendarModel.Day day)
        {
            Bitmap bitmap = new Bitmap(day.PictureBox.Width, day.PictureBox.Height);

            using (Graphics g = Graphics.FromImage(bitmap))
            {
                for (int i = 1; i < 24; i++)
                {
                    g.DrawLine(Pens.DarkGray, new Point(0, i * cellHeight), new Point(bitmap.Width, i * cellHeight));
                }
            }
            day.PictureBox.BackgroundImage = bitmap;
            day.PictureBox.BackColor       = Color.Transparent;
            day.PictureBox.MouseClick     += new MouseEventHandler(day_MouseClick);
            day.PictureBox.Image           = new Bitmap(day.PictureBox.Width, day.PictureBox.Height);
            using (Graphics g = Graphics.FromImage(day.PictureBox.Image))
            {
                int cornerX = 0;
                for (int i = 0; i < day.Events.Count; i++)
                {
                    Event e = day.Events[i];

                    int j = i + 1;
                    while (j < day.Events.Count && (day.Events[j].Start.Hour < e.End.Hour || (day.Events[j].Start.Hour == e.End.Hour && day.Events[j].Start.Minute < e.End.Minute)))
                    {
                        j++;
                    }
                    int width = (day.PictureBox.Width - cornerX - 1) / (j - i);

                    Color eventColor        = DataModel.IsEventAccepted(e.Id) ? e.Type.Color.Color : notAcceptedEventColor;
                    Color lighterEventColor = ControlPaint.Light(ControlPaint.LightLight(eventColor));
                    Point corner            = new Point(cornerX, cellHeight * e.Start.Hour + (e.Start.Minute / 60) * cellHeight);
                    int   height            = (int)(((e.End.Hour - e.Start.Hour) * 60 + e.End.Minute - e.Start.Minute) * cellHeight / 60);
                    g.FillRectangle(new SolidBrush(lighterEventColor), new Rectangle(new Point(corner.X, corner.Y), new Size(width, height)));
                    TextRenderer.DrawText(g, e.Name, new Font("Arial", 10, FontStyle.Bold), new Rectangle(new Point(corner.X + 3, corner.Y + 3), new Size(width, height)), Color.Gray, lighterEventColor, TextFormatFlags.WordBreak | TextFormatFlags.WordEllipsis | TextFormatFlags.Top | TextFormatFlags.Left);
                    g.DrawRectangle(new Pen(eventColor, 1), new Rectangle(corner, new Size(width, height)));

                    if (j - i == 1)
                    {
                        cornerX = 0;
                    }
                    else
                    {
                        cornerX += width + 1;
                    }
                }
            }
        }
Exemplo n.º 21
0
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.FillRoundedRectangle(new SolidBrush(Color.White), 20, 20, this.Width - 40, this.Height - 60, 30);
            SolidBrush brush = new SolidBrush(
                Color.White
                );

            g.FillRoundedRectangle(brush, 12, 12, this.Width - 44, this.Height - 64, 10);
            g.DrawRoundedRectangle(new Pen(ControlPaint.Light(Color.White, 0.00f)), 12, 12, this.Width - 44,
                                   this.Height - 64, 10);
            g.FillRoundedRectangle(new SolidBrush(Color.White), 12, 12 + ((this.Height - 64) / 2), this.Width - 44,
                                   (this.Height - 64) / 2, 10);
        }
Exemplo n.º 22
0
        protected override void OnPaintAdornments(PaintEventArgs pe)
        {
            Rectangle clientRectangle = this.Control.ClientRectangle;

            clientRectangle.Width--;
            clientRectangle.Height--;
            Color backColor = this.Control.BackColor;
            Color color     = ((double)backColor.GetBrightness() < 0.5) ? ControlPaint.Light(backColor) : ControlPaint.Dark(backColor);

            using (Pen pen = new Pen(color))
            {
                pen.DashStyle = DashStyle.Dash;
                pe.Graphics.DrawRectangle(pen, clientRectangle);
            }
            base.OnPaintAdornments(pe);
        }
Exemplo n.º 23
0
        public Color GetFileTypeColor(string Filename)
        {
            string ext   = Path.GetExtension(Filename).ToUpper();
            Color  color = Color.Wheat;
            int    code  = ext.GetHashCode();
            //code >>= 8;
            int B = code & 0xF7;

            code >>= 8;
            int G = code & 0xF7;

            code >>= 8;
            int R = code & 0xF7;

            return(ControlPaint.Light(Color.FromArgb(R, G, B)));
        }
Exemplo n.º 24
0
 public static Color GetLightFromColor(Color basecolor)
 {
     if (basecolor == Color.Silver)
     {
         return(Color.White);
     }
     if (basecolor == Color.FromArgb(112, 112, 112))
     {
         return(Color.FromArgb(184, 184, 184));
     }
     if (basecolor == Color.FromArgb(169, 200, 169))
     {
         return(Color.FromArgb(218, 223, 218));
     }
     return(ControlPaint.Light(basecolor, 70));
 }
Exemplo n.º 25
0
 /// <summary>
 /// Lightens colors from given array.
 /// </summary>
 /// <param name="colorsToLighten">The colors to lighten.</param>
 /// <returns></returns>
 public static Color[] LightenColors(params Color[] colorsToLighten)
 {
     Color[] colorsToReturn = new Color[colorsToLighten.Length];
     for (int i = 0; i < colorsToLighten.Length; i++)
     {
         if (colorsToLighten[i] == Color.FromKnownColor(KnownColor.Transparent))
         {
             colorsToReturn[i] = colorsToLighten[i];
         }
         else
         {
             colorsToReturn[i] = ControlPaint.Light(colorsToLighten[i]);
         }
     }
     return(colorsToReturn);
 }
Exemplo n.º 26
0
            /// <summary>
            /// Draw the text of the button
            /// </summary>
            /// <param name="e"></param>
            /// <param name="bounds"></param>
            public virtual void DrawText(VCButtonItem button, ItemPaintEventArgs e, Rectangle textBounds)
            {
                // Calculate formatting
                StringFormat format = new StringFormat();

                format.Alignment     = StringAlignment.Center;
                format.LineAlignment = StringAlignment.Center;

                // Draw text
                Color c = button.Enabled ? button.TextColor : ControlPaint.Light(button.TextColor);

                using (Brush brush = new SolidBrush(c))
                {
                    e.Graphics.DrawString(button.Text, button.Font, brush, textBounds, format);
                }
            }
Exemplo n.º 27
0
 protected override void OnPaint(PaintEventArgs e)
 {
     if (Paint != null)
     {
         Paint(this, e);
     }
     else
     {
         base.OnPaint(e);
         float               num   = 1f - (((float)base.Width) / ((float)base.Height));
         float               angle = 50f - (15f * num);
         float               num3  = 230f - (15f * num);
         Rectangle           rect  = new Rectangle(PosFromAlignment.X, PosFromAlignment.Y, itemSize.Width, itemSize.Height);
         LinearGradientBrush brush = new LinearGradientBrush(rect, ControlPaint.Dark(base.Parent.BackColor), ControlPaint.LightLight(base.Parent.BackColor), angle);
         Blend               blend = new Blend
         {
             Positions = new float[] { 0f, 0.2f, 0.4f, 0.6f, 0.8f, 1f },
             Factors   = new float[] { 0.2f, 0.2f, 0.4f, 0.4f, 1f, 1f }
         };
         brush.Blend = blend;
         Rectangle rectangle2 = rect;
         rectangle2.Inflate(1, 1);
         e.Graphics.FillEllipse(brush, rectangle2);
         if (base.Enabled)
         {
             if (Checked)
             {
                 e.Graphics.FillEllipse(new SolidBrush(ControlPaint.Light(ledColor)), PosFromAlignment.X, PosFromAlignment.Y, itemSize.Width, itemSize.Height);
             }
             else
             {
                 e.Graphics.FillEllipse(new SolidBrush(ControlPaint.Dark(ledColor)), PosFromAlignment.X, PosFromAlignment.Y, itemSize.Width, itemSize.Height);
             }
         }
         LinearGradientBrush brush2 = new LinearGradientBrush(rect, Color.FromArgb(150, 0xff, 0xff, 0xff), Color.Transparent, angle);
         LinearGradientBrush brush3 = new LinearGradientBrush(rect, Color.FromArgb(100, 0xff, 0xff, 0xff), Color.FromArgb(100, 0xff, 0xff, 0xff), angle);
         Blend blend2 = new Blend
         {
             Positions = new float[] { 0f, 0.2f, 0.4f, 0.6f, 0.8f, 1f },
             Factors   = new float[] { 0.2f, 0.2f, 0.4f, 0.4f, 1f, 1f }
         };
         brush2.Blend = blend2;
         brush3.Blend = blend2;
         e.Graphics.FillEllipse(brush3, (int)(PosFromAlignment.X + ((itemSize.Width * 13) / 100)), (int)(PosFromAlignment.Y + ((itemSize.Height * 13) / 100)), (int)((itemSize.Width * 40) / 100), (int)((itemSize.Height * 40) / 100));
         e.Graphics.FillEllipse(brush2, new Rectangle(PosFromAlignment, itemSize));
     }
 }
Exemplo n.º 28
0
 private void AttachButton_Click(object sender, EventArgs e)
 {
     if (!_attached)
     {
         if (openAttachDialog.ShowDialog() == DialogResult.OK)
         {
             _attachList.AddRange(openAttachDialog.FileNames);
             attachButton.BackColor = ControlPaint.Light(Color.LawnGreen, 0.8f);
         }
     }
     else
     {
         _attachList.Clear();
         attachButton.BackColor = Color.White;
     }
     _attached = !_attached;
 }
Exemplo n.º 29
0
        private void DDB_Draw3DBorder(System.Drawing.Graphics g, Rectangle r, bool raised)
        {
            if (BackColor != SystemColors.Control && SystemInformation.HighContrast)
            {
                if (raised)
                {
                    Color c = ControlPaint.LightLight(BackColor);
                    ControlPaint.DrawBorder(g, r,
                                            c, 1, ButtonBorderStyle.Outset,
                                            c, 1, ButtonBorderStyle.Outset,
                                            c, 2, ButtonBorderStyle.Inset,
                                            c, 2, ButtonBorderStyle.Inset);
                }
                else
                {
                    ControlPaint.DrawBorder(g, r, ControlPaint.Dark(BackColor), ButtonBorderStyle.Solid);
                }
            }
            else
            {
                if (raised)
                {
                    Color c = ControlPaint.Light(BackColor);
                    ControlPaint.DrawBorder(g, r,
                                            c, 1, ButtonBorderStyle.Solid,
                                            c, 1, ButtonBorderStyle.Solid,
                                            BackColor, 2, ButtonBorderStyle.Outset,
                                            BackColor, 2, ButtonBorderStyle.Outset);

                    Rectangle inside = r;
                    inside.Offset(1, 1);
                    inside.Width  -= 3;
                    inside.Height -= 3;
                    c              = ControlPaint.LightLight(BackColor);
                    ControlPaint.DrawBorder(g, inside,
                                            c, 1, ButtonBorderStyle.Solid,
                                            c, 1, ButtonBorderStyle.Solid,
                                            c, 1, ButtonBorderStyle.None,
                                            c, 1, ButtonBorderStyle.None);
                }
                else
                {
                    ControlPaint.DrawBorder(g, r, ControlPaint.Dark(BackColor), ButtonBorderStyle.Solid);
                }
            }
        }
        /// <summary>
        /// Applies the modern style event.
        /// </summary>
        private void ApplyModernStyleEvent()
        {
            this.Enter += (s, e) =>
            {
                this.LineColor = UseStyleColors ? ControlPaint.Light(ModernPaint.GetStyleColor(ColorStyle), 0.2F) : ModernPaint.BackColor.Button.Normal(ThemeStyle);
            };

            this.Leave += (s, e) =>
            {
                this.LineColor = ModernPaint.BackColor.Button.Disabled(ThemeStyle);
            };

            this.EnabledChanged += (s, e) =>
            {
                this.LineColor = this.Enabled ? (UseStyleColors ? ControlPaint.Light(ModernPaint.GetStyleColor(ColorStyle), 0.2F) : ModernPaint.BackColor.Button.Normal(ThemeStyle)) : ModernPaint.BackColor.Button.Disabled(ThemeStyle);
            };
        }