* UITabControl:重绘左右按钮
This commit is contained in:
parent
8372ca96f0
commit
af63124c44
BIN
Bin/SunnyUI.dll
BIN
Bin/SunnyUI.dll
Binary file not shown.
BIN
Bin/SunnyUI.pdb
BIN
Bin/SunnyUI.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
5
SunnyUI.Demo/Controls/FButton.Designer.cs
generated
5
SunnyUI.Demo/Controls/FButton.Designer.cs
generated
@ -925,6 +925,7 @@
|
|||||||
// uiImageButton1
|
// uiImageButton1
|
||||||
//
|
//
|
||||||
this.uiImageButton1.Cursor = System.Windows.Forms.Cursors.Hand;
|
this.uiImageButton1.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.uiImageButton1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||||
this.uiImageButton1.Image = global::Sunny.UI.Demo.Properties.Resources.dashboard0;
|
this.uiImageButton1.Image = global::Sunny.UI.Demo.Properties.Resources.dashboard0;
|
||||||
this.uiImageButton1.ImageHover = global::Sunny.UI.Demo.Properties.Resources.dashboard;
|
this.uiImageButton1.ImageHover = global::Sunny.UI.Demo.Properties.Resources.dashboard;
|
||||||
this.uiImageButton1.ImagePress = global::Sunny.UI.Demo.Properties.Resources.dashboard0;
|
this.uiImageButton1.ImagePress = global::Sunny.UI.Demo.Properties.Resources.dashboard0;
|
||||||
@ -939,6 +940,7 @@
|
|||||||
// uiImageButton2
|
// uiImageButton2
|
||||||
//
|
//
|
||||||
this.uiImageButton2.Cursor = System.Windows.Forms.Cursors.Hand;
|
this.uiImageButton2.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.uiImageButton2.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||||
this.uiImageButton2.Image = global::Sunny.UI.Demo.Properties.Resources.relationship0;
|
this.uiImageButton2.Image = global::Sunny.UI.Demo.Properties.Resources.relationship0;
|
||||||
this.uiImageButton2.ImageHover = global::Sunny.UI.Demo.Properties.Resources.relationship;
|
this.uiImageButton2.ImageHover = global::Sunny.UI.Demo.Properties.Resources.relationship;
|
||||||
this.uiImageButton2.ImagePress = global::Sunny.UI.Demo.Properties.Resources.relationship0;
|
this.uiImageButton2.ImagePress = global::Sunny.UI.Demo.Properties.Resources.relationship0;
|
||||||
@ -952,6 +954,7 @@
|
|||||||
// uiImageButton3
|
// uiImageButton3
|
||||||
//
|
//
|
||||||
this.uiImageButton3.Cursor = System.Windows.Forms.Cursors.Hand;
|
this.uiImageButton3.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.uiImageButton3.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||||
this.uiImageButton3.Image = global::Sunny.UI.Demo.Properties.Resources.save0;
|
this.uiImageButton3.Image = global::Sunny.UI.Demo.Properties.Resources.save0;
|
||||||
this.uiImageButton3.ImageHover = global::Sunny.UI.Demo.Properties.Resources.save;
|
this.uiImageButton3.ImageHover = global::Sunny.UI.Demo.Properties.Resources.save;
|
||||||
this.uiImageButton3.ImagePress = global::Sunny.UI.Demo.Properties.Resources.save0;
|
this.uiImageButton3.ImagePress = global::Sunny.UI.Demo.Properties.Resources.save0;
|
||||||
@ -965,6 +968,8 @@
|
|||||||
// uiImageButton4
|
// uiImageButton4
|
||||||
//
|
//
|
||||||
this.uiImageButton4.Cursor = System.Windows.Forms.Cursors.Hand;
|
this.uiImageButton4.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.uiImageButton4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
|
this.uiImageButton4.ForeColor = System.Drawing.Color.Red;
|
||||||
this.uiImageButton4.Image = global::Sunny.UI.Demo.Properties.Resources.dashboard0;
|
this.uiImageButton4.Image = global::Sunny.UI.Demo.Properties.Resources.dashboard0;
|
||||||
this.uiImageButton4.ImageHover = global::Sunny.UI.Demo.Properties.Resources.dashboard;
|
this.uiImageButton4.ImageHover = global::Sunny.UI.Demo.Properties.Resources.dashboard;
|
||||||
this.uiImageButton4.ImageOffset = new System.Drawing.Point(12, 5);
|
this.uiImageButton4.ImageOffset = new System.Drawing.Point(12, 5);
|
||||||
|
6
SunnyUI.Demo/Forms/FLogin.Designer.cs
generated
6
SunnyUI.Demo/Forms/FLogin.Designer.cs
generated
@ -33,7 +33,7 @@
|
|||||||
//
|
//
|
||||||
// lblTitle
|
// lblTitle
|
||||||
//
|
//
|
||||||
this.lblTitle.Text = "FLogin";
|
this.lblTitle.Text = "SunnyUI.Net Login Form";
|
||||||
//
|
//
|
||||||
// FLogin
|
// FLogin
|
||||||
//
|
//
|
||||||
@ -41,9 +41,9 @@
|
|||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
|
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
|
||||||
this.ClientSize = new System.Drawing.Size(750, 450);
|
this.ClientSize = new System.Drawing.Size(750, 450);
|
||||||
this.LoginImage = Sunny.UI.UILoginForm.UILoginImage.Login5;
|
this.LoginImage = Sunny.UI.UILoginForm.UILoginImage.Login6;
|
||||||
this.Name = "FLogin";
|
this.Name = "FLogin";
|
||||||
this.Text = "FLogin";
|
this.Text = "SunnyUI.Net Login Form";
|
||||||
this.ButtonLoginClick += new System.EventHandler(this.FLogin_ButtonLoginClick);
|
this.ButtonLoginClick += new System.EventHandler(this.FLogin_ButtonLoginClick);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -31,11 +31,6 @@ namespace Sunny.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class UIImageButton : PictureBox
|
public sealed class UIImageButton : PictureBox
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 必需的设计器变量。
|
|
||||||
/// </summary>
|
|
||||||
private IContainer components;
|
|
||||||
|
|
||||||
private bool IsPress;
|
private bool IsPress;
|
||||||
private bool IsHover;
|
private bool IsHover;
|
||||||
|
|
||||||
@ -46,7 +41,6 @@ namespace Sunny.UI
|
|||||||
private bool selected;
|
private bool selected;
|
||||||
private string text;
|
private string text;
|
||||||
private ContentAlignment textAlign = ContentAlignment.MiddleCenter;
|
private ContentAlignment textAlign = ContentAlignment.MiddleCenter;
|
||||||
private Font font = UIFontColor.Font;
|
|
||||||
private Color foreColor = UIFontColor.Primary;
|
private Color foreColor = UIFontColor.Primary;
|
||||||
|
|
||||||
[Category("外观")]
|
[Category("外观")]
|
||||||
@ -83,10 +77,10 @@ namespace Sunny.UI
|
|||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||||
public override Font Font
|
public override Font Font
|
||||||
{
|
{
|
||||||
get => font;
|
get => base.Font;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
font = value;
|
base.Font = value;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +113,6 @@ namespace Sunny.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public UIImageButton()
|
public UIImageButton()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
|
||||||
SetDefaultControlStyles();
|
SetDefaultControlStyles();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
BorderStyle = BorderStyle.None;
|
BorderStyle = BorderStyle.None;
|
||||||
@ -128,6 +121,7 @@ namespace Sunny.UI
|
|||||||
Height = 35;
|
Height = 35;
|
||||||
Version = UIGlobal.Version;
|
Version = UIGlobal.Version;
|
||||||
Cursor = Cursors.Hand;
|
Cursor = Cursors.Hand;
|
||||||
|
base.Font = UIFontColor.Font;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Version { get; }
|
public string Version { get; }
|
||||||
@ -208,20 +202,6 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 清理所有正在使用的资源。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing)
|
|
||||||
{
|
|
||||||
components?.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetDefaultControlStyles()
|
private void SetDefaultControlStyles()
|
||||||
{
|
{
|
||||||
SetStyle(ControlStyles.UserPaint, true);
|
SetStyle(ControlStyles.UserPaint, true);
|
||||||
@ -395,18 +375,5 @@ namespace Sunny.UI
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 组件设计器生成的代码
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设计器支持所需的方法 - 不要
|
|
||||||
/// 使用代码编辑器修改此方法的内容。
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
components = new Container();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion 组件设计器生成的代码
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -149,6 +149,20 @@ namespace Sunny.UI
|
|||||||
tabControl = ctrl;
|
tabControl = ctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NavMenuItem this[int index]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (index < 0 || index >= tabControl.TabPages.Count)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
|
|
||||||
|
TabPage page = tabControl.TabPages[index];
|
||||||
|
return PageItems.ContainsKey(page) ? PageItems[page] : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public UIPage AddPage(int pageIndex, UIPage page)
|
public UIPage AddPage(int pageIndex, UIPage page)
|
||||||
{
|
{
|
||||||
page.PageIndex = pageIndex;
|
page.PageIndex = pageIndex;
|
||||||
@ -313,6 +327,8 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public Guid PageGuid { get; set; } = Guid.Empty;
|
public Guid PageGuid { get; set; } = Guid.Empty;
|
||||||
|
|
||||||
|
public bool AlwaysOpen { get; set; } = false;
|
||||||
|
|
||||||
public NavMenuItem()
|
public NavMenuItem()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -322,6 +338,7 @@ namespace Sunny.UI
|
|||||||
Text = page.Text;
|
Text = page.Text;
|
||||||
PageIndex = page.PageIndex;
|
PageIndex = page.PageIndex;
|
||||||
PageGuid = page.PageGuid;
|
PageGuid = page.PageGuid;
|
||||||
|
AlwaysOpen = page.AlwaysOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NavMenuItem(string text, int pageIndex)
|
public NavMenuItem(string text, int pageIndex)
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
* 创建日期: 2020-01-01
|
* 创建日期: 2020-01-01
|
||||||
*
|
*
|
||||||
* 2020-01-01: V2.2.0 增加文件说明
|
* 2020-01-01: V2.2.0 增加文件说明
|
||||||
|
* 2020-06-27: V2.2.5 重绘左右选择按钮
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -66,41 +67,20 @@ namespace Sunny.UI
|
|||||||
[DefaultValue(true)]
|
[DefaultValue(true)]
|
||||||
public bool ForbidCtrlTab { get; set; } = true;
|
public bool ForbidCtrlTab { get; set; } = true;
|
||||||
|
|
||||||
public void SelectPage(int pageIndex)
|
public void SelectPage(int pageIndex) => Helper.SelectPage(pageIndex);
|
||||||
{
|
|
||||||
Helper.SelectPage(pageIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SelectPage(Guid pageGuid)
|
public void SelectPage(Guid pageGuid) => Helper.SelectPage(pageGuid);
|
||||||
{
|
|
||||||
Helper.SelectPage(pageGuid);
|
public void AddPage(UIPage page) => Helper.AddPage(page);
|
||||||
}
|
|
||||||
|
public void AddPage(int pageIndex, UITabControl page) => Helper.AddPage(pageIndex, page);
|
||||||
public void AddPage(UIPage page)
|
|
||||||
{
|
public void AddPage(int pageIndex, UITabControlMenu page) => Helper.AddPage(pageIndex, page);
|
||||||
Helper.AddPage(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddPage(int pageIndex, UITabControl page)
|
|
||||||
{
|
|
||||||
Helper.AddPage(pageIndex, page);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddPage(int pageIndex, UITabControlMenu page)
|
|
||||||
{
|
|
||||||
Helper.AddPage(pageIndex, page);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddPage(Guid guid, UITabControl page)
|
|
||||||
{
|
|
||||||
Helper.AddPage(guid, page);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddPage(Guid guid, UITabControlMenu page)
|
|
||||||
{
|
|
||||||
Helper.AddPage(guid, page);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public void AddPage(Guid guid, UITabControl page) => Helper.AddPage(guid, page);
|
||||||
|
|
||||||
|
public void AddPage(Guid guid, UITabControlMenu page) => Helper.AddPage(guid, page);
|
||||||
|
|
||||||
public string Version { get; }
|
public string Version { get; }
|
||||||
|
|
||||||
private Color _fillColor = UIColor.LightBlue;
|
private Color _fillColor = UIColor.LightBlue;
|
||||||
@ -401,9 +381,16 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
g.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, textLeft, TabRect.Top + 2 + (TabRect.Height - sf.Height) / 2.0f);
|
g.DrawString(TabPages[index].Text, Font, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, textLeft, TabRect.Top + 2 + (TabRect.Height - sf.Height) / 2.0f);
|
||||||
if (ShowCloseButton || (ShowActiveCloseButton && index == SelectedIndex))
|
|
||||||
|
var menuItem = Helper[index];
|
||||||
|
bool showButton = menuItem == null || !menuItem.AlwaysOpen;
|
||||||
|
|
||||||
|
if (showButton)
|
||||||
{
|
{
|
||||||
g.DrawFontImage(61453, 20, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, new Rectangle(TabRect.Width - 28, TabRect.Top, 24, TabRect.Height));
|
if (ShowCloseButton || (ShowActiveCloseButton && index == SelectedIndex))
|
||||||
|
{
|
||||||
|
g.DrawFontImage(77, 28, index == SelectedIndex ? tabSelectedForeColor : TabUnSelectedForeColor, new Rectangle(TabRect.Width - 28, TabRect.Top, 24, TabRect.Height));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 绘制图标
|
// 绘制图标
|
||||||
@ -543,13 +530,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
Graphics g = e.Graphics;
|
Graphics g = e.Graphics;
|
||||||
Rectangle rect = e.ClipRectangle;
|
Rectangle rect = e.ClipRectangle;
|
||||||
|
|
||||||
Color upButtonBaseColor = tabBackColor;
|
|
||||||
Color upButtonBorderColor = tabBackColor;
|
|
||||||
Color upButtonArrowColor = tabUnSelectedForeColor;
|
Color upButtonArrowColor = tabUnSelectedForeColor;
|
||||||
|
|
||||||
Color downButtonBaseColor = tabBackColor;
|
|
||||||
Color downButtonBorderColor = tabBackColor;
|
|
||||||
Color downButtonArrowColor = tabUnSelectedForeColor;
|
Color downButtonArrowColor = tabUnSelectedForeColor;
|
||||||
|
|
||||||
Rectangle upButtonRect = rect;
|
Rectangle upButtonRect = rect;
|
||||||
@ -573,125 +554,47 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
//鼠标按下
|
//鼠标按下
|
||||||
if (e.MouseInUpButton)
|
if (e.MouseInUpButton)
|
||||||
{
|
upButtonArrowColor = Color.FromArgb(200, TabSelectedHighColor);
|
||||||
upButtonArrowColor = GetColor(tabBackColor, 0, -35, -24, -9);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
downButtonArrowColor = Color.FromArgb(200, TabSelectedHighColor);
|
||||||
downButtonArrowColor = GetColor(tabBackColor, 0, -35, -24, -9);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//鼠标移动
|
//鼠标移动
|
||||||
if (e.MouseInUpButton)
|
if (e.MouseInUpButton)
|
||||||
{
|
upButtonArrowColor = TabSelectedHighColor;
|
||||||
upButtonArrowColor = GetColor(tabBackColor, 0, 35, 24, 9);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
downButtonArrowColor = TabSelectedHighColor;
|
||||||
downButtonArrowColor = GetColor(tabBackColor, 0, 35, 24, 9);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
upButtonBaseColor = SystemColors.Control;
|
|
||||||
upButtonBorderColor = SystemColors.ControlDark;
|
|
||||||
upButtonArrowColor = SystemColors.ControlDark;
|
upButtonArrowColor = SystemColors.ControlDark;
|
||||||
|
|
||||||
downButtonBaseColor = SystemColors.Control;
|
|
||||||
downButtonBorderColor = SystemColors.ControlDark;
|
|
||||||
downButtonArrowColor = SystemColors.ControlDark;
|
downButtonArrowColor = SystemColors.ControlDark;
|
||||||
}
|
}
|
||||||
|
|
||||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||||
|
RenderButton(g, upButtonRect, upButtonArrowColor, ArrowDirection.Left);
|
||||||
//Color color = Enabled ? BackColor : SystemColors.Control;
|
RenderButton(g, downButtonRect, downButtonArrowColor, ArrowDirection.Right);
|
||||||
//rect.Inflate(1, 1);
|
|
||||||
//g.FillRectangle(color, rect);
|
|
||||||
|
|
||||||
|
|
||||||
RenderButton(g, upButtonRect, upButtonBaseColor, upButtonBorderColor, upButtonArrowColor, ArrowDirection.Left);
|
|
||||||
RenderButton(g, downButtonRect, downButtonBaseColor, downButtonBorderColor, downButtonArrowColor, ArrowDirection.Right);
|
|
||||||
|
|
||||||
UpDownButtonPaintEventHandler handler = Events[EventPaintUpDownButton] as UpDownButtonPaintEventHandler;
|
UpDownButtonPaintEventHandler handler = Events[EventPaintUpDownButton] as UpDownButtonPaintEventHandler;
|
||||||
handler?.Invoke(this, e);
|
handler?.Invoke(this, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RenderButton(Graphics g, Rectangle rect, Color baseColor, Color borderColor, Color arrowColor, ArrowDirection direction)
|
internal void RenderButton(Graphics g, Rectangle rect, Color arrowColor, ArrowDirection direction)
|
||||||
{
|
{
|
||||||
//RenderBackgroundInternal(g, rect, baseColor, borderColor, 0.45f, true, LinearGradientMode.Vertical);
|
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
case ArrowDirection.Left:
|
case ArrowDirection.Left:
|
||||||
g.DrawFontImage(61700, (int)(30 * this.ItemSize.Height / 40), arrowColor, rect);
|
g.DrawFontImage(61700, 24, arrowColor, rect);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ArrowDirection.Right:
|
case ArrowDirection.Right:
|
||||||
g.DrawFontImage(61701, (int)(30 * this.ItemSize.Height / 40), arrowColor, rect, 1);
|
g.DrawFontImage(61701, 24, arrowColor, rect, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Color GetColor(Color colorBase, int a, int r, int g, int b)
|
|
||||||
{
|
|
||||||
int a0 = colorBase.A;
|
|
||||||
int r0 = colorBase.R;
|
|
||||||
int g0 = colorBase.G;
|
|
||||||
int b0 = colorBase.B;
|
|
||||||
|
|
||||||
if (a + a0 > 255) { a = 255; } else { a = Math.Max(a + a0, 0); }
|
|
||||||
if (r + r0 > 255) { r = 255; } else { r = Math.Max(r + r0, 0); }
|
|
||||||
if (g + g0 > 255) { g = 255; } else { g = Math.Max(g + g0, 0); }
|
|
||||||
if (b + b0 > 255) { b = 255; } else { b = Math.Max(b + b0, 0); }
|
|
||||||
|
|
||||||
return Color.FromArgb(a, r, g, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void RenderBackgroundInternal(Graphics g, Rectangle rect, Color baseColor, Color borderColor, float basePosition, bool drawBorder, LinearGradientMode mode)
|
|
||||||
{
|
|
||||||
using (LinearGradientBrush brush = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, mode))
|
|
||||||
{
|
|
||||||
Color[] colors = new Color[4];
|
|
||||||
colors[0] = GetColor(baseColor, 0, 35, 24, 9);
|
|
||||||
colors[1] = GetColor(baseColor, 0, 13, 8, 3);
|
|
||||||
colors[2] = baseColor;
|
|
||||||
colors[3] = GetColor(baseColor, 0, 68, 69, 54);
|
|
||||||
|
|
||||||
ColorBlend blend = new ColorBlend();
|
|
||||||
blend.Positions = new[] { 0.0f, basePosition, basePosition + 0.05f, 1.0f };
|
|
||||||
blend.Colors = colors;
|
|
||||||
brush.InterpolationColors = blend;
|
|
||||||
g.FillRectangle(brush, rect);
|
|
||||||
}
|
|
||||||
if (baseColor.A > 80)
|
|
||||||
{
|
|
||||||
Rectangle rectTop = rect;
|
|
||||||
if (mode == LinearGradientMode.Vertical)
|
|
||||||
{
|
|
||||||
rectTop.Height = (int)(rectTop.Height * basePosition);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rectTop.Width = (int)(rect.Width * basePosition);
|
|
||||||
}
|
|
||||||
using (SolidBrush brushAlpha = new SolidBrush(Color.FromArgb(80, 255, 255, 255)))
|
|
||||||
{
|
|
||||||
g.FillRectangle(brushAlpha, rectTop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (drawBorder)
|
|
||||||
{
|
|
||||||
using (Pen pen = new Pen(borderColor))
|
|
||||||
{
|
|
||||||
g.DrawRectangle(pen, rect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static readonly object EventPaintUpDownButton = new object();
|
private static readonly object EventPaintUpDownButton = new object();
|
||||||
private const string UpDownButtonClassName = "msctls_updown32";
|
private const string UpDownButtonClassName = "msctls_updown32";
|
||||||
private UpDownButtonNativeWindow _upDownButtonNativeWindow;
|
private UpDownButtonNativeWindow _upDownButtonNativeWindow;
|
||||||
@ -765,13 +668,12 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
private UITabControl _owner;
|
private UITabControl _owner;
|
||||||
private bool _bPainting;
|
private bool _bPainting;
|
||||||
private Rectangle clipRect = new Rectangle();
|
private Rectangle clipRect;
|
||||||
|
|
||||||
public UpDownButtonNativeWindow(UITabControl owner)
|
public UpDownButtonNativeWindow(UITabControl owner)
|
||||||
{
|
{
|
||||||
_owner = owner;
|
_owner = owner;
|
||||||
AssignHandle(owner.UpDownButtonHandle);
|
AssignHandle(owner.UpDownButtonHandle);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool LeftKeyPressed()
|
private bool LeftKeyPressed()
|
||||||
@ -811,8 +713,8 @@ namespace Sunny.UI
|
|||||||
case NativeMethods.WM_PAINT:
|
case NativeMethods.WM_PAINT:
|
||||||
if (!_bPainting)
|
if (!_bPainting)
|
||||||
{
|
{
|
||||||
Point UpDownButtonLocation = new Point((int)(_owner.Size.Width - _owner.ItemSize.Height * 1.5), 0);
|
Point UpDownButtonLocation = new Point(_owner.Size.Width - 52, 0);
|
||||||
Size UpDownButtonSize = new Size((int)(_owner.ItemSize.Height * 1.5), _owner.ItemSize.Height);
|
Size UpDownButtonSize = new Size(52, _owner.ItemSize.Height);
|
||||||
clipRect = new Rectangle(UpDownButtonLocation, UpDownButtonSize);
|
clipRect = new Rectangle(UpDownButtonLocation, UpDownButtonSize);
|
||||||
NativeMethods.MoveWindow(Handle, UpDownButtonLocation.X, UpDownButtonLocation.Y, clipRect.Width, clipRect.Height);
|
NativeMethods.MoveWindow(Handle, UpDownButtonLocation.X, UpDownButtonLocation.Y, clipRect.Width, clipRect.Height);
|
||||||
|
|
||||||
@ -829,6 +731,7 @@ namespace Sunny.UI
|
|||||||
base.WndProc(ref m);
|
base.WndProc(ref m);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
base.WndProc(ref m);
|
base.WndProc(ref m);
|
||||||
break;
|
break;
|
||||||
@ -852,10 +755,6 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public const int VK_LBUTTON = 0x1;
|
public const int VK_LBUTTON = 0x1;
|
||||||
public const int VK_RBUTTON = 0x2;
|
public const int VK_RBUTTON = 0x2;
|
||||||
|
|
||||||
private const int TCM_FIRST = 0x1300;
|
|
||||||
public const int TCM_GETITEMRECT = (TCM_FIRST + 10);
|
|
||||||
|
|
||||||
public static readonly IntPtr TRUE = new IntPtr(1);
|
public static readonly IntPtr TRUE = new IntPtr(1);
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
@ -910,16 +809,10 @@ namespace Sunny.UI
|
|||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
public static extern short GetKeyState(int nVirtKey);
|
public static extern short GetKeyState(int nVirtKey);
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, ref RECT lParam);
|
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static extern bool GetCursorPos(ref Point lpPoint);
|
public static extern bool GetCursorPos(ref Point lpPoint);
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
public extern static int OffsetRect(ref RECT lpRect, int x, int y);
|
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static extern bool PtInRect([In] ref RECT lprc, Point pt);
|
public static extern bool PtInRect([In] ref RECT lprc, Point pt);
|
||||||
@ -928,26 +821,15 @@ namespace Sunny.UI
|
|||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
|
public static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
|
||||||
public static extern bool GetClientRect(IntPtr hWnd, ref RECT r);
|
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static extern bool MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool bRepaint = true);
|
public static extern bool MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool bRepaint = true);
|
||||||
|
|
||||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
|
||||||
public static extern bool IsWindowVisible(IntPtr hwnd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public delegate void UpDownButtonPaintEventHandler(object sender, UpDownButtonPaintEventArgs e);
|
public delegate void UpDownButtonPaintEventHandler(object sender, UpDownButtonPaintEventArgs e);
|
||||||
|
|
||||||
public class UpDownButtonPaintEventArgs : PaintEventArgs
|
public class UpDownButtonPaintEventArgs : PaintEventArgs
|
||||||
{
|
{
|
||||||
private bool _mouseOver;
|
|
||||||
private bool _mousePress;
|
|
||||||
private bool _mouseInUpButton;
|
|
||||||
|
|
||||||
public UpDownButtonPaintEventArgs(
|
public UpDownButtonPaintEventArgs(
|
||||||
Graphics graphics,
|
Graphics graphics,
|
||||||
Rectangle clipRect,
|
Rectangle clipRect,
|
||||||
@ -956,25 +838,16 @@ namespace Sunny.UI
|
|||||||
bool mouseInUpButton)
|
bool mouseInUpButton)
|
||||||
: base(graphics, clipRect)
|
: base(graphics, clipRect)
|
||||||
{
|
{
|
||||||
_mouseOver = mouseOver;
|
MouseOver = mouseOver;
|
||||||
_mousePress = mousePress;
|
MousePress = mousePress;
|
||||||
_mouseInUpButton = mouseInUpButton;
|
MouseInUpButton = mouseInUpButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool MouseOver
|
public bool MouseOver { get; }
|
||||||
{
|
|
||||||
get { return _mouseOver; }
|
public bool MousePress { get; }
|
||||||
}
|
|
||||||
|
|
||||||
public bool MousePress
|
public bool MouseInUpButton { get; }
|
||||||
{
|
|
||||||
get { return _mousePress; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool MouseInUpButton
|
|
||||||
{
|
|
||||||
get { return _mouseInUpButton; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -97,6 +97,9 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DefaultValue(false),Description("在Frame框架中不被关闭")]
|
||||||
|
public bool AlwaysOpen { get; set; }
|
||||||
|
|
||||||
protected virtual void SymbolChange()
|
protected virtual void SymbolChange()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
+ 增加; - 删除; * 修改
|
+ 增加; - 删除; * 修改
|
||||||
|
|
||||||
|
2020.06.27
|
||||||
|
* UITabControl:重绘左右按钮
|
||||||
|
|
||||||
2020.06.26
|
2020.06.26
|
||||||
+ UIDoughnutChart:增加控件:环状图
|
+ UIDoughnutChart:增加控件:环状图
|
||||||
+ UILoginForm:新增两张背景图
|
+ UILoginForm:新增两张背景图
|
||||||
|
* 对PNG图片进行了压缩,减少了SunnyUI.Dll的大小
|
||||||
|
|
||||||
2020.06.25
|
2020.06.25
|
||||||
+ UIScrollingText:增加控件:滚动文字
|
+ UIScrollingText:增加控件:滚动文字
|
||||||
|
Loading…
x
Reference in New Issue
Block a user