ソースを参照

添加伪窗体阴影测试

yuzhengyang 8 年 前
コミット
ac9f6d0960

+ 18 - 5
Fork.Net/Test/Y.Test/Views/MainForm.Designer.cs

@@ -33,11 +33,12 @@
             this.TestUpdateForm = new System.Windows.Forms.Button();
             this.TestPackForm = new System.Windows.Forms.Button();
             this.TestIconGroupForm = new System.Windows.Forms.Button();
+            this.TestShadowForm = new System.Windows.Forms.Button();
             this.SuspendLayout();
             // 
             // ChineseCalendarForm
             // 
-            this.ChineseCalendarForm.Location = new System.Drawing.Point(70, 80);
+            this.ChineseCalendarForm.Location = new System.Drawing.Point(12, 12);
             this.ChineseCalendarForm.Name = "ChineseCalendarForm";
             this.ChineseCalendarForm.Size = new System.Drawing.Size(262, 23);
             this.ChineseCalendarForm.TabIndex = 0;
@@ -47,7 +48,7 @@
             // 
             // TestComputerInfoForm
             // 
-            this.TestComputerInfoForm.Location = new System.Drawing.Point(70, 149);
+            this.TestComputerInfoForm.Location = new System.Drawing.Point(12, 41);
             this.TestComputerInfoForm.Name = "TestComputerInfoForm";
             this.TestComputerInfoForm.Size = new System.Drawing.Size(262, 23);
             this.TestComputerInfoForm.TabIndex = 1;
@@ -57,7 +58,7 @@
             // 
             // TestUpdateForm
             // 
-            this.TestUpdateForm.Location = new System.Drawing.Point(70, 206);
+            this.TestUpdateForm.Location = new System.Drawing.Point(12, 70);
             this.TestUpdateForm.Name = "TestUpdateForm";
             this.TestUpdateForm.Size = new System.Drawing.Size(262, 23);
             this.TestUpdateForm.TabIndex = 2;
@@ -67,7 +68,7 @@
             // 
             // TestPackForm
             // 
-            this.TestPackForm.Location = new System.Drawing.Point(70, 267);
+            this.TestPackForm.Location = new System.Drawing.Point(12, 99);
             this.TestPackForm.Name = "TestPackForm";
             this.TestPackForm.Size = new System.Drawing.Size(262, 23);
             this.TestPackForm.TabIndex = 3;
@@ -77,7 +78,7 @@
             // 
             // TestIconGroupForm
             // 
-            this.TestIconGroupForm.Location = new System.Drawing.Point(70, 322);
+            this.TestIconGroupForm.Location = new System.Drawing.Point(12, 128);
             this.TestIconGroupForm.Name = "TestIconGroupForm";
             this.TestIconGroupForm.Size = new System.Drawing.Size(262, 23);
             this.TestIconGroupForm.TabIndex = 4;
@@ -85,11 +86,22 @@
             this.TestIconGroupForm.UseVisualStyleBackColor = true;
             this.TestIconGroupForm.Click += new System.EventHandler(this.TestIconGroupForm_Click);
             // 
+            // TestShadowForm
+            // 
+            this.TestShadowForm.Location = new System.Drawing.Point(12, 157);
+            this.TestShadowForm.Name = "TestShadowForm";
+            this.TestShadowForm.Size = new System.Drawing.Size(262, 23);
+            this.TestShadowForm.TabIndex = 5;
+            this.TestShadowForm.Text = "TestShadowForm";
+            this.TestShadowForm.UseVisualStyleBackColor = true;
+            this.TestShadowForm.Click += new System.EventHandler(this.TestShadowForm_Click);
+            // 
             // MainForm
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(564, 427);
+            this.Controls.Add(this.TestShadowForm);
             this.Controls.Add(this.TestIconGroupForm);
             this.Controls.Add(this.TestPackForm);
             this.Controls.Add(this.TestUpdateForm);
@@ -108,5 +120,6 @@
         private System.Windows.Forms.Button TestUpdateForm;
         private System.Windows.Forms.Button TestPackForm;
         private System.Windows.Forms.Button TestIconGroupForm;
+        private System.Windows.Forms.Button TestShadowForm;
     }
 }

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

@@ -41,5 +41,10 @@ namespace Y.Test.Views
         {
             R.Forms.GetUnique<TestIconGroupForm>().Show();
         }
+
+        private void TestShadowForm_Click(object sender, EventArgs e)
+        {
+            R.Forms.GetUnique<TestShadowForm>().Show();
+        }
     }
 }

+ 51 - 0
Fork.Net/Test/Y.Test/Views/TestShadowForm.Designer.cs

@@ -0,0 +1,51 @@
+namespace Y.Test.Views
+{
+    partial class TestShadowForm
+    {
+        /// <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();
+            // 
+            // 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.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
+    }
+}

+ 110 - 0
Fork.Net/Test/Y.Test/Views/TestShadowForm.cs

@@ -0,0 +1,110 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Windows.Forms;
+using Y.Utils.WindowsUtils.APIUtils;
+
+namespace Y.Test.Views
+{
+    public partial class TestShadowForm : Form
+    {
+        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);
+            }
+        }
+    }
+}

+ 120 - 0
Fork.Net/Test/Y.Test/Views/TestShadowForm.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>

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

@@ -136,6 +136,12 @@
     <Compile Include="Views\TestPackForm.Designer.cs">
       <DependentUpon>TestPackForm.cs</DependentUpon>
     </Compile>
+    <Compile Include="Views\TestShadowForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="Views\TestShadowForm.Designer.cs">
+      <DependentUpon>TestShadowForm.cs</DependentUpon>
+    </Compile>
     <Compile Include="Views\TestSimpleTitle.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -188,6 +194,9 @@
     <EmbeddedResource Include="Views\TestPackForm.resx">
       <DependentUpon>TestPackForm.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="Views\TestShadowForm.resx">
+      <DependentUpon>TestShadowForm.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="Views\TestSimpleTitle.resx">
       <DependentUpon>TestSimpleTitle.cs</DependentUpon>
     </EmbeddedResource>

+ 6 - 3
Fork.Net/Y.Skin/YoForm/Irregular/IrregularForm.cs

@@ -1,7 +1,10 @@
-//############################################################
+//************************************************************************
 //      https://github.com/yuzhengyang
-//      author: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;