Browse Source

添加带阴影自定义窗体

yuzhengyang 8 years ago
parent
commit
8833b7bb5b

+ 25 - 2
Fork.Net/Test/Y.Test/Views/TestShadowForm.Designer.cs

@@ -28,24 +28,47 @@
         /// </summary>
         private void InitializeComponent()
         {
+            this.button2 = new System.Windows.Forms.Button();
+            this.button1 = new System.Windows.Forms.Button();
             this.SuspendLayout();
             // 
+            // button2
+            // 
+            this.button2.Location = new System.Drawing.Point(41, 90);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(75, 23);
+            this.button2.TabIndex = 3;
+            this.button2.Text = "button2";
+            this.button2.UseVisualStyleBackColor = true;
+            // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(41, 46);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(75, 23);
+            this.button1.TabIndex = 2;
+            this.button1.Text = "button1";
+            this.button1.UseVisualStyleBackColor = true;
+            // 
             // TestShadowForm
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.Color.White;
             this.ClientSize = new System.Drawing.Size(701, 460);
-            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+            this.Controls.Add(this.button2);
+            this.Controls.Add(this.button1);
             this.Name = "TestShadowForm";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
             this.Text = "TestShadowForm";
             this.Load += new System.EventHandler(this.TestShadowForm_Load);
-            this.LocationChanged += new System.EventHandler(this.TestShadowForm_LocationChanged);
             this.ResumeLayout(false);
 
         }
 
         #endregion
+
+        private System.Windows.Forms.Button button2;
+        private System.Windows.Forms.Button button1;
     }
 }

+ 3 - 89
Fork.Net/Test/Y.Test/Views/TestShadowForm.cs

@@ -7,104 +7,18 @@ using System.Linq;
 using System.Runtime.InteropServices;
 using System.Text;
 using System.Windows.Forms;
+using Y.Skin.YoForm.Shadow;
 using Y.Utils.WindowsUtils.APIUtils;
 
 namespace Y.Test.Views
 {
-    public partial class TestShadowForm : Form
+    public partial class TestShadowForm : ShadowForm
     {
-        private Point _MouseLocation;
-        internal Point MouseLocation { get { return _MouseLocation; } }
-        int ShadowWidth = 0;
-        private Form Shadow;
         public TestShadowForm()
         {
             InitializeComponent();
-            FormBorderStyle = FormBorderStyle.None;//设置无边框的窗口样式
-            //Opacity = 0.5;
         }
         private void TestShadowForm_Load(object sender, EventArgs e)
-        {
-            if (!DesignMode)
-            {
-                Shadow = new Form();//创建皮肤层
-                Owner = Shadow;//设置控件层的拥有皮肤层
-                Shadow.ShowInTaskbar = false;//禁止阴影显示到任务栏
-                Shadow.Size = Size;//统一大小
-                ShadowWidth = (Shadow.Width - 2 - Shadow.ClientRectangle.Width) / 2;
-                Shadow.Width += ShadowWidth * 2;
-                Shadow.Height += ShadowWidth;
-                TestShadowForm_LocationChanged(this, null);
-                Shadow.Show();//显示皮肤层
-            }
-        }
-
-        #region 属性
-        private bool _Moveable = true;
-        [Category("Skin")]
-        [Description("窗体是否可以移动")]
-        [DefaultValue(typeof(bool), "true")]
-        public bool Movable
-        {
-            get { return _Moveable; }
-            set
-            {
-                if (_Moveable != value)
-                {
-                    _Moveable = value;
-                }
-            }
-        }
-        private bool _InTaskbar = true;
-        [Category("Skin")]
-        [Description("窗体是否显示到任务栏")]
-        [DefaultValue(typeof(bool), "true")]
-        public bool InTaskbar
-        {
-            get { return _InTaskbar; }
-            set
-            {
-                if (_InTaskbar != value)
-                {
-                    _InTaskbar = value;
-                }
-            }
-        }
-        #endregion
-        /// <summary>
-        /// 窗体显示状态
-        /// </summary>
-        /// <param name="value"></param>
-        public void Visibility(bool value)
-        {
-            if (value)
-            {
-                Show();
-                Shadow.Show();
-            }
-            else
-            {
-                Hide();
-                Shadow.Hide();
-            }
-        }
-        protected override void OnMouseMove(MouseEventArgs e)
-        {
-            base.OnMouseMove(e);
-            _MouseLocation = e.Location;
-            if (e.Button == MouseButtons.Left)
-            {
-                FormStyleAPI.ReleaseCapture();
-                FormStyleAPI.SendMessage(Handle, FormStyleAPI.WM_NCLBUTTONDOWN, FormStyleAPI.HTCAPTION, 0);
-            }
-        }
-
-        private void TestShadowForm_LocationChanged(object sender, EventArgs e)
-        {
-            if (Shadow != null)
-            {
-                Shadow.Location = new Point(Left - ShadowWidth, Top);
-            }
-        }
+        { }
     }
 }

+ 18 - 0
Fork.Net/Y.Skin/Y.Skin.csproj

@@ -91,6 +91,18 @@
     <Compile Include="YoForm\NoTitle\NoTitleForm.Designer.cs">
       <DependentUpon>NoTitleForm.cs</DependentUpon>
     </Compile>
+    <Compile Include="YoForm\Shadow\ShadowForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="YoForm\Shadow\ShadowForm.Designer.cs">
+      <DependentUpon>ShadowForm.cs</DependentUpon>
+    </Compile>
+    <Compile Include="YoForm\Shadow\ShadowFormSkin.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="YoForm\Shadow\ShadowFormSkin.Designer.cs">
+      <DependentUpon>ShadowFormSkin.cs</DependentUpon>
+    </Compile>
     <Compile Include="YoForm\Toast\ToastForm.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -144,6 +156,12 @@
     <EmbeddedResource Include="YoForm\NoTitle\NoTitleForm.resx">
       <DependentUpon>NoTitleForm.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="YoForm\Shadow\ShadowForm.resx">
+      <DependentUpon>ShadowForm.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="YoForm\Shadow\ShadowFormSkin.resx">
+      <DependentUpon>ShadowFormSkin.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="YoForm\Toast\ToastForm.resx">
       <DependentUpon>ToastForm.cs</DependentUpon>
     </EmbeddedResource>

+ 50 - 0
Fork.Net/Y.Skin/YoForm/Shadow/ShadowForm.Designer.cs

@@ -0,0 +1,50 @@
+namespace Y.Skin.YoForm.Shadow
+{
+    partial class ShadowForm
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.SuspendLayout();
+            // 
+            // ShadowForm
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(284, 261);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+            this.MinimumSize = new System.Drawing.Size(1, 1);
+            this.Name = "ShadowForm";
+            this.Text = "ShadowForm";
+            this.Load += new System.EventHandler(this.IrregularForm_Load);
+            this.LocationChanged += new System.EventHandler(this.ShadowForm_LocationChanged);
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+    }
+}

+ 90 - 0
Fork.Net/Y.Skin/YoForm/Shadow/ShadowForm.cs

@@ -0,0 +1,90 @@
+//************************************************************************
+//      https://github.com/yuzhengyang
+//      author:     yuzhengyang
+//      date:       2017.4.27 - 2017.8.25
+//      desc:       工具描述
+//      Copyright (c) yuzhengyang. All rights reserved.
+//************************************************************************
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using Y.Utils.WindowsUtils.APIUtils;
+
+namespace Y.Skin.YoForm.Shadow
+{
+    public partial class ShadowForm : Form
+    {
+        private Point _MouseLocation;
+        internal Point MouseLocation { get { return _MouseLocation; } }
+        internal int ShadowWidth = 15;
+        private ShadowFormSkin Skin;
+        public ShadowForm()
+        {
+            InitializeComponent();
+            //SetStyles();//减少闪烁
+            FormBorderStyle = FormBorderStyle.None;//设置无边框的窗口样式
+        }
+        private void IrregularForm_Load(object sender, EventArgs e)
+        {
+            if (!DesignMode)
+            {
+                Skin = new ShadowFormSkin(this);//创建皮肤层
+                ShadowForm_LocationChanged(null, null);
+                Skin.BackColor = Color.Red;
+                Skin.Show();//显示皮肤层
+            }
+        }
+        #region 减少闪烁
+        private void SetStyles()
+        {
+            SetStyle(
+                ControlStyles.UserPaint |
+                ControlStyles.AllPaintingInWmPaint |
+                ControlStyles.OptimizedDoubleBuffer |
+                ControlStyles.ResizeRedraw |
+                ControlStyles.DoubleBuffer, true);
+            //强制分配样式重新应用到控件上
+            UpdateStyles();
+            base.AutoScaleMode = AutoScaleMode.None;
+        }
+        #endregion
+        /// <summary>
+        /// 窗体显示状态
+        /// </summary>
+        /// <param name="value"></param>
+        public void Visibility(bool value)
+        {
+            if (value)
+            {
+                Show();
+                Skin.Show();
+            }
+            else
+            {
+                Hide();
+                Skin.Hide();
+            }
+        }
+        protected override void OnMouseMove(MouseEventArgs e)
+        {
+            base.OnMouseMove(e);
+            _MouseLocation = e.Location;
+            if (e.Button == MouseButtons.Left)
+            {
+                FormStyleAPI.ReleaseCapture();
+                FormStyleAPI.SendMessage(Handle, FormStyleAPI.WM_NCLBUTTONDOWN, FormStyleAPI.HTCAPTION, 0);
+            }
+        }
+        private void ShadowForm_LocationChanged(object sender, EventArgs e)
+        {
+            if (Skin != null)
+            {
+                Skin.Location = new Point(Left - ShadowWidth, Top - ShadowWidth);
+                Skin.DrawShadow();
+            }
+        }
+    }
+}

+ 120 - 0
Fork.Net/Y.Skin/YoForm/Shadow/ShadowForm.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 49 - 0
Fork.Net/Y.Skin/YoForm/Shadow/ShadowFormSkin.Designer.cs

@@ -0,0 +1,49 @@
+namespace Y.Skin.YoForm.Shadow
+{
+    partial class ShadowFormSkin
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.SuspendLayout();
+            // 
+            // ShadowFormSkin
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(284, 261);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+            this.MinimumSize = new System.Drawing.Size(1, 1);
+            this.Name = "ShadowFormSkin";
+            this.Text = "ShadowFormSkin";
+            this.Load += new System.EventHandler(this.ShadowFormSkin_Load);
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+    }
+}

+ 161 - 0
Fork.Net/Y.Skin/YoForm/Shadow/ShadowFormSkin.cs

@@ -0,0 +1,161 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using Y.Utils.WindowsUtils.APIUtils;
+
+namespace Y.Skin.YoForm.Shadow
+{
+    partial class ShadowFormSkin : Form
+    {
+        private Point _MouseLocation;
+        internal Point MouseLocation { get { return _MouseLocation; } }
+        private ShadowForm Main;
+        public ShadowFormSkin(ShadowForm main)
+        {
+            InitializeComponent();
+            SetStyles();//减少闪烁
+            Main = main;//获取控件层对象
+            Text = main.Text;//设置标题栏文本
+            Icon = main.Icon;//设置图标
+            TopMost = main.TopMost;
+            FormBorderStyle = FormBorderStyle.None;//设置无边框的窗口样式
+            ShowInTaskbar = false;//使控件层显示到任务栏
+            Size = Main.Size;//统一大小
+            Width += (Main.ShadowWidth * 2);
+            Height += (Main.ShadowWidth * 2);
+            Main.Owner = this;//设置控件层的拥有皮肤层
+            //SetBits();//绘制半透明不规则皮肤
+        }
+        private void ShadowFormSkin_Load(object sender, EventArgs e)
+        {
+            DrawShadow();
+        }
+        #region 减少闪烁
+        private void SetStyles()
+        {
+            SetStyle(
+                ControlStyles.UserPaint |
+                ControlStyles.AllPaintingInWmPaint |
+                ControlStyles.OptimizedDoubleBuffer |
+                ControlStyles.ResizeRedraw |
+                ControlStyles.DoubleBuffer, true);
+            //强制分配样式重新应用到控件上
+            UpdateStyles();
+            base.AutoScaleMode = AutoScaleMode.None;
+        }
+        #endregion
+        #region 绘图
+        protected override CreateParams CreateParams
+        {
+            get
+            {
+                CreateParams cParms = base.CreateParams;
+                cParms.ExStyle |= 0x00080000; // WS_EX_LAYERED
+                return cParms;
+            }
+        }
+        internal void DrawShadow()
+        {
+            Bitmap bitmap = null;
+            Graphics g = null;
+            try
+            {
+                bitmap = new Bitmap(Width, Height);
+                g = Graphics.FromImage(bitmap);
+                g.SmoothingMode = SmoothingMode.AntiAlias;
+
+                Color c = Color.FromArgb(0, 0, 0, 0);
+                Pen p = new Pen(c, 3);
+
+                for (int i = 0; i < Main.ShadowWidth; i++)
+                {
+                    p.Color = Color.FromArgb((255 / 10 / Main.ShadowWidth) * i, c);
+                    //g.DrawRectangle(p, new Rectangle(i, i, Width - (2 * i) - 1, Height - (2 * i) - 1));
+                    DrawRoundRectangle(g, p, new Rectangle(i, i, Width - (2 * i) - 1, Height - (2 * i) - 1), Main.ShadowWidth - i);
+                }
+                SetBits(bitmap);
+            }
+            catch { }
+            finally
+            {
+                g?.Dispose();
+                bitmap?.Dispose();
+            }
+        }
+        public void SetBits(Bitmap bitmap)
+        {
+            if (!Image.IsCanonicalPixelFormat(bitmap.PixelFormat) || !Image.IsAlphaPixelFormat(bitmap.PixelFormat))
+                throw new ApplicationException("图片必须是32位带Alhpa通道的图片。");
+            IntPtr oldBits = IntPtr.Zero;
+            IntPtr screenDC = FormStyleAPI.GetDC(IntPtr.Zero);
+            IntPtr hBitmap = IntPtr.Zero;
+            IntPtr memDc = FormStyleAPI.CreateCompatibleDC(screenDC);
+
+            try
+            {
+                FormStyleAPI.Point topLoc = new FormStyleAPI.Point(Left, Top);
+                FormStyleAPI.Size bitMapSize = new FormStyleAPI.Size(Width, Height);
+                FormStyleAPI.BLENDFUNCTION blendFunc = new FormStyleAPI.BLENDFUNCTION();
+                FormStyleAPI.Point srcLoc = new FormStyleAPI.Point(0, 0);
+
+                hBitmap = bitmap.GetHbitmap(Color.FromArgb(0));
+                oldBits = FormStyleAPI.SelectObject(memDc, hBitmap);
+
+                blendFunc.BlendOp = FormStyleAPI.AC_SRC_OVER;
+                blendFunc.SourceConstantAlpha = Byte.Parse(((int)(Main.Opacity * 255)).ToString());
+                blendFunc.AlphaFormat = FormStyleAPI.AC_SRC_ALPHA;
+                blendFunc.BlendFlags = 0;
+
+                FormStyleAPI.UpdateLayeredWindow(Handle, screenDC, ref topLoc, ref bitMapSize, memDc, ref srcLoc, 0, ref blendFunc, FormStyleAPI.ULW_ALPHA);
+            }
+            finally
+            {
+                if (hBitmap != IntPtr.Zero)
+                {
+                    FormStyleAPI.SelectObject(memDc, oldBits);
+                    FormStyleAPI.DeleteObject(hBitmap);
+                }
+                FormStyleAPI.ReleaseDC(IntPtr.Zero, screenDC);
+                FormStyleAPI.DeleteDC(memDc);
+            }
+        }
+        #endregion
+        #region MyRegion
+        public static void DrawRoundRectangle(Graphics g, Pen pen, Rectangle rect, int cornerRadius)
+        {
+            using (GraphicsPath path = CreateRoundedRectanglePath(rect, cornerRadius))
+            {
+                g.DrawPath(pen, path);
+            }
+        }
+        public static void FillRoundRectangle(Graphics g, Brush brush, Rectangle rect, int cornerRadius)
+        {
+            using (GraphicsPath path = CreateRoundedRectanglePath(rect, cornerRadius))
+            {
+                g.FillPath(brush, path);
+            }
+        }
+        internal static GraphicsPath CreateRoundedRectanglePath(Rectangle rect, int cornerRadius)
+        {
+            GraphicsPath roundedRect = new GraphicsPath();
+            roundedRect.AddArc(rect.X, rect.Y, cornerRadius * 2, cornerRadius * 2, 180, 90);
+            roundedRect.AddLine(rect.X + cornerRadius, rect.Y, rect.Right - cornerRadius * 2, rect.Y);
+            roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y, cornerRadius * 2, cornerRadius * 2, 270, 90);
+            roundedRect.AddLine(rect.Right, rect.Y + cornerRadius * 2, rect.Right, rect.Y + rect.Height - cornerRadius * 2);
+            roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y + rect.Height - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 0, 90);
+            roundedRect.AddLine(rect.Right - cornerRadius * 2, rect.Bottom, rect.X + cornerRadius * 2, rect.Bottom);
+            roundedRect.AddArc(rect.X, rect.Bottom - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 90, 90);
+            roundedRect.AddLine(rect.X, rect.Bottom - cornerRadius * 2, rect.X, rect.Y + cornerRadius * 2);
+            roundedRect.CloseFigure();
+            return roundedRect;
+        }
+        #endregion
+    }
+}

+ 120 - 0
Fork.Net/Y.Skin/YoForm/Shadow/ShadowFormSkin.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>