更新小Bug

This commit is contained in:
Sunny 2020-06-05 22:42:48 +08:00
parent 96c318a979
commit ad0cf151ed
4 changed files with 76 additions and 93 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -21,6 +21,7 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
@ -29,48 +30,103 @@ namespace Sunny.UI
[DefaultEvent("Initialize")]
public partial class UIPage : Form, IStyleInterface
{
public event EventHandler Initialize;
public readonly Guid Guid = Guid.NewGuid();
private Color _rectColor = UIColor.Blue;
private ToolStripStatusLabelBorderSides _rectSides = ToolStripStatusLabelBorderSides.None;
protected UIStyle _style = UIStyle.Blue;
public UIStatusForm StatusForm;
public UIPage()
{
InitializeComponent();
base.BackColor = UIColor.LightBlue;
if (this.Register())
{
SetStyle(UIStyles.Style);
}
TopLevel = false;
if (this.Register()) SetStyle(UIStyles.Style);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
UpdateStyles();
if (!IsDesignMode)
{
base.Dock = DockStyle.Fill;
}
if (!IsDesignMode) base.Dock = DockStyle.Fill;
Version = UIGlobal.Version;
}
public UIStatusForm StatusForm;
[Browsable(false)] public Point ParentLocation { get; set; } = new Point(0, 0);
public int PageIndex { get; set; } = -1;
/// <summary>
/// 边框颜色
/// </summary>
/// <value>The color of the border style.</value>
[Description("边框颜色")]
public Color RectColor
{
get => _rectColor;
set
{
_rectColor = value;
AfterSetRectColor(value);
_style = UIStyle.Custom;
Invalidate();
}
}
protected bool IsDesignMode
{
get
{
var ReturnFlag = false;
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
ReturnFlag = true;
else if (Process.GetCurrentProcess().ProcessName == "devenv")
ReturnFlag = true;
return ReturnFlag;
}
}
[DefaultValue(ToolStripStatusLabelBorderSides.None)]
[Description("边框显示位置")]
public ToolStripStatusLabelBorderSides RectSides
{
get => _rectSides;
set
{
_rectSides = value;
Invalidate();
}
}
[DefaultValue(null)] public string TagString { get; set; }
public string Version { get; }
[DefaultValue(UIStyle.Blue)]
public UIStyle Style
{
get => _style;
set => SetStyle(value);
}
[DefaultValue(false)] public bool StyleCustomMode { get; set; }
public event EventHandler Initialize;
public void ShowStatus(string title, string desc, int max = 100, int value = 0)
{
if (StatusForm == null)
{
StatusForm = new UIStatusForm();
}
if (StatusForm == null) StatusForm = new UIStatusForm();
StatusForm.Style = Style;
StatusForm.Show(title, desc, max, value);
}
[Browsable(false)]
public Point ParentLocation { get; set; } = new Point(0, 0);
public void HideStatus()
{
StatusForm.Hide();
@ -86,21 +142,10 @@ namespace Sunny.UI
base.OnControlAdded(e);
if (e.Control is IStyleInterface ctrl)
{
if (!ctrl.StyleCustomMode)
{
ctrl.Style = Style;
}
}
}
public int PageIndex { get; set; } = -1;
[DefaultValue(null)]
public string TagString { get; set; }
public string Version { get; }
public virtual void Init()
{
Initialize?.Invoke(this, null);
@ -110,16 +155,6 @@ namespace Sunny.UI
{
}
protected UIStyle _style = UIStyle.Blue;
private Color _rectColor = UIColor.Blue;
[DefaultValue(UIStyle.Blue)]
public UIStyle Style
{
get => _style;
set => SetStyle(value);
}
public void SetStyle(UIStyle style)
{
this.SetChildUIStyle(style);
@ -138,26 +173,6 @@ namespace Sunny.UI
Invalidate();
}
[DefaultValue(false)]
public bool StyleCustomMode { get; set; }
/// <summary>
/// 边框颜色
/// </summary>
/// <value>The color of the border style.</value>
[Description("边框颜色")]
public Color RectColor
{
get => _rectColor;
set
{
_rectColor = value;
AfterSetRectColor(value);
_style = UIStyle.Custom;
Invalidate();
}
}
protected virtual void AfterSetFillColor(Color color)
{
}
@ -170,30 +185,11 @@ namespace Sunny.UI
{
}
protected bool IsDesignMode
{
get
{
bool ReturnFlag = false;
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
ReturnFlag = true;
else if (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv")
ReturnFlag = true;
return ReturnFlag;
}
}
public readonly Guid Guid = Guid.NewGuid();
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (Width <= 0 || Height <= 0)
{
return;
}
if (Width <= 0 || Height <= 0) return;
if (RectSides != ToolStripStatusLabelBorderSides.None)
{
@ -208,19 +204,6 @@ namespace Sunny.UI
}
}
private ToolStripStatusLabelBorderSides _rectSides = ToolStripStatusLabelBorderSides.None;
[DefaultValue(ToolStripStatusLabelBorderSides.None), Description("边框显示位置")]
public ToolStripStatusLabelBorderSides RectSides
{
get => _rectSides;
set
{
_rectSides = value;
Invalidate();
}
}
protected override void OnBackColorChanged(EventArgs e)
{
base.OnBackColorChanged(e);
@ -237,7 +220,7 @@ namespace Sunny.UI
private void UIPage_Shown(object sender, EventArgs e)
{
SetStyle(UIStyles.Style);
//SetStyle(UIStyles.Style);
}
}
}