Browse Source

双层窗体实现异形窗体自定义控件完成

yuzhengyang 8 years ago
parent
commit
ee21af752c

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

@@ -43,6 +43,18 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="YoForm\Irregular\IrregularForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="YoForm\Irregular\IrregularForm.Designer.cs">
+      <DependentUpon>IrregularForm.cs</DependentUpon>
+    </Compile>
+    <Compile Include="YoForm\Irregular\IrregularFormSkin.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="YoForm\Irregular\IrregularFormSkin.Designer.cs">
+      <DependentUpon>IrregularFormSkin.cs</DependentUpon>
+    </Compile>
     <Compile Include="YoPanel\EmbedArticlePanel.cs">
       <SubType>Component</SubType>
     </Compile>
@@ -64,7 +76,6 @@
   </ItemGroup>
   <ItemGroup>
     <Folder Include="YoCtrl\" />
-    <Folder Include="YoForm\IrregularForm\" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\Y.Utils\Y.Utils.csproj">
@@ -73,6 +84,12 @@
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
+    <EmbeddedResource Include="YoForm\Irregular\IrregularForm.resx">
+      <DependentUpon>IrregularForm.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="YoForm\Irregular\IrregularFormSkin.resx">
+      <DependentUpon>IrregularFormSkin.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="YoPanel\EmbedPanel.resx">
       <DependentUpon>EmbedPanel.cs</DependentUpon>
     </EmbeddedResource>

+ 47 - 0
Fork.Net/Y.Skin/YoForm/Irregular/IrregularForm.Designer.cs

@@ -0,0 +1,47 @@
+namespace Y.Skin.YoForm.Irregular
+{
+    partial class IrregularForm
+    {
+        /// <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();
+            // 
+            // IrregularForm
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(284, 261);
+            this.Name = "IrregularForm";
+            this.Text = "IrregularForm";
+            this.Load += new System.EventHandler(this.IrregularForm_Load);
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+    }
+}

+ 84 - 0
Fork.Net/Y.Skin/YoForm/Irregular/IrregularForm.cs

@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Y.Skin.YoForm.Irregular
+{
+    public partial class IrregularForm : Form
+    {
+        private IrregularFormSkin Skin;
+        public IrregularForm()
+        {
+            InitializeComponent();
+            //SetStyles();//减少闪烁
+            ShowInTaskbar = false;//禁止控件层显示到任务栏
+            FormBorderStyle = FormBorderStyle.None;//设置无边框的窗口样式
+            TransparencyKey = BackColor;//使控件层背景透明
+        }
+        private void IrregularForm_Load(object sender, EventArgs e)
+        {
+            if (!DesignMode)
+            {
+                Opacity = 0;
+                Skin = new IrregularFormSkin(this);//创建皮肤层 
+                BackgroundImage = null;//去除控件层背景
+                Skin.Show();//显示皮肤层 
+                AnimateShow();
+            }
+        }
+
+        #region 属性
+        private bool _skinmobile = true;
+        [Category("Skin")]
+        [Description("窗体是否可以移动")]
+        [DefaultValue(typeof(bool), "true")]
+        public bool SkinMovable
+        {
+            get { return _skinmobile; }
+            set
+            {
+                if (_skinmobile != value)
+                {
+                    _skinmobile = value;
+                }
+            }
+        }
+        #endregion
+        #region 减少闪烁
+        private void SetStyles()
+        {
+            SetStyle(
+                ControlStyles.UserPaint |
+                ControlStyles.AllPaintingInWmPaint |
+                ControlStyles.OptimizedDoubleBuffer |
+                ControlStyles.ResizeRedraw |
+                ControlStyles.DoubleBuffer, true);
+            //强制分配样式重新应用到控件上
+            UpdateStyles();
+            base.AutoScaleMode = AutoScaleMode.None;
+        }
+        #endregion
+        private void AnimateShow()
+        {
+            Task.Factory.StartNew(() =>
+            {
+                for (int i = 0; i <= 10; i++)
+                {
+                    BeginInvoke(new Action(() =>
+                    {
+                        Opacity = i / 10.0;
+                        Skin.SetBits();
+                    }));
+                    Thread.Sleep(25);
+                }
+            });
+        }
+    }
+}

+ 120 - 0
Fork.Net/Y.Skin/YoForm/Irregular/IrregularForm.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>

+ 46 - 0
Fork.Net/Y.Skin/YoForm/Irregular/IrregularFormSkin.Designer.cs

@@ -0,0 +1,46 @@
+namespace Y.Skin.YoForm.Irregular
+{
+    partial class IrregularFormSkin
+    {
+        /// <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();
+            // 
+            // IrregularFormSkin
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(284, 261);
+            this.Name = "IrregularFormSkin";
+            this.Text = "IrregularFormSkin";
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+    }
+}

+ 219 - 0
Fork.Net/Y.Skin/YoForm/Irregular/IrregularFormSkin.cs

@@ -0,0 +1,219 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using Y.Utils.WindowsUtils.APIUtils;
+
+namespace Y.Skin.YoForm.Irregular
+{
+    partial class IrregularFormSkin : Form
+    {
+        private IrregularForm Main;
+        public IrregularFormSkin(IrregularForm main)
+        {
+            InitializeComponent();
+            SetStyles();//减少闪烁
+            Main = main;//获取控件层对象
+            FormBorderStyle = FormBorderStyle.None;//设置无边框的窗口样式
+            ShowInTaskbar = true;//使控件层显示到任务栏
+            BackgroundImage = Main.BackgroundImage;//将控件层背景图应用到皮肤层
+            BackgroundImageLayout = ImageLayout.Stretch;//自动拉伸背景图以适应窗口
+            Size = Main.Size;//统一大小
+            Main.Owner = this;//设置控件层的拥有皮肤层
+            FormMovableEvent();//激活皮肤层窗体移动
+            SetBits();//绘制半透明不规则皮肤
+            Location = new Point(Main.Location.X, Main.Location.Y);//统一控件层和皮肤层的位置
+        }
+
+        #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;
+            }
+        }
+        public void SetBits()
+        {
+            if (BackgroundImage != null)
+            {
+                //绘制绘图层背景
+                Bitmap bitmap = new Bitmap(BackgroundImage, base.Width, base.Height);
+                if (!Bitmap.IsCanonicalPixelFormat(bitmap.PixelFormat) || !Bitmap.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);
+                    bitmap.Dispose();
+                }
+            }
+        }
+        #endregion
+        #region 无标题栏的窗口移动
+        private Point mouseOffset; //记录鼠标指针的坐标
+        private bool isMouseDown = false; //记录鼠标按键是否按下
+
+        /// <summary>
+        /// 窗体移动监听绑定
+        /// </summary>
+        private void FormMovableEvent()
+        {
+            //绘制层窗体移动
+            this.MouseDown += new MouseEventHandler(Frm_MouseDown);
+            this.MouseMove += new MouseEventHandler(Frm_MouseMove);
+            this.MouseUp += new MouseEventHandler(Frm_MouseUp);
+            this.LocationChanged += new EventHandler(Frm_LocationChanged);
+            //控制层层窗体移动
+            Main.MouseDown += new MouseEventHandler(Frm_MouseDown);
+            Main.MouseMove += new MouseEventHandler(Frm_MouseMove);
+            Main.MouseUp += new MouseEventHandler(Frm_MouseUp);
+            Main.LocationChanged += new EventHandler(Frm_LocationChanged);
+        }
+
+        /// <summary>
+        /// 窗体按下时
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void Frm_MouseDown(object sender, MouseEventArgs e)
+        {
+            if (Main.SkinMovable)
+            {
+                int xOffset;
+                int yOffset;
+                //点击窗体时,记录鼠标位置,启动移动
+                if (e.Button == MouseButtons.Left)
+                {
+                    xOffset = -e.X;
+                    yOffset = -e.Y;
+                    mouseOffset = new Point(xOffset, yOffset);
+                    isMouseDown = true;
+                }
+            }
+        }
+
+        /// <summary>
+        /// 窗体移动时
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void Frm_MouseMove(object sender, MouseEventArgs e)
+        {
+            if (Main.SkinMovable)
+            {
+                //将调用此事件的窗口保存下
+                Form frm = (Form)sender;
+                //确定开启了移动模式后
+                if (isMouseDown)
+                {
+                    //移动的位置计算
+                    Point mousePos = Control.MousePosition;
+                    mousePos.Offset(mouseOffset.X, mouseOffset.Y);
+                    //判断是绘图层还是控件层调用了移动事件,并作出相应回馈
+                    if (frm == this)
+                    {
+                        Location = mousePos;
+                    }
+                    else
+                    {
+                        Main.Location = mousePos;
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// 窗体按下并释放按钮时
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void Frm_MouseUp(object sender, MouseEventArgs e)
+        {
+            if (Main.SkinMovable)
+            {
+                // 修改鼠标状态isMouseDown的值
+                // 确保只有鼠标左键按下并移动时,才移动窗体
+                if (e.Button == MouseButtons.Left)
+                {
+                    //松开鼠标时,停止移动
+                    isMouseDown = false;
+                    //Top高度小于0的时候,等于0
+                    if (this.Top < 0)
+                    {
+                        this.Top = 0;
+                        Main.Top = 0;
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// 窗口移动时
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        void Frm_LocationChanged(object sender, EventArgs e)
+        {
+            //将调用此事件的窗口保存下
+            Form frm = (Form)sender;
+            if (frm == this)
+            {
+                Main.Location = new Point(this.Left, this.Top);
+            }
+            else
+            {
+                Location = new Point(Main.Left, Main.Top);
+            }
+        }
+        #endregion
+    }
+}

+ 120 - 0
Fork.Net/Y.Skin/YoForm/Irregular/IrregularFormSkin.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>

BIN
Fork.Net/Y.Test/Images/BackgroundImages/Rainbow.png


+ 2 - 1
Fork.Net/Y.Test/Program.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Windows.Forms;
+using Y.Test.Views;
 
 namespace Y.Test
 {
@@ -16,7 +17,7 @@ namespace Y.Test
         {
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
-            Application.Run(new Form1());
+            Application.Run(new MainForm());
         }
     }
 }

+ 112 - 0
Fork.Net/Y.Test/Views/MainForm.Designer.cs

@@ -0,0 +1,112 @@
+namespace Y.Test.Views
+{
+    partial class MainForm
+    {
+        /// <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()
+        {
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
+            this.button1 = new System.Windows.Forms.Button();
+            this.checkBox1 = new System.Windows.Forms.CheckBox();
+            this.label1 = new System.Windows.Forms.Label();
+            this.listView1 = new System.Windows.Forms.ListView();
+            this.button2 = new System.Windows.Forms.Button();
+            this.SuspendLayout();
+            // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(169, 176);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(75, 23);
+            this.button1.TabIndex = 0;
+            this.button1.Text = "button1";
+            this.button1.UseVisualStyleBackColor = true;
+            // 
+            // checkBox1
+            // 
+            this.checkBox1.AutoSize = true;
+            this.checkBox1.Location = new System.Drawing.Point(180, 269);
+            this.checkBox1.Name = "checkBox1";
+            this.checkBox1.Size = new System.Drawing.Size(78, 16);
+            this.checkBox1.TabIndex = 1;
+            this.checkBox1.Text = "checkBox1";
+            this.checkBox1.UseVisualStyleBackColor = true;
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(201, 332);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(41, 12);
+            this.label1.TabIndex = 2;
+            this.label1.Text = "label1";
+            // 
+            // listView1
+            // 
+            this.listView1.Location = new System.Drawing.Point(270, 102);
+            this.listView1.Name = "listView1";
+            this.listView1.Size = new System.Drawing.Size(121, 97);
+            this.listView1.TabIndex = 3;
+            this.listView1.UseCompatibleStateImageBehavior = false;
+            // 
+            // button2
+            // 
+            this.button2.Location = new System.Drawing.Point(315, 244);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(75, 23);
+            this.button2.TabIndex = 4;
+            this.button2.Text = "button2";
+            this.button2.UseVisualStyleBackColor = true;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
+            // 
+            // MainForm
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
+            this.ClientSize = new System.Drawing.Size(591, 532);
+            this.Controls.Add(this.button2);
+            this.Controls.Add(this.listView1);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.checkBox1);
+            this.Controls.Add(this.button1);
+            this.Name = "MainForm";
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+            this.Text = "MainForm";
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.CheckBox checkBox1;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.ListView listView1;
+        private System.Windows.Forms.Button button2;
+    }
+}

+ 26 - 0
Fork.Net/Y.Test/Views/MainForm.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using Y.Skin.YoForm.Irregular;
+
+namespace Y.Test.Views
+{
+    public partial class MainForm : IrregularForm
+    {
+        public MainForm()
+        {
+            InitializeComponent();
+        }
+
+        private void button2_Click(object sender, EventArgs e)
+        {
+            Close();
+        }
+    }
+}

File diff suppressed because it is too large
+ 6985 - 0
Fork.Net/Y.Test/Views/MainForm.resx


+ 13 - 0
Fork.Net/Y.Test/Y.Test.csproj

@@ -54,6 +54,12 @@
     </Compile>
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Views\MainForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="Views\MainForm.Designer.cs">
+      <DependentUpon>MainForm.cs</DependentUpon>
+    </Compile>
     <EmbeddedResource Include="Form1.resx">
       <DependentUpon>Form1.cs</DependentUpon>
     </EmbeddedResource>
@@ -66,6 +72,9 @@
       <AutoGen>True</AutoGen>
       <DependentUpon>Resources.resx</DependentUpon>
     </Compile>
+    <EmbeddedResource Include="Views\MainForm.resx">
+      <DependentUpon>MainForm.cs</DependentUpon>
+    </EmbeddedResource>
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -85,6 +94,10 @@
       <Name>Y.Skin</Name>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup />
+  <ItemGroup>
+    <Content Include="Images\BackgroundImages\Rainbow.png" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.

+ 137 - 0
Fork.Net/Y.Utils/WindowsUtils/APIUtils/FormStyleAPI.cs

@@ -0,0 +1,137 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Y.Utils.WindowsUtils.APIUtils
+{
+    public class FormStyleAPI
+    {
+        [StructLayout(LayoutKind.Sequential)]
+        public struct Size
+        {
+            public Int32 cx;
+            public Int32 cy;
+
+            public Size(Int32 x, Int32 y)
+            {
+                cx = x;
+                cy = y;
+            }
+        }
+
+        [StructLayout(LayoutKind.Sequential, Pack = 1)]
+        public struct BLENDFUNCTION
+        {
+            public byte BlendOp;
+            public byte BlendFlags;
+            public byte SourceConstantAlpha;
+            public byte AlphaFormat;
+        }
+
+        [StructLayout(LayoutKind.Sequential)]
+        public struct Point
+        {
+            public Int32 x;
+            public Int32 y;
+
+            public Point(Int32 x, Int32 y)
+            {
+                this.x = x;
+                this.y = y;
+            }
+        }
+
+        public const byte AC_SRC_OVER = 0;
+        public const Int32 ULW_ALPHA = 2;
+        public const byte AC_SRC_ALPHA = 1;
+
+        /// <summary>
+        /// 从左到右显示
+        /// </summary>
+        public const Int32 AW_HOR_POSITIVE = 0x00000001;
+        /// <summary>
+        /// 从右到左显示
+        /// </summary>
+        public const Int32 AW_HOR_NEGATIVE = 0x00000002;
+        /// <summary>
+        /// 从上到下显示
+        /// </summary>
+        public const Int32 AW_VER_POSITIVE = 0x00000004;
+        /// <summary>
+        /// 从下到上显示
+        /// </summary>
+        public const Int32 AW_VER_NEGATIVE = 0x00000008;
+        /// <summary>
+        /// 若使用了AW_HIDE标志,则使窗口向内重叠,即收缩窗口;否则使窗口向外扩展,即展开窗口
+        /// </summary>
+        public const Int32 AW_CENTER = 0x00000010;
+        /// <summary>
+        /// 隐藏窗口,缺省则显示窗口
+        /// </summary>
+        public const Int32 AW_HIDE = 0x00010000;
+        /// <summary>
+        /// 激活窗口。在使用了AW_HIDE标志后不能使用这个标志
+        /// </summary>
+        public const Int32 AW_ACTIVATE = 0x00020000;
+        /// <summary>
+        /// 使用滑动类型。缺省则为滚动动画类型。当使用AW_CENTER标志时,这个标志就被忽略
+        /// </summary>
+        public const Int32 AW_SLIDE = 0x00040000;
+        /// <summary>
+        /// 透明度从高到低
+        /// </summary>
+        public const Int32 AW_BLEND = 0x00080000;
+
+        /// <summary>
+        /// 执行动画
+        /// </summary>
+        /// <param name="whnd">控件句柄</param>
+        /// <param name="dwtime">动画时间</param>
+        /// <param name="dwflag">动画组合名称</param>
+        /// <returns>bool值,动画是否成功</returns>
+        [DllImport("user32")]
+        public static extern bool AnimateWindow(IntPtr whnd, int dwtime, int dwflag);
+
+        [DllImport("user32")]
+        public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
+
+        [DllImport("gdi32.dll")]
+        public static extern int CreateRoundRectRgn(int x1, int y1, int x2, int y2, int x3, int y3);
+
+        [DllImport("user32.dll")]
+        public static extern int SetWindowRgn(IntPtr hwnd, int hRgn, Boolean bRedraw);
+
+        [DllImport("user32", EntryPoint = "GetWindowLong")]
+        public static extern uint GetWindowLong(IntPtr hwnd, int nIndex);
+
+        [DllImport("user32", EntryPoint = "SetWindowLong")]
+        public static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint dwNewLong);
+
+        [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
+        public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
+
+        [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
+        public static extern IntPtr GetDC(IntPtr hWnd);
+
+        [DllImport("gdi32.dll", ExactSpelling = true)]
+        public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObj);
+
+        [DllImport("user32.dll", ExactSpelling = true)]
+        public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
+
+        [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
+        public static extern int DeleteDC(IntPtr hDC);
+
+        [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
+        public static extern int DeleteObject(IntPtr hObj);
+
+        [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
+        public static extern int UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pptSrc, Int32 crKey, ref BLENDFUNCTION pblend, Int32 dwFlags);
+
+        [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
+        public static extern IntPtr ExtCreateRegion(IntPtr lpXform, uint nCount, IntPtr rgnData);
+    }
+}

+ 1 - 0
Fork.Net/Y.Utils/Y.Utils.csproj

@@ -64,6 +64,7 @@
     <Compile Include="IOUtils\PathUtils\DirTool.cs" />
     <Compile Include="IOUtils\FileUtils\FileCodeTool.cs" />
     <Compile Include="IOUtils\FileUtils\FileTool.cs" />
+    <Compile Include="WindowsUtils\APIUtils\FormStyleAPI.cs" />
     <Compile Include="WindowsUtils\InfoUtils\ClipboardTool.cs" />
     <Compile Include="DataUtils\EncryptUtils\AesTool.cs" />
     <Compile Include="DataUtils\EncryptUtils\DesTool.cs" />