* 重构下拉框组件配色
This commit is contained in:
parent
b988632507
commit
cdbd479d5e
Binary file not shown.
Binary file not shown.
@ -65,7 +65,7 @@ namespace Sunny.UI
|
||||
{
|
||||
tip.IsScaled = true;
|
||||
float size = SubFont != null ? SubFont.Size : UIFontColor.SubFontSize;
|
||||
tip.Font = this.DPIScaleFont(Font, size);
|
||||
tip.Font = this.Font.DPIScaleFont(size);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
@ -201,7 +201,7 @@ namespace Sunny.UI
|
||||
if (tmpFont == null || !tmpFont.Size.EqualsFloat(size / UIDPIScale.DPIScale()))
|
||||
{
|
||||
tmpFont?.Dispose();
|
||||
tmpFont = this.DPIScaleFont(Font, size);
|
||||
tmpFont = this.Font.DPIScaleFont(size);
|
||||
}
|
||||
|
||||
return tmpFont;
|
||||
@ -219,7 +219,7 @@ namespace Sunny.UI
|
||||
if (tmpLegendFont == null || !tmpLegendFont.Size.EqualsFloat(size / UIDPIScale.DPIScale()))
|
||||
{
|
||||
tmpLegendFont?.Dispose();
|
||||
tmpLegendFont = this.DPIScaleFont(Font, size);
|
||||
tmpLegendFont = this.Font.DPIScaleFont(size);
|
||||
}
|
||||
|
||||
return tmpLegendFont;
|
||||
|
@ -605,7 +605,7 @@ namespace Sunny.UI
|
||||
e.Graphics.FillRectangle(c, r);
|
||||
}
|
||||
|
||||
public override void SetStyle(UIBaseStyle uiColor)
|
||||
public override void SetStyleColor(UIBaseStyle uiColor)
|
||||
{
|
||||
base.SetStyleColor(uiColor);
|
||||
RectColor = uiColor.RectColor;
|
||||
|
@ -264,6 +264,18 @@ namespace Sunny.UI
|
||||
|
||||
}
|
||||
|
||||
public override void SetStyleColor(UIBaseStyle uiColor)
|
||||
{
|
||||
base.SetStyleColor(uiColor);
|
||||
pFilter.SetStyleColor(uiColor.DropDownStyle);
|
||||
dataGridView.SetStyleColor(uiColor.DropDownStyle);
|
||||
panel.SetStyleColor(uiColor.DropDownStyle);
|
||||
edtFilter.SetStyleColor(uiColor.DropDownStyle);
|
||||
btnOK.SetStyleColor(uiColor.DropDownStyle);
|
||||
btnSearch.SetStyleColor(uiColor.DropDownStyle);
|
||||
btnClear.SetStyleColor(uiColor.DropDownStyle);
|
||||
}
|
||||
|
||||
private void DataGridView_DataSourceChanged(object sender, System.EventArgs e)
|
||||
{
|
||||
if (dataGridView.RowCount > 0)
|
||||
|
@ -150,8 +150,9 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetStyle(UIBaseStyle style)
|
||||
public override void SetStyleColor(UIBaseStyle style)
|
||||
{
|
||||
base.SetStyleColor(style);
|
||||
treeView.Style = style.Name;
|
||||
panel.Style = style.Name;
|
||||
btnOK.Style = style.Name;
|
||||
|
@ -555,6 +555,8 @@ namespace Sunny.UI
|
||||
b2.SetStyleColor(uiColor);
|
||||
b3.SetStyleColor(uiColor);
|
||||
b4.SetStyleColor(uiColor);
|
||||
fillColor = Color.White;
|
||||
foreColor = uiColor.DropDownPanelForeColor;
|
||||
|
||||
b1.FillColor = b2.FillColor = b3.FillColor = b4.FillColor = TopPanel.FillColor;
|
||||
RectColor = uiColor.RectColor;
|
||||
|
@ -961,7 +961,13 @@ namespace Sunny.UI
|
||||
public override void SetStyleColor(UIBaseStyle uiColor)
|
||||
{
|
||||
base.SetStyleColor(uiColor);
|
||||
FillColor = Color.White;
|
||||
|
||||
btnOK.SetStyleColor(uiColor);
|
||||
btnCancel.SetStyleColor(uiColor);
|
||||
|
||||
fillColor = Color.White;
|
||||
foreColor = uiColor.DropDownPanelForeColor;
|
||||
|
||||
b1.SetStyleColor(uiColor);
|
||||
b2.SetStyleColor(uiColor);
|
||||
b3.SetStyleColor(uiColor);
|
||||
@ -989,13 +995,6 @@ namespace Sunny.UI
|
||||
s1.SymbolColor = s2.SymbolColor = RectColor;
|
||||
}
|
||||
|
||||
public override void SetStyle(UIBaseStyle style)
|
||||
{
|
||||
base.SetStyle(style);
|
||||
btnOK.SetStyleColor(style);
|
||||
btnCancel.SetStyleColor(style);
|
||||
}
|
||||
|
||||
private void UITimeItem_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
if (e.Delta < 0)
|
||||
|
@ -286,7 +286,7 @@ namespace Sunny.UI
|
||||
|
||||
if (!edit.Visible)
|
||||
{
|
||||
base.OnPaintFore(g, path);
|
||||
g.DrawString(Text, Font, GetForeColor(), Size, Padding, TextAlignment);
|
||||
}
|
||||
|
||||
g.FillRectangle(GetFillColor(), new Rectangle(Width - 27, Radius / 2, 26, Height - Radius));
|
||||
@ -367,7 +367,7 @@ namespace Sunny.UI
|
||||
public override void SetStyleColor(UIBaseStyle uiColor)
|
||||
{
|
||||
base.SetStyleColor(uiColor);
|
||||
foreColor = uiColor.DropDownControlColor;
|
||||
foreColor = uiColor.DropDownPanelForeColor;
|
||||
edit.BackColor = fillColor = Color.White;
|
||||
}
|
||||
|
||||
@ -394,7 +394,7 @@ namespace Sunny.UI
|
||||
ItemForm.SetRectColor(rectColor);
|
||||
ItemForm.SetFillColor(fillColor);
|
||||
ItemForm.SetForeColor(foreColor);
|
||||
ItemForm.SetStyle(UIStyles.ActiveStyleColor);
|
||||
ItemForm.SetStyle(UIStyles.ActiveStyleColor.DropDownStyle);
|
||||
}
|
||||
|
||||
DropDown?.Invoke(this, e);
|
||||
|
@ -344,7 +344,7 @@ namespace Sunny.UI
|
||||
|
||||
public void SetStyle(UIBaseStyle style)
|
||||
{
|
||||
Item?.SetStyle(style);
|
||||
Item?.SetStyleColor(style);
|
||||
}
|
||||
}
|
||||
}
|
@ -94,10 +94,6 @@ namespace Sunny.UI
|
||||
parent?.Close();
|
||||
}
|
||||
|
||||
public virtual void SetStyle(UIBaseStyle style)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void InitShow()
|
||||
{
|
||||
|
||||
|
@ -595,17 +595,13 @@ namespace Sunny.UI
|
||||
Close();
|
||||
}
|
||||
|
||||
public override void SetStyle(UIBaseStyle style)
|
||||
{
|
||||
base.SetStyle(style);
|
||||
btnOK.SetStyleColor(style);
|
||||
btnCancel.SetStyleColor(style);
|
||||
}
|
||||
|
||||
public override void SetStyleColor(UIBaseStyle uiColor)
|
||||
{
|
||||
base.SetStyleColor(uiColor);
|
||||
|
||||
btnOK.SetStyleColor(uiColor);
|
||||
btnCancel.SetStyleColor(uiColor);
|
||||
|
||||
h1.SetStyleColor(uiColor);
|
||||
h2.SetStyleColor(uiColor);
|
||||
m1.SetStyleColor(uiColor);
|
||||
|
@ -208,7 +208,7 @@ namespace Sunny.UI
|
||||
public override void SetStyleColor(UIBaseStyle uiColor)
|
||||
{
|
||||
base.SetStyleColor(uiColor);
|
||||
ListBox.SetStyleColor(uiColor);
|
||||
ListBox.SetStyleColor(uiColor.DropDownStyle);
|
||||
}
|
||||
|
||||
public object DataSource
|
||||
|
@ -765,7 +765,7 @@ namespace Sunny.UI
|
||||
if (tmpFont == null || !tmpFont.Size.EqualsFloat(TipsFont.DPIScaleFontSize()))
|
||||
{
|
||||
tmpFont?.Dispose();
|
||||
tmpFont = this.DPIScaleFont(TipsFont);
|
||||
tmpFont = TipsFont.DPIScaleFont();
|
||||
}
|
||||
|
||||
return tmpFont;
|
||||
|
@ -697,6 +697,7 @@ namespace Sunny.UI
|
||||
return Enabled ? (isReadOnly ? fillReadOnlyColor : fillColor) : fillDisableColor;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 屏蔽原属性,获取或设置一个值,该值指示是否在 Windows 任务栏中显示窗体。
|
||||
/// </summary>
|
||||
|
@ -92,7 +92,7 @@ namespace Sunny.UI
|
||||
|
||||
if (!UIDPIScale.DPIScaleIsOne())
|
||||
{
|
||||
TitleFont = this.DPIScaleFont(TitleFont);
|
||||
TitleFont = TitleFont.DPIScaleFont();
|
||||
}
|
||||
|
||||
foreach (Control control in this.GetAllDPIScaleControls())
|
||||
|
@ -50,9 +50,9 @@ namespace Sunny.UI
|
||||
{
|
||||
this.SetDPIScaleFont();
|
||||
|
||||
noteTitle.Font = noteTitle.DPIScaleFont(noteTitle.Font);
|
||||
noteContent.Font = noteContent.DPIScaleFont(noteContent.Font);
|
||||
noteDate.Font = noteDate.DPIScaleFont(noteDate.Font);
|
||||
noteTitle.Font = noteTitle.Font.DPIScaleFont();
|
||||
noteContent.Font = noteContent.Font.DPIScaleFont();
|
||||
noteDate.Font = noteDate.Font.DPIScaleFont();
|
||||
|
||||
foreach (Control control in this.GetAllDPIScaleControls())
|
||||
{
|
||||
@ -385,7 +385,7 @@ namespace Sunny.UI
|
||||
//-------------------------------------------------------------------------------------------------------------------------------
|
||||
private void onMenuClick(object sender, EventArgs e)
|
||||
{
|
||||
closeAllToolStripMenuItem.Font = menu.DPIScaleFont(menu.Font);
|
||||
closeAllToolStripMenuItem.Font = menu.Font.DPIScaleFont();
|
||||
menu.Show(buttonMenu, new Point(0, buttonMenu.Height));
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ namespace Sunny.UI
|
||||
this.SetDPIScaleFont();
|
||||
if (!UIDPIScale.DPIScaleIsOne())
|
||||
{
|
||||
this.TitleFont = this.DPIScaleFont(this.TitleFont);
|
||||
this.TitleFont = TitleFont.DPIScaleFont();
|
||||
}
|
||||
|
||||
foreach (Control control in this.GetAllDPIScaleControls())
|
||||
|
@ -37,7 +37,7 @@ namespace Sunny.UI
|
||||
return DPIScale().EqualsFloat(1);
|
||||
}
|
||||
|
||||
public static float DPIScaleFontSize(this Control control, Font font)
|
||||
internal static float DPIScaleFontSize(this Font font)
|
||||
{
|
||||
if (UIStyles.DPIScale)
|
||||
return font.Size / DPIScale();
|
||||
@ -45,43 +45,12 @@ namespace Sunny.UI
|
||||
return font.Size;
|
||||
}
|
||||
|
||||
public static float DPIScaleFontSize(this Font font)
|
||||
internal static Font DPIScaleFont(this Font font)
|
||||
{
|
||||
return font.Size.DPIScaleFontSize();
|
||||
return DPIScaleFont(font, font.Size);
|
||||
}
|
||||
|
||||
public static float DPIScaleFontSize(this float fontSize)
|
||||
{
|
||||
if (UIStyles.DPIScale)
|
||||
return fontSize / DPIScale();
|
||||
else
|
||||
return fontSize;
|
||||
}
|
||||
|
||||
public static Font DPIScaleFont(this Control control, Font font)
|
||||
{
|
||||
return control.DPIScaleFont(font, font.Size);
|
||||
}
|
||||
|
||||
public static Font DPIScaleFont(this Font font)
|
||||
{
|
||||
if (UIStyles.DPIScale)
|
||||
{
|
||||
if (font.GdiCharSet == 134)
|
||||
return new Font(font.FontFamily, font.Size / DPIScale(), font.Style, font.Unit, font.GdiCharSet);
|
||||
else
|
||||
return new Font(font.FontFamily, font.Size / DPIScale());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (font.GdiCharSet == 134)
|
||||
return new Font(font.FontFamily, font.Size, font.Style, font.Unit, font.GdiCharSet);
|
||||
else
|
||||
return new Font(font.FontFamily, font.Size);
|
||||
}
|
||||
}
|
||||
|
||||
public static Font DPIScaleFont(this Control control, Font font, float fontSize)
|
||||
internal static Font DPIScaleFont(this Font font, float fontSize)
|
||||
{
|
||||
if (UIStyles.DPIScale)
|
||||
{
|
||||
@ -99,7 +68,7 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetDPIScaleFont(this Control control)
|
||||
internal static void SetDPIScaleFont(this Control control)
|
||||
{
|
||||
if (!UIStyles.DPIScale) return;
|
||||
if (!UIDPIScale.DPIScaleIsOne())
|
||||
@ -107,12 +76,12 @@ namespace Sunny.UI
|
||||
if (control is IStyleInterface ctrl)
|
||||
{
|
||||
if (!ctrl.IsScaled)
|
||||
control.Font = control.DPIScaleFont(control.Font);
|
||||
control.Font = control.Font.DPIScaleFont();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Control> GetAllDPIScaleControls(this Control control)
|
||||
internal static List<Control> GetAllDPIScaleControls(this Control control)
|
||||
{
|
||||
var list = new List<Control>();
|
||||
foreach (Control con in control.Controls)
|
||||
|
@ -174,8 +174,10 @@ namespace Sunny.UI
|
||||
public virtual Color PanelTitleColor { get; protected set; }
|
||||
public virtual Color PanelTitleForeColor { get; protected set; }
|
||||
|
||||
//DrawDownControl
|
||||
//DropDownControl
|
||||
public virtual Color DropDownControlColor { get; protected set; }
|
||||
public virtual Color DropDownPanelFillColor { get; protected set; }
|
||||
public virtual Color DropDownPanelForeColor { get; protected set; }
|
||||
|
||||
//ListBox
|
||||
public virtual Color ListItemSelectBackColor { get; protected set; }
|
||||
@ -222,6 +224,8 @@ namespace Sunny.UI
|
||||
|
||||
protected Color ForeColor { get; set; }
|
||||
|
||||
public UIBaseStyle DropDownStyle { get; protected set; }
|
||||
|
||||
public virtual UIBaseStyle Init(Color color, UIStyle style, Color reverseColor, Color foreColor)
|
||||
{
|
||||
Name = style;
|
||||
@ -356,6 +360,8 @@ namespace Sunny.UI
|
||||
TabControlBackColor = PlainColor;
|
||||
|
||||
DropDownControlColor = foreColor;
|
||||
DropDownPanelFillColor = PlainColor;
|
||||
DropDownPanelForeColor = foreColor;
|
||||
|
||||
ListItemSelectBackColor = PrimaryColor;
|
||||
ListItemSelectForeColor = PlainColor;
|
||||
@ -384,6 +390,8 @@ namespace Sunny.UI
|
||||
FlowLayoutPanelBarFillColor = PlainColor;
|
||||
FlowLayoutPanelBarForeColor = PrimaryColor;
|
||||
|
||||
DropDownStyle = this;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -568,6 +576,12 @@ namespace Sunny.UI
|
||||
ScrollingTextForeColor = ForeColor;
|
||||
|
||||
LogoForeColor = UIFontColor.Primary;
|
||||
|
||||
DropDownControlColor = ForeColor;
|
||||
DropDownPanelFillColor = UIColor.LightBlue;
|
||||
DropDownPanelForeColor = UIFontColor.Primary;
|
||||
|
||||
DropDownStyle = UIStyles.Blue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -674,6 +688,12 @@ namespace Sunny.UI
|
||||
ScrollingTextForeColor = ForeColor;
|
||||
|
||||
LogoForeColor = UIFontColor.Primary;
|
||||
|
||||
DropDownControlColor = ForeColor;
|
||||
DropDownPanelFillColor = UIColor.LightBlue;
|
||||
DropDownPanelForeColor = UIFontColor.Primary;
|
||||
|
||||
DropDownStyle = UIStyles.Blue;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user