### RaUI V4.0.2606.0401 - *.[新增]QuickWeb新增支持重试次数。 - *.[新增]RySetting类新增支持json格式设置存储和获取。 - *.[新增]RySetting类新增支持读取设置到内存,然后按配置名称读取。 - *.[新增]新增SuperFileSearch类,文件查找。 - *.[新增]QuickWeb新增CurPageUrl属性。 - *.[新增]HardWare新增支持获取显示器信息。 - *.[新增]HardWare新增GetWMI函数。 - *.[改进]QuickWeb类的UA从IE改为Edge。 - *.[改进]Hosts类IP与域名分隔符从\t改为三个空格。 - *.[改进]RyImage的CropOrFill函数,如果输入的长宽比例与原图一致,则返回原图的副本而不是原图。 - *.[改进]RySoft类的CompareVer函数支持特殊格式的版本号。 - *.[改进]QuickWeb的ConvertUrl函数新增支持自动从CurPageUrl获取。 - *.[改进]DateDiff函数对时间差异小于等于10秒的,自动加上毫秒数据。 - *.[修复]修复ObjectListView控件的AspectGetter方法可能调用null对象的问题。 - *.[修复]修复日期选择控件在获取节假日数据时,会因为节假日文件夹无法访问而报错的问题。 - *.[修复]修复某些情况下剪切板权限问题导致ObjectListView控件报错。 - *.[修复]修复RyImage的CropOrFill函数图片比例不一致时,也是返回原图副本的BUG。 ### Itrycn_Project2 V1.0.2606.0401 - *.[改进]将公共调用,无需新增内容的部分代码,改到Public文件夹下
257 lines
9.5 KiB
C#
257 lines
9.5 KiB
C#
using MGdu.WinFormUI;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
|
|
namespace RySkins
|
|
{
|
|
public partial class SkinMdiForm : GMForm
|
|
{
|
|
/// <summary>
|
|
/// 顶部栏
|
|
/// </summary>
|
|
[Description("顶部栏")]
|
|
public Panel TopPanel { get; set; } = null;
|
|
/// <summary>
|
|
/// 左侧栏
|
|
/// </summary>
|
|
[Description("左侧栏")]
|
|
public Panel LeftPanel { get; set; } = null;
|
|
public SkinMdiForm()
|
|
{
|
|
InitializeComponent();
|
|
InitMdiSkin();
|
|
}
|
|
public SkinMdiForm(string[] args)
|
|
{
|
|
InitializeComponent();
|
|
InitMdiSkin();
|
|
}
|
|
#region 加载皮肤
|
|
/// <summary>
|
|
/// 加载皮肤
|
|
/// </summary>
|
|
public void InitMdiSkin()
|
|
{
|
|
_mdiClient = FindMdiClient();
|
|
base.SizeChanged += new EventHandler((object sender, EventArgs e) =>
|
|
{
|
|
if (base.WindowState == FormWindowState.Maximized)
|
|
{
|
|
base.ControlBoxOffset = new Point(4, base.BorderWidth);
|
|
}
|
|
else
|
|
{
|
|
base.ControlBoxOffset = new Point(4, 1);
|
|
}
|
|
SetFormItemLocation(TopPanel);
|
|
});
|
|
base.Load += new EventHandler((object sender, EventArgs e) =>
|
|
{
|
|
base.XTheme = new RySkins.ThemeForm();
|
|
base.XTheme.Mdi_TabMinWidth = 70;
|
|
base.XTheme.Mdi_TabNormalWidth = 100;
|
|
base.XTheme.Mdi_TabMaxWidth = 145;
|
|
base.XTheme.Mdi_ShowNewTabBtn = false;
|
|
base.XTheme.Mdi_AlwaysShowListAllBtn = false;
|
|
base.XTheme.Mdi_BarBottomRegionHeight = 0;
|
|
base.XTheme.Mdi_ShowTabCloseIcon = true;
|
|
base.XTheme.Mdi_TabShowBorder = false;
|
|
base.XTheme.Mdi_BarMargin = new Padding(6, 0, 100, 0);
|
|
base.XTheme.Mdi_TabActiveBackColorTop = Color.White;
|
|
base.XTheme.Mdi_ShowTabIcon = false;
|
|
base.XTheme.Mdi_TabActiveBackColorBottom = Color.FromArgb(248, 248, 248);
|
|
base.XTheme.Mdi_TabDeactiveBackColorTop = Color.FromArgb(230, 230, 230);
|
|
base.XTheme.Mdi_TabDeactiveBackColorBottom = Color.FromArgb(230, 230, 230);
|
|
//base.XTheme.Mdi_UseMsgToActivateChild
|
|
base.MdiNewTabButtonClick += new EventHandler(NewFormClick);
|
|
base.MdiTabCloseButtonClick += new EventHandler(ChildFormClose);
|
|
//base.XTheme.Mdi_TabTopSpace += 80;
|
|
if (_mdiClient != null)
|
|
{
|
|
_mdiClient.Dock = DockStyle.None;
|
|
_mdiClient.BackColor = Color.White;
|
|
}
|
|
this.Location = new Point((Screen.PrimaryScreen.WorkingArea.Width - Width) / 2, (Screen.PrimaryScreen.WorkingArea.Height - Height) / 2);
|
|
});
|
|
base.MdiBarCreated += new EventHandler((object sender, EventArgs e) =>
|
|
{
|
|
SetFormItemLocation(TopPanel);
|
|
Application.DoEvents();
|
|
Thread th = new Thread(Start);
|
|
th.Start();
|
|
void Start()
|
|
{
|
|
Thread.Sleep(10);
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
this.SuspendLayout();
|
|
//CreateNewChild(typeof(DYun.OTools.FrmGZ));
|
|
for (int i = 0; i < MdiForms.Count; i++)
|
|
{
|
|
CreateNewChild(MdiForms[i]);
|
|
}
|
|
this.ResumeLayout(false);
|
|
//CreateNewChild(typeof(DbOp.FrmCaijiView));
|
|
//Application.DoEvents();
|
|
if (this.MdiChildren.Length > 0)
|
|
{
|
|
this.ActivateMdiChildForm(this.MdiChildren[0]);
|
|
}
|
|
}));
|
|
}
|
|
});
|
|
}
|
|
/// <summary>
|
|
/// 要初始化加载的Form列表
|
|
/// </summary>
|
|
public List<Form> MdiForms { get; set; } = new List<Form>();
|
|
/// <summary>
|
|
/// 创建子窗体
|
|
/// </summary>
|
|
/// <param name="form"></param>
|
|
public void CreateNewChild(Form form)
|
|
{
|
|
//form.SuspendLayout();
|
|
form.FormClosed += new FormClosedEventHandler(base.MdiChildClosed);
|
|
form.VisibleChanged += new EventHandler(base.MdiChildVisibleChange);
|
|
form.MdiParent = this;
|
|
//f.BackColor = Color.White;
|
|
//form.FormBorderStyle = FormBorderStyle.SizableToolWindow;
|
|
form.SizeGripStyle = SizeGripStyle.Show;
|
|
form.WindowState = FormWindowState.Maximized;
|
|
form.Show();
|
|
//form.Refresh();
|
|
// form.ResumeLayout(false);
|
|
//f.Focus();
|
|
}
|
|
private void CreateNewChild(Type form)
|
|
{
|
|
Form f = (Form)Activator.CreateInstance(form);
|
|
f.FormClosed += new FormClosedEventHandler(base.MdiChildClosed);
|
|
f.VisibleChanged += new EventHandler(base.MdiChildVisibleChange);
|
|
f.MdiParent = this;
|
|
//f.BackColor = Color.White;
|
|
f.FormBorderStyle = FormBorderStyle.SizableToolWindow;
|
|
f.SizeGripStyle = SizeGripStyle.Show;
|
|
f.WindowState = FormWindowState.Maximized;
|
|
f.Show();
|
|
//f.Focus();
|
|
}
|
|
|
|
MdiClient _mdiClient;
|
|
private int PanelTopHeight
|
|
{
|
|
get
|
|
{
|
|
return TopPanel == null ? 0 : TopPanel.Height;
|
|
}
|
|
|
|
}
|
|
|
|
private void NewFormClick(object sender, EventArgs e)
|
|
{
|
|
// CreateNewChild();
|
|
}
|
|
/// <summary>
|
|
/// 至少保留一个子窗体
|
|
/// </summary>
|
|
public bool AleastOneChild { get; set; } = true;
|
|
private void ChildFormClose(object sender, EventArgs e)
|
|
{
|
|
if (sender is Form f)
|
|
{
|
|
if (AleastOneChild)
|
|
{
|
|
if (this.GetCurrentMdiChildren().Count == 1) { return; }
|
|
}
|
|
f.Close();
|
|
}
|
|
this.Invalidate();
|
|
}
|
|
private MdiClient FindMdiClient()
|
|
{
|
|
MdiClient mdi = null;
|
|
foreach (Control c in Controls)
|
|
{
|
|
if ((mdi = c as MdiClient) != null)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
return mdi;
|
|
}
|
|
private void SetMdiBarLocation()
|
|
{
|
|
Padding newMargin = Padding.Empty;
|
|
//if (WindowState == FormWindowState.Maximized)
|
|
// newMargin = new Padding(BorderWidth, BorderWidth, BorderWidth, 0);
|
|
//else
|
|
//PnlMenu.Top = BorderWidth + base.XTheme.CaptionHeight;
|
|
int left_bar_width = 0;
|
|
if (LeftPanel != null) { left_bar_width = LeftPanel.Width; }
|
|
newMargin = new Padding(BorderWidth + left_bar_width, BorderWidth + base.XTheme.CaptionHeight + PanelTopHeight, BorderWidth, 0);
|
|
if (base.XTheme.Mdi_BarMargin != newMargin)
|
|
{
|
|
base.XTheme.Mdi_BarMargin = newMargin;
|
|
Invalidate();
|
|
}
|
|
}
|
|
private void SetPanelTopLocation(Panel PnlTop)
|
|
{
|
|
//Point newLocation = new Point(base.MdiBarBounds.Left, base.XTheme.CaptionHeight + BorderWidth);
|
|
//var size = new Size(base.MdiBarBounds.Width, PanelTopHeight);
|
|
//if (PnlTop != null)
|
|
//{
|
|
// //PnlTop.Anchor = AnchorStyles.None;
|
|
// PnlTop.Location = newLocation;
|
|
// PnlTop.Size = size;
|
|
// //PnlTop.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
|
|
//}
|
|
}
|
|
private void SetFormItemLocation(Panel PnlTop)
|
|
{
|
|
if (DesignMode) { return; }
|
|
SetMdiBarLocation();
|
|
SetPanelTopLocation(PnlTop);
|
|
SetMdiClientLocation(PnlTop);
|
|
}
|
|
private void SetMdiClientLocation(Panel PnlTop)
|
|
{
|
|
if (_mdiClient == null)
|
|
return;
|
|
int left_bar_width = 0;
|
|
if (LeftPanel != null) { left_bar_width = LeftPanel.Width; }
|
|
Point newLocation = new Point(BorderWidth, base.XTheme.CaptionHeight + base.XTheme.Mdi_TabHeight);
|
|
var size = new Size(ClientRectangle.Width - BorderWidth - BorderWidth, ClientRectangle.Height - base.XTheme.CaptionHeight - base.XTheme.Mdi_TabHeight - BorderWidth);
|
|
if (PnlTop != null)
|
|
{
|
|
newLocation = new Point(PnlTop.Left + left_bar_width, PnlTop.Bottom + base.XTheme.Mdi_TabHeight);
|
|
if (_mdiClient.Location == newLocation)
|
|
return;
|
|
|
|
int height = base.Height - newLocation.Y - BorderWidth - BorderWidth;
|
|
|
|
size = new Size(PnlTop.Width - left_bar_width, height);
|
|
}
|
|
_mdiClient.Anchor = AnchorStyles.None;
|
|
_mdiClient.Location = newLocation;
|
|
_mdiClient.Size = size;
|
|
_mdiClient.Anchor =
|
|
AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;
|
|
}
|
|
#endregion
|
|
|
|
private void SkinMdiForm_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|