Last active
April 29, 2020 13:13
-
-
Save sharpicx/9cd241d9b8a498ebc0ac8a762b35c632 to your computer and use it in GitHub Desktop.
TabControl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Globalization; | |
using System.IO; | |
using System.Linq; | |
using System.Reflection; | |
using System.Runtime.CompilerServices; | |
using System.Security; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Microsoft.VisualBasic; | |
using System.Drawing.Drawing2D; | |
class ArrezunTab : TabControl | |
{ | |
public () | |
{ | |
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); | |
DoubleBuffered = true; | |
SizeMode = TabSizeMode.Fixed; | |
ItemSize = new Size(44, 136); | |
} | |
protected override void CreateHandle() | |
{ | |
base.CreateHandle(); | |
Alignment = TabAlignment.Left; | |
} | |
private Color C1 = Color.FromArgb(42, 42, 42); | |
[Category("Colors")] | |
public Color Color1 | |
{ | |
get { return C1; } | |
set { aC1 = value; } | |
} | |
private Color C2 = Color.FromArgb(42, 42, 42); | |
[Category("Colors")] | |
public Color Color2 | |
{ | |
get{ return C2; } | |
set { C2 = value; } | |
} | |
private Color C3 = Color.FromArgb(42, 42, 42); | |
[Category("Colors")] | |
public Color Color3 | |
{ | |
get { return C3; } | |
set { C3 = value; } | |
} | |
private Color BC = Color.Gray; | |
[Category("Colors")] | |
public Color BorderColor | |
{ | |
get { return BC; } | |
set { BC = value; } | |
} | |
private bool OB = false; | |
[Category("Colors")] | |
public bool ShowOuterBorders | |
{ | |
get{ return OB; } | |
set{ OB = value; } | |
} | |
private Color shit = Color.FromArgb(17, 16, 24); | |
protected override void OnPaint(PaintEventArgs e) | |
{ | |
SolidBrush nana = new SolidBrush(shit); | |
Bitmap B = new Bitmap(Width, Height); | |
Graphics G = Graphics.FromImage(B); | |
// // | |
try | |
{ | |
SelectedTab.BackColor = shit; | |
} | |
catch | |
{ | |
} // tab background color, comment out to set your own color!!!! | |
// // | |
G.Clear(shit); // set outer stuff | |
G.FillRectangle(new SolidBrush(C3), new Rectangle(0, 0, ItemSize.Height + 4, Height)); | |
if (OB) | |
{ | |
G.DrawLine(new Pen(BC), new Point(Width - 1, 0), new Point(Width - 1, Height - 1)); // comment out to get rid of the borders | |
G.DrawLine(new Pen(BC), new Point(ItemSize.Height + 1, 0), new Point(Width - 1, 0)); // comment out to get rid of the borders | |
G.DrawLine(new Pen(BC), new Point(ItemSize.Height + 3, Height - 1), new Point(Width - 1, Height - 1)); // comment out to get rid of the borders | |
} | |
G.DrawLine(BC, new Point(ItemSize.Height + 3, 0), new Point(ItemSize.Height + 3, 999)); | |
for (var i = 0; i <= TabCount - 1; i++) | |
{ | |
if (i == SelectedIndex) | |
{ | |
Rectangle x2 = new Rectangle(new Point(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2), new Size(GetTabRect(i).Width + 3, GetTabRect(i).Height - 1)); | |
ColorBlend myBlend = new ColorBlend(); | |
myBlend.Colors = new[] { C1, C2, C1 }; | |
myBlend.Positions = new[] { 0.0F, 0.5F, 1.0F }; | |
LinearGradientBrush lgBrush = new LinearGradientBrush(x2, Color.Black, Color.Black, 90.0F); | |
lgBrush.InterpolationColors = myBlend; | |
G.FillRectangle(lgBrush, x2); | |
G.DrawRectangle(BC, x2); | |
G.SmoothingMode = SmoothingMode.HighQuality; | |
Point[] p = new[] { new Point(ItemSize.Height - 3, GetTabRect(i).Location.Y + 20), new Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + 14), new Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + 27) }; | |
// G.FillPolygon(nana, p) ' | |
// G.DrawPolygon(BC, p) | |
if (ImageList != null) | |
{ | |
try | |
{ | |
if (ImageList.Images(TabPages[i].ImageIndex) != null) | |
{ | |
G.DrawImage(ImageList.Images(TabPages[i].ImageIndex), new Point(x2.Location.X + 8, x2.Location.Y + 6)); | |
G.DrawString(" " + TabPages[i].Text, Font, Brushes.White, x2, new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); | |
} | |
else | |
G.DrawString(TabPages[i].Text, new Font(Font.FontFamily, Font.Size, FontStyle.Bold), Brushes.White, x2, new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); | |
} | |
catch (Exception ex) | |
{ | |
G.DrawString(TabPages[i].Text, new Font(Font.FontFamily, Font.Size, FontStyle.Bold), Brushes.White, x2, new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); | |
} | |
} | |
else | |
G.DrawString(TabPages[i].Text, new Font(Font.FontFamily, Font.Size, FontStyle.Bold), Brushes.White, x2, new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); | |
} | |
else | |
{ | |
Rectangle x2 = new Rectangle(new Point(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2), new Size(GetTabRect(i).Width + 3, GetTabRect(i).Height + 1)); | |
G.FillRectangle(new SolidBrush(C3), x2); | |
G.DrawLine(new Pen(BC), new Point(x2.Right, x2.Top), new Point(x2.Right, x2.Bottom)); | |
if (ImageList != null) | |
{ | |
try | |
{ | |
if (ImageList.Images(TabPages[i].ImageIndex) != null) | |
{ | |
G.DrawImage(ImageList.Images(TabPages[i].ImageIndex), new Point(x2.Location.X + 8, x2.Location.Y + 6)); | |
G.DrawString(" " + TabPages[i].Text, Font, Brushes.DimGray, x2, new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); | |
} | |
else | |
G.DrawString(TabPages[i].Text, Font, Brushes.DimGray, x2, new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); | |
} | |
catch (Exception ex) | |
{ | |
G.DrawString(TabPages[i].Text, Font, Brushes.DimGray, x2, new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); | |
} | |
} | |
else | |
G.DrawString(TabPages[i].Text, Font, Brushes.DimGray, x2, new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); | |
} | |
} | |
e.Graphics.DrawImage(B.Clone, 0, 0); | |
G.Dispose(); B.Dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment