* UIForm:修改不显示标题时标题栏的按钮位置仍然可以点击的Bug

This commit is contained in:
Sunny 2020-10-21 21:27:39 +08:00
parent 52caed5317
commit 68a806126a
5 changed files with 77 additions and 9 deletions

Binary file not shown.

View File

@ -411,7 +411,7 @@ namespace Sunny.UI
protected override void OnMouseClick(MouseEventArgs e)
{
if (FormBorderStyle == FormBorderStyle.None)
if (FormBorderStyle == FormBorderStyle.None && ShowTitle)
{
if (InControlBox)
{

View File

@ -431,6 +431,7 @@
<Compile Include="Units\UConcurrentDoubleKeyDictionary.cs" />
<Compile Include="Units\UConcurrentGroupDictionary.cs" />
<Compile Include="Units\UDateTimeInt64.cs" />
<Compile Include="Units\UJson.cs" />
<Compile Include="Units\UJsonConfig.cs" />
<Compile Include="Units\USnowflakeID.cs" />
<Compile Include="Units\USuspendCtrlAltDel.cs" />

73
SunnyUI/Units/UJson.cs Normal file
View File

@ -0,0 +1,73 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2020 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@qq.com
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.dll can be used for free under the GPL-3.0 license.
* If you use this code, please keep this note.
* 使
******************************************************************************
* : UJson.cs
* : Json扩展类Json字符串和对象的转换
* : V2.2
* : 2020-10-21
*
* 2020-10-21: V2.2.9
******************************************************************************/
using System;
using System.IO;
using System.Text;
using System.Web.Script.Serialization;
namespace Sunny.UI
{
public static class Json
{
public static T Deserialize<T>(string input)
{
try
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize<T>(input);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return default(T);
}
}
public static string Serialize(object obj)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Serialize(obj);
}
public static T DeserializeFromFile<T>(string filename, Encoding encoding)
{
string jsonStr = File.ReadAllText(filename, encoding);
return Deserialize<T>(jsonStr);
}
public static string SerializeToFile(object obj, string filename, Encoding encoding)
{
string jsonStr = Serialize(obj);
try
{
DirEx.CreateDir(Path.GetDirectoryName(filename));
File.WriteAllText(filename, jsonStr, encoding);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
return jsonStr;
}
}
}

View File

@ -22,7 +22,6 @@
using System;
using System.IO;
using System.Text;
using System.Web.Script.Serialization;
namespace Sunny.UI
{
@ -54,9 +53,7 @@ namespace Sunny.UI
try
{
string jsonStr = File.ReadAllText(filename, Encoding.Default);
JavaScriptSerializer js = new JavaScriptSerializer();
current = js.Deserialize<TConfig>(jsonStr);
current = Json.DeserializeFromFile<TConfig>(filename, Encoding.Default);
return true;
}
catch (Exception ex)
@ -80,10 +77,7 @@ namespace Sunny.UI
throw new ApplicationException($"未指定{typeof(TConfig).Name}的配置文件路径!");
}
JavaScriptSerializer js = new JavaScriptSerializer();
string jsonStr = js.Serialize(current);
DirEx.CreateDir(Path.GetDirectoryName(filename));
File.WriteAllText(filename, jsonStr, Encoding.Default);
Json.SerializeToFile(current, filename, Encoding.Default);
}
}
}