示例#1
0
        public static Color_ Light(Color_ baseColor, float percOfLightLight)
        {
            if (baseColor.ToArgb() == ThemeEngine.Current.ColorControl.ToArgb())
            {
                int    r_sub, g_sub, b_sub;
                Color_ color;

                if (percOfLightLight <= 0f)
                {
                    return(ThemeEngine.Current.ColorControlLight);
                }

                if (percOfLightLight == 1.0f)
                {
                    return(ThemeEngine.Current.ColorControlLightLight);
                }

                r_sub = ThemeEngine.Current.ColorControlLightLight.R - ThemeEngine.Current.ColorControlLight.R;
                g_sub = ThemeEngine.Current.ColorControlLightLight.G - ThemeEngine.Current.ColorControlLight.G;
                b_sub = ThemeEngine.Current.ColorControlLightLight.B - ThemeEngine.Current.ColorControlLight.B;

                color = Color_.FromArgb(ThemeEngine.Current.ColorControlLight.A,
                                        (int)(ThemeEngine.Current.ColorControlLight.R + (r_sub * percOfLightLight)),
                                        (int)(ThemeEngine.Current.ColorControlLight.G + (g_sub * percOfLightLight)),
                                        (int)(ThemeEngine.Current.ColorControlLight.B + (b_sub * percOfLightLight)));
                return(color);
            }

            int H, I, S;

            ControlPaint.Color2HBS(baseColor, out H, out I, out S);
            int NewIntensity = Math.Min(255, I + (int)((255 - I) * 0.5f * percOfLightLight));

            return(ControlPaint.HBS2Color(H, NewIntensity, S));
        }
示例#2
0
 static SCAN_SkinsLibrary()
 {
     _Initialized          = false;
     knownSkins            = new Dictionary <string, GUISkin>();
     GUIStyle_.knownStyles = new List <GUIStyle>();
     Color_.initColorTable();                    // initalize the table of known colors
 }
示例#3
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaint(e);

            if (this.Owner != null)
            {
                Color_ font_color = this.Enabled ? this.ForeColor : SystemColors.GrayText;
                Image  draw_image = this.Enabled ? this.Image : ToolStripRenderer.CreateDisabledImage(this.Image);

                this.Owner.Renderer.DrawButtonBackground(new System.Windows.Forms.ToolStripItemRenderEventArgs(e.Graphics, this));

                Rectangle_ text_layout_rect;
                Rectangle_ image_layout_rect;

                this.CalculateTextAndImageRectangles(out text_layout_rect, out image_layout_rect);

                if (text_layout_rect != Rectangle_.Empty)
                {
                    this.Owner.Renderer.DrawItemText(new System.Windows.Forms.ToolStripItemTextRenderEventArgs(e.Graphics, this, this.Text, text_layout_rect, font_color, this.Font, this.TextAlign));
                }
                if (image_layout_rect != Rectangle_.Empty)
                {
                    this.Owner.Renderer.DrawItemImage(new System.Windows.Forms.ToolStripItemImageRenderEventArgs(e.Graphics, this, draw_image, image_layout_rect));
                }

                return;
            }
        }
 public ToolStripRenderEventArgs(Graphics g, ToolStrip toolStrip, Rectangle_ affectedBounds, Color_ backColor)
 {
     this.graphics        = g;
     this.tool_strip      = toolStrip;
     this.affected_bounds = affectedBounds;
     this.back_color      = backColor;
 }
示例#5
0
        public SolidBrush(Color_ color)
        {
            this.color = color;
            Status status = GDIPlus.GdipCreateSolidFill(color.ToArgb(), out nativeObject);

            GDIPlus.CheckStatus(status);
        }
示例#6
0
 public StatusBarDrawItemEventArgs(Graphics g, Font font, Rectangle_ r,
                                   int itemId, DrawItemState itemState, StatusBarPanel panel,
                                   Color_ foreColor, Color_ backColor) : base(g, font, r,
                                                                              itemId, itemState)
 {
     this.panel = panel;
 }
示例#7
0
        internal static Color_ HBS2Color(int hue, int lum, int sat)
        {
            int R;
            int G;
            int B;
            int Magic1;
            int Magic2;

            if (sat == 0)                          /* Achromatic */
            {
                R = G = B = (lum * RGBMax) / HLSMax;
                // FIXME : Should throw exception if hue!=0
            }
            else
            {
                if (lum <= (HLSMax / 2))
                {
                    Magic2 = (lum * (HLSMax + sat) + (HLSMax / 2)) / HLSMax;
                }
                else
                {
                    Magic2 = sat + lum - ((sat * lum) + (HLSMax / 2)) / HLSMax;
                }
                Magic1 = 2 * lum - Magic2;

                R = Math.Min(255, (HueToRGB(Magic1, Magic2, hue + (HLSMax / 3)) * RGBMax + (HLSMax / 2)) / HLSMax);
                G = Math.Min(255, (HueToRGB(Magic1, Magic2, hue) * RGBMax + (HLSMax / 2)) / HLSMax);
                B = Math.Min(255, (HueToRGB(Magic1, Magic2, hue - (HLSMax / 3)) * RGBMax + (HLSMax / 2)) / HLSMax);
            }
            return(Color_.FromArgb(R, G, B));
        }
示例#8
0
        public static Color_ FromKnownColor(KnownColor kc)
        {
            Color_ c;
            short  n = (short)kc;

            if ((n <= 0) || (n >= ArgbValues.Length))
            {
                // This is what it returns!
                c = Color_.FromArgb(0, 0, 0, 0);
#if ONLY_1_1
                c.name = kc.ToString();
#endif
                c.state |= (short)Color_.ColorType.Named;
            }
            else
            {
                c       = new Color_();
                c.state = (short)(Color_.ColorType.ARGB | Color_.ColorType.Known | Color_.ColorType.Named);
                if ((n < 27) || (n > 169))
                {
                    c.state |= (short)Color_.ColorType.System;
                }
                c.Value = ArgbValues [n];
#if ONLY_1_1
                c.name = GetName(n);
#endif
            }
            c.knownColor = n;
            return(c);
        }
示例#9
0
        public ToolTip()
        {
            // Defaults from MS
            is_active       = true;
            automatic_delay = 500;
            autopop_delay   = 5000;
            initial_delay   = 500;
            re_show_delay   = 100;
            show_always     = false;
            back_color      = SystemColors.Info;
            fore_color      = SystemColors.InfoText;

            isBalloon       = false;
            stripAmpersands = false;
            useAnimation    = true;
            useFading       = true;
            tooltip_strings = new Hashtable(5);
            controls        = new ArrayList(5);

            tooltip_window             = new ToolTipWindow();
            tooltip_window.MouseLeave += new EventHandler(control_MouseLeave);
            tooltip_window.Draw       += new DrawToolTipEventHandler(tooltip_window_Draw);
            tooltip_window.Popup      += new PopupEventHandler(tooltip_window_Popup);

            // UIA Framework: Static event handlers
            tooltip_window.UnPopup += delegate(object sender, PopupEventArgs args) {
                OnUnPopup(args);
            };
            UnPopup += new PopupEventHandler(OnUIAUnPopup);

            timer         = new Timer();
            timer.Enabled = false;
            timer.Tick   += new EventHandler(timer_Tick);
        }
示例#10
0
        public DataGridTableStyle(bool isDefaultTableStyle)
        {
            is_default       = isDefaultTableStyle;
            allow_sorting    = true;
            datagrid         = null;
            header_forecolor = def_header_forecolor;
            mapping_name     = string.Empty;
            table_relations  = new ArrayList();
            column_styles    = new GridColumnStylesCollection(this);

            alternating_backcolor = def_alternating_backcolor;
            columnheaders_visible = true;
            gridline_color        = def_gridline_color;
            gridline_style        = DataGridLineStyle.Solid;
            header_backcolor      = def_header_backcolor;
            header_font           = null;
            link_color            = def_link_color;
            link_hovercolor       = def_link_hovercolor;
            preferredcolumn_width = ThemeEngine.Current.DataGridPreferredColumnWidth;
            preferredrow_height   = ThemeEngine.Current.DefaultFont.Height + 3;
            _readonly             = false;
            rowheaders_visible    = true;
            selection_backcolor   = def_selection_backcolor;
            selection_forecolor   = def_selection_forecolor;
            rowheaders_width      = 35;
            backcolor             = def_backcolor;
            forecolor             = def_forecolor;
        }
示例#11
0
 private Color_ ParseColor(string color)
 {
     if (color.IndexOf ("#") >= 0) {
         return Color_.FromArgb (int.Parse (color.Substring (color.IndexOf ("#") + 1), NumberStyles.HexNumber));
     }
     return Color_.FromName (color);
 }
        public void SetColorKey(Color_ colorLow, Color_ colorHigh, ColorAdjustType type)
        {
            Status status = GDIPlus.GdipSetImageAttributesColorKeys(nativeImageAttr, type, true,
                                                                    colorLow.ToArgb(), colorHigh.ToArgb());

            GDIPlus.CheckStatus(status);
        }
示例#13
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (this.Owner != null)
            {
                Color_ font_color = this.Enabled ? this.ForeColor : SystemColors.GrayText;
                Image  draw_image = this.Enabled ? this.Image : ToolStripRenderer.CreateDisabledImage(this.Image);

                this.Owner.Renderer.DrawSplitButton(new System.Windows.Forms.ToolStripItemRenderEventArgs(e.Graphics, this));

                Rectangle_ text_layout_rect;
                Rectangle_ image_layout_rect;

                Rectangle_ r = this.ContentRectangle;
                r.Width -= (this.drop_down_button_width + 1);

                this.CalculateTextAndImageRectangles(r, out text_layout_rect, out image_layout_rect);

                if (text_layout_rect != Rectangle_.Empty)
                {
                    this.Owner.Renderer.DrawItemText(new System.Windows.Forms.ToolStripItemTextRenderEventArgs(e.Graphics, this, this.Text, text_layout_rect, font_color, this.Font, this.TextAlign));
                }
                if (image_layout_rect != Rectangle_.Empty)
                {
                    this.Owner.Renderer.DrawItemImage(new System.Windows.Forms.ToolStripItemImageRenderEventArgs(e.Graphics, this, draw_image, image_layout_rect));
                }

                this.Owner.Renderer.DrawArrow(new ToolStripArrowRenderEventArgs(e.Graphics, this, new Rectangle_(this.Width - 9, 1, 6, this.Height), Color_.Black, ArrowDirection.Down));

                return;
            }
        }
示例#14
0
        public IResult Add(Color_ color)
        {
            //ValidationTool.Validate(new ColorValidator(), color);
            _colorDal.Add(color);

            return(new SuccessResult(Messages.ColorAdded));
        }
示例#15
0
        public virtual void DrawPopupPressedCheckBox(Graphics g, Rectangle_ bounds, Color_ backColor, Color_ foreColor, CheckState state)
        {
            Rectangle_ checkbox_rectangle;
            Rectangle_ fill_rectangle;

            // clip one pixel from bottom right for non popup rendered checkboxes
            checkbox_rectangle = new Rectangle_(bounds.X, bounds.Y, Math.Max(bounds.Width - 1, 0), Math.Max(bounds.Height - 1, 0));
            fill_rectangle     = new Rectangle_(checkbox_rectangle.X + 1, checkbox_rectangle.Y + 1, Math.Max(checkbox_rectangle.Width - 3, 0), Math.Max(checkbox_rectangle.Height - 3, 0));

            g.FillRectangle(ResPool.GetSolidBrush(backColor), fill_rectangle);

            // draw sunken effect
            ThemeEngine.Current.CPDrawBorder3D(g, checkbox_rectangle, Border3DStyle.SunkenInner, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, backColor);

            bounds.Offset(-1, 0);

            if (state == CheckState.Checked)
            {
                DrawCheck(g, bounds, Color_.Black);
            }
            else if (state == CheckState.Indeterminate)
            {
                DrawCheck(g, bounds, SystemColors.ControlDarkDark);
            }
        }
示例#16
0
 private static Color_ ColorFromGdkColor(GdkColorStruct gtkcolor)
 {
     return(Color_.FromArgb(255,
                            (gtkcolor.red >> 8) & 0xff,
                            (gtkcolor.green >> 8) & 0xff,
                            (gtkcolor.blue >> 8) & 0xff));
 }
示例#17
0
            private Image CreateImage(Image value, Color_ transparentColor)
            {
                int             imageWidth;
                int             imageHeight;
                ImageAttributes imageAttributes;

                if (transparentColor.A == 0)
                {
                    imageAttributes = null;
                }
                else
                {
                    imageAttributes = new ImageAttributes();
                    imageAttributes.SetColorKey(transparentColor, transparentColor);
                }

                var bitmap = new Bitmap(imageWidth = this.imageSize.Width, imageHeight = this.imageSize.Height, PixelFormat.Format32bppArgb);

                using (var graphics = Graphics.FromImage(bitmap))
                    graphics.DrawImage(value, new Rectangle_(0, 0, imageWidth, imageHeight), 0, 0, value.Width, value.Height, GraphicsUnit.Pixel, imageAttributes);

                if (imageAttributes != null)
                {
                    imageAttributes.Dispose();
                }

                ReduceColorDepth(bitmap);
                return(bitmap);
            }
示例#18
0
 public static void DrawText(Graphics g, string text, Font font, Color_ color, float x, float y, bool showNonPrint)
 {
     if (!use_textrenderer)
     {
         if (showNonPrint)
         {
             g.DrawString(text, font, ThemeEngine.Current.ResPool.GetSolidBrush(color), x, y, sf_nonprinting);
         }
         else
         {
             g.DrawString(text, font, ThemeEngine.Current.ResPool.GetSolidBrush(color), x, y, sf_printing);
         }
     }
     else
     {
         if (showNonPrint)
         {
             TextRenderer.DrawTextInternal(g, text, font, new Rectangle_(new Point_((int)x, (int)y), max_size), color, TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix, false);
         }
         else
         {
             TextRenderer.DrawTextInternal(g, text, font, new Rectangle_(new Point_((int)x, (int)y), max_size), color, TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix, false);
         }
     }
 }
示例#19
0
 public DataGridViewLinkCell()
 {
     activeLinkColor    = Color_.Red;
     linkColor          = Color_.FromArgb(0, 0, 255);
     trackVisitedState  = true;
     visited_link_color = Color_.FromArgb(128, 0, 128);
 }
示例#20
0
        public LinearGradientBrush(RectangleF_ rect, Color_ color1, Color_ color2, float angle, bool isAngleScaleable)
        {
            Status status = GDIPlus.GdipCreateLineBrushFromRectWithAngle(ref rect, color1.ToArgb(), color2.ToArgb(), angle, isAngleScaleable, WrapMode.Tile, out nativeObject);

            GDIPlus.CheckStatus(status);

            rectangle = rect;
        }
示例#21
0
        public LinearGradientBrush(RectangleF_ rect, Color_ color1, Color_ color2, LinearGradientMode linearGradientMode)
        {
            Status status = GDIPlus.GdipCreateLineBrushFromRect(ref rect, color1.ToArgb(), color2.ToArgb(), linearGradientMode, WrapMode.Tile, out nativeObject);

            GDIPlus.CheckStatus(status);

            rectangle = rect;
        }
示例#22
0
            protected override void OnSelectedIndexChanged(EventArgs e)
            {
                ColorComboBoxItem ccbi = Items[SelectedIndex] as ColorComboBoxItem;

                selectedColor = ccbi.Color;

                fontDialog.Color = selectedColor;
            }
示例#23
0
 public SwitchCheckBox()
 {
     AutoCheck      = true;
     ThumbColor     = Color.WhiteSmoke;
     UncheckedColor = Color_.FromArgb(0xFF808080);
     CheckedColor   = Color_.FromArgb(0xFF1C76FF);
     Padding        = new Padding(3);
 }
示例#24
0
        private static Color_ ChangeIntensity(Color_ baseColor, float percent)
        {
            int H, I, S;

            ControlPaint.Color2HBS(baseColor, out H, out I, out S);
            int NewIntensity = Math.Min(255, (int)(I * percent));

            return(ControlPaint.HBS2Color(H, NewIntensity, S));
        }
示例#25
0
        internal SolidBrush(IntPtr ptr)
            : base(ptr)
        {
            int    val;
            Status status = GDIPlus.GdipGetSolidFillColor(ptr, out val);

            GDIPlus.CheckStatus(status);
            color = Color_.FromArgb(val);
        }
示例#26
0
        public virtual void DrawDisabledCheckBox(Graphics g, Rectangle_ bounds, Color_ backColor, Color_ foreColor, CheckState state)
        {
            DrawPressedCheckBox(g, bounds, backColor, foreColor, CheckState.Unchecked);

            if (state == CheckState.Checked || state == CheckState.Indeterminate)
            {
                DrawCheck(g, bounds, SystemColors.ControlDark);
            }
        }
 public ToolStripArrowRenderEventArgs(Graphics g, ToolStripItem toolStripItem, Rectangle_ arrowRectangle, Color_ arrowColor, ArrowDirection arrowDirection)
     : base()
 {
     this.graphics        = g;
     this.tool_strip_item = toolStripItem;
     this.arrow_rectangle = arrowRectangle;
     this.arrow_color     = arrowColor;
     this.arrow_direction = arrowDirection;
 }
示例#28
0
        public LinearGradientBrush(PointF_ point1, PointF_ point2, Color_ color1, Color_ color2)
        {
            Status status = GDIPlus.GdipCreateLineBrush(ref point1, ref point2, color1.ToArgb(), color2.ToArgb(), WrapMode.Tile, out nativeObject);

            GDIPlus.CheckStatus(status);

            status = GDIPlus.GdipGetLineRect(nativeObject, out rectangle);
            GDIPlus.CheckStatus(status);
        }
示例#29
0
 public static void DrawBorder(Graphics graphics, Rectangle_ bounds, Color_ leftColor, int leftWidth,
                               ButtonBorderStyle leftStyle, Color_ topColor, int topWidth, ButtonBorderStyle topStyle,
                               Color_ rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color_ bottomColor, int bottomWidth,
                               ButtonBorderStyle bottomStyle)
 {
     ThemeEngine.Current.CPDrawBorder(graphics, bounds, leftColor, leftWidth,
                                      leftStyle, topColor, topWidth, topStyle, rightColor, rightWidth, rightStyle,
                                      bottomColor, bottomWidth, bottomStyle);
 }
示例#30
0
 public virtual void ApplyStyle(DataGridViewCellStyle dataGridViewCellStyle)
 {
     // We should only apply the new style if it is 'set'.
     if (dataGridViewCellStyle.alignment != DataGridViewContentAlignment.NotSet)
     {
         this.alignment = dataGridViewCellStyle.alignment;
     }
     if (dataGridViewCellStyle.backColor != Color_.Empty)
     {
         this.backColor = dataGridViewCellStyle.backColor;
     }
     if (dataGridViewCellStyle.dataSourceNullValue != DBNull.Value)
     {
         this.dataSourceNullValue = dataGridViewCellStyle.dataSourceNullValue;
     }
     if (dataGridViewCellStyle.font != null)
     {
         this.font = dataGridViewCellStyle.font;
     }
     if (dataGridViewCellStyle.foreColor != Color_.Empty)
     {
         this.foreColor = dataGridViewCellStyle.foreColor;
     }
     if (dataGridViewCellStyle.format != string.Empty)
     {
         this.format = dataGridViewCellStyle.format;
     }
     if (dataGridViewCellStyle.formatProvider != null)
     {
         this.formatProvider = dataGridViewCellStyle.formatProvider;
     }
     if (dataGridViewCellStyle.nullValue != null)
     {
         this.nullValue = dataGridViewCellStyle.nullValue;
     }
     if (dataGridViewCellStyle.padding != Padding.Empty)
     {
         this.padding = dataGridViewCellStyle.padding;
     }
     if (dataGridViewCellStyle.selectionBackColor != Color_.Empty)
     {
         this.selectionBackColor = dataGridViewCellStyle.selectionBackColor;
     }
     if (dataGridViewCellStyle.selectionForeColor != Color_.Empty)
     {
         this.selectionForeColor = dataGridViewCellStyle.selectionForeColor;
     }
     if (dataGridViewCellStyle.tag != null)
     {
         this.tag = dataGridViewCellStyle.tag;
     }
     if (dataGridViewCellStyle.wrapMode != DataGridViewTriState.NotSet)
     {
         this.wrapMode = dataGridViewCellStyle.wrapMode;
     }
 }