Update Shell

This commit is contained in:
Bruce
2025-11-21 12:55:08 +08:00
parent 1674f2c35b
commit ae3771bfdb
33 changed files with 972 additions and 78 deletions

18
appinstaller/app.manifest Normal file
View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"
xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a4e38}"/>
</application>
</compatibility>
</assembly>

Binary file not shown.

View File

@@ -97,6 +97,9 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>shlwapi.lib;version.lib;dwmapi.lib;$(OutDir)pkgread.lib;$(OutDir)pkgmgr.lib;$(OutDir)certmgr.lib;$(OutDir)priformatcli.lib;$(OutDir)notice.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Manifest>
<AdditionalManifestFiles>app.manifest</AdditionalManifestFiles>
</Manifest>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
@@ -130,6 +133,9 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>shlwapi.lib;version.lib;dwmapi.lib;$(OutDir)pkgread.lib;$(OutDir)pkgmgr.lib;$(OutDir)certmgr.lib;$(OutDir)priformatcli.lib;$(OutDir)notice.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Manifest>
<AdditionalManifestFiles>app.manifest</AdditionalManifestFiles>
</Manifest>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
@@ -150,6 +156,12 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\certmgr\certmgr.h" />
<ClInclude Include="..\notice\notice.h" />
<ClInclude Include="..\pkgmgr\pkgmgr.h" />
<ClInclude Include="..\pkgread\pkgread.h" />
<ClInclude Include="..\priformatcli\priformatcli.h" />
<ClInclude Include="appxinfo.h" />
<ClInclude Include="cmdargs.h" />
<ClInclude Include="dynarr.h" />
<ClInclude Include="filepath.h" />
@@ -160,6 +172,7 @@
<ClInclude Include="nstring.h" />
<ClInclude Include="raii.h" />
<ClInclude Include="rctools.h" />
<ClInclude Include="resmap.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="strcmp.h" />
<ClInclude Include="strcode.h" />
@@ -194,11 +207,13 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\pugixml.1.15.0\build\native\pugixml.targets" Condition="Exists('..\packages\pugixml.1.15.0\build\native\pugixml.targets')" />
<Import Project="..\packages\rapidjson.1.0.2\build\native\rapidjson.targets" Condition="Exists('..\packages\rapidjson.1.0.2\build\native\rapidjson.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\pugixml.1.15.0\build\native\pugixml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\pugixml.1.15.0\build\native\pugixml.targets'))" />
<Error Condition="!Exists('..\packages\rapidjson.1.0.2\build\native\rapidjson.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\rapidjson.1.0.2\build\native\rapidjson.targets'))" />
</Target>
</Project>

View File

@@ -66,6 +66,27 @@
<ClInclude Include="ieshell.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="resmap.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="appxinfo.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\certmgr\certmgr.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\notice\notice.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\pkgmgr\pkgmgr.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\pkgread\pkgread.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\priformatcli\priformatcli.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">

311
appinstaller/appxinfo.h Normal file
View File

@@ -0,0 +1,311 @@
#pragma once
#include <Windows.h>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <rapidjson\document.h>
#include <rapidjson\writer.h>
#include <rapidjson\stringbuffer.h>
#include <codecvt>
#include <locale>
#include "nstring.h"
#include "priformatcli.h"
#include "pkgread.h"
static std::string ws2utf8 (const std::wstring &ws)
{
std::wstring_convert <std::codecvt_utf8 <wchar_t>> conv;
return conv.to_bytes (ws);
}
static rapidjson::Value ver_to_json (const VERSION &ver, rapidjson::Document::AllocatorType &alloc)
{
rapidjson::Value obj (rapidjson::kObjectType);
obj.AddMember ("major", ver.major, alloc);
obj.AddMember ("minor", ver.minor, alloc);
obj.AddMember ("build", ver.build, alloc);
obj.AddMember ("revision", ver.revision, alloc);
return obj;
}
struct pkginfo
{
std::wstring filepath;
bool valid = false;
// 包的类型Appx 包还是 AppxBundle 包。返回 PKGTYPE_* 宏
WORD type = 0;
// 包的类型:是应用包、框架包还是资源包。
// 对于 AppxBundle 包永远返回是资源包(因为框架包无法打包成 AppxBundle资源包必须与应用包一同打包进 AppxBundle
// 返回 PKGROLE_* 宏。
WORD role = 0;
struct
{
std::wstring name,
publisher,
package_family_name,
package_full_name,
resource_id;
VERSION version, realver;
DWORD architecture;
} identity;
struct
{
std::wstring display_name;
std::wstring publisher_display_name;
std::wstring description;
std::wstring logo;
std::wstring logo_base64;
bool framework = false;
bool resource_package = false;
} properties;
struct application: std::map <std::wnstring, std::wstring>
{
using base = std::map <std::wnstring, std::wstring>;
using base::base;
application () = default;
std::wstring user_model_id () { return this->at (L"AppUserModelID"); }
friend bool operator == (application &a1, application &a2) { return a1.user_model_id () == a2.user_model_id (); }
friend bool operator != (application &a1, application &a2) { return a1.user_model_id () != a2.user_model_id (); }
explicit operator bool () { return this->user_model_id ().empty (); }
};
std::vector <application> applications;
struct
{
std::vector <std::wnstring> capabilities_name;
std::vector <std::wnstring> device_capabilities;
} capabilities;
struct dependency
{
std::wstring name, publisher;
VERSION vermin;
dependency (const std::wstring &name = L"", const std::wstring &pub = L"", const VERSION &ver = VERSION ()):
name (name), publisher (pub), vermin (ver) {}
};
std::vector <dependency> dependencies;
struct
{
std::set <std::wnstring> languages;
std::set <UINT32> scales;
// PKG_RESOURCES_DXFEATURE_LEVEL* 前缀常量
std::set <DWORD> dx_feature_levels;
} resources;
struct
{
VERSION os_min_version, os_max_version_tested;
} prerequisites;
static pkginfo parse (const std::wstring &filepath)
{
pkginfo pkg;
pkg.filepath = filepath;
package_reader pread (filepath);
pread.use_pri (true);
pread.enable_pri_convert (true);
pkg.valid = pread.valid ();
if (!pkg.valid) return pkg;
pkg.type = pread.package_type ();
pkg.role = pread.package_role ();
{
auto id = pread.get_identity ();
pkg.identity.architecture = id.architecture ();
pkg.identity.name = id.name ();
pkg.identity.package_family_name = id.package_family_name ();
pkg.identity.package_full_name = id.package_full_name ();
pkg.identity.publisher = id.publisher ();
pkg.identity.resource_id = id.resource_id ();
pkg.identity.version = id.version ();
pkg.identity.realver = id.version (true);
}
{
auto prop = pread.get_properties ();
pkg.properties.description = prop.description ();
pkg.properties.display_name = prop.display_name ();
pkg.properties.framework = prop.framework ();
pkg.properties.logo = prop.logo ();
pkg.properties.logo_base64 = prop.logo_base64 ();
pkg.properties.publisher_display_name = prop.publisher_display_name ();
pkg.properties.resource_package = prop.resource_package ();
}
{
auto prer = pread.get_prerequisites ();
pkg.prerequisites.os_min_version = prer.os_min_version ();
pkg.prerequisites.os_max_version_tested = prer.os_max_version_tested ();
}
{
auto apps = pread.get_applications ();
std::vector <package_reader::application> appmap;
apps.get (appmap);
pkg.applications.reserve (appmap.size ());
for (auto &mp : appmap)
{
application app;
for (auto &it : mp)
{
if (std::find (g_filepathitems.begin (), g_filepathitems.end (), it.first) != g_filepathitems.end ())
app [it.first] = mp.newat_base64 (it.first);
else app [it.first] = mp.newat (it.first);
}
pkg.applications.push_back (app);
}
}
{
auto caps = pread.get_capabilities ();
std::vector <std::wstring> vws;
caps.capabilities_name (vws);
pkg.capabilities.capabilities_name.reserve (vws.size ());
for (auto &it : vws) pkg.capabilities.capabilities_name.push_back (it);
vws.clear ();
caps.device_capabilities (vws);
pkg.capabilities.device_capabilities.reserve (vws.size ());
for (auto &it : vws) pkg.capabilities.device_capabilities.push_back (it);
}
{
std::vector <package_reader::dependency> deps;
auto depr = pread.get_dependencies ();
pkg.dependencies.reserve (depr.get (deps));
for (auto &it : deps)
{
dependency dep;
dep.name = it.name;
dep.publisher = it.publisher;
dep.vermin = it.vermin;
pkg.dependencies.push_back (dep);
}
}
{
auto ress = pread.get_resources ();
{
std::vector <std::wstring> langs;
ress.languages (langs);
for (auto &it : langs) pkg.resources.languages.insert (it);
}
{
std::vector <UINT32> ss;
ress.scales (ss);
for (auto &it : ss) pkg.resources.scales.insert (it);
}
{
DWORD dx = ress.dx_feature_level ();
if (dx & PKG_RESOURCES_DXFEATURE_LEVEL9)
pkg.resources.dx_feature_levels.insert (PKG_RESOURCES_DXFEATURE_LEVEL9);
else if (dx & PKG_RESOURCES_DXFEATURE_LEVEL10)
pkg.resources.dx_feature_levels.insert (PKG_RESOURCES_DXFEATURE_LEVEL10);
else if (dx & PKG_RESOURCES_DXFEATURE_LEVEL11)
pkg.resources.dx_feature_levels.insert (PKG_RESOURCES_DXFEATURE_LEVEL11);
else if (dx & PKG_RESOURCES_DXFEATURE_LEVEL12)
pkg.resources.dx_feature_levels.insert (PKG_RESOURCES_DXFEATURE_LEVEL12);
}
}
return pkg;
}
std::wstring parseJson ()
{
using namespace rapidjson;
Document doc;
doc.SetObject ();
auto &alloc = doc.GetAllocator ();
doc.AddMember ("filepath", Value (ws2utf8 (filepath).c_str (), alloc), alloc);
doc.AddMember ("valid", valid, alloc);
doc.AddMember ("type", type, alloc);
doc.AddMember ("role", role, alloc);
{
Value obj (kObjectType);
obj.AddMember ("name", Value (ws2utf8 (identity.name).c_str (), alloc), alloc);
obj.AddMember ("publisher", Value (ws2utf8 (identity.publisher).c_str (), alloc), alloc);
obj.AddMember ("package_family_name", Value (ws2utf8 (identity.package_family_name).c_str (), alloc), alloc);
obj.AddMember ("package_full_name", Value (ws2utf8 (identity.package_full_name).c_str (), alloc), alloc);
obj.AddMember ("resource_id", Value (ws2utf8 (identity.resource_id).c_str (), alloc), alloc);
obj.AddMember ("architecture", (uint32_t)identity.architecture, alloc);
obj.AddMember ("version", ver_to_json (identity.version, alloc), alloc);
obj.AddMember ("realver", ver_to_json (identity.realver, alloc), alloc);
doc.AddMember ("identity", obj, alloc);
}
{
Value obj (kObjectType);
obj.AddMember ("display_name", Value (ws2utf8 (properties.display_name).c_str (), alloc), alloc);
obj.AddMember ("publisher_display_name", Value (ws2utf8 (properties.publisher_display_name).c_str (), alloc), alloc);
obj.AddMember ("description", Value (ws2utf8 (properties.description).c_str (), alloc), alloc);
obj.AddMember ("logo", Value (ws2utf8 (properties.logo).c_str (), alloc), alloc);
obj.AddMember ("logo_base64", Value (ws2utf8 (properties.logo_base64).c_str (), alloc), alloc);
obj.AddMember ("framework", properties.framework, alloc);
obj.AddMember ("resource_package", properties.resource_package, alloc);
doc.AddMember ("properties", obj, alloc);
}
{
Value arr (kArrayType);
for (auto &app : applications)
{
Value obj (kObjectType);
for (auto &it : app)
{
std::string key = ws2utf8 (it.first);
std::string val = ws2utf8 (it.second);
obj.AddMember (
Value (key.c_str (), alloc),
Value (val.c_str (), alloc),
alloc
);
}
arr.PushBack (obj, alloc);
}
doc.AddMember ("applications", arr, alloc);
}
{
Value obj (kObjectType);
{
Value arr (kArrayType);
for (auto &it : capabilities.capabilities_name)
arr.PushBack (Value (ws2utf8 (it).c_str (), alloc), alloc);
obj.AddMember ("capabilities_name", arr, alloc);
}
{
Value arr (kArrayType);
for (auto &it : capabilities.device_capabilities) arr.PushBack (Value (ws2utf8 (it).c_str (), alloc), alloc);
obj.AddMember ("device_capabilities", arr, alloc);
}
doc.AddMember ("capabilities", obj, alloc);
}
{
Value arr (kArrayType);
for (auto& d : dependencies)
{
Value obj (kObjectType);
obj.AddMember ("name", Value (ws2utf8 (d.name).c_str (), alloc), alloc);
obj.AddMember ("publisher", Value (ws2utf8 (d.publisher).c_str (), alloc), alloc);
obj.AddMember ("vermin", ver_to_json (d.vermin, alloc), alloc);
arr.PushBack (obj, alloc);
}
doc.AddMember ("dependencies", arr, alloc);
}
{
Value obj (kObjectType);
{
Value arr (kArrayType);
for (auto &it : resources.languages) arr.PushBack (Value (ws2utf8 (it).c_str (), alloc), alloc);
obj.AddMember ("languages", arr, alloc);
}
{
Value arr (kArrayType);
for (auto &it : resources.scales) arr.PushBack ((uint32_t)it, alloc);
obj.AddMember ("scales", arr, alloc);
}
{
Value arr (kArrayType);
for (auto &it : resources.dx_feature_levels) arr.PushBack ((uint32_t)it, alloc);
obj.AddMember ("dx_feature_levels", arr, alloc);
}
doc.AddMember ("resources", obj, alloc);
}
{
Value obj (kObjectType);
obj.AddMember ("os_min_version", ver_to_json (prerequisites.os_min_version, alloc), alloc);
obj.AddMember ("os_max_version_tested", ver_to_json (prerequisites.os_max_version_tested, alloc), alloc);
doc.AddMember ("prerequisites", obj, alloc);
}
StringBuffer buffer;
Writer<StringBuffer> writer (buffer);
doc.Accept (writer);
std::string utf8 = buffer.GetString ();
std::wstring_convert <std::codecvt_utf8 <wchar_t>> conv;
return conv.from_bytes (utf8);
}
};

1
appinstaller/certmgr.h Symbolic link
View File

@@ -0,0 +1 @@
E:/Profiles/Bruce/Documents/Visual Studio 2015/Projects/AppInstallerReset/certmgr/certmgr.h

View File

@@ -10,7 +10,7 @@
#include "strcmp.h"
#include "version.h"
#include "module.h"
typedef version VERSION;
typedef version S_VERSION;
template <typename T> constexpr T Max (T l, T r) { return l > r ? l : r; }
template <typename T> constexpr T Max (T l, T m, T r) { return Max (Max (l, r), m); }
template <typename T> constexpr T Max (T l, T ml, T mr, T r) { return Max (Max (l, ml), Max (mr, r)); }
@@ -202,9 +202,9 @@ std::wstring GetCurrentProgramPathW (HMODULE hModule hModule_DefaultParam)
}
std::string GetCurrentProgramNameA (HMODULE hModule hModule_DefaultParam) { return PathFindFileNameA (GetCurrentProgramPathA (hModule).c_str ()); }
std::wstring GetCurrentProgramNameW (HMODULE hModule hModule_DefaultParam) { return PathFindFileNameW (GetCurrentProgramPathW (hModule).c_str ()); }
VERSION GetExeFileVersion (LPCSTR lpszFilePath)
S_VERSION GetExeFileVersion (LPCSTR lpszFilePath)
{
VERSION ver (0);
S_VERSION ver (0);
DWORD dummy;
DWORD size = GetFileVersionInfoSizeA (lpszFilePath, &dummy);
std::vector <BYTE> pVersionInfo (size);
@@ -222,7 +222,7 @@ VERSION GetExeFileVersion (LPCSTR lpszFilePath)
{
return ver;
}
ver = VERSION (
ver = S_VERSION (
HIWORD (pFileInfo->dwFileVersionMS),
LOWORD (pFileInfo->dwFileVersionMS),
HIWORD (pFileInfo->dwFileVersionLS),
@@ -230,9 +230,9 @@ VERSION GetExeFileVersion (LPCSTR lpszFilePath)
);
return ver;
}
VERSION GetExeFileVersion (LPCWSTR lpswFilePath)
S_VERSION GetExeFileVersion (LPCWSTR lpswFilePath)
{
VERSION ver (0);
S_VERSION ver (0);
DWORD dummy;
DWORD size = GetFileVersionInfoSizeW (lpswFilePath, &dummy);
std::vector <BYTE> pVersionInfo (size);
@@ -250,7 +250,7 @@ VERSION GetExeFileVersion (LPCWSTR lpswFilePath)
{
return ver;
}
ver = VERSION (
ver = S_VERSION (
HIWORD (pFileInfo->dwFileVersionMS),
LOWORD (pFileInfo->dwFileVersionMS),
HIWORD (pFileInfo->dwFileVersionLS),
@@ -258,11 +258,11 @@ VERSION GetExeFileVersion (LPCWSTR lpswFilePath)
);
return ver;
}
VERSION GetExeFileVersion (std::wstring objswFilePath)
S_VERSION GetExeFileVersion (std::wstring objswFilePath)
{
return GetExeFileVersion (objswFilePath.c_str ());
}
VERSION GetExeFileVersion (std::string objszFilePath)
S_VERSION GetExeFileVersion (std::string objszFilePath)
{
return GetExeFileVersion (objszFilePath.c_str ());
}

View File

@@ -12,6 +12,9 @@
#include "resource.h"
#include "vemani.h"
#include "ieshell.h"
#include "resmap.h"
#include "appxinfo.h"
using namespace System;
using namespace System::Runtime::InteropServices;
@@ -20,6 +23,7 @@ using namespace System::Runtime::InteropServices;
#else
#define DEBUGMODE false
#endif
#define JS_SAFE [MarshalAs (UnmanagedType::SafeArray, SafeArraySubType = VarEnum::VT_VARIANT)]
LPCWSTR g_lpAppId = L"Microsoft.DesktopAppInstaller";
auto &g_identity = g_lpAppId;
@@ -44,6 +48,9 @@ resxmldoc g_scaleres (
CombinePath (GetProgramRootDirectoryW (), L"VisualElements\\scale.xml") :
CombinePath (GetProgramRootDirectoryW (), L"VisualElementsManifest.xml")
);
WORD g_wcmdflags = 0;
std::set <std::wnstring> g_pkgfiles;
std::vector <pkginfo> g_pkginfo;
HRESULT GetWebBrowser2Interface (System::Windows::Forms::WebBrowser ^fwb, IWebBrowser2 **output)
{
@@ -66,6 +73,9 @@ public ref class SplashForm: public System::Windows::Forms::Form
private:
PictureBox ^picbox;
Timer ^timer;
System::Drawing::Image ^splashimg = nullptr;
System::Drawing::Color background = System::Drawing::Color::Transparent;
// System::Windows::Forms ^parent = nullptr;
double opastep = 0.05;
void InitForm ()
{
@@ -140,14 +150,26 @@ public ref class SplashForm: public System::Windows::Forms::Form
try
{
auto img = System::Drawing::Image::FromFile (gcnew System::String (filefullpath.c_str ()));
if (img != nullptr) picbox->Image = img;
if (img != nullptr)
{
splashimg = img;
picbox->Image = img;
}
}
catch (...) { }
if (splashimg) picbox->Image = splashimg;
if (backcolor != Drawing::Color::Transparent)
{
background = backcolor;
picbox->BackColor = backcolor;
this->BackColor = backcolor;
}
else
{
picbox->BackColor = background;
this->BackColor = background;
}
if (this->Owner != nullptr)
{
this->Owner->Resize += gcnew System::EventHandler (this, &SplashForm::OnResizeOwner);
@@ -160,6 +182,27 @@ public ref class SplashForm: public System::Windows::Forms::Form
timer->Tick += gcnew System::EventHandler (this, &SplashForm::OnFadeTimer);
this->Load += gcnew EventHandler (this, &SplashForm::OnLoad);
}
void ReInit ()
{
InitForm ();
picbox = gcnew System::Windows::Forms::PictureBox ();
picbox->BackColor = background;
if (splashimg) picbox->Image = splashimg;
picbox->SizeMode = System::Windows::Forms::PictureBoxSizeMode::Zoom;
picbox->Anchor = System::Windows::Forms::AnchorStyles::None;
double dDpi = GetDPI () * 0.01;
picbox->Size = Drawing::Size (620 * dDpi, 300 * dDpi);
this->BackColor = background;
this->Controls->Clear ();
this->Controls->Add (picbox);
timer = gcnew System::Windows::Forms::Timer ();
timer->Interval = 15;
timer->Tick += gcnew EventHandler (this, &SplashForm::OnFadeTimer);
this->Resize += gcnew EventHandler (this, &SplashForm::OnResize);
this->Load += gcnew EventHandler (this, &SplashForm::OnLoad);
ChangePosAndSize ();
this->Opacity = 1.0;
}
void ChangePosAndSize ()
{
if (this->Owner && this->Owner->IsHandleCreated)
@@ -185,14 +228,14 @@ public ref class SplashForm: public System::Windows::Forms::Form
);
}
}
void SetSplashImage (System::Drawing::Image ^img) { if (picbox) picbox->Image = img; }
void SetSplashImage (System::Drawing::Image ^img) { if (picbox && picbox->IsHandleCreated) { splashimg = img; picbox->Image = splashimg; } else splashimg = img; }
void SetSplashImage (System::String ^imgpath) { try { SetSplashImage (System::Drawing::Image::FromFile (imgpath)); } catch (...) {} }
void SetSplashImage (const std::wstring &imgpath) { SetSplashImage (CStringToMPString (imgpath)); }
void SetSplashBackgroundColor (System::Drawing::Color color) { picbox->BackColor = color; this->BackColor = color; }
void SetSplashBackgroundColor (System::Drawing::Color color) { background = color; picbox->BackColor = color; this->BackColor = color; }
// 渐变消失
void FadeOut () { timer->Start (); }
// 立即消失
void FadeAway () { this->Visible = false; this->Close (); }
void FadeAway () { timer->Start (); }
~SplashForm ()
{
if (this->Owner != nullptr)
@@ -202,7 +245,37 @@ public ref class SplashForm: public System::Windows::Forms::Form
}
}
};
bool ReadPackagesTask ()
{
std::set <std::wstring> noread;
std::set <std::wstring> hasread;
for (auto &it : g_pkgfiles)
{
bool isfind = false;
for (auto &rit : g_pkginfo)
{
if (rit.filepath == it)
{
isfind == true;
hasread.insert (it);
break;
}
}
if (!isfind) noread.insert (it);
}
for (auto &it : noread)
{
auto pi = pkginfo::parse (it);
if (pi.valid)
{
hasread.insert (it);
g_pkginfo.push_back (pi);
}
}
g_pkgfiles.clear ();
for (auto &it : hasread) g_pkgfiles.insert (it);
return hasread.size ();
}
[ComVisible (true)]
public ref class MainHtmlWnd: public System::Windows::Forms::Form
{
@@ -229,18 +302,166 @@ public ref class MainHtmlWnd: public System::Windows::Forms::Form
private:
MainHtmlWnd ^wndinst = nullptr;
public:
ref struct _I_UI_Size
{
private:
int m_width = 0;
int m_height = 0;
public:
property int width { int get () { return m_width; } }
property int height { int get () { return m_height; }}
property int Width { int get () { return m_width; } }
property int Height { int get () { return m_height; }}
int getWidth () { return m_width; }
int getHeight () { return m_height; }
_I_UI_Size (int w, int h): m_width (w), m_height (h) {}
};
_I_UI (MainHtmlWnd ^wnd): wndinst (wnd) {}
property int DPIPercent { int get () { return GetDPI (); }}
property double DPI { double get () { return DPIPercent * 0.01; }}
void showSplash () { wndinst->SplashScreen->Show (); }
void fadeAwaySplash () { wndinst->SplashScreen->FadeAway (); }
void fadeOutSplash () { wndinst->SplashScreen->FadeOut (); }
property _I_UI_Size ^WndSize { _I_UI_Size ^get () { return gcnew _I_UI_Size (wndinst->Width, wndinst->Height); } }
property _I_UI_Size ^ClientSize { _I_UI_Size ^get () { auto cs = wndinst->ClientSize; return gcnew _I_UI_Size (cs.Width, cs.Height); } }
property String ^SplashImage
{
String ^get ()
{
auto uri = gcnew Uri (CStringToMPString (wndinst->GetSuitSplashImage ()));
return uri->AbsoluteUri;
}
}
property String ^SplashBackgroundColor { String ^get () { return CStringToMPString (g_vemani.splash_screen_backgroundcolor (L"App")); } }
void ShowSplash () { if (wndinst->SplashScreen->IsHandleCreated) wndinst->SplashScreen->Show (); else wndinst->SplashScreen->ReInit (); }
void FadeAwaySplash () { wndinst->SplashScreen->FadeAway (); }
void FadeOutSplash () { wndinst->SplashScreen->FadeOut (); }
};
ref class _I_Resources
{
public:
String ^GetById (unsigned int uiResId) { return GetRCStringCli (uiResId); }
unsigned ToId (String ^lpResName)
{
auto it = g_nameToId.find (MPStringToStdA (lpResName));
return (it != g_nameToId.end ()) ? it->second : 0;
}
String ^ToName (unsigned int ulResId)
{
for (auto &it : g_nameToId) {if (it.second == ulResId) return CStringToMPString (it.first);}
return "";
}
String ^GetByName (String ^lpResId) { return GetById (ToId (lpResId)); }
String ^operator [] (unsigned int uiResId) { return GetRCStringCli (uiResId); }
};
ref class _I_Version
{
private:
UINT16 major = 0, minor = 0, build = 0, revision = 0;
public:
property UINT16 Major { UINT16 get () { return major; } void set (UINT16 value) { major = value; } }
property UINT16 Minor { UINT16 get () { return minor; } void set (UINT16 value) { minor = value; } }
property UINT16 Build { UINT16 get () { return build; } void set (UINT16 value) { build = value; } }
property UINT16 Revision { UINT16 get () { return revision; } void set (UINT16 value) { revision = value; } }
property array <UINT16> ^Data
{
array <UINT16> ^get ()
{
return gcnew array <UINT16> {
major, minor, build, revision
};
}
void set (array <UINT16> ^arr)
{
major = minor = build = revision = 0;
for (size_t i = 0; i < arr->Length; i ++)
{
switch (i)
{
case 0: major = arr [i]; break;
case 1: minor = arr [i]; break;
case 2: build = arr [i]; break;
case 3: revision = arr [i]; break;
default: break;
}
}
}
}
property String ^DataStr
{
String ^get () { return Stringify (); }
void set (String ^str) { Parse (str); }
}
_I_Version (UINT16 p_ma, UINT16 p_mi, UINT16 p_b, UINT16 p_r):
major (p_ma), minor (p_mi), build (p_b), revision (p_r) {}
_I_Version (UINT16 p_ma, UINT16 p_mi, UINT16 p_b):
major (p_ma), minor (p_mi), build (p_b), revision (0) {}
_I_Version (UINT16 p_ma, UINT16 p_mi):
major (p_ma), minor (p_mi), build (0), revision (0) {}
_I_Version (UINT16 p_ma):
major (p_ma), minor (0), build (0), revision (0) {}
_I_Version () {}
_I_Version %Parse (String ^ver)
{
auto strarr = ver->Split ('.');
auto arr = gcnew array <UINT16> (4);
for (size_t i = 0; i < strarr->Length; i ++)
{
try { arr [i] = Convert::ToUInt16 (strarr [i]); }
catch (...) {}
}
Data = arr;
return *this;
}
String ^Stringify () { return major + "." + minor + "." + build + "." + revision; }
String ^ToString () override { return Stringify (); }
bool Valid () { return Major != 0 && Minor != 0 && Build != 0 && Revision != 0; }
};
private:
_I_UI ^ui = gcnew _I_UI (wndinst);
_I_Resources ^ires = gcnew _I_Resources ();
public:
_I_System (MainHtmlWnd ^wnd): wndinst (wnd) {}
property _I_UI ^UI { _I_UI ^get () { return ui; } }
property _I_Resources ^Resources { _I_Resources ^get () { return ires; } }
property _I_Version ^Version
{
_I_Version ^get ()
{
#pragma warning(push)
#pragma warning(disable:4996)
auto ver = gcnew _I_Version ();
OSVERSIONINFOEXW osvi = {0};
osvi.dwOSVersionInfoSize = sizeof (osvi);
if (!GetVersionExW ((LPOSVERSIONINFOW)&osvi)) return ver;
ver->Major = osvi.dwMajorVersion;
ver->Minor = osvi.dwMinorVersion;
ver->Build = osvi.dwBuildNumber;
HKEY hKey;
{
DWORD ubr = 0, size = sizeof (DWORD);
if (RegOpenKeyExW (HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
RegQueryValueExW (hKey, L"UBR", 0, NULL, (LPBYTE)&ubr, &size);
RegCloseKey (hKey);
}
ver->Revision = ubr;
}
return ver;
#pragma warning(pop)
}
}
property bool IsWindows10
{
bool get ()
{
OSVERSIONINFOEX osvi = {0};
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
osvi.dwMajorVersion = 10;
DWORDLONG conditionMask = 0;
VER_SET_CONDITION (conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
if (VerifyVersionInfoW (&osvi, VER_MAJORVERSION, conditionMask)) return TRUE;
DWORD error = GetLastError ();
return (error == ERROR_OLD_WIN_VERSION) ? FALSE : FALSE;
}
}
};
ref class _I_IEFrame
{
@@ -289,36 +510,31 @@ public ref class MainHtmlWnd: public System::Windows::Forms::Form
String ^ToLower (String ^src) { return CStringToMPString (StringToLower (MPStringToStdW (src))); }
String ^ToUpper (String ^src) { return CStringToMPString (StringToUpper (MPStringToStdW (src))); }
};
ref class _I_Package
{
public:
};
private:
_I_System ^system = gcnew _I_System (wndinst);
_I_IEFrame ^ieframe = gcnew _I_IEFrame (wndinst);
_I_Storage ^storage = gcnew _I_Storage (wndinst);
_I_String ^str = gcnew _I_String ();
_I_Package ^pkg = gcnew _I_Package ();
public:
property _I_System ^System { _I_System ^get () { return system; }}
property _I_IEFrame ^IEFrame { _I_IEFrame ^get () { return ieframe; }}
property _I_Storage ^Storage { _I_Storage ^get () { return storage; }}
property _I_String ^String { _I_String ^get () { return str; }}
property _I_Package ^Package { _I_Package ^get () { return pkg; }}
};
protected:
property WebBrowser ^WebUI { WebBrowser ^get () { return this->webui; } }
property SplashForm ^SplashScreen { SplashForm ^get () { return this->splash; } }
property int DPIPercent { int get () { return GetDPI (); }}
property double DPI { double get () { return DPIPercent * 0.01; }}
void Init ()
void InitSize ()
{
this->Visible = false;
this->webui = gcnew System::Windows::Forms::WebBrowser ();
this->SuspendLayout ();
this->webui->Dock = System::Windows::Forms::DockStyle::Fill;
this->webui->IsWebBrowserContextMenuEnabled = DEBUGMODE;
this->webui->AllowWebBrowserDrop = false;
this->Controls->Add (this->webui);
if (g_hIconMain.hIcon)
{
try { this->Icon = System::Drawing::Icon::FromHandle (IntPtr (g_hIconMain.hIcon)); }
catch (...) {}
}
unsigned ww = 0, wh = 0;
auto &ini = g_initfile;
auto setsect = ini ["Settings"];
@@ -333,11 +549,26 @@ public ref class MainHtmlWnd: public System::Windows::Forms::Form
wh = setsect [L"DefaultHeight"].read_uint (rcInt (IDS_DEFAULTHEIGHT));
}
this->MinimumSize = System::Drawing::Size (
setsect [L"MinimumWidth"].read_uint (rcInt (IDS_MINWIDTH)) * DPI,
setsect [L"MinimumWidth"].read_uint (rcInt (IDS_MINWIDTH)) * DPI,
setsect [L"MinimumHeight"].read_uint (rcInt (IDS_MINHIEHGT)) * DPI
);
this->ClientSize = System::Drawing::Size (ww * DPI, wh * DPI);
this->WindowState = (System::Windows::Forms::FormWindowState)setsect [L"LastWndState"].read_int ((int)System::Windows::Forms::FormWindowState::Normal);
}
void Init ()
{
this->Visible = false;
this->webui = gcnew System::Windows::Forms::WebBrowser ();
this->SuspendLayout ();
this->webui->Dock = System::Windows::Forms::DockStyle::Fill;
this->webui->IsWebBrowserContextMenuEnabled = DEBUGMODE;
this->webui->AllowWebBrowserDrop = false;
this->Controls->Add (this->webui);
if (g_hIconMain.hIcon)
{
try { this->Icon = System::Drawing::Icon::FromHandle (IntPtr (g_hIconMain.hIcon)); }
catch (...) {}
}
this->Text = rcString (IDS_WINTITLE);
this->ResumeLayout (false);
webui->ObjectForScripting = gcnew IBridge (this);
@@ -354,7 +585,8 @@ public ref class MainHtmlWnd: public System::Windows::Forms::Form
ExecScript ("Windows.UI.DPI.mode = 1");
ExecScript ("Bridge.Frame.scale = Bridge.Frame.scale * Bridge.UI.dpi");
splash->FadeOut ();
// splash->FadeOut ();
splash->FadeAway ();
}
}
void OnCreate (System::Object ^sender, System::EventArgs ^e)
@@ -372,19 +604,45 @@ public ref class MainHtmlWnd: public System::Windows::Forms::Form
}
void OnResize (Object ^sender, EventArgs ^e)
{
ResizeEvent ();
}
void OnResizeEnd (Object ^sender, EventArgs ^e)
{
}
std::wstring GetSuitSplashImage ()
{
std::wstring path = g_scaleres [this->Width >= 1024 && this->Height >= 768 ? L"splashlarge" : L"splash"];
if (IsNormalizeStringEmpty (path)) path = g_vemani.splash_screen_image (L"App");
return path;
}
void ResizeEvent ()
{
splash->SetSplashImage (GetSuitSplashImage ());
ExecScript (
"(function () {"
"var splash = Page.splash;"
"if (!splash) return null;"
"splash.imagesrc = Bridge.UI.Splash.imageurl;"
"splash.background = Bridge.UI.Splash.backcolor;"
"var progress = splash.content.querySelector (\"progress\");"
"if (Bridge.Frame.WindowSize.height / Bridge.UI.dpi < 500) {"
"if (progress.classList.contains(\"win-ring\")) progress.classList.remove(\"win-ring\");}"
"else { if (!progress.classList.contains(\"win-ring\")) progress.classList.add(\"win-ring\"); }"
"}) ();"
);
}
void PackageLoadTask ()
{
if (!g_pkginfo.size ())
}
public:
MainHtmlWnd ()
{
InitSize ();
splash = gcnew SplashForm (
gcnew String (g_vemani.splash_screen_image (L"App").c_str ()),
StringToColor (gcnew String (g_vemani.splash_screen_backgroundcolor (L"App").c_str ())),
CStringToMPString (GetSuitSplashImage ()),
StringToColor (CStringToMPString (g_vemani.splash_screen_backgroundcolor (L"App"))),
this
);
System::Windows::Forms::Application::DoEvents ();
@@ -578,7 +836,7 @@ int APIENTRY wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCm
SetProcessDPIAware ();
{
// 设置当前目录为程序所在目录
std::wnstring currdir = GetCurrentProgramPathW ();
std::wnstring currdir = GetCurrentDirectoryW ();
std::wnstring rootdir = GetProgramRootDirectoryW ();
if (!PathEquals (currdir, rootdir)) SetCurrentDirectoryW (rootdir.c_str ());
}
@@ -586,6 +844,12 @@ int APIENTRY wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCm
destruct relco ([] () {
CoUninitialize ();
});
{
std::map <cmdkey, cmdvalue> pair_cmdkv;
ParseCmdLine (lpCmdLine, pair_cmdkv);
std::set <std::wnstring> uris;
g_wcmdflags = CmdMapsToFlags (pair_cmdkv, g_pkgfiles, uris);
}
System::Windows::Forms::Application::EnableVisualStyles ();
System::Windows::Forms::Application::SetCompatibleTextRenderingDefault (false);
auto mwnd = gcnew MainHtmlWnd ();

1
appinstaller/notice.h Symbolic link
View File

@@ -0,0 +1 @@
E:/Profiles/Bruce/Documents/Visual Studio 2015/Projects/AppInstallerReset/notice/notice.h

View File

@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="pugixml" version="1.15.0" targetFramework="native" />
<package id="rapidjson" version="1.0.2" targetFramework="native" />
</packages>

1
appinstaller/pkgmgr.h Symbolic link
View File

@@ -0,0 +1 @@
E:/Profiles/Bruce/Documents/Visual Studio 2015/Projects/AppInstallerReset/pkgmgr/pkgmgr.h

1
appinstaller/pkgread.h Symbolic link
View File

@@ -0,0 +1 @@
E:/Profiles/Bruce/Documents/Visual Studio 2015/Projects/AppInstallerReset/pkgread/pkgread.h

1
appinstaller/priformatcli.h Symbolic link
View File

@@ -0,0 +1 @@
E:/Profiles/Bruce/Documents/Visual Studio 2015/Projects/AppInstallerReset/priformatcli/priformatcli.h

53
appinstaller/resmap.h Normal file
View File

@@ -0,0 +1,53 @@
#pragma once
#include <map>
#include <string>
#include "rctools.h"
#include "resource.h"
#define MAKENAMEIDMAP(_Res_Name_) {#_Res_Name_, _Res_Name_}
std::map <std::string, unsigned> g_nameToId = {
MAKENAMEIDMAP (IDS_WINTITLE),
MAKENAMEIDMAP (IDS_PLEASEWAIT),
MAKENAMEIDMAP (IDS_PUBLISHER),
MAKENAMEIDMAP (IDS_VERSION),
MAKENAMEIDMAP (IDS_MSAPP),
MAKENAMEIDMAP (IDS_FUNCTIONNAME),
MAKENAMEIDMAP (IDS_MOREINFO),
MAKENAMEIDMAP (IDS_SELECT_TITLE),
MAKENAMEIDMAP (IDS_SELECT_DLGTITLE),
MAKENAMEIDMAP (IDS_SELECT_DLGAPPX),
MAKENAMEIDMAP (IDS_SELECT_DLGALL),
MAKENAMEIDMAP (IDS_SELECT_OPENFILE),
MAKENAMEIDMAP (IDS_PREINSTALL_TITLE),
MAKENAMEIDMAP (IDS_PREINSTALL_TUPDATE),
MAKENAMEIDMAP (IDS_PREINSTALL_TREINSTALL),
MAKENAMEIDMAP (IDS_PREINSTALL_TINSTALL),
MAKENAMEIDMAP (IDS_PREINSTALL_CUPDATE),
MAKENAMEIDMAP (IDS_PREINSTALL_CREINSTALL),
MAKENAMEIDMAP (IDS_PREINSTALL_CANCEL),
MAKENAMEIDMAP (IDS_PREINSTALL_MTTITLE),
MAKENAMEIDMAP (IDS_PREINSTALL_MSELECT),
MAKENAMEIDMAP (IDS_PREINSTALL_MPKGNAME),
MAKENAMEIDMAP (IDS_INSTALLING_TITLE),
MAKENAMEIDMAP (IDS_INSTALLING_SLOADING),
MAKENAMEIDMAP (IDS_INSTALLING_SLOADCER),
MAKENAMEIDMAP (IDS_INSTALLING_SINSTALLING),
MAKENAMEIDMAP (IDS_INSTALLING_SINSTALLING_PROGRESS),
MAKENAMEIDMAP (IDS_INSTALLING_MTITLE),
MAKENAMEIDMAP (IDS_INSTALLING_MPKGNAME),
MAKENAMEIDMAP (IDS_INSTALLING_MSINSTALLING_PROGRESS),
MAKENAMEIDMAP (IDS_LAUNCHWHENREADY),
MAKENAMEIDMAP (IDS_SUCCESS_TITLE),
MAKENAMEIDMAP (IDS_SUCCESS_MTITLE),
MAKENAMEIDMAP (IDS_FAILED_TITLE),
MAKENAMEIDMAP (IDS_FAILED_REASONNAME),
MAKENAMEIDMAP (IDS_SUCCESS_LAUNCH),
MAKENAMEIDMAP (IDS_COMMAND_CANCEL),
MAKENAMEIDMAP (IDS_CMDPARAM_SILENT),
MAKENAMEIDMAP (IDS_CMDPARAM_VERYSILENT),
MAKENAMEIDMAP (IDS_CMDPARAM_MULTIPLE),
MAKENAMEIDMAP (IDS_DEFAULTWIDTH),
MAKENAMEIDMAP (IDS_DEFAULTHEIGHT),
MAKENAMEIDMAP (IDS_MINWIDTH),
MAKENAMEIDMAP (IDS_MINHIEHGT)
};

View File

@@ -308,13 +308,29 @@ class resxmldoc
catch (...) {}
}
}
std::vector <std::pair <int, std::string>> existfilepath;
{
std::vector <std::pair <int, std::string>> vec (s_v.begin (), s_v.end ());
std::sort (vec.begin (), vec.end (), [] (auto &a, auto &b) { return a.second < b.second; });
for (auto &it_ss : vec)
{
it_ss.second = pugi::as_utf8 (CombinePath (GetFileDirectoryW (filepath), pugi::as_wide (it_ss.second)));
if (IsFileExists (pugi::as_wide (it_ss.second))) existfilepath.push_back (it_ss);
}
}
int dpipercent = GetDPI ();
for (auto &it_path : existfilepath)
{
if (it_path.first >= dpipercent) return it_path.second;
}
if (!existfilepath.empty ()) return existfilepath.at (0).second;
return "";
break;
}
}
return "";
}
std::wstring get (const std::wstring &id) const { return pugi::as_wide (get (WStringToString (id)).c_str ()); }
std::wstring get (const std::wstring &id) const { return pugi::as_wide (get (WStringToString (id))); }
std::wstring operator [] (const std::wstring &id) const { return get (id); }
std::wstring operator [] (const std::wstring &id) { return get (id); }
std::string operator [] (const std::string &id) const { return get (id); }

View File

@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resource id="splash">
<scale dpi="100">splash\SplashScreen.scale-100.png</scale>
<scale dpi="125">splash\SplashScreen.scale-125.png</scale>
<scale dpi="150">splash\SplashScreen.scale-150.png</scale>
<scale dpi="200">splash\SplashScreen.scale-200.png</scale>
<scale dpi="100">splash\AppPackageSplashScreen.scale-100.png</scale>
<scale dpi="125">splash\AppPackageSplashScreen.scale-125.png</scale>
<scale dpi="150">splash\AppPackageSplashScreen.scale-150.png</scale>
<scale dpi="200">splash\AppPackageSplashScreen.scale-200.png</scale>
<scale dpi="400">splash\AppPackageSplashScreen.scale-200.png</scale>
<scale dpi="default">SplashScreen.png</scale>
</resource>
<resource id="splashlarge">

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -65,7 +65,7 @@ body * {
transform: translate(-50%, -50%);
}
.page.splash progress.win-ring {
.page.splash .content.splash progress.win-ring {
width: 30px;
height: 30px;
margin-top: 32px;
@@ -74,6 +74,12 @@ body * {
color: white;
}
.page.splash .content.splash progress {
border-style: none;
background-color: transparent;
color: white;
}
.page.splash>.content {
position: absolute;
text-align: center;

View File

@@ -15,31 +15,49 @@
<script type="text/javascript" src="js/promise.js"></script>
<script type="text/javascript" src="js/bridge.js"></script>
<script type="text/javascript" src="js/dpimodes.js"></script>
<script type="text/javascript" src="js/resources.js"></script>
<script type="text/javascript" src="js/animation.js"></script>
<link rel="stylesheet" href="fonts/fonts.css">
<link rel="stylesheet" href="css/pages.css">
<script type="text/javascript" src="js/event.js"></script>
<script type="text/javascript" src="js/pages.js"></script>
<script type="text/javascript" src="js/load.js"></script>
<script type="text/javascript" src="js/init.js"></script>
</head>
<body>
<div id="page-container" class="pagecontainer full">
<div class="page preinstall">
<div class="page splash">
<!-- Splash Screen -->
<img class="splash" src="images/splash.default.png" alt="Splash Screen">
<img class="splash" src="images/splash.default.png" alt="Splash Screen" width="620" height="300">
<div class="content splash">
<progress class="win-ring"></progress>
</div>
<script>
(function() {
"use strict";
var img = document.querySelector(".pagecontainer .page img.splash");
if (img) img.src = Bridge.UI.Splash.imageurl;
var progress = document.querySelector(".pagecontainer .page .content.splash progress");
if (Bridge.Frame.WindowSize.height / Bridge.UI.dpi < 500) {
if (progress.classList.contains("win-ring")) progress.classList.remove("win-ring");
} else progress.classList.add("win-ring");
var splashpage = document.querySelector(".pagecontainer .page.splash");
if (splashpage) {
splashpage.style.backgroundColor = Bridge.UI.Splash.backcolor;
}
})();
</script>
<!-- Loading... -->
<div class="content loading">
<span class="ring-loading">&#57543;</span>&nbsp;
<span>请稍候...</span>
<span data-res-byname="IDS_PLEASEWAIT">Please wait...</span>
</div>
<!-- Main Page -->
<div class="content select preinstall installing installsuccess installfailed">
<div style="width: 100%; box-sizing: border-box;" class="currentfile multiple">
<h1 class="win-type-x-large">有多个包将要安装</h1><br />
<label for="select-package" class="win-label">在这里请选择一个包查看信息。</label><br />
<h1 class="win-type-x-large" data-res-byname="IDS_PREINSTALL_MTTITLE"></h1>
<label for="select-package" class="win-label" data-res-byname="IDS_PREINSTALL_MSELECT">在这里请选择一个包查看信息。</label><br />
<select id="select-package"></select><br />
</div>
<div class="storelogo">
@@ -47,18 +65,18 @@
<img src="images/splash.default.png" alt="App Store Logo">
</div>
</div>
<h1 class="win-type-x-large pkgtitle">Install {Package Title}?</h1>
<p class="pkgtitle multiple">{Package Title}</p>
<p>Microsoft Store Application</p>
<p class="pkgpublisher">Publisher: {Package Publisher}</p>
<p class="pkgversion"> Version: {Package Version}</p><br />
<p class="pkgfunctions-label"><span>Functions</span>: </p>
<h1 class="win-type-x-large pkgtitle" data-res-byname="IDS_PREINSTALL_TITLE"></h1>
<p class="pkgtitle multiple" data-res-byname="IDS_PREINSTALL_MPKGNAME"></p>
<p data-res-byname="IDS_MSAPP"></p>
<p class="pkgpublisher" data-res-byname="IDS_PUBLISHER"></p>
<p class="pkgversion" data-res-byname="IDS_VERSION"></p><br />
<p class="pkgfunctions-label" data-res-byname="IDS_FUNCTIONNAME"></p>
<div class="functions">
<ul>
<li>使用全部的系统资源</li>
</ul>
</div>
<a class="moreinfo">更多信息</a>
<a class="moreinfo" data-res-byname="IDS_MOREINFO"></a>
<script>
(function() {
"use strict";
@@ -87,24 +105,25 @@
</div>
<div class="progress installing">
<div>
<span class="ring-loading">&#57543;</span>&nbsp;<span class="status">Installing... 0%</span>
<span class="ring-loading">&#57543;</span>&nbsp;<span class="status" data-res-byname="IDS_INSTALLING_SLOADING"></span>
</div>
<progress min="0" max="100" value="50" class="win-progress-bar"></progress>
</div>
<div class="reason installfailed">
<p><span>Reason</span>: </p>
<p data-res-byname="IDS_FAILED_REASONNAME"></p>
<textarea class="win-textarea" readonly></textarea>
</div>
<div class="controls select preinstall installing installsuccess installfailed">
<div class="checkbox">
<input type="checkbox" id="preinst-enablelaunch" class="win-checkbox">
<label for="preinst-enablelaunch">Launch app after installation</label>
<label for="preinst-enablelaunch" data-res-byname="IDS_LAUNCHWHENREADY"></label>
</div>
<div class="command">
<button>Install</button>
<button>Cancel</button>
<button data-res-byname="IDS_PREINSTALL_TINSTALL"></button>
<button data-res-byname="IDS_PREINSTALL_CANCEL"></button>
</div>
</div>
<div data-win-control="WinJS.UI.Flyout" id="moreinfo-flyout"></div>
</div>
</div>
</body>

View File

@@ -12,7 +12,13 @@
isIe10: function() { return ext.IEFrame.Version === 10; },
isIe11: function() { return ext.IEFrame.Version === 11; }
},
UI: {},
UI: {
Splash: {
show: function() { ext.System.UI.ShowSplash(); },
fadeAway: function() { ext.System.UI.FadeAwaySplash(); },
fadeOut: function() { ext.System.UI.FadeOutSplash(); }
}
},
String: {
trim: function(str) { return ext.String.Trim(str); },
tolower: function(str) { return ext.String.ToLower(str); },
@@ -23,8 +29,14 @@
compare: function(str1, str2) { return ext.String.NString.Compare(str1, str2); },
empty: function(str) { return ext.String.NString.Empty(str); },
length: function(str) { return ext.String.NString.Length(str); },
},
Resources: {
byname: function(resname) { return ext.System.Resources.GetByName(resname); },
byid: function(resid) { return ext.System.Resources.GetById(resid); },
nameToId: function(resname) { return ext.System.Resources.ToId(resname); },
idToName: function(resid) { return ext.System.Resources.ToName(resid); },
}
}
};
Object.defineProperty(global.Bridge.Frame, "scale", {
get: function() { return ext.IEFrame.Scale; },
set: function(value) { ext.IEFrame.Scale = value; return ext.IEFrame.Scale; }
@@ -32,10 +44,24 @@
Object.defineProperty(global.Bridge.Frame, "version", {
get: function() { return ext.IEFrame.Version; },
});
Object.defineProperty(global.Bridge.Frame, "WindowSize", {
get: function() { return ext.System.UI.WndSize; },
});
Object.defineProperty(global.Bridge.Frame, "ClientSize", {
get: function() { return ext.System.UI.ClientSize; },
});
Object.defineProperty(global.Bridge.UI, "dpiPercent", {
get: function() { return ext.System.UI.DPIPercent; }
});
Object.defineProperty(global.Bridge.UI, "dpi", {
get: function() { return ext.System.UI.DPI; }
});
Object.defineProperty(global.Bridge.UI.Splash, "backcolor", {
get: function() { return ext.System.UI.SplashBackgroundColor; },
});
Object.defineProperty(global.Bridge.UI.Splash, "imageurl", {
get: function() { return ext.System.UI.SplashImage; },
});
})(this);

View File

@@ -24,21 +24,21 @@
break;
}
var images = document.getElementsByTagName('img');
for (var i = 0; i < images.length; i++) {
var img = images[i];
var parent = img.parentElement;
if (!parent) continue;
var parentWidth = parent.offsetWidth;
var parentHeight = parent.offsetHeight;
var scaledWidth = img.naturalWidth * dpiValue;
var scaledHeight = img.naturalHeight * dpiValue;
if (scaledWidth > parentWidth || scaledHeight > parentHeight) {
img.style.transform = 'none';
} else {
img.style.transform = 'scale(' + dpiValue + ')';
}
// console.log('Image:', img, 'Parent Size:', parentWidth, parentHeight, 'Scaled:', scaledWidth, scaledHeight, 'Transform:', img.style.transform);
}
/* for (var i = 0; i < images.length; i++) {
var img = images[i];
var parent = img.parentElement;
if (!parent) continue;
var parentWidth = parent.offsetWidth;
var parentHeight = parent.offsetHeight;
var scaledWidth = img.naturalWidth * dpiValue;
var scaledHeight = img.naturalHeight * dpiValue;
if (scaledWidth > parentWidth || scaledHeight > parentHeight) {
img.style.transform = 'none';
} else {
img.style.transform = 'scale(' + dpiValue + ')';
}
// console.log('Image:', img, 'Parent Size:', parentWidth, parentHeight, 'Scaled:', scaledWidth, scaledHeight, 'Transform:', img.style.transform);
} */
if (IsIeVersionElder && IsIeVersionElder()) {
var contentElements = document.getElementsByClassName('content');
var controlElements = document.getElementsByClassName('control-column-bottom');

11
shared/html/js/init.js Normal file
View File

@@ -0,0 +1,11 @@
(function(global) {
"use strict";
function ready(e) {
function nextstep() {
Resources.processAll();
}
WinJS.UI.processAll().done(nextstep);
}
OnLoad.add(ready);
})(this);

40
shared/html/js/load.js Normal file
View File

@@ -0,0 +1,40 @@
(function() {
"use strict";
var loaddelegate = [];
loaddelegate.push(window.onload);
var elderload = loaddelegate[0];
function onLoad(e) {
for (var i = 0; i < loaddelegate.length; i++) {
if (typeof loaddelegate[i] === "function") {
loaddelegate[i](e);
}
}
}
window.onload = onLoad;
module.exports = {
OnLoad: {
add: function(func) {
if (typeof func === "function") {
for (var i = 0; i < loaddelegate.length; i++) {
if (!i) continue; // 第一个元素必须保留,因为其为原生的 onload 事件
if (loaddelegate[i] === func) {
return;
}
}
loaddelegate.push(func);
}
},
remove: function(func) {
if (!func) return;
for (var i = 0; i < loaddelegate.length; i++) {
if (!i) continue;
if (loaddelegate[i] === func) {
loaddelegate.splice(i, 1);
return;
}
}
}
}
};
})();

View File

@@ -9,6 +9,7 @@
}
var supportPageList = [
"splash",
"loading",
"select",
"preinstall",
"installing",
@@ -22,6 +23,8 @@
"installfailed"
];
var splashBackColor = "";
function setPage(swPageLabel, bIsMulti) {
var page = getPage();
swPageLabel = ("" + (swPageLabel || ""));
@@ -32,6 +35,13 @@
if (page.classList.contains(supportPageList[i])) page.classList.remove(supportPageList[i]);
}
}
if (Bridge.NString.equals(swPageLabel, "splash")) {
if (splashBackColor) {
page.style.backgroundColor = splashBackColor;
}
} else {
page.style.backgroundColor = "";
}
if (page.classList.contains("multiple")) page.classList.remove("multiple");
for (var j = 0; j < supportMulPageList.length; j++) {
if (Bridge.NString.equals(swPageLabel, supportMulPageList[j]) && bIsMulti) {
@@ -60,6 +70,40 @@
setPage(getPageLabel(), bIsMulti);
}
function getSplashPage() {
var page = document.querySelector(".page.splash");
if (!page) return null;
var ret = {};
Object.defineProperty(ret, "background", {
get: function() {
var page = document.querySelector(".page.splash");
return page.style.backgroundColor || splashBackColor;
},
set: function(value) {
splashBackColor = value;
var page = document.querySelector(".page.splash");
if (page) page.style.backgroundColor = value;
}
});
Object.defineProperty(ret, "imagesrc", {
get: function() {
var splashimg = page.querySelector("img.splash");
return splashimg.src;
},
set: function(value) {
var splashimg = page.querySelector("img.splash");
splashimg.src = value;
}
});
Object.defineProperty(ret, "content", {
get: function() {
var content = page.querySelector(".content.splash");
return content;
},
});
return ret;
}
module.exports = {
Page: {}
};
@@ -71,4 +115,7 @@
get: function() { return isMultiPage(); },
set: function(bIsMulti) { setPage(getPageLabel(), bIsMulti); }
});
Object.defineProperty(Page, "splash", {
get: function() { return getSplashPage(); }
});
})(this);

View File

@@ -0,0 +1,40 @@
(function() {
"use strict";
function getAllNodesHasResource() {
var allElements = document.body.getElementsByTagName('*');
var result = [];
for (var i = 0; i < allElements.length; i++) {
var el = allElements[i];
var tag = el.tagName.toLowerCase();
if (tag === 'script' || tag === 'style' || tag === 'link') {
continue;
}
var byName = el.getAttribute('data-res-byname');
var byId = el.getAttribute('data-res-byid');
if ((byName && !Bridge.NString.empty(byName)) || (byId && parseInt(byId, 10) > 0)) {
result.push(el);
}
}
return result; // 返回符合条件的元素数组
}
module.exports = {
Resources: {
processAll: function() {
var nodes = getAllNodesHasResource();
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].hasAttribute('data-res-byname')) {
var resName = nodes[i].getAttribute('data-res-byname');
nodes[i].textContent = Bridge.Resources.byname(resName);
} else if (nodes[i].hasAttribute('data-res-byid')) {
var resId = parseInt(nodes[i].getAttribute('data-res-byid'), 10);
nodes[i].textContent = Bridge.Resources.byid(resId);
} else {
nodes[i].textContent = "";
}
}
}
}
};
})();