-
-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
1,367 additions
and
310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
src/Snap.Hutao/Snap.Hutao/Core/Database/SettingEntryHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Copyright (c) DGP Studio. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using Microsoft.EntityFrameworkCore; | ||
using Snap.Hutao.Model.Entity; | ||
|
||
namespace Snap.Hutao.Core.Database; | ||
|
||
/// <summary> | ||
/// 设置帮助类 | ||
/// </summary> | ||
public static class SettingEntryHelper | ||
{ | ||
/// <summary> | ||
/// 获取或添加一个对应的设置 | ||
/// </summary> | ||
/// <param name="dbSet">设置集</param> | ||
/// <param name="key">键</param> | ||
/// <param name="value">值</param> | ||
/// <returns>设置</returns> | ||
public static SettingEntry SingleOrAdd(this DbSet<SettingEntry> dbSet, string key, string value) | ||
{ | ||
SettingEntry? entry = dbSet.SingleOrDefault(entry => key == entry.Key); | ||
|
||
if (entry == null) | ||
{ | ||
entry = new(key, value); | ||
dbSet.Add(entry); | ||
dbSet.Context().SaveChanges(); | ||
} | ||
|
||
return entry; | ||
} | ||
|
||
/// <summary> | ||
/// 获取或添加一个对应的设置 | ||
/// </summary> | ||
/// <param name="dbSet">设置集</param> | ||
/// <param name="key">键</param> | ||
/// <param name="valueFactory">值工厂</param> | ||
/// <returns>设置</returns> | ||
public static SettingEntry SingleOrAdd(this DbSet<SettingEntry> dbSet, string key, Func<string> valueFactory) | ||
{ | ||
SettingEntry? entry = dbSet.SingleOrDefault(entry => key == entry.Key); | ||
|
||
if (entry == null) | ||
{ | ||
entry = new(key, valueFactory()); | ||
dbSet.Add(entry); | ||
dbSet.Context().SaveChanges(); | ||
} | ||
|
||
return entry; | ||
} | ||
|
||
/// <summary> | ||
/// 获取 Boolean 值 | ||
/// </summary> | ||
/// <param name="entry">设置</param> | ||
/// <returns>值</returns> | ||
public static bool GetBoolean(this SettingEntry entry) | ||
{ | ||
return bool.Parse(entry.Value!); | ||
} | ||
|
||
/// <summary> | ||
/// 设置 Boolean 值 | ||
/// </summary> | ||
/// <param name="entry">设置</param> | ||
/// <param name="value">值</param> | ||
public static void SetBoolean(this SettingEntry entry, bool value) | ||
{ | ||
entry.Value = value.ToString(); | ||
} | ||
|
||
/// <summary> | ||
/// 获取 Int32 值 | ||
/// </summary> | ||
/// <param name="entry">设置</param> | ||
/// <returns>值</returns> | ||
public static int GetInt32(this SettingEntry entry) | ||
{ | ||
return int.Parse(entry.Value!); | ||
} | ||
|
||
/// <summary> | ||
/// 设置 Int32 值 | ||
/// </summary> | ||
/// <param name="entry">设置</param> | ||
/// <param name="value">值</param> | ||
public static void SetInt32(this SettingEntry entry, int value) | ||
{ | ||
entry.Value = value.ToString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/Snap.Hutao/Snap.Hutao/Core/Windowing/IExtendedWindowSource.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) DGP Studio. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using Microsoft.UI.Xaml; | ||
using Windows.Graphics; | ||
using Windows.Win32.UI.WindowsAndMessaging; | ||
|
||
namespace Snap.Hutao.Core.Windowing; | ||
|
||
/// <summary> | ||
/// 为扩展窗体提供必要的选项 | ||
/// </summary> | ||
/// <typeparam name="TWindow">窗体类型</typeparam> | ||
internal interface IExtendedWindowSource | ||
{ | ||
/// <summary> | ||
/// 提供的标题栏 | ||
/// </summary> | ||
FrameworkElement TitleBar { get; } | ||
|
||
/// <summary> | ||
/// 是否持久化尺寸 | ||
/// </summary> | ||
bool PersistSize { get; } | ||
|
||
/// <summary> | ||
/// 初始大小 | ||
/// </summary> | ||
SizeInt32 InitSize { get; } | ||
|
||
/// <summary> | ||
/// 处理最大最小信息 | ||
/// </summary> | ||
/// <param name="pInfo">信息指针</param> | ||
/// <param name="scalingFactor">缩放比</param> | ||
unsafe void ProcessMinMaxInfo(MINMAXINFO* pInfo, double scalingFactor); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.