Пример #1
0
        protected virtual Bitmap CreateImage(Color colour)
        {
            int num;

            if (this.m_text == "Not Set")
            {
                return(null);
            }
            string path = Environment.GetEnvironmentVariable("TEMP") + @"\Aqua\";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string str2 = string.Concat(new object[] { path, this.cleanedName, this.width, "x", this.height, "_", colour.ToString(), "-", this.Font.Size, this.m_textColour.ToString(), ".Png" });

            if (File.Exists(str2))
            {
                return(new Bitmap(str2));
            }
            LayeredImage image = new LayeredImage(this.width, this.height);

            image.Layers.Add().Clear(this.CCC);
            if (this.dropshadow)
            {
                Layer layer2 = image.Layers.Add();
                image.ActiveLayer = layer2;
                image.BackColor   = Color.Black;
                image.Selection.SelectEllipse(this.margin, this.margin, this.buttonwidth, this.buttonheight, LFY.Controls.SelectionMode.Replace);
                image.Fill();
                Blur.ApplyTo(layer2.Bitmap, this.blurx, this.blury);
                layer2.OffsetX = this.shadowoffsetx;
                layer2.OffsetY = this.shadowoffsety;
                layer2.Opacity = this.shadowopacity;
            }
            Layer layer3 = image.Layers.Add();

            image.Selection.SelectEllipse(this.margin, this.margin, this.buttonwidth, this.buttonheight, LFY.Controls.SelectionMode.Replace);
            image.ActiveLayer = layer3;
            image.ForeColor   = this.bordercolor;
            image.BackColor   = Color.Black;
            image.Fill(this.borderfillx0, this.borderfilly0, this.borderfillx1, this.borderfilly1, FillType.Radial);
            image.Selection.SelectEllipse(this.buttoncolorx, this.buttoncolory, this.buttoncolorwidth, this.buttoncolorheight, LFY.Controls.SelectionMode.Replace);
            image.BackColor = colour;
            image.Fill();
            Layer layer4 = image.Layers.Add();

            image.ActiveLayer = layer4;
            image.Selection.SelectEllipse(this.buttoncolorx - 2, this.buttoncolory - 2, this.buttoncolorwidth + 4, this.buttoncolorheight + 4, LFY.Controls.SelectionMode.Replace);
            image.Selection.SelectEllipse(this.shadeleftx, this.shadelefty, this.shadeleftwidth, this.shadeleftheight, LFY.Controls.SelectionMode.Subtract);
            image.Selection.Feather(this.featherleft);
            image.BackColor = Color.Black;
            image.Fill();
            layer4.Opacity = this.shadeopacity;
            image.Selection.SelectEllipse(this.buttoncolorx - 2, this.buttoncolory - 2, this.buttoncolorwidth + 4, this.buttoncolorheight + 4, LFY.Controls.SelectionMode.Replace);
            image.Selection.SelectEllipse(this.shadetopx, this.shadetopy, this.shadetopwidth, this.shadetopheight, LFY.Controls.SelectionMode.Subtract);
            image.Selection.Feather(this.feathertop);
            image.Fill();
            FastBitmap bitmap   = new FastBitmap(this.width, this.height, PixelFormat.Format24bppRgb);
            Graphics   graphics = Graphics.FromImage(bitmap._bitmap);

            graphics.SmoothingMode = SmoothingMode.AntiAlias;
            SolidBrush brush  = new SolidBrush(Color.Black);
            SolidBrush brush2 = new SolidBrush(Color.White);

            graphics.FillRectangle(brush, 0, 0, this.width, this.height);
            graphics.FillEllipse(brush2, this.buttoncolorx, this.buttoncolory, this.buttoncolorwidth, this.buttoncolorheight);
            brush2.Dispose();
            brush.Dispose();
            graphics.Dispose();
            layer4.Mask = bitmap;
            Layer     layer5  = image.Layers.Add();
            FontStyle regular = FontStyle.Regular;

            for (num = 0; num < this.fontstyle.Length; num++)
            {
                char ch = this.fontstyle[num];
                if (ch != 'b')
                {
                    switch (ch)
                    {
                    case 'r':
                    {
                        regular = regular;
                        continue;
                    }

                    case 's':
                    {
                        regular |= FontStyle.Strikeout;
                        continue;
                    }

                    case 't':
                    {
                        continue;
                    }

                    case 'u':
                    {
                        regular |= FontStyle.Underline;
                        continue;
                    }

                    case 'i':
                        goto Label_047E;
                    }
                }
                else
                {
                    regular |= FontStyle.Bold;
                }
                continue;
Label_047E:
                regular |= FontStyle.Italic;
            }
            Font         font   = new Font(this.fontface, (float)this.fontsize, regular);
            StringFormat format = new StringFormat();

            format.Alignment     = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;
            format.Trimming      = StringTrimming.None;
            SolidBrush    brush3  = new SolidBrush(this.m_textColour);
            StringBuilder builder = new StringBuilder(this.m_text.Length);

            for (num = 0; num < this.m_text.Length; num++)
            {
                if (this.m_text[num] == '\\')
                {
                    if ((num + 1) < this.m_text.Length)
                    {
                        if (this.m_text[num + 1] == 'n')
                        {
                            builder.Append(Environment.NewLine);
                            num++;
                        }
                        else if (this.m_text[num + 1] == '\\')
                        {
                            builder.Append('\\');
                            num++;
                        }
                        else
                        {
                            builder.Append('\\');
                        }
                    }
                    else
                    {
                        builder.Append('\\');
                    }
                }
                else
                {
                    builder.Append(this.m_text[num]);
                }
            }
            layer5.DrawText(0, 0, this.width, this.height, builder.ToString(), base.Font, brush3, format);
            brush3.Dispose();
            font.Dispose();
            layer5.Opacity = 1.0 - this.texttrans;
            Layer layer6 = image.Layers.Add();

            image.ActiveLayer = layer6;
            image.ForeColor   = Color.White;
            image.BackColor   = Color.Transparent;
            image.Selection.SelectEllipse(this.highlightx, this.highlighty, this.highlightwidth, this.highlightheight, LFY.Controls.SelectionMode.Replace);
            image.Fill(0, this.highlightfilly0, 0, this.highlightfilly1, FillType.Linear);
            FastBitmap  bitmap2 = image.Flatten();
            ImageFormat png     = ImageFormat.Png;

            try
            {
                bitmap2.Save(str2, png);
            }
            catch (Exception)
            {
            }
            return(bitmap2._bitmap);
        }
Пример #2
0
 public void Feather(int radius)
 {
     Blur.ApplyTo(this._bitmap, radius, radius);
 }