* UIStyles: 增加了一个设置控件容器内子控件自定义主题色的方法
This commit is contained in:
parent
41f23482cd
commit
3f2d4d542b
@ -430,6 +430,45 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetChildCustomStyle(this Control ctrl, UIStyle style)
|
||||
{
|
||||
List<Control> controls = ctrl.GetUIStyleControls("IStyleInterface");
|
||||
foreach (var control in controls)
|
||||
{
|
||||
if (control is IStyleInterface item)
|
||||
{
|
||||
if (item is UIPage uipage && uipage.Parent is TabPage tabpage)
|
||||
{
|
||||
TabControl tabControl = tabpage.Parent as TabControl;
|
||||
if (tabControl.SelectedTab == tabpage)
|
||||
{
|
||||
item.SetStyleColor(style.Colors());
|
||||
item.Style = UIStyle.Custom;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
item.SetStyleColor(style.Colors());
|
||||
item.Style = UIStyle.Custom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FieldInfo[] fieldInfo = ctrl.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
foreach (var info in fieldInfo)
|
||||
{
|
||||
if (info.FieldType.Name == "UIContextMenuStrip")
|
||||
{
|
||||
UIContextMenuStrip item = (UIContextMenuStrip)info.GetValue(ctrl);
|
||||
if (item != null)
|
||||
{
|
||||
item.SetStyleColor(style.Colors());
|
||||
item.Style = UIStyle.Custom;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找包含接口名称的控件列表
|
||||
/// </summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user