示例#1
0
        private Image GenerateBuildingImage()
        {
            Bitmap bmp = new Bitmap(base.Width, base.Height);

            using (Graphics g = Graphics.FromImage(bmp))
            {
                g.DrawImage(World.Biome[BiomeID].Terrain, 0, 0, base.Width, base.Height);

                string buildingName = BuildingName;

                if (BuildingID == 0)
                {
                    if (World.Region[RegionID].Type == RegionType.Capital)
                    {
                        buildingName = "Capital Pallace";
                    }
                    else
                    {
                        buildingName = "City Pallace";
                    }
                }

                if (BuildingID == 0)
                {
                    g.DrawImage(DrawingPlus.LoadImage(NarivianClass.AssetsDirectory + World.AssetsPack + "\\Buildings\\" + World.Culture[CultureID].Name + "\\Small\\" + buildingName + ".PNG"), 0, 0, base.Width, base.Height);
                }
                else
                {
                    g.DrawImage(World.Building[BuildingID].Icon[CultureID], 0, 0, base.Width, base.Height);
                }
            }

            return((Image)bmp);
        }
示例#2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);
            Rectangle r = new Rectangle(0, 0, Width, Height);
            Graphics  g = e.Graphics;

            DrawingPlus.DrawPanel(g, r, BackColor, 2);

            // Text Formatting
            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            StringFormat sf   = new StringFormat();
            Int32        lNum = (Int32)Math.Log((Double)TitleTextAlign, 2);

            sf.LineAlignment = (StringAlignment)(lNum / 4);
            sf.Alignment     = (StringAlignment)(lNum % 4);

            // Text Shadow
            if (ShadowColor != Color.Transparent)
            {
                g.DrawString(TitleText, Font, new SolidBrush(ShadowColor),
                             new Rectangle(1, 1, Width, Height), sf);
            }

            // Text
            g.DrawString(TitleText, Font, new SolidBrush(ForeColor), ClientRectangle, sf);
        }
示例#3
0
        public static void DrawPanel(Graphics g, Rectangle area, Color color, int borderSize)
        {
            // Border
            g.FillRectangle(new SolidBrush(DrawingPlus.DarkenColor(color, 64)), area);

            // Base
            area = new Rectangle(area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2);
            g.FillRectangle(new SolidBrush(color), area);

            // Top
            g.FillRectangle(new SolidBrush(DrawingPlus.DarkenColor(color, -24)),
                            new Rectangle(area.X, area.Y, area.Width, borderSize));

            // Left
            g.FillRectangle(new SolidBrush(DrawingPlus.DarkenColor(color, -24)),
                            new Rectangle(area.X, area.Y, borderSize, area.Height));

            // Bottom
            g.FillRectangle(new SolidBrush(DrawingPlus.DarkenColor(color, 24)),
                            new Rectangle(area.X, area.Y + area.Height - borderSize, area.Width, borderSize));

            // Right
            g.FillRectangle(new SolidBrush(DrawingPlus.DarkenColor(color, 24)),
                            new Rectangle(area.X + area.Width - borderSize, area.Y + borderSize, borderSize, area.Height - borderSize));
        }
示例#4
0
        protected override void OnPaint(PaintEventArgs p)
        {
            Graphics     g  = p.Graphics;
            Font         f  = new Font(Font.FontFamily, Height / 3, Font.Style);
            Brush        fb = new SolidBrush(ForeColor);
            Brush        sb;
            Rectangle    r  = new Rectangle(0, 0, Width, Height);
            StringFormat sf = new StringFormat()
            {
                Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
            };

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            if (Enabled == false)
            {
                fb = new SolidBrush(ColorTranslator.FromHtml("#A0A0A0"));
            }

            int brdSize;

            if (AutoSizeBorder)
            {
                brdSize = Math.Max(Math.Min(8, Height / 8), 4);
                if (brdSize % 2 != 0)
                {
                    brdSize -= 1;
                }
            }
            else
            {
                brdSize = BorderSize;
            }

            int fillWidth = (Width - brdSize * 2) * Value / 100;

            if (Value < 50)
            {
                fb = new SolidBrush(FillColor);
                sb = new SolidBrush(BackColor);
            }
            else
            {
                fb = new SolidBrush(BackColor);
                sb = new SolidBrush(FillColor);
            }

            DrawingPlus.DrawBorder(g, r, BorderColor, brdSize);
            if (fillWidth > 0)
            {
                DrawingPlus.DrawPanel(g, new Rectangle(brdSize, brdSize, fillWidth, Height - brdSize * 2), FillColor, 2);
            }
            if (fillWidth < Width - brdSize * 2)
            {
                DrawingPlus.DrawPanel(g, new Rectangle(brdSize + fillWidth, brdSize, Width - brdSize * 2 - fillWidth, Height - brdSize * 2), BackColor, 2);
            }

            g.DrawString(Value + "%", f, sb, new Rectangle(1, 1, Width, Height), sf);
            g.DrawString(Value + "%", f, fb, r, sf);
        }
示例#5
0
        public RegionBar()
        {
            Size = new System.Drawing.Size(240, 36);

            InitializeComponent();
            AddControls();

            lblRegionName.Image = DrawingPlus.LoadImage(NarivianClass.PanelsDirectory + "Region Name.PNG");
        }
示例#6
0
        public frmRecruit(frmGame frmGame)
        {
            InitializeComponent();
            this.frmGame = frmGame;

            unitCard.BackColor = frmGame.World.Faction[frmGame.Player].Color;

            pbMoney.Image = DrawingPlus.LoadImage(NarivianClass.IconsDirectory + "Money.PNG");
            lblMoney.Text = frmGame.World.Faction[frmGame.Player].Money + " gold";

            SelectUnit(1);
        }
示例#7
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle r = new Rectangle(10, 10, 50, 50);
            Graphics  g = e.Graphics;

            //base.OnPaint(e);

            if (FullScreen == false)
            {
                DrawingPlus.DrawBorder(g, ClientRectangle, BorderColor, BorderSize);
            }
        }
示例#8
0
        private void cmbFaction_SelectedIndexChanged(object sender, EventArgs e)
        {
            int fct = cmbFaction.SelectedIndex + 1;

            pbFaction.Image = DrawingPlus.ResizeImage(world.Faction[fct].Symbol,
                                                      pbFaction.Width, pbFaction.Height);

            lblFactionDescription.Text = world.Faction[fct].Description;
            lblAbilityDetails.Text     = GetAbilityDetails(world.Faction[fct].Ability);

            pbMap.Image = GetFactionPreview(fct);
        }
示例#9
0
        public static void DrawBorder(Graphics g, Rectangle area, Color color, int size)
        {
            if (size % 2 != 0)
            {
                size -= 1;
            }
            if (size < 2)
            {
                size = 2;
            }

            size -= 2;

            int b2size = 1;

            if (size == 0)
            {
                b2size = 0;
                size  += 2;
            }

            g.FillRectangles(new SolidBrush(DrawingPlus.DarkenColor(color, 64)), new Rectangle[]
            {
                new Rectangle(area.X, area.Y, area.Width, b2size),
                new Rectangle(area.X, area.Y + b2size + size, area.Width, b2size),

                new Rectangle(area.X, area.Y, b2size, area.Height),
                new Rectangle(area.X + b2size + size, area.Y, b2size, area.Height),

                new Rectangle(area.X, area.Y + area.Height - b2size, area.Width, b2size),
                new Rectangle(area.X, area.Y + area.Height - b2size * 2 - size, area.Width, b2size),

                new Rectangle(area.X + area.Width - b2size, area.Y, b2size, area.Height),
                new Rectangle(area.X + area.Width - b2size * 2 - size, area.Y, b2size, area.Height)
            });

            g.FillRectangles(new SolidBrush(DrawingPlus.DarkenColor(color, -24)), new Rectangle[]
            {
                new Rectangle(area.X + b2size, area.Y + b2size, area.Width - b2size * 2, size / 2),
                new Rectangle(area.X + b2size, area.Y + b2size, size / 2, area.Height - b2size * 2),
                new Rectangle(area.X + b2size, area.Y + area.Height - b2size - size, area.Width - b2size * 2, size / 2),
                new Rectangle(area.X + area.Width - b2size - size, area.Y + b2size, size / 2, area.Height - b2size * 2 - size),
            });

            g.FillRectangles(new SolidBrush(DrawingPlus.DarkenColor(color, 24)), new Rectangle[]
            {
                new Rectangle(area.X + b2size + size / 2, area.Y + b2size + size / 2, area.Width - b2size * 2 - size / 2, size / 2),
                new Rectangle(area.X + b2size + size / 2, area.Y + b2size + size / 2, size / 2, area.Height - b2size * 2 - size / 2),
                new Rectangle(area.X + b2size + size / 2, area.Y + area.Height - b2size - size / 2, area.Width - b2size * 2 - size / 2, size / 2),
                new Rectangle(area.X + area.Width - b2size - size / 2, area.Y + 1 + size / 2, size / 2, area.Height - b2size * 2 - size / 2)
            });
        }
示例#10
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics  g = e.Graphics;
            Rectangle r = new Rectangle(0, (base.Size.Height - 16) / 2, 16, 16);
            Image     img;
            Brush     fb;
            int       dotSize = 5;

            g.SmoothingMode = SmoothingMode.AntiAlias;

            if (Enabled)
            {
                fb = new SolidBrush(ForeColor);
            }
            else
            {
                fb = new SolidBrush(ColorTranslator.FromHtml("#A0A0A0"));
            }

            base.OnPaint(e);

            if (Selected == false)
            {
                if (Clicked == false)
                {
                    img = DrawingPlus.LoadImage(NarivianClass.PanelsDirectory + "RadioButton\\Idle.PNG", false);
                }
                else
                {
                    img = DrawingPlus.LoadImage(NarivianClass.PanelsDirectory + "RadioButton\\Clicked.PNG", false);
                }
            }
            else
            {
                img = DrawingPlus.LoadImage(NarivianClass.PanelsDirectory + "RadioButton\\Selected.PNG", false);
            }

            if (img != null)
            {
                g.DrawImage(img, r);
            }
            else
            {
                g.FillEllipse(new SolidBrush(BoxColor), r);
            }

            if (Checked)
            {
                g.FillEllipse(fb, new Rectangle(
                                  r.X + (r.Width - dotSize) / 2, r.Y + (r.Height - dotSize) / 2, dotSize, dotSize));
            }
        }
示例#11
0
        public Notice()
        {
            InitializeComponent();
            InitializeStyles();
            InitializeButtons();
            InitializeDrag();

            BackgroundImage = DrawingPlus.LoadImage(NarivianClass.NoticesDirectory + "Background.PNG");
            Cursor          = CustomCursor.Load("Default.CUR");

            Sound.Play("Notice\\Notice.MP3");

            BringToFront();
        }
示例#12
0
        public static DialogResult Show(string msg, string title, string imageSound)
        {
            Me = new Notice();

            Me.pbImage.Image = DrawingPlus.LoadImage(NarivianClass.NoticesDirectory + imageSound + ".PNG");

            Me.lblMessage.Text = msg;
            Me.lblTitle.Text   = title;

            Sound.Play("Notice\\" + imageSound + ".MP3");

            Me.ShowDialog();

            return(dialogResult);
        }
示例#13
0
        public static void DrawBilinearHorizontalGradient(Graphics g, Rectangle area, Color color, float strength, bool flip = false)
        {
            Color color2            = DrawingPlus.DarkenColor(color, (int)(area.Height * strength));
            Point pt1               = new Point(area.X, area.Y);
            Point pt2               = new Point(area.X, area.Y + area.Height / 2);
            LinearGradientBrush grd = new LinearGradientBrush(pt2, pt1, color, color2);

            if (flip == true)
            {
                grd = new LinearGradientBrush(pt1, pt2, color, color2);
            }

            grd.WrapMode = WrapMode.TileFlipXY;
            g.FillRectangle(grd, area);
        }
示例#14
0
        void CustomComboBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }

            ComboBox cb = (ComboBox)sender;
            Graphics g  = e.Graphics;
            Color    clrText;
            Color    clrHighlight;
            Color    clrShadow;

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                clrHighlight = ForeColor;
                clrText      = BackColor;
                clrShadow    = Color.Transparent;
            }
            else
            {
                clrHighlight = BackColor;

                if (Enabled)
                {
                    clrText = ForeColor;
                }
                else
                {
                    clrText = ColorTranslator.FromHtml("#A0A0A0");
                }

                clrShadow = ShadowColor;
            }

            DrawingPlus.DrawBilinearHorizontalGradient(g, e.Bounds, clrHighlight, 3);
            if (clrShadow != Color.Transparent)
            {
                g.DrawString(cb.Items[e.Index].ToString(), e.Font, new SolidBrush(ShadowColor),
                             new Point(e.Bounds.X - 1, e.Bounds.Y + 1));
            }

            g.DrawString(cb.Items[e.Index].ToString(), e.Font, new SolidBrush(clrText), new Point(e.Bounds.X, e.Bounds.Y));

            e.DrawFocusRectangle();
        }
示例#15
0
        public frmBuild(frmGame frmGame)
        {
            InitializeComponent();
            this.frmGame = frmGame;

            BuildingID = -1;
            RegionID   = frmGame.selectedRegion;

            World world = frmGame.World;

            pbMoney.Image  = DrawingPlus.LoadImage(NarivianClass.IconsDirectory + "Money.PNG");
            pbMoney2.Image = pbMoney.Image;

            lblMoney.Text = frmGame.World.Faction[frmGame.Player].Money.ToString();

            UpdateBuildingList();
        }
示例#16
0
        protected override void OnPaint(PaintEventArgs p)
        {
            Graphics  g = p.Graphics;
            Rectangle r = new Rectangle(0, (base.Size.Height - 16) / 2, 16, 16);
            Brush     fb;
            Color     bg;

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            if (Enabled)
            {
                fb = new SolidBrush(ForeColor);
            }
            else
            {
                fb = new SolidBrush(ColorTranslator.FromHtml("#A0A0A0"));
            }

            base.OnPaint(p);

            if (Clicked)
            {
                bg = DrawingPlus.DarkenColor(BoxColor, -32);
            }
            else if (Selected)
            {
                bg = DrawingPlus.DarkenColor(BoxColor, -16);
            }
            else
            {
                bg = BoxColor;
            }

            DrawingPlus.DrawBorder(g, r, BorderColor, 4);
            DrawingPlus.DrawPanel(g, new Rectangle(r.X + 4, r.Y + 4, r.X + r.Width - 8, r.Height - 8), bg, 2);

            if (this.Checked)
            {
                g.DrawString("✔", new Font("Lucida Console", 7), fb, r, new StringFormat()
                {
                    Alignment     = StringAlignment.Center,
                    LineAlignment = StringAlignment.Center
                });
            }
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics  g = e.Graphics;
            Brush     fb;
            Rectangle recBody     = new Rectangle(Height, 0, Width - Height, Height);
            Rectangle recBuilding = new Rectangle(0, 0, Height, Height);

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            if (Enabled)
            {
                fb = new SolidBrush(ForeColor);
            }
            else
            {
                fb = new SolidBrush(ColorTranslator.FromHtml("#A0A0A0"));
            }

            if (Selected == false)
            {
                g.FillRectangle(new SolidBrush(BackColor), recBody);
                g.FillRectangle(Brushes.DarkRed, recBuilding);
            }
            else
            {
                DrawingPlus.DrawBilinearHorizontalGradient(g, recBody, BackColor, -1);
                DrawingPlus.DrawBilinearHorizontalGradient(g, recBuilding, Color.DarkRed, -1);
            }

            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.DrawImage(Building.Icon[CultureID], new Rectangle(0, 4, 32, 25));

            StringFormat sf = new StringFormat();

            sf.LineAlignment = StringAlignment.Center;

            g.DrawString(Text, Font, new SolidBrush(ShadowColor),
                         new Rectangle(recBody.X + 1, recBody.Y + 1, recBody.Width, recBody.Height), sf);
            g.DrawString(Text, Font, fb, recBody, sf);
        }
示例#18
0
        private void OnDraw(object sender, DrawToolTipEventArgs e)
        {
            Graphics g               = e.Graphics;
            Color    clrFaction      = Faction.Color;
            int      titleTextSpacer = 1;
            int      borderSize      = 1;

            Rectangle r      = new Rectangle(1, 1, e.Bounds.Width - 2, e.Bounds.Height - 2);
            Rectangle rTitle = new Rectangle(r.X, r.Y, r.Width, 16);
            Rectangle rBody  = new Rectangle(r.X, r.Y + rTitle.Height + borderSize, r.Width, r.Height - rTitle.Height - borderSize);

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            g.Clear(Color.Black);

            // Header
            DrawingPlus.DrawBilinearHorizontalGradient(g, rTitle, clrFaction, 2);

            // Body
            g.FillRectangle(new LinearGradientBrush(e.Bounds, clrFaction, Color.White, 45f), rBody);

            // Faction Symbol
            g.DrawImage(DrawingPlus.ResizeImage(Faction.Symbol, 39, 39),
                        new Point(1, rBody.Y + (rBody.Height - 39) / 2));

            // Resource Icon
            if (Region.Resource != 0)
            {
                g.DrawImage((DrawingPlus.ResizeImage(Resource.Icon, 16, 16)),
                            new Point(titleTextSpacer, 1));

                titleTextSpacer += 17;
            }

            // Religion Icon
            if (Region.DominantReligion != 0)
            {
                g.DrawImage((DrawingPlus.ResizeImage(Religion.Icon, 16, 16)),
                            new Point(titleTextSpacer, 1));

                titleTextSpacer += 17;
            }

            // Capital Icon
            if (Region.Type == RegionType.Capital)
            {
                Image imgCapital;

                if (Region.State == RegionState.Free)
                {
                    imgCapital = DrawingPlus.ResizeImage(DrawingPlus.LoadImage(NarivianClass.IconsDirectory + "Capital.PNG"), 16, 16);
                }
                else
                {
                    imgCapital = DrawingPlus.ResizeImage(DrawingPlus.LoadImage(NarivianClass.IconsDirectory + "Capital Other.PNG"), 16, 16);
                }

                g.DrawImage(imgCapital, new Point(e.Bounds.Width - 17, 1));
            }

            // Title
            g.DrawString(Region.Name, new Font("Microsoft Sans Serif", 10, FontStyle.Bold),
                         Brushes.Black, new Point(rTitle.X + titleTextSpacer, rTitle.Y));

            // Message
            g.DrawString(e.ToolTipText, new Font("Microsoft Sans Serif", 8),
                         Brushes.Black, new PointF(40, rBody.Y + 2));

            // Border
            //g.DrawRectangle(new Pen(Color.Black, borderSize * 2), new Rectangle(
            //e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1));
            //g.DrawLine(new Pen(Color.Black, borderSize), new Point(0, 17), new Point(e.Bounds.Width, 17));
        }
示例#19
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics  g = e.Graphics;
            Brush     fb;
            Rectangle recBody = new Rectangle(Width / 4, 0, Width - Width / 4, Height);
            Rectangle recMap  = new Rectangle(0, 0, Width / 4, Height);

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            if (Enabled)
            {
                fb = new SolidBrush(ForeColor);
            }
            else
            {
                fb = new SolidBrush(ColorTranslator.FromHtml("#A0A0A0"));
            }

            if (Selected == false)
            {
                g.FillRectangle(new SolidBrush(BackColor), recBody);
                g.FillRectangle(Brushes.DarkRed, recMap);
            }
            else
            {
                DrawingPlus.DrawBilinearHorizontalGradient(g, recBody, BackColor, -1);
                DrawingPlus.DrawBilinearHorizontalGradient(g, recMap, Color.DarkRed, -1);
            }

            // Status icon
            g.SmoothingMode = SmoothingMode.AntiAlias;
            Image imgStatus;

            if (Installed)
            {
                if (UpToDate)
                {
                    imgStatus = Properties.Resources.Success;
                }
                else
                {
                    imgStatus = Properties.Resources.Warning;
                }
            }
            else
            {
                imgStatus = Properties.Resources.Error;
            }
            g.DrawImage(imgStatus, new Rectangle(Width - Height, 0, Height, Height));

            StringFormat sf = new StringFormat();

            sf.LineAlignment = StringAlignment.Center;

            // Map Name
            g.DrawString(MapDisplayName + " (v" + MapVersion + ")", Font, new SolidBrush(ShadowColor),
                         new Rectangle(recMap.X + 1, recMap.Y + 1, recMap.Width, recMap.Height), sf);
            g.DrawString(MapDisplayName + " (v" + MapVersion + ")", Font, fb, recMap, sf);

            // Map Description
            g.DrawString(MapDescription, Font, new SolidBrush(ShadowColor),
                         new Rectangle(recBody.X + 1, recBody.Y + 1, recBody.Width, recBody.Height), sf);
            g.DrawString(MapDescription, Font, fb, recBody, sf);
        }
示例#20
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Size     titleSize;
            Point    titlePosition;
            Color    bg;
            Brush    fb;
            int      borderSize = 4;

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            if (Enabled)
            {
                fb = new SolidBrush(ForeColor);
            }
            else
            {
                fb = new SolidBrush(ColorTranslator.FromHtml("#A0A0A0"));
            }

            if (BackColor != Color.Transparent)
            {
                bg = BackColor;
            }
            else
            if (Parent.GetType() == typeof(CustomGroupBox))
            {
                bg = Color.Transparent;
            }
            else
            {
                bg = Color.FromArgb(31, Color.Black);
            }

            g.FillRectangle(new SolidBrush(bg), new Rectangle(borderSize, borderSize, Width - borderSize * 2, Height - borderSize * 2));
            DrawingPlus.DrawBorder(g, ClientRectangle, BorderColor, borderSize);

            titleSize        = new Size();
            titleSize.Width  = (int)g.MeasureString(Text, Font).Width + 2 + borderSize;
            titleSize.Height = (int)g.MeasureString(Text, Font).Height + 2;

            switch (TextPosition)
            {
            case CustomGroupBoxTextPosition.Left:
                titlePosition = new Point(0, 0);
                break;

            case CustomGroupBoxTextPosition.Center:
                titlePosition = new Point((Width - titleSize.Width) / 2, 0);
                break;

            case CustomGroupBoxTextPosition.Right:
                titlePosition = new Point(Width - titleSize.Width, 0);
                break;

            default:
                goto case CustomGroupBoxTextPosition.Left;
            }

            DrawingPlus.DrawPanel(g,
                                  new Rectangle(titlePosition.X, titlePosition.Y, titleSize.Width, titleSize.Height),
                                  BorderColor, borderSize - 2);

            if (ShadowColor != Color.Transparent)
            {
                g.DrawString(Text, Font, new SolidBrush(ShadowColor),
                             new Point(titlePosition.X + borderSize + 1, 0));
            }
            g.DrawString(Text, Font, fb,
                         new Point(titlePosition.X + borderSize, 0));
        }
示例#21
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics     g  = e.Graphics;
            Font         f  = new Font(Font.FontFamily, Height / 3, Font.Style);
            Brush        fb = new SolidBrush(ForeColor);
            Brush        sb = new SolidBrush(ForeColor);
            Rectangle    r  = new Rectangle(0, 0, Width, Height);
            StringFormat sf = new StringFormat()
            {
                Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
            };
            Color bg;

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            if (Enabled == false)
            {
                fb = new SolidBrush(ColorTranslator.FromHtml("#A0A0A0"));
            }

            int brdSize;

            if (AutoSizeBorder)
            {
                brdSize = Math.Max(Math.Min(8, Height / 8), 4);
                if (brdSize % 2 != 0)
                {
                    brdSize -= 1;
                }
            }
            else
            {
                brdSize = BorderSize;
            }

            if (Clicked)
            {
                bg = DrawingPlus.DarkenColor(BackColor, -32);
            }
            else if (Selected)
            {
                bg = DrawingPlus.DarkenColor(BackColor, -16);
            }
            else
            {
                bg = BackColor;
            }

            if (Clicked || Selected)
            {
                brdSize += 2;
            }

            DrawingPlus.DrawBorder(g, r, BorderColor, brdSize);
            DrawingPlus.DrawPanel(g, new Rectangle(brdSize, brdSize, Width - brdSize * 2, Height - brdSize * 2), bg, Math.Max(2, brdSize - 4));

            if (ShadowColor != Color.Transparent)
            {
                g.DrawString(Text, f, Brushes.Black,
                             new Rectangle(1, 1, Width, Height), sf);
            }
            g.DrawString(Text, f, fb, r, sf);
        }
示例#22
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);
            Graphics  g = e.Graphics;
            Rectangle rBrowse;
            Brush     fb = new SolidBrush(ForeColor);
            Color     bg;
            int       brdSize = BorderSize;

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            if (Enabled == false)
            {
                fb = new SolidBrush(ColorTranslator.FromHtml("#A0A0A0"));
            }

            if (Clicked)
            {
                bg = DrawingPlus.DarkenColor(BackColor, -32);
            }
            else if (Selected)
            {
                bg = DrawingPlus.DarkenColor(BackColor, -16);
            }
            else
            {
                bg = BackColor;
            }

            if (Clicked || Selected)
            {
                brdSize += 2;
            }

            rBrowse = new Rectangle(Width - Height + brdSize, brdSize, Height - brdSize * 2, Height - brdSize * 2);

            #region alternative design
            DrawingPlus.DrawBorder(g, new Rectangle(0, 0, Width - Height, Height), BorderColor, BorderSize);
            DrawingPlus.DrawPanel(g, new Rectangle(
                                      BorderSize, BorderSize, Width - Height - BorderSize * 2, Height - BorderSize * 2),
                                  BackColor, BorderSize - 2);

            DrawingPlus.DrawBorder(g, new Rectangle(Width - Height, 0, Height, Height), BorderColor, BorderSize);
            DrawingPlus.DrawPanel(g, new Rectangle(
                                      Width - Height + BorderSize, BorderSize,
                                      Height - BorderSize * 2, Height - borderSize * 2),
                                  BackColor, BorderSize - 2);
            #endregion

            DrawingPlus.DrawBorder(g, new Rectangle(0, 0, Width, Height), BorderColor, brdSize);
            DrawingPlus.DrawPanel(g, new Rectangle(brdSize, brdSize, Width - Height, Height - brdSize * 2), bg, Math.Max(2, brdSize - 4));
            DrawingPlus.DrawPanel(g, rBrowse, bg, Math.Max(2, brdSize - 4));

            StringFormat sf       = new StringFormat();
            StringFormat sfBrowse = new StringFormat();
            sf.LineAlignment       = StringAlignment.Center;
            sfBrowse.LineAlignment = StringAlignment.Center;
            sfBrowse.Alignment     = StringAlignment.Center;
            Font fBrowse = new Font(Font.FontFamily, (int)(Font.Size * 0.66));

            if (ShadowColor != Color.Transparent)
            {
                g.DrawString(Text, Font, Brushes.Black, new Rectangle(brdSize + 1, 1, Width, Height), sf);
                g.DrawString("▼", fBrowse, Brushes.Black, new Rectangle(rBrowse.X + 1, rBrowse.Y + 1, rBrowse.Width, rBrowse.Height), sfBrowse);
            }

            g.DrawString(Text, Font, fb, new Rectangle(brdSize, 0, Width, Height), sf);
            g.DrawString("▼", fBrowse, fb, rBrowse, sfBrowse);
        }