Compare commits

...

2 Commits

18 changed files with 203 additions and 26 deletions

View File

@@ -282,7 +282,6 @@ namespace Demo
//
textBox1.Location = new Point(270, 13);
textBox1.Name = "textBox1";
textBox1.SelectionStart = 7;
textBox1.Size = new Size(114, 38);
textBox1.TabIndex = 3;
textBox1.Text = "#1677FF";
@@ -523,6 +522,7 @@ namespace Demo
ClientSize = new Size(964, 461);
Controls.Add(tableLPanel);
Font = new Font("Microsoft YaHei UI", 14F);
Icon = Properties.Resources.icon;
MinimumSize = new Size(980, 500);
Name = "Colors";
StartPosition = FormStartPosition.CenterScreen;

View File

@@ -754,6 +754,7 @@ namespace Demo
Controls.Add(button1);
Font = new Font("Microsoft YaHei UI Light", 12F);
ForeColor = Color.Black;
Icon = Properties.Resources.icon;
MinimumSize = new Size(1300, 720);
Name = "Main";
StartPosition = FormStartPosition.CenterScreen;

View File

@@ -182,6 +182,7 @@ namespace Demo
Controls.Add(windowBar);
Font = new Font("Microsoft YaHei UI", 12F);
ForeColor = Color.Black;
Icon = Properties.Resources.icon;
MinimumSize = new Size(660, 400);
Name = "Overview";
StartPosition = FormStartPosition.CenterScreen;

View File

@@ -1,4 +1,4 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
@@ -19,7 +19,7 @@ namespace Demo.Properties {
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -130,6 +130,16 @@ namespace Demo.Properties {
}
}
/// <summary>
/// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
/// </summary>
internal static System.Drawing.Icon icon {
get {
object obj = ResourceManager.GetObject("icon", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// 查找类似 &lt;svg viewBox=&quot;0 0 64 41&quot;&gt;&lt;g transform=&quot;translate(0 1)&quot; fill=&quot;none&quot;&gt;&lt;ellipse fill=&quot;#f5f5f5&quot; cx=&quot;32&quot; cy=&quot;33&quot; rx=&quot;32&quot; ry=&quot;7&quot;&gt;&lt;/ellipse&gt;&lt;g stroke=&quot;#d9d9d9&quot;&gt;&lt;path d=&quot;M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237 [字符串的其余部分被截断]&quot;; 的本地化字符串。
/// </summary>

View File

@@ -139,6 +139,9 @@
<data name="bg7" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bg\bg7.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon_empty" xml:space="preserve">
<value>&lt;svg viewBox="0 0 64 41"&gt;&lt;g transform="translate(0 1)" fill="none"&gt;&lt;ellipse fill="#f5f5f5" cx="32" cy="33" rx="32" ry="7"&gt;&lt;/ellipse&gt;&lt;g stroke="#d9d9d9"&gt;&lt;path d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"&gt;&lt;/path&gt;&lt;path d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z" fill="#fafafa"&gt;&lt;/path&gt;&lt;/g&gt;&lt;/g&gt;&lt;/svg&gt;</value>
</data>

View File

@@ -92,6 +92,7 @@ namespace Demo
ClientSize = new System.Drawing.Size(830, 414);
Controls.Add(button1);
Controls.Add(tabHeader1);
Icon = Properties.Resources.icon;
Name = "TabHeaderForm";
StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
Text = "TabHeader";

View File

@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<Directives>
<Application>
<Assembly Name="System.Resources.Extensions">
<Type Name="System.Resources.Extensions.RuntimeResourceSet" Dynamic="Required All" />
<Type Name="System.Resources.Extensions.DeserializingResourceReader" Dynamic="Required All" />
</Assembly>
<Assembly Name="System.Drawing">
<Type Name="System.Drawing.Bitmap" Dynamic="Required All" />
</Assembly>
</Application>
</Directives>
<Application>
<Assembly Name="System.Resources.Extensions">
<Type Name="System.Resources.Extensions.RuntimeResourceSet" Dynamic="Required All" />
<Type Name="System.Resources.Extensions.DeserializingResourceReader" Dynamic="Required All" />
</Assembly>
<Assembly Name="System.Drawing">
<Type Name="System.Drawing.Bitmap" Dynamic="Required All" />
<Type Name="System.Drawing.Icon" Dynamic="Required All" />
</Assembly>
</Application>
</Directives>

View File

@@ -21,6 +21,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.Windows.Forms;
@@ -428,6 +429,59 @@ namespace AntdUI
#endregion
Color? back;
/// <summary>
/// 背景颜色
/// </summary>
[Description("背景颜色"), Category("外观"), DefaultValue(null)]
[Editor(typeof(Design.ColorEditor), typeof(UITypeEditor))]
public Color? Back
{
get => back;
set
{
if (back == value) return;
back = value;
Invalidate();
OnPropertyChanged(nameof(Back));
}
}
string? backExtend;
/// <summary>
/// 背景渐变色
/// </summary>
[Description("背景渐变色"), Category("外观"), DefaultValue(null)]
public string? BackExtend
{
get => backExtend;
set
{
if (backExtend == value) return;
backExtend = value;
Invalidate();
OnPropertyChanged(nameof(BackExtend));
}
}
Color? fore;
/// <summary>
/// 文字颜色
/// </summary>
[Description("文字颜色"), Category("外观"), DefaultValue(null)]
[Editor(typeof(Design.ColorEditor), typeof(UITypeEditor))]
public Color? Fore
{
get => fore;
set
{
if (fore == value) return;
fore = value;
Invalidate();
OnPropertyChanged(nameof(Fore));
}
}
#endregion
#region
@@ -442,7 +496,10 @@ namespace AntdUI
int _radius = (int)(radius * Config.Dpi);
using (var path = rect_read.RoundPath(_radius))
{
g.Fill(Colour.BgElevated.Get(nameof(Calendar), ColorScheme), path);
using (var brush = backExtend.BrushEx(rect_read, back, Colour.BgElevated.Get(nameof(Calendar), ColorScheme)))
{
g.Fill(brush, path);
}
}
#region
@@ -546,7 +603,7 @@ namespace AntdUI
/// <param name="datas">数据</param>
void PrintYear(Canvas g, Rectangle rect_read, int radius, List<Calendari> datas)
{
var color_fore = Colour.TextBase.Get(nameof(Calendar), ColorScheme);
var color_fore = fore ?? Colour.TextBase.Get(nameof(Calendar), ColorScheme);
using (var font = new Font(Font.FontFamily, Font.Size, FontStyle.Bold))
{
if (hover_year.Animation) g.String(year_str, font, color_fore.BlendColors(hover_year.Value, Colour.Primary.Get(nameof(Calendar), ColorScheme)), rect_year_l, s_f);
@@ -596,7 +653,7 @@ namespace AntdUI
/// <param name="datas">数据</param>
void PrintMonth(Canvas g, Rectangle rect_read, int radius, List<Calendari> datas)
{
var color_fore = Colour.TextBase.Get(nameof(Calendar), ColorScheme);
var color_fore = fore ?? Colour.TextBase.Get(nameof(Calendar), ColorScheme);
using (var font = new Font(Font.FontFamily, Font.Size, FontStyle.Bold))
{
string yearStr = _Date.ToString(YearFormat, Culture);
@@ -651,7 +708,7 @@ namespace AntdUI
void PrintDay(Canvas g, Rectangle rect_read, int radius, List<Calendari> datas)
{
if (rect_day_s == null) return;
var color_fore = Colour.TextBase.Get(nameof(Calendar), ColorScheme);
var color_fore = fore ?? Colour.TextBase.Get(nameof(Calendar), ColorScheme);
using (var font = new Font(Font.FontFamily, Font.Size, FontStyle.Bold))
{
string yearStr = _Date.ToString(YearFormat, Culture), monthStr = _Date.ToString(MonthFormat, Culture);

View File

@@ -515,6 +515,11 @@ namespace AntdUI
/// </summary>
public bool DefaultFocus { get; set; }
/// <summary>
/// 默认接受OK按钮
/// </summary>
public bool DefaultAcceptButton { get; set; } = true;
/// <summary>
/// 取消按钮字体
/// </summary>
@@ -712,6 +717,11 @@ namespace AntdUI
DefaultFocus = value;
return this;
}
public Config SetDefaultAcceptButton(bool value = false)
{
DefaultAcceptButton = value;
return this;
}
public Config SetInput(Input value)
{
DefaultFocus = true;

View File

@@ -464,7 +464,10 @@ namespace AntdUI
}
}
void InputEdit_SelectedValueChanged(object? sender, ObjectNEventArgs e) => EditModeClose();
void InputEdit_LostFocus(object? sender, EventArgs e) => EditModeClose();
void InputEdit_LostFocus(object? sender, EventArgs e)
{
if (EditLostFocus) EditModeClose();
}
#endregion

View File

@@ -920,6 +920,14 @@ namespace AntdUI
[Description("编辑模式自动高度"), Category("行为"), DefaultValue(false)]
public bool EditAutoHeight { get; set; }
/// <summary>
/// 失去焦点退出编辑模式
/// </summary>
[Description("失去焦点退出编辑模式"), Category("行为"), DefaultValue(true)]
public bool EditLostFocus { get; set; } = true;
#endregion
/// <summary>
/// 树表格的箭头样式
/// </summary>
@@ -932,8 +940,6 @@ namespace AntdUI
[Description("动画时长ms"), Category("行为"), DefaultValue(100)]
public int AnimationTime { get; set; } = 100;
#endregion
bool pauseLayout = false;
[Browsable(false), Description("暂停布局"), Category("行为"), DefaultValue(false)]
public bool PauseLayout

View File

@@ -144,6 +144,7 @@ namespace AntdUI
rect_right.Enable = Helper.DateExceedMonth(value.AddMonths(1), minDate, maxDate);
rect_lefts.Enable = Helper.DateExceedYear(value.AddYears(-1), minDate, maxDate);
rect_rights.Enable = Helper.DateExceedYear(value.AddYears(1), minDate, maxDate);
LoadLayoutDiv();
if (badge_action == null) return;
var oldval = value;
@@ -766,6 +767,25 @@ namespace AntdUI
SetSize(rw, r_h);
}
void LoadLayoutDiv()
{
if (rect_div.Count == 0) return;
switch (showType)
{
case TDatePicker.Date:
if (calendar_day == null) return;
foreach (var it in calendar_day) rect_div[it.id].Enable = it.enable;
break;
case TDatePicker.Month:
if (calendar_month == null) return;
foreach (var it in calendar_month) rect_div[it.id].Enable = it.enable;
break;
case TDatePicker.Year:
if (calendar_year == null) return;
foreach (var it in calendar_year) rect_div[it.id].Enable = it.enable;
break;
}
}
void ScrollTime(List<CalendarT> calendar_time, DateTime d)
{
CalendarT? find_h = calendar_time.Find(a => a.rx == 0 && a.t == d.Hour),

View File

@@ -221,6 +221,7 @@ namespace AntdUI
rect_right.Enable = Helper.DateExceedMonth(value.AddMonths(1), minDate, maxDate);
rect_lefts.Enable = Helper.DateExceedYear(value.AddYears(-1), minDate, maxDate);
rect_rights.Enable = Helper.DateExceedYear(value.AddYears(1), minDate, maxDate);
LoadLayoutDiv();
if (badge_action == null) return;
var oldval = value;
@@ -1031,6 +1032,28 @@ namespace AntdUI
SetSize(rw, r_h);
}
void LoadLayoutDiv()
{
if (rect_div.Count == 0) return;
switch (showType)
{
case TDatePicker.Date:
if (calendar_day == null || calendar_day2 == null) return;
foreach (var it in calendar_day) rect_div[it.id].Enable = it.enable;
foreach (var it in calendar_day2) rect_div["R_" + it.id].Enable = it.enable;
break;
case TDatePicker.Month:
if (calendar_month == null || calendar_month2 == null) return;
foreach (var it in calendar_month) rect_div[it.id].Enable = it.enable;
foreach (var it in calendar_month2) rect_div["R_" + it.id].Enable = it.enable;
break;
case TDatePicker.Year:
if (calendar_year == null || calendar_year2 == null) return;
foreach (var it in calendar_year) rect_div[it.id].Enable = it.enable;
foreach (var it in calendar_year2) rect_div["R_" + it.id].Enable = it.enable;
break;
}
}
void LoadLayoutButton(int t_x, int r_h, int t_time_height)
{

View File

@@ -161,6 +161,7 @@ namespace AntdUI
rect_right.Enable = Helper.DateExceedMonth(value.AddMonths(1), minDate, maxDate);
rect_lefts.Enable = Helper.DateExceedYear(value.AddYears(-1), minDate, maxDate);
rect_rights.Enable = Helper.DateExceedYear(value.AddYears(1), minDate, maxDate);
LoadLayoutDiv();
if (badge_action == null) return;
var oldval = value;
@@ -809,6 +810,25 @@ namespace AntdUI
SetSize(rw, r_h);
}
void LoadLayoutDiv()
{
if (rect_div.Count == 0) return;
switch (showType)
{
case TDatePicker.Date:
if (calendar_day == null) return;
foreach (var it in calendar_day) rect_div[it.id].Enable = it.enable;
break;
case TDatePicker.Month:
if (calendar_month == null) return;
foreach (var it in calendar_month) rect_div[it.id].Enable = it.enable;
break;
case TDatePicker.Year:
if (calendar_year == null) return;
foreach (var it in calendar_year) rect_div[it.id].Enable = it.enable;
break;
}
}
void ScrollTime(List<CalendarT> calendar_time, DateTime d)
{
CalendarT? find_h = calendar_time.Find(a => a.rx == 0 && a.t == d.Hour),

View File

@@ -188,8 +188,8 @@ namespace AntdUI
{
if (butt_h > 0)
{
AcceptButton = btn_ok;
CancelButton = btn_no;
if (config.DefaultAcceptButton) AcceptButton = btn_ok;
}
else ONESC = () => DialogResult = DialogResult.No;
}

View File

@@ -474,9 +474,13 @@ namespace AntdUI
public void Dispose()
{
if (token == null) return;
token.Cancel();
token.Dispose();
token = null;
try
{
token.Cancel();
token.Dispose();
token = null;
}
catch { }
}
}

View File

@@ -70,7 +70,7 @@ namespace AntdUI
else nCharLen += nLastCharLen;
lst_history_break_type.Add(nRightBreakType);
nIndex += nLastCharLen;
if (nLeftBreakType != Extended_Pictographic) nLeftBreakType = nRightBreakType;
nLeftBreakType = nRightBreakType;
}
if (nCharLen != 0)
{
@@ -139,7 +139,7 @@ namespace AntdUI
else nCharLen += nLastCharLen;
lst_history_break_type.Add(nRightBreakType);
nIndex += LastLen;
if (nLeftBreakType != Extended_Pictographic) nLeftBreakType = nRightBreakType;
nLeftBreakType = nRightBreakType;
}
if (nCharLen != 0 && nIndexCharStart < strText.Length)
{

View File

@@ -315,6 +315,23 @@ namespace AntdUI
return new SolidBrush(def);
}
/// <summary>
/// 画刷(渐变色)
/// </summary>
/// <param name="code">渐变代码H5</param>
/// <param name="rect">区域</param>
/// <param name="defn">默认空颜色</param>
/// <param name="def">默认颜色</param>
public static Brush BrushEx(this string? code, Rectangle rect, Color? defn, Color def)
{
if (code != null)
{
var arr = BrushEx(code);
if (arr.Length > 1) return BrushEx(code, arr, rect);
}
return new SolidBrush(defn ?? def);
}
/// <summary>
/// 画刷(渐变色)
/// </summary>