* UIPage: 更改了下页面切换重复执行的Init事件调用

This commit is contained in:
Sunny 2021-05-21 11:23:20 +08:00
parent 2b5067abc7
commit f762c913da
12 changed files with 42 additions and 68 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -945,7 +945,6 @@
//
// uiSwitch1
//
this.uiSwitch1.Active = true;
this.uiSwitch1.ActiveText = "On";
this.uiSwitch1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.uiSwitch1.InActiveText = "Off";
@ -1152,7 +1151,6 @@
//
// uiSwitch4
//
this.uiSwitch4.Active = true;
this.uiSwitch4.ActiveText = "On";
this.uiSwitch4.Font = new System.Drawing.Font("微软雅黑", 12F);
this.uiSwitch4.InActiveText = "Off";

View File

@ -13,6 +13,22 @@ namespace Sunny.UI.Demo
uiSymbolButton2.Symbol, 32, UIColor.Red);
}
//放在OnLoad事件的每次页面切换都会执行
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
uiSwitch1.Active = uiSwitch4.Active = true;
uiSwitch2.Active = uiSwitch3.Active = false;
}
//放在Init事件的每次页面切换都会执行和OnLoad保留一个就行了
//public override void Init()
//{
// base.Init();
// uiSwitch1.Active = uiSwitch4.Active = true;
// uiSwitch2.Active = uiSwitch3.Active = false;
//}
private void uiButton10_Click(object sender, EventArgs e)
{
uiButton10.Selected = !uiButton10.Selected;

View File

@ -607,7 +607,7 @@ namespace Sunny.UI
List<UIPage> pages = TabPages[SelectedIndex].GetControls<UIPage>();
foreach (var page in pages)
{
page.Init();
page.ReLoad();
}
List<UITabControlMenu> leftTabControls = TabPages[SelectedIndex].GetControls<UITabControlMenu>();

View File

@ -129,6 +129,11 @@ namespace Sunny.UI
MainTabControl.SelectPage(pageIndex);
}
public virtual void SelectPage(Guid guid)
{
MainTabControl.SelectPage(guid);
}
public bool RemovePage(int pageIndex)
{
return MainTabControl.RemovePage(pageIndex);

View File

@ -37,7 +37,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(802, 460);
this.DoubleBuffered = true;
this.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Margin = new System.Windows.Forms.Padding(5);
this.Name = "UIPage";
@ -45,6 +45,7 @@
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "UIPage";
this.Load += new System.EventHandler(this.UIPage_Load);
this.Shown += new System.EventHandler(this.UIPage_Shown);
this.ResumeLayout(false);

View File

@ -187,8 +187,6 @@ namespace Sunny.UI
[Description("获取或设置可以自定义主题风格"), Category("SunnyUI")]
public bool StyleCustomMode { get; set; }
public event EventHandler Initialize;
protected override void OnControlAdded(ControlEventArgs e)
{
base.OnControlAdded(e);
@ -219,7 +217,18 @@ namespace Sunny.UI
public virtual void Init()
{
Initialize?.Invoke(this, null);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Init();
}
public void ReLoad()
{
OnLoad(EventArgs.Empty);
}
public virtual void Final()
@ -570,5 +579,10 @@ namespace Sunny.UI
}
#endregion
private void UIPage_Load(object sender, EventArgs e)
{
}
}
}

View File

@ -1,64 +1,4 @@
<?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.
-->
<root>
<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">