using MGdu.WinFormUI; using ryControls; using SkinPreview; 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; namespace RySkins { [ComVisible(true)] public partial class SKinTabForm : SKinForm { public new DateTime OpenTime { get; private set; } = DateTime.MinValue; /// /// 无参数启动 /// public SKinTabForm() : base() { OpenTime = DateTime.Now; InitializeComponent(); this.Resize += TabControl1_Resize; InitTab(); } /// /// 无参数启动 /// public SKinTabForm(string[] args) : base() { OpenTime = DateTime.Now; InitializeComponent(); this.Resize += TabControl1_Resize; InitTab(); } private void InitTab() { UpdateSkins(); //chromeTabControl1.Radius =4; chromeTabControl1.TabMaxWidth = 200; chromeTabControl1.SizeMode = TabSizeMode.Fixed; chromeTabControl1.SelectedIndexChanged += TabControl1_SelectedIndexChanged; } /// /// 显示的窗口列表 /// public List
TabForms { get; set; }=new List(); private int _SelectedIndex = 0; /// /// 设置选择的标签页 /// public int SelectedIndex { get { return _SelectedIndex; } set { _SelectedIndex = value; if(chromeTabControl1.TabPages.Count> _SelectedIndex) { chromeTabControl1.SelectedIndex= _SelectedIndex; } } } public void UpdateSkins() { chromeTabControl1.TabOnColorStart = XTheme.Mdi_TabActiveBackColorTop; chromeTabControl1.TabOnColorEnd = XTheme.Mdi_TabActiveBackColorBottom; chromeTabControl1.TabOffColorStart = XTheme.Mdi_TabDeactiveBackColorTop; chromeTabControl1.TabOffColorEnd = XTheme.Mdi_TabDeactiveBackColorBottom; chromeTabControl1.TabMoveColorStart = SkinSetting.TabMoveColorStart; chromeTabControl1.TabMoveColorEnd = SkinSetting.TabMoveColorEnd; chromeTabControl1.DrawTabBorder = SkinSetting.DrawTabBorder; chromeTabControl1.BackTabPageColor = SkinSetting.AllTabBackColor; this.BackColor= SkinSetting.AllTabBackColor; //chromeTabControl1.wid chromeTabControl1.Radius= XTheme.TabRadius; chromeTabControl1.Refresh(); } private void SKinTabForm_Load(object sender, EventArgs e) { UpdateSkins(); for (int i = 0; i < TabForms.Count; i++) { var item = TabForms[i]; item.EnabledChanged += Item_EnabledChanged; TabPage tab = new TabPage { Text = item.Text+" ", BackColor= SystemColors.Window }; ryCommon.RyForm.SetChildStyle(item); ryCommon.RyForm.SetParentWin(item, tab); chromeTabControl1.TabPages.Add(tab); if(i==_SelectedIndex) { item.Show(); } } ReizeUI(); } private void Item_EnabledChanged(object sender, EventArgs e) { this.Enabled = ((Form)sender).Enabled; } private void TabControl1_SelectedIndexChanged(object sender, EventArgs e) { TabForms[chromeTabControl1.SelectedIndex].Activate(); TabForms[chromeTabControl1.SelectedIndex].Show(); } private void TabControl1_Resize(object sender, EventArgs e) { ReizeUI(); } private void ReizeUI() { if(chromeTabControl1.TabPages.Count!= TabForms.Count) { return; } for (int i = 0; i < TabForms.Count; i++) { var item = TabForms[i]; chromeTabControl1.TabPages[i].Refresh(); ryCommon.RyForm.ResizeWin(item, chromeTabControl1.TabPages[i]); } } private void SKinTabForm_FormClosing(object sender, FormClosingEventArgs e) { for (int i = 0; i < TabForms.Count; i++) { var item = TabForms[i]; item.Close(); } } private void SKinTabForm_FormClosed(object sender, FormClosedEventArgs e) { } } }