diff --git a/SunnyUI.Demo/Bin/SunnyUI.Demo.exe b/SunnyUI.Demo/Bin/SunnyUI.Demo.exe index 4f64b968..c885c134 100644 Binary files a/SunnyUI.Demo/Bin/SunnyUI.Demo.exe and b/SunnyUI.Demo/Bin/SunnyUI.Demo.exe differ diff --git a/SunnyUI.Demo/Controls/FFlowLayoutPanel.Designer.cs b/SunnyUI.Demo/Controls/FFlowLayoutPanel.Designer.cs index e76faaf5..caddee63 100644 --- a/SunnyUI.Demo/Controls/FFlowLayoutPanel.Designer.cs +++ b/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; } } \ No newline at end of file diff --git a/SunnyUI.Demo/Controls/FFlowLayoutPanel.cs b/SunnyUI.Demo/Controls/FFlowLayoutPanel.cs index 12f95a7b..3f9bd942 100644 --- a/SunnyUI.Demo/Controls/FFlowLayoutPanel.cs +++ b/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("Button01"); + var button = uiFlowLayoutPanel1.Get("Button01"); - //遍历,与原生方法不同,UIFlowLayoutPanel是组合控件,从其Panel控件遍历 + //遍历,方法一 + 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控件遍历 foreach (Control item in uiFlowLayoutPanel1.Panel.Controls) { Console.WriteLine(item.Name); diff --git a/SunnyUI.Demo/SunnyUI.Demo.csproj b/SunnyUI.Demo/SunnyUI.Demo.csproj index e46da40b..18ad70e9 100644 --- a/SunnyUI.Demo/SunnyUI.Demo.csproj +++ b/SunnyUI.Demo/SunnyUI.Demo.csproj @@ -375,6 +375,12 @@ + + UserControl + + + UIFlowItem.cs + Form @@ -548,6 +554,9 @@ Resources.resx True + + UIFlowItem.cs + FCommon.cs diff --git a/SunnyUI.Demo/UIFlowItem.Designer.cs b/SunnyUI.Demo/UIFlowItem.Designer.cs new file mode 100644 index 00000000..aab9f3a5 --- /dev/null +++ b/SunnyUI.Demo/UIFlowItem.Designer.cs @@ -0,0 +1,45 @@ +namespace Sunny.UI.Demo +{ + partial class UIFlowItem + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + 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 + } +} diff --git a/SunnyUI.Demo/UIFlowItem.cs b/SunnyUI.Demo/UIFlowItem.cs new file mode 100644 index 00000000..c903be25 --- /dev/null +++ b/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); + } + } +} diff --git a/SunnyUI.Demo/UIFlowItem.resx b/SunnyUI.Demo/UIFlowItem.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/SunnyUI.Demo/UIFlowItem.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file