📄 form.cs
字号:
using System;
using System.Windows;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
namespace System.Windows.Forms
{
public class MyForm:System.Windows.Forms.Form
{
public MyForm()
{
InitializeComponent();
}
[STAThread]
static void Main()
{
Application.Run(new MyForm());
}
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MyForm));
this.button1 = new System.Windows.Forms.Button();
this.skinUI1 = new DotNetSkin.SkinUI();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(56, 56);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// skinUI1
//
this.skinUI1.Active = true;
this.skinUI1.Button = true;
this.skinUI1.Caption = true;
this.skinUI1.CheckBox = true;
this.skinUI1.ComboBox = true;
this.skinUI1.ContextMenu = true;
this.skinUI1.DisableTag = 999;
this.skinUI1.Edit = true;
this.skinUI1.GroupBox = true;
this.skinUI1.ImageList = null;
this.skinUI1.MaiMenu = true;
this.skinUI1.Panel = true;
this.skinUI1.Progress = true;
this.skinUI1.RadioButton = true;
this.skinUI1.ScrollBar = true;
this.skinUI1.SkinFile = null;
this.skinUI1.SkinSteam = ((System.IO.MemoryStream)(resources.GetObject("skinUI1.SkinSteam")));
this.skinUI1.Spin = true;
this.skinUI1.StatusBar = true;
this.skinUI1.SystemMenu = true;
this.skinUI1.TabControl = true;
this.skinUI1.Text = "Mycontrol1=edit\r\nMycontrol2=edit\r\n";
this.skinUI1.ToolBar = true;
this.skinUI1.TrackBar = true;
//
// MyForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(408, 358);
this.Controls.Add(this.button1);
this.Name = "MyForm";
this.Text = "123";
this.Resize += new System.EventHandler(this.MyForm_Resize);
this.ResumeLayout(false);
}
[DllImport ("User32.dll")]
private static extern IntPtr GetWindowDC(IntPtr hwnd);
[DllImport ("User32.dll")]
private static extern int ReleaseDC(IntPtr hwnd, IntPtr hdc);
[DllImport ("Kernel32.dll")]
private static extern int GetLastError();
Rectangle m_rect = new Rectangle(30, 8, 100, 20);
string drawText;
string skinPath="";
Color captionTextColor=Color.Black;
private System.Windows.Forms.Button button1;
private DotNetSkin.SkinUI skinUI1;
StringAlignment stringAlignment=StringAlignment.Near;
public StringAlignment CaptionTextAlignment
{
get
{
return stringAlignment;
}
set
{
this.stringAlignment=value;
}
}
new public string Text
{
get
{
return drawText;
}
set
{
base.Text=value;
this.drawText=value;
//skinUI.LoadSkinFile(value);
}
}
/// <summary>
/// 标题颜色
/// </summary>
public Color CaptionTextColor
{
get
{
return captionTextColor;
}
set
{
this.captionTextColor=value;
}
}
/// <summary>
/// 皮肤路径
/// </summary>
public string SkinPath
{
get
{
return skinPath;
}
set
{
this.skinPath=value;
}
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
int num=m.Msg;
if(num==0x10||num==0x11||num==0x12||num==2)return;
if(m.Msg<=20)
{
IntPtr hDC = GetWindowDC(m.HWnd);
Graphics gs = Graphics.FromHdc(hDC);
StringFormat strFmt = new StringFormat();
strFmt.Alignment = stringAlignment;
strFmt.LineAlignment = StringAlignment.Center;
gs.DrawString(this.drawText, this.Font, new SolidBrush(this.captionTextColor), m_rect, strFmt);
gs.Dispose();
ReleaseDC(m.HWnd, hDC);
}
}
private void button1_Click(object sender, System.EventArgs e)
{
this.Text+="aa";
}
private void MyForm_Resize(object sender, System.EventArgs e)
{
m_rect=new Rectangle(30,8,this.Width,20);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -