Skip to content

Commit 34d84aa

Browse files
committed
WinFormsTabs
1 parent 9c7d1d6 commit 34d84aa

File tree

6 files changed

+351
-1
lines changed

6 files changed

+351
-1
lines changed

RookieProject.sln

+15-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PDF417Maker", "PDF417Maker\
118118
EndProject
119119
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkitDemo", "CommunityToolkitDemo\CommunityToolkitDemo.csproj", "{770745BD-2DBD-411B-9E2A-D2E8DCE822D1}"
120120
EndProject
121-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsJsonTreeView", "WinFormsJsonTreeView\WinFormsJsonTreeView.csproj", "{EDB293AC-9DB7-40BA-A3BE-22100DBF3005}"
121+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsJsonTreeView", "WinFormsJsonTreeView\WinFormsJsonTreeView.csproj", "{EDB293AC-9DB7-40BA-A3BE-22100DBF3005}"
122+
EndProject
123+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsTabs", "WinFormsTabs\WinFormsTabs.csproj", "{8AA31570-A600-495C-A3F1-DB08355873FF}"
122124
EndProject
123125
Global
124126
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -750,6 +752,18 @@ Global
750752
{EDB293AC-9DB7-40BA-A3BE-22100DBF3005}.Release|x64.Build.0 = Release|Any CPU
751753
{EDB293AC-9DB7-40BA-A3BE-22100DBF3005}.Release|x86.ActiveCfg = Release|Any CPU
752754
{EDB293AC-9DB7-40BA-A3BE-22100DBF3005}.Release|x86.Build.0 = Release|Any CPU
755+
{8AA31570-A600-495C-A3F1-DB08355873FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
756+
{8AA31570-A600-495C-A3F1-DB08355873FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
757+
{8AA31570-A600-495C-A3F1-DB08355873FF}.Debug|x64.ActiveCfg = Debug|Any CPU
758+
{8AA31570-A600-495C-A3F1-DB08355873FF}.Debug|x64.Build.0 = Debug|Any CPU
759+
{8AA31570-A600-495C-A3F1-DB08355873FF}.Debug|x86.ActiveCfg = Debug|Any CPU
760+
{8AA31570-A600-495C-A3F1-DB08355873FF}.Debug|x86.Build.0 = Debug|Any CPU
761+
{8AA31570-A600-495C-A3F1-DB08355873FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
762+
{8AA31570-A600-495C-A3F1-DB08355873FF}.Release|Any CPU.Build.0 = Release|Any CPU
763+
{8AA31570-A600-495C-A3F1-DB08355873FF}.Release|x64.ActiveCfg = Release|Any CPU
764+
{8AA31570-A600-495C-A3F1-DB08355873FF}.Release|x64.Build.0 = Release|Any CPU
765+
{8AA31570-A600-495C-A3F1-DB08355873FF}.Release|x86.ActiveCfg = Release|Any CPU
766+
{8AA31570-A600-495C-A3F1-DB08355873FF}.Release|x86.Build.0 = Release|Any CPU
753767
EndGlobalSection
754768
GlobalSection(SolutionProperties) = preSolution
755769
HideSolutionNode = FALSE

WinFormsTabs/Form1.Designer.cs

+170
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WinFormsTabs/Form1.cs

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// **********************************
2+
// Densen Informatica 中讯科技
3+
// 作者:Alex Chow
4+
5+
// **********************************
6+
7+
namespace WinFormsTabs
8+
{
9+
public partial class Form1 : Form
10+
{
11+
public Form1()
12+
{
13+
InitializeComponent();
14+
15+
// click tab page change page activate color
16+
this.tabControl1.DrawMode = TabDrawMode.OwnerDrawFixed;
17+
this.tabControl1.DrawItem += new DrawItemEventHandler(tabControl1_DrawItem);
18+
19+
}
20+
21+
private void tabControl1_DrawItem(object? sender, DrawItemEventArgs e)
22+
{
23+
//e.Graphics.DrawString("❎", e.Font, Brushes.Black, e.Bounds.Right - 15, e.Bounds.Top + 4);
24+
//e.Graphics.DrawString(this.tabControl1.TabPages[e.Index].Text, e.Font, Brushes.Black, e.Bounds.Left + 12, e.Bounds.Top + 4);
25+
//e.DrawFocusRectangle();
26+
27+
28+
if (e.Index < 0)
29+
return;
30+
31+
Rectangle rect = e.Bounds;
32+
//每一项的边框
33+
34+
//确定显示的文字的颜色()
35+
Brush b2 = Brushes.Black;
36+
//绘制项如果被选中则显示高亮显示背景,否则用白色
37+
if (Convert.ToBoolean(e.State) & Convert.ToBoolean(DrawItemState.Selected))
38+
{
39+
e.Graphics.FillRectangle(SystemBrushes.Highlight, rect);
40+
b2 = SystemBrushes.Window;
41+
}
42+
else
43+
{
44+
e.Graphics.FillRectangle(SystemBrushes.Window, rect);
45+
b2 = SystemBrushes.Highlight;
46+
}
47+
48+
49+
string colorname = "green";
50+
SolidBrush b = new SolidBrush(System.Drawing.Color.FromName(colorname));
51+
52+
53+
////缩小选定项区域()
54+
rect.Inflate(-16, -2);
55+
////填充颜色(文字对应的颜色)
56+
//e.Graphics.FillRectangle(b, rect);
57+
////绘制边框()
58+
//e.Graphics.DrawRectangle(Pens.Black, rect);
59+
//Brush b2= Brushes.Black;
60+
////确定显示的文字的颜色()
61+
//if (Convert.ToInt32(b.Color.R) + Convert.ToInt32(b.Color.G) + Convert.ToInt32(b.Color.B) > 128 * 3)
62+
//{
63+
// b2 = Brushes.Black;
64+
//}
65+
//else
66+
//{
67+
// b2 = Brushes.White;
68+
//}
69+
e.Graphics.DrawString(this.tabControl1.TabPages[e.Index].Text, this.tabControl1.Font, b2, rect.X, rect.Y);
70+
}
71+
}
72+
}

WinFormsTabs/Form1.resx

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<root>
2+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
3+
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
4+
<xsd:element name="root" msdata:IsDataSet="true">
5+
<xsd:complexType>
6+
<xsd:choice maxOccurs="unbounded">
7+
<xsd:element name="metadata">
8+
<xsd:complexType>
9+
<xsd:sequence>
10+
<xsd:element name="value" type="xsd:string" minOccurs="0" />
11+
</xsd:sequence>
12+
<xsd:attribute name="name" use="required" type="xsd:string" />
13+
<xsd:attribute name="type" type="xsd:string" />
14+
<xsd:attribute name="mimetype" type="xsd:string" />
15+
<xsd:attribute ref="xml:space" />
16+
</xsd:complexType>
17+
</xsd:element>
18+
<xsd:element name="assembly">
19+
<xsd:complexType>
20+
<xsd:attribute name="alias" type="xsd:string" />
21+
<xsd:attribute name="name" type="xsd:string" />
22+
</xsd:complexType>
23+
</xsd:element>
24+
<xsd:element name="data">
25+
<xsd:complexType>
26+
<xsd:sequence>
27+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
28+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
29+
</xsd:sequence>
30+
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
31+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
32+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
33+
<xsd:attribute ref="xml:space" />
34+
</xsd:complexType>
35+
</xsd:element>
36+
<xsd:element name="resheader">
37+
<xsd:complexType>
38+
<xsd:sequence>
39+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
40+
</xsd:sequence>
41+
<xsd:attribute name="name" type="xsd:string" use="required" />
42+
</xsd:complexType>
43+
</xsd:element>
44+
</xsd:choice>
45+
</xsd:complexType>
46+
</xsd:element>
47+
</xsd:schema>
48+
<resheader name="resmimetype">
49+
<value>text/microsoft-resx</value>
50+
</resheader>
51+
<resheader name="version">
52+
<value>2.0</value>
53+
</resheader>
54+
<resheader name="reader">
55+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
56+
</resheader>
57+
<resheader name="writer">
58+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
59+
</resheader>
60+
</root>

WinFormsTabs/Program.cs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// **********************************
2+
// Densen Informatica 中讯科技
3+
// 作者:Alex Chow
4+
5+
// **********************************
6+
7+
namespace WinFormsTabs
8+
{
9+
internal static class Program
10+
{
11+
/// <summary>
12+
/// The main entry point for the application.
13+
/// </summary>
14+
[STAThread]
15+
static void Main()
16+
{
17+
// To customize application configuration such as set high DPI settings or default font,
18+
// see https://aka.ms/applicationconfiguration.
19+
ApplicationConfiguration.Initialize();
20+
Application.Run(new Form1());
21+
}
22+
}
23+
}

WinFormsTabs/WinFormsTabs.csproj

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net7.0-windows</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<UseWindowsForms>true</UseWindowsForms>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
</PropertyGroup>
10+
11+
</Project>

0 commit comments

Comments
 (0)