Updated manager and added appx manifest reader.

This commit is contained in:
Bruce
2026-01-24 22:06:55 +08:00
parent 75cb72964d
commit 503ece1c64
60 changed files with 4980 additions and 3819 deletions

View File

@@ -53,6 +53,7 @@
<Compile Include="ManagerShell.Designer.cs">
<DependentUpon>ManagerShell.cs</DependentUpon>
</Compile>
<Compile Include="Polyfill.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="ManagerShell.resx">
@@ -66,6 +67,7 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.manifest" />
<None Include="Properties\Settings.settings">

View File

@@ -40,6 +40,7 @@
this.PageScale = 125;
this.Text = "Form1";
this.Load += new System.EventHandler(this.ManagerShell_Load);
this.Resize += new System.EventHandler(this.ManagerShell_Resize);
this.ResumeLayout(false);
}

View File

@@ -14,12 +14,82 @@ namespace Manager
public ManagerShell ()
{
InitializeComponent ();
SplashScreen.SplashBackgroundColor = Color.Honeydew;
try
{
var relativePath = DataUtils.VisualElementsStore.Vemanifest.SplashScreenImage (Program.g_appId);
var img = Image.FromFile (relativePath);
SplashScreen.SplashImage = img;
} catch (Exception e) {
var ex = e;
}
try
{
SplashScreen.SplashBackgroundColor = DataUtils.UITheme.StringToColor (DataUtils.VisualElementsStore.Vemanifest.SplashScreenBackgroundColor (Program.g_appId));
}
catch { }
InitSize ();
}
private void InitSize ()
{
uint ww = 0, wh = 0;
var ini = Bridge.InitFileStore.Config;
var setsect = ini ["Settings"];
var savepos = setsect.GetKey ("PackageManager:SavePosAndSizeBeforeCancel");
var lastw = setsect.GetKey ("PackageManager:LastWidth");
var lasth = setsect.GetKey ("PackageManager:LastHeight");
var defw = setsect.GetKey ("PackageManager:DefaultWidth");
var defh = setsect.GetKey ("PackageManager:DefaultHeight");
var minw = setsect.GetKey ("PackageManager:MinimumWidth");
var minh = setsect.GetKey ("PackageManager:MinimumHeight");
var lasts = setsect.GetKey ("PackageManager:LastWndState");
if (savepos.ReadBool ())
{
ww = lastw.ReadUInt (defw.ReadUInt (Properties.Resources.IDS_DEFAULTWIDTH.ParseTo <uint> ()));
wh = lasth.ReadUInt (defh.ReadUInt (Properties.Resources.IDS_DEFAULTHEIGHT.ParseTo <uint> ()));
}
else
{
ww = defw.ReadUInt (Properties.Resources.IDS_DEFAULTWIDTH.ParseTo<uint> ());
wh = defh.ReadUInt (Properties.Resources.IDS_DEFAULTHEIGHT.ParseTo<uint> ());
}
ClientSize = new Size ((int)(ww * DataUtils.UITheme.DPIDouble), (int)(wh * DataUtils.UITheme.DPIDouble));
int hborder = Size.Width - ClientSize.Width,
vborder = Size.Height - ClientSize.Height;
MinimumSize = new Size (
(int)(minw.ReadUInt (Properties.Resources.IDS_MINWIDTH.ParseTo <uint> ()) * DataUtils.UITheme.DPIDouble) + hborder,
(int)(minh.ReadUInt (Properties.Resources.IDS_MINHEIGHT.ParseTo <uint> ()) * DataUtils.UITheme.DPIDouble) + vborder
);
WindowState = (FormWindowState)lasts.ReadInt ((int)FormWindowState.Normal);
}
private void ManagerShell_Load (object sender, EventArgs e)
{
var root = Path.GetDirectoryName (DataUtils.Utilities.GetCurrentProgramPath ());
WebUI.Navigate (Path.Combine (root, "html\\manager.html"));
var pkg = new AppxPackage.PackageReader (@"F:\新建文件夹 (2)\9E2F88E3.Twitter_1.1.13.8_x86__wgeqdkkx372wm.appx");
pkg.EnablePri = true;
pkg.UsePri = true;
var displayName = pkg.Properties.LogoBase64;
}
private void ManagerShell_Resize (object sender, EventArgs e)
{
var ini = Bridge.InitFileStore.Config;
var setsect = ini ["Settings"];
var savepos = setsect.GetKey ("PackageManager:SavePosAndSizeBeforeCancel");
var lastw = setsect.GetKey ("PackageManager:LastWidth");
var lasth = setsect.GetKey ("PackageManager:LastHeight");
var lasts = setsect.GetKey ("PackageManager:LastWndState");
switch (WindowState)
{
case FormWindowState.Normal:
case FormWindowState.Maximized:
lasts.Write ((int)WindowState);
break;
}
if (WindowState == FormWindowState.Normal && savepos.ReadBool ())
{
lastw.Write ((int)(ClientSize.Width / DataUtils.UITheme.DPIDouble));
lasth.Write ((int)(ClientSize.Height / DataUtils.UITheme.DPIDouble));
}
}
}
}

40
Manager/Polyfill.cs Normal file
View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
namespace Manager
{
public static class Polyfill
{
public static T ParseTo <T> (this string src, T dflt = default (T))
{
if (string.IsNullOrWhiteSpace (src)) return dflt;
try
{
Type targetType = typeof (T);
Type underlying = Nullable.GetUnderlyingType (targetType);
if (underlying != null)
{
object v = Convert.ChangeType (src, underlying, CultureInfo.InvariantCulture);
return (T)v;
}
if (targetType.IsEnum)
{
object enumValue = Enum.Parse (targetType, src, true);
return (T)enumValue;
}
TypeConverter converter = TypeDescriptor.GetConverter (targetType);
if (converter != null && converter.CanConvertFrom (typeof (string)))
{
object v = converter.ConvertFrom (null, CultureInfo.InvariantCulture, src);
return (T)v;
}
}
catch { }
return dflt;
}
}
}

View File

@@ -7,6 +7,8 @@ namespace Manager
{
static class Program
{
static public readonly string g_appUserId = "WindowsModern.PracticalToolsProject!Manager";
static public readonly string g_appId = "Manager";
/// <summary>
/// 应用程序的主入口点。
/// </summary>

View File

@@ -1,71 +1,99 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// 对此文件的更改可能导致不正确的行为,并且如果
// 重新生成代码,这些更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Manager.Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute ("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute ()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute ()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute ("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources ()
{
}
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute (global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager ("Manager.Properties.Resources", typeof (Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 覆盖当前线程的 CurrentUICulture 属性
/// 使用此强类型的资源类的资源查找。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute (global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
namespace Manager.Properties {
using System;
/// <summary>
/// 一个强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Manager.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 使用此强类型资源类,为所有资源查找
/// 重写当前线程的 CurrentUICulture 属性。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// 查找类似 600 的本地化字符串。
/// </summary>
internal static string IDS_DEFAULTHEIGHT {
get {
return ResourceManager.GetString("IDS_DEFAULTHEIGHT", resourceCulture);
}
}
/// <summary>
/// 查找类似 800 的本地化字符串。
/// </summary>
internal static string IDS_DEFAULTWIDTH {
get {
return ResourceManager.GetString("IDS_DEFAULTWIDTH", resourceCulture);
}
}
/// <summary>
/// 查找类似 412 的本地化字符串。
/// </summary>
internal static string IDS_MINHEIGHT {
get {
return ResourceManager.GetString("IDS_MINHEIGHT", resourceCulture);
}
}
/// <summary>
/// 查找类似 504 的本地化字符串。
/// </summary>
internal static string IDS_MINWIDTH {
get {
return ResourceManager.GetString("IDS_MINWIDTH", resourceCulture);
}
}
}
}

View File

@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
@@ -68,9 +69,10 @@
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
@@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
@@ -109,9 +112,25 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="IDS_DEFAULTHEIGHT" xml:space="preserve">
<value>600</value>
<comment>默认窗口高度</comment>
</data>
<data name="IDS_DEFAULTWIDTH" xml:space="preserve">
<value>800</value>
<comment>默认窗口宽度</comment>
</data>
<data name="IDS_MINHEIGHT" xml:space="preserve">
<value>412</value>
<comment>默认最小窗口高度</comment>
</data>
<data name="IDS_MINWIDTH" xml:space="preserve">
<value>504</value>
<comment>默认最小窗口宽度</comment>
</data>
</root>

View File

@@ -8,16 +8,16 @@
如果想要更改 Windows 用户帐户控制级别,请使用
以下节点之一替换 requestedExecutionLevel 节点。n
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="asInvoker" uiAccess="false" /> -->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
<!-- <requestedExecutionLevel level="highestAvailable" uiAccess="false" />
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
如果你的应用程序需要此虚拟化来实现向后兼容性,则删除此
元素。
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<!-- <requestedExecutionLevel level="asInvoker" uiAccess="false" /> -->
</requestedPrivileges>
</security>
</trustInfo>