protected override void OnPaint(PaintEventArgs e) { Bitmap b = new Bitmap(Width, Height); Graphics g = Graphics.FromImage(b); { //Draw Background { g.Clear(_BackColor); } //Draw Border { Pen p = new Pen(_BorderColor); g.DrawLine(p, new Point(2, 1), new Point(Width - 2, 1)); g.DrawLine(p, new Point(Width - 2, 2), new Point(Width - 2, Height - 2)); g.DrawLine(p, new Point(Width - 3, Height - 2), new Point(1, Height - 2)); g.DrawLine(p, new Point(1, Height - 3), new Point(1, 1)); } //Draw Text { //Draw Text SizeF size_of_NormalText; { Graphics gs = this.CreateGraphics(); size_of_NormalText = gs.MeasureString(_Text, _Font); gs.Dispose(); } g.DrawString(_Text, _Font, new SolidBrush(_NormalFontColor), new Point((Width - (int)size_of_NormalText.Width) / 2 + (_IsMouseDown ? 1 : 0), (Height - (int)size_of_NormalText.Height) / 2 + (_IsMouseDown ? 1 : 0))); //Draw TextCover { } } } g.Save(); g.Dispose(); if (_bG != null) { b = (Bitmap)ImageEx.ChangeImageOpacity(b, (_HoverOpacity - _NormalOpacity) * (CurrentOpacityPercent / 100.0) + _NormalOpacity); b = ImageEx.JoinMImage((Bitmap)_bG.Clone(), b, ClientRectangle); } //b = ImageEx.BrightnessP(b, -25); e.Graphics.DrawImage(b, new Point(0, 0)); b.Dispose(); base.OnPaint(e); }
private void SetShadeBackgroundImg(System.Windows.Forms.Control containerControl, Control shadeControl) { shadeControl.Visible = false; System.Drawing.Image bitmap; if (containerControl is Form) { bitmap = WinformControlEx.CreateFormImg(containerControl as Form); } else { bitmap = WinformControlEx.CreateControlImg(containerControl); } bitmap = ImageEx.ChangeImageOpacity(bitmap, 50); shadeControl.BackgroundImage = bitmap; shadeControl.Visible = true; }
protected override void OnPaint(PaintEventArgs e) { Bitmap b = new Bitmap(Width, Height); Graphics g = Graphics.FromImage(b); { //Draw Background { g.Clear(_BackColor); } //Draw Border { Pen p = new Pen(_BorderColor); g.DrawLine(p, new Point(2, 1), new Point(Width - 2, 1)); g.DrawLine(p, new Point(Width - 2, 2), new Point(Width - 2, Height - 2)); g.DrawLine(p, new Point(Width - 3, Height - 2), new Point(1, Height - 2)); g.DrawLine(p, new Point(1, Height - 3), new Point(1, 1)); } //Draw Image { if (_Image != null) { g.DrawImage(_Image, new Rectangle(2, 2, Width - 4, Height - 4)); } } } g.Save(); g.Dispose(); if (_bG != null) { b = (Bitmap)ImageEx.ChangeImageOpacity(b, (_HoverOpacity - _NormalOpacity) * (CurrentOpacityPercent / 100.0) + _NormalOpacity); b = ImageEx.JoinMImage((Bitmap)_bG.Clone(), b, ClientRectangle); } //b = ImageEx.BrightnessP(b, -25); e.Graphics.DrawImage(b, new Point(0, 0)); b.Dispose(); base.OnPaint(e); }
protected override void OnPaint(PaintEventArgs e) { Bitmap b = new Bitmap(Width, Height); Graphics g = Graphics.FromImage(b); { //if (_BG != null) // g.DrawImage(_BG, new Point(0, 0)); Size Bar_Size = new Size(12, Height); //Draw BackGround { g.Clear(_BackColor); g.FillRectangle( new SolidBrush(Color.FromArgb((int)(255 * (CurrentTransPercent / 100.0)), _SwitchedColor)), new Rectangle(2, 2, (int)((Width - Bar_Size.Width) * (CurrentTransPercent / 100.0)) - 2, Height - 4)); } //Draw Border { Pen p = new Pen(_BorderColor); g.DrawLine(p, new Point(2, 1), new Point(Width - 2, 1)); g.DrawLine(p, new Point(Width - 2, 2), new Point(Width - 2, Height - 2)); g.DrawLine(p, new Point(Width - 3, Height - 2), new Point(1, Height - 2)); g.DrawLine(p, new Point(1, Height - 3), new Point(1, 1)); } //Draw HighLight Border if (IsMouseIn) { Pen p = new Pen(_HoverBorderColor); g.DrawLine(p, new Point(0, 0), new Point(Width, 0)); g.DrawLine(p, new Point(Width - 1, 0), new Point(Width - 1, Height - 1)); g.DrawLine(p, new Point(Width - 1, Height - 1), new Point(0, Height - 1)); g.DrawLine(p, new Point(0, Height), new Point(0, 0)); } //Draw SwitchBar { Bitmap b_Bar = new Bitmap(Bar_Size.Width, Bar_Size.Height); Graphics g_Bar = Graphics.FromImage(b_Bar); //SwitchBar BackGround g_Bar.Clear(_SwitchBarColor); //SwitchBar Border Pen p = new Pen(_BorderColor); g_Bar.DrawLine(p, new Point(0, 0), new Point(Bar_Size.Width, 0)); g_Bar.DrawLine(p, new Point(Bar_Size.Width - 1, 0), new Point(Bar_Size.Width - 1, Bar_Size.Height - 1)); g_Bar.DrawLine(p, new Point(Bar_Size.Width - 1, Bar_Size.Height - 1), new Point(0, Bar_Size.Height - 1)); g_Bar.DrawLine(p, new Point(0, Bar_Size.Height), new Point(0, 0)); g_Bar.Save(); g_Bar.Dispose(); g.DrawImage(b_Bar, new Point((int)((Width - Bar_Size.Width) * (CurrentTransPercent / 100.0)), 0)); b_Bar.Dispose(); } } g.Save(); g.Dispose(); if (_bG != null) { b = (Bitmap)ImageEx.ChangeImageOpacity(b, (_HoverOpacity - _NormalOpacity) * (CurrentOpacityPercent / 100.0) + _NormalOpacity); b = ImageEx.JoinMImage((Bitmap)_bG.Clone(), b, ClientRectangle); } //b = ImageEx.BrightnessP(b, -25); e.Graphics.DrawImage(b, new Point(0, 0)); b.Dispose(); base.OnPaint(e); }
protected override void OnPaint(PaintEventArgs e) { Bitmap b = new Bitmap(Width, Height); Graphics g = Graphics.FromImage(b); { //try //{ // if(NeedRefresh) // if (Parent is MoUI_Panel) // { // if (((MoUI_Panel)Parent)._BG != null) // { // if (_BG == null) // _BG = new Bitmap(Width, Height); // _BG = ((MoUI_Panel)Parent)._BG.Clone(Bounds, ((MoUI_Panel)Parent)._BG.PixelFormat); // NeedRefresh = false; // } // } //} //catch { } //Draw Background { g.Clear(_BackColor); if (_IsSelected) { if (_BG != null && !_BGColorStyle) { g.DrawImage(_BG, new Point(0, 0)); } Bitmap bb = new Bitmap(Width, Height); Graphics gb = Graphics.FromImage(bb); gb.FillRectangle(new SolidBrush(Color.FromArgb(20, 0, 0, 255)), new Rectangle(0, 0, Width, Height)); gb.Save(); gb.Dispose(); bb = (Bitmap)ImageEx.ChangeImageOpacity(bb, 0.5); g.DrawImage(bb, new Point(0, 0)); bb.Dispose(); } else { if (_BG != null && !_BGColorStyle) { g.DrawImage(_BG, new Point(0, 0)); } Bitmap bb = new Bitmap(Width, Height); Graphics gb = Graphics.FromImage(bb); gb.FillRectangle(new SolidBrush(Color.FromArgb(20, 255, 255, 255)), new Rectangle(0, 0, Width, Height)); gb.Save(); gb.Dispose(); bb = (Bitmap)ImageEx.ChangeImageOpacity(bb, (CurrentOpacityPercent / 100.0) * 0.5); g.DrawImage(bb, new Point(0, 0)); bb.Dispose(); } } //Draw Border { if (_IsSelected) { Pen p = new Pen(Color.FromArgb(28, 100, 160)); g.DrawLine(p, new Point(2, 1), new Point(Width - 2, 1)); g.DrawLine(p, new Point(Width - 2, 2), new Point(Width - 2, Height - 2)); g.DrawLine(p, new Point(Width - 3, Height - 2), new Point(1, Height - 2)); g.DrawLine(p, new Point(1, Height - 3), new Point(1, 1)); } else if (IsMouseIn) { Pen p = new Pen(Color.FromArgb(125, 255, 255, 255)); g.DrawLine(p, new Point(2, 1), new Point(Width - 2, 1)); g.DrawLine(p, new Point(Width - 2, 2), new Point(Width - 2, Height - 2)); g.DrawLine(p, new Point(Width - 3, Height - 2), new Point(1, Height - 2)); g.DrawLine(p, new Point(1, Height - 3), new Point(1, 1)); } } //Draw Text { //Draw Text SizeF size_of_Text; { Graphics gs = this.CreateGraphics(); size_of_Text = gs.MeasureString(_Text, _Font); gs.Dispose(); } g.DrawString(_Text, _Font, new SolidBrush(_NormalFontColor), new Point((Width - (int)size_of_Text.Width) / 2 + (_IsMouseDown ? 1 : 0), (Height - (int)size_of_Text.Height) / 2 + (_IsMouseDown ? 1 : 0) - (Height / 4))); //Draw Text SizeF size_of_TextB; { Graphics gs = this.CreateGraphics(); size_of_TextB = gs.MeasureString(_TextB, _Font); gs.Dispose(); } g.DrawString(_TextB, _Font, new SolidBrush(_NormalFontColor), new Point((Width - (int)size_of_TextB.Width) / 2 + (_IsMouseDown ? 1 : 0), (Height - (int)size_of_TextB.Height) / 2 + (_IsMouseDown ? 1 : 0) + (Height / 4))); } } g.Save(); g.Dispose(); if (_BG != null && !_BGColorStyle) { if (_IsSelected) { } else { b = (Bitmap)ImageEx.ChangeImageOpacity(b, (_HoverOpacity - _NormalOpacity) * (CurrentOpacityPercent / 100.0) + _NormalOpacity); b = ImageEx.JoinMImage((Bitmap)_bG.Clone(), b, ClientRectangle); } } e.Graphics.DrawImage(b, new Point(0, 0)); b.Dispose(); base.OnPaint(e); }