SunnyUI/SunnyUI/Frames/UIMainFrame.cs
Sunny 030db76dd8 * UIForm:增加IFrame接口
- UIMainFrame:删除IFrame接口,移到父类UIForm
2021-10-16 16:30:49 +08:00

104 lines
3.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/******************************************************************************
* SunnyUI 开源控件库、工具类库、扩展类库、多页面开发框架。
* CopyRight (C) 2012-2021 ShenYongHua(沈永华).
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.dll can be used for free under the GPL-3.0 license.
* If you use this code, please keep this note.
* 如果您使用此代码,请保留此说明。
******************************************************************************
* 文件名称: UIMainFrame.cs
* 文件说明: 页面框架基类
* 当前版本: V3.0
* 创建日期: 2020-05-05
*
* 2020-05-05: V2.2.5 页面框架基类
* 2021-08-17: V3.0.8 删除IFrame接口移到父类UIForm
******************************************************************************/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
namespace Sunny.UI
{
public partial class UIMainFrame : UIForm
{
public UIMainFrame()
{
InitializeComponent();
MainContainer.TabVisible = false;
MainContainer.BringToFront();
MainContainer.TabPages.Clear();
MainContainer.BeforeRemoveTabPage += MainContainer_BeforeRemoveTabPage;
MainContainer.AfterRemoveTabPage += MainContainer_AfterRemoveTabPage;
}
[DefaultValue(false)]
[Description("多页面框架时包含UIPage在点击Tab页关闭时关闭UIPage"), Category("SunnyUI")]
public bool AutoClosePage
{
get => MainContainer.AutoClosePage;
set => MainContainer.AutoClosePage = value;
}
private void MainContainer_AfterRemoveTabPage(object sender, int index)
{
AfterRemoveTabPage?.Invoke(this, index);
}
private bool MainContainer_BeforeRemoveTabPage(object sender, int index)
{
return BeforeRemoveTabPage == null || BeforeRemoveTabPage.Invoke(this, index);
}
public event UITabControl.OnBeforeRemoveTabPage BeforeRemoveTabPage;
public event UITabControl.OnAfterRemoveTabPage AfterRemoveTabPage;
protected override void OnShown(EventArgs e)
{
MainContainer.BringToFront();
base.OnShown(e);
}
public bool TabVisible
{
get => MainContainer.TabVisible;
set => MainContainer.TabVisible = value;
}
public bool TabShowCloseButton
{
get => MainContainer.ShowCloseButton;
set => MainContainer.ShowCloseButton = value;
}
public bool TabShowActiveCloseButton
{
get => MainContainer.ShowActiveCloseButton;
set => MainContainer.ShowActiveCloseButton = value;
}
private void MainContainer_Selecting(object sender, TabControlCancelEventArgs e)
{
if (Selecting != null)
{
List<UIPage> pages = e.TabPage.GetControls<UIPage>();
Selecting?.Invoke(this, e, pages.Count == 0 ? null : pages[0]);
}
}
public delegate void OnSelecting(object sender, TabControlCancelEventArgs e, UIPage page);
[Description("页面选择事件"), Category("SunnyUI")]
public event OnSelecting Selecting;
}
}