Browse Source

* UIFlowLayoutPanel: 更新Demo

pull/95/head
Sunny 2 years ago
parent
commit
1902dc2e50
  1. BIN
      SunnyUI.Demo/Bin/SunnyUI.Demo.exe
  2. 30
      SunnyUI.Demo/Controls/FFlowLayoutPanel.Designer.cs
  3. 40
      SunnyUI.Demo/Controls/FFlowLayoutPanel.cs
  4. 9
      SunnyUI.Demo/SunnyUI.Demo.csproj
  5. 45
      SunnyUI.Demo/UIFlowItem.Designer.cs
  6. 20
      SunnyUI.Demo/UIFlowItem.cs
  7. 120
      SunnyUI.Demo/UIFlowItem.resx

BIN
SunnyUI.Demo/Bin/SunnyUI.Demo.exe

30
SunnyUI.Demo/Controls/FFlowLayoutPanel.Designer.cs

@ -34,14 +34,13 @@ namespace Sunny.UI.Demo
this.uiButton2 = new Sunny.UI.UIButton();
this.uiButton3 = new Sunny.UI.UIButton();
this.uiButton4 = new Sunny.UI.UIButton();
this.uiFlowLayoutPanel2 = new Sunny.UI.UIFlowLayoutPanel();
this.SuspendLayout();
//
// uiButton1
//
this.uiButton1.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiButton1.Font = new System.Drawing.Font("宋体", 12F);
this.uiButton1.Location = new System.Drawing.Point(30, 462);
this.uiButton1.Location = new System.Drawing.Point(30, 518);
this.uiButton1.MinimumSize = new System.Drawing.Size(1, 1);
this.uiButton1.Name = "uiButton1";
this.uiButton1.Size = new System.Drawing.Size(100, 35);
@ -59,7 +58,7 @@ namespace Sunny.UI.Demo
this.uiFlowLayoutPanel1.Name = "uiFlowLayoutPanel1";
this.uiFlowLayoutPanel1.Padding = new System.Windows.Forms.Padding(2);
this.uiFlowLayoutPanel1.ShowText = false;
this.uiFlowLayoutPanel1.Size = new System.Drawing.Size(354, 390);
this.uiFlowLayoutPanel1.Size = new System.Drawing.Size(746, 441);
this.uiFlowLayoutPanel1.TabIndex = 10;
this.uiFlowLayoutPanel1.Text = "`";
this.uiFlowLayoutPanel1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
@ -68,7 +67,7 @@ namespace Sunny.UI.Demo
//
this.uiButton2.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiButton2.Font = new System.Drawing.Font("宋体", 12F);
this.uiButton2.Location = new System.Drawing.Point(408, 462);
this.uiButton2.Location = new System.Drawing.Point(408, 518);
this.uiButton2.MinimumSize = new System.Drawing.Size(1, 1);
this.uiButton2.Name = "uiButton2";
this.uiButton2.Size = new System.Drawing.Size(100, 35);
@ -82,7 +81,7 @@ namespace Sunny.UI.Demo
this.uiButton3.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiButton3.Enabled = false;
this.uiButton3.Font = new System.Drawing.Font("宋体", 12F);
this.uiButton3.Location = new System.Drawing.Point(157, 462);
this.uiButton3.Location = new System.Drawing.Point(157, 518);
this.uiButton3.MinimumSize = new System.Drawing.Size(1, 1);
this.uiButton3.Name = "uiButton3";
this.uiButton3.Size = new System.Drawing.Size(100, 35);
@ -95,7 +94,7 @@ namespace Sunny.UI.Demo
//
this.uiButton4.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiButton4.Font = new System.Drawing.Font("宋体", 12F);
this.uiButton4.Location = new System.Drawing.Point(284, 462);
this.uiButton4.Location = new System.Drawing.Point(284, 518);
this.uiButton4.MinimumSize = new System.Drawing.Size(1, 1);
this.uiButton4.Name = "uiButton4";
this.uiButton4.Size = new System.Drawing.Size(100, 35);
@ -104,27 +103,11 @@ namespace Sunny.UI.Demo
this.uiButton4.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiButton4.Click += new System.EventHandler(this.uiButton4_Click);
//
// uiFlowLayoutPanel2
//
this.uiFlowLayoutPanel2.Font = new System.Drawing.Font("宋体", 12F);
this.uiFlowLayoutPanel2.Location = new System.Drawing.Point(408, 55);
this.uiFlowLayoutPanel2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiFlowLayoutPanel2.MinimumSize = new System.Drawing.Size(1, 1);
this.uiFlowLayoutPanel2.Name = "uiFlowLayoutPanel2";
this.uiFlowLayoutPanel2.Padding = new System.Windows.Forms.Padding(2);
this.uiFlowLayoutPanel2.ShowText = false;
this.uiFlowLayoutPanel2.Size = new System.Drawing.Size(354, 390);
this.uiFlowLayoutPanel2.TabIndex = 15;
this.uiFlowLayoutPanel2.Text = "`";
this.uiFlowLayoutPanel2.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.uiFlowLayoutPanel2.WrapContents = false;
//
// FFlowLayoutPanel
//
this.AllowShowTitle = true;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(800, 539);
this.Controls.Add(this.uiFlowLayoutPanel2);
this.ClientSize = new System.Drawing.Size(800, 576);
this.Controls.Add(this.uiButton4);
this.Controls.Add(this.uiButton3);
this.Controls.Add(this.uiButton2);
@ -146,6 +129,5 @@ namespace Sunny.UI.Demo
private UIButton uiButton2;
private UIButton uiButton3;
private UIButton uiButton4;
private UIFlowLayoutPanel uiFlowLayoutPanel2;
}
}

40
SunnyUI.Demo/Controls/FFlowLayoutPanel.cs

@ -15,18 +15,17 @@ namespace Sunny.UI.Demo
base.Init();
uiFlowLayoutPanel1.Clear();
index = 0;
for (int i = 0; i < 10; i++)
{
uiButton1.PerformClick();
uiButton1_Click(null, null);
}
}
private int index;
UIButton btn;
UIFlowItem btn;
private void uiButton1_Click(object sender, System.EventArgs e)
{
btn = new UIButton();
btn = new UIFlowItem();
btn.SetDPIScale();
btn.Text = "Button" + index++.ToString("D2");
btn.Name = btn.Text;
@ -39,22 +38,14 @@ namespace Sunny.UI.Demo
//uiFlowLayoutPanel1.Panel.Controls.Add(btn);
//不能用原生方法Controls.Add
//uiFlowLayoutPanel1.Controls.Add(btn);
var box = new UIGroupBox();
box.Width = 100;
box.Height = uiFlowLayoutPanel2.Height - 32;
box.SetDPIScale();
box.Text = "Button" + index++.ToString("D2");
box.Name = box.Text;
uiFlowLayoutPanel2.Add(box);
//----uiFlowLayoutPanel1.Controls.Add(btn);----
uiButton3.Enabled = true;
}
private void Btn_Click(object sender, System.EventArgs e)
{
var button = (UIButton)sender;
var button = (UIFlowItem)sender;
ShowInfoTip(button.Text);
}
@ -62,12 +53,11 @@ namespace Sunny.UI.Demo
{
//清除用Clear方法
uiFlowLayoutPanel1.Clear();
uiFlowLayoutPanel2.Clear();
//或者用
//uiFlowLayoutPanel1.Panel.Controls.Clear();
//不能用原生方法Controls.Clear
//uiFlowLayoutPanel1.Controls.Clear();
//----uiFlowLayoutPanel1.Controls.Clear();----
uiButton3.Enabled = false;
}
@ -82,7 +72,7 @@ namespace Sunny.UI.Demo
//uiFlowLayoutPanel1.Panel.Controls.Remove(btn);
//不能用原生方法Controls.Remove
//uiFlowLayoutPanel1.Controls.Remove(btn);
//----uiFlowLayoutPanel1.Controls.Remove(btn);----
btn = null;
}
@ -99,9 +89,21 @@ namespace Sunny.UI.Demo
btn = uiFlowLayoutPanel1["Button01"];
//通过名称和类型获取
UIButton button = uiFlowLayoutPanel1.Get<UIButton>("Button01");
var button = uiFlowLayoutPanel1.Get<UIFlowItem>("Button01");
//遍历,方法一
for (int i = 0; i < uiFlowLayoutPanel1.ControlCount; i++)
{
Console.WriteLine(uiFlowLayoutPanel1.Get(i).Name);
}
//遍历,方法二
foreach (Control item in uiFlowLayoutPanel1.AllControls)
{
Console.WriteLine(item.Name);
}
//遍历,与原生方法不同,UIFlowLayoutPanel是组合控件,从其Panel控件遍历
//遍历,方法三,与原生方法不同,UIFlowLayoutPanel是组合控件,从其Panel控件遍历
foreach (Control item in uiFlowLayoutPanel1.Panel.Controls)
{
Console.WriteLine(item.Name);

9
SunnyUI.Demo/SunnyUI.Demo.csproj

@ -375,6 +375,12 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UIFlowItem.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UIFlowItem.Designer.cs">
<DependentUpon>UIFlowItem.cs</DependentUpon>
</Compile>
<Compile Include="Units\FCommon.cs">
<SubType>Form</SubType>
</Compile>
@ -548,6 +554,9 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="UIFlowItem.resx">
<DependentUpon>UIFlowItem.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Units\FCommon.resx">
<DependentUpon>FCommon.cs</DependentUpon>
</EmbeddedResource>

45
SunnyUI.Demo/UIFlowItem.Designer.cs

@ -0,0 +1,45 @@
namespace Sunny.UI.Demo
{
partial class UIFlowItem
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// UIFlowItem
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Name = "UIFlowItem";
this.Size = new System.Drawing.Size(173, 103);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.UIFlowItem_Paint);
this.ResumeLayout(false);
}
#endregion
}
}

20
SunnyUI.Demo/UIFlowItem.cs

@ -0,0 +1,20 @@
using System.Drawing;
namespace Sunny.UI.Demo
{
public partial class UIFlowItem : UIUserControl
{
public UIFlowItem()
{
InitializeComponent();
}
private void UIFlowItem_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
e.Graphics.FillEllipse(Color.Lime, new Rectangle(10, 10, 20, 20));
e.Graphics.DrawString(Text, Font, ForeColor, new Rectangle(35, 0, Width, 40), ContentAlignment.MiddleLeft);
e.Graphics.DrawLine(ForeColor, 10, 40, Width - 20, 40);
e.Graphics.DrawString("Hello SunnyUI !", Font, ForeColor, new Rectangle(10, 40, Width, Height - 40), ContentAlignment.MiddleLeft);
}
}
}

120
SunnyUI.Demo/UIFlowItem.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>
Loading…
Cancel
Save